diff --git a/template/5iux/js/sou.js b/template/5iux/js/sou.js new file mode 100644 index 0000000..eae3d3e --- /dev/null +++ b/template/5iux/js/sou.js @@ -0,0 +1,78 @@ +/* +作者:D.Young +主页:https://yyv.me/ +github:https://github.com/5iux/sou +日期:2020/11/18 +版权所有,请勿删除 +*/ + +$(document).ready(function() { + //判断窗口大小,添加输入框自动完成 + var wid = $("body").width(); + if (wid < 640) { + //$(".wd").attr('autocomplete', 'off'); + } else { + $(".wd").focus(); + } + //菜单点击 + $("#menu").click(function(event) { + $(this).toggleClass('on'); + $(".list").toggleClass('closed'); + $(".mywth").toggleClass('hidden'); + }); + $("#content").click(function(event) { + $(".on").removeClass('on'); + $(".list").addClass('closed'); + $(".mywth").removeClass('hidden'); + $('#word').hide(); + }); + $(".mywth").click(function(event) { + var wt = $("body").width(); + if (wt < 750 || wt == 750) { + //window.location.href = "https://tianqi.qq.com/"; + window.location.href = "/weather/"; + } + }); +}); + +//关键词sug +$(function() { + //当键盘键被松开时发送Ajax获取数据 + $('.wd').keyup(function() { + var keywords = $(this).val(); + if (keywords == '') { $('#word').hide(); return }; + $.ajax({ + url: 'https://suggestion.baidu.com/su?wd=' + keywords, + dataType: 'jsonp', + jsonp: 'cb', //回调函数的参数名(键值)key + // jsonpCallback: 'fun', //回调函数名(值) value + beforeSend: function() { + // $('#word').append('
  • 正在加载。。。
  • '); + }, + success: function(data) { + $('#word').empty().show(); + if (data.s == '') { + //$('#word').append('
    Not find "' + keywords + '"
    '); + $('#word').hide(); + } + $.each(data.s, function() { + $('#word').append('
  • ' + this + '
  • '); + }) + }, + error: function() { + $('#word').empty().show(); + //$('#word').append('
    Fail "' + keywords + '"
    '); + $('#word').hide(); + } + }) + }) + //点击搜索数据复制给搜索框 + $(document).on('click', '#word li', function() { + var word = $(this).text(); + $('.wd').val(word); + $('#word').hide(); + $("form").submit(); + // $('#texe').trigger('click');触发搜索事件 + }) + +}) \ No newline at end of file diff --git a/template/5iux/js/wea.js b/template/5iux/js/wea.js new file mode 100644 index 0000000..ef3402b --- /dev/null +++ b/template/5iux/js/wea.js @@ -0,0 +1,55 @@ +/*天气插件开始 +天气插件api请在wea目录中index.php修改 +申请地址:和风天气-https://dev.heweather.com/ +*/ +//菜单点击 +$("#menu").click(function(event) { + $(".mywth").toggleClass('hidden'); +}); +$("#content").click(function(event) { + $(".mywth").removeClass('hidden'); +}); + +$.ajax({ + url: './template/5iux/wea/', + dataType: 'json', + error: function() { + console.log('天气插件网络错误!'); + }, + success: function(res) { + //判断夜晚 + var now = new Date(), + hour = now.getHours(); + if (hour < 18) { myday = "d"; } else { myday = "n"; } + //天气 + $('.mywth').append(res.HeWeather6[0].basic.location + ' ' + res.HeWeather6[0].now.cond_txt + ' ' + res.HeWeather6[0].now.tmp + '℃ ' + res.HeWeather6[0].now.wind_dir); + + $('.wea_hover').css('background-image', 'url(https://cdn.heweather.com/img/plugin/190516/bg/view/' + res.HeWeather6[0].now.cond_code + myday + '.png)'); + //今日天气 + $('.wea_top').append('' + res.HeWeather6[0].basic.location + ' ' + res.HeWeather6[0].update.loc + ' 更新 ' + res.HeWeather6[0].now.tmp + '℃' + res.HeWeather6[0].now.cond_txt + '紫外线指数:' + res.HeWeather6[0].lifestyle[5].brf + '
    相对湿度:' + res.HeWeather6[0].now.hum + '%
    ' + res.HeWeather6[0].now.wind_dir + ':' + res.HeWeather6[0].now.wind_sc + '级
    ' + res.HeWeather6[0].lifestyle[3].txt + ''); + //今日指数 + var wea_con; + for (var x = 0; x < 8; x++) { + wea_con = '
  • 指数
    ' + res.HeWeather6[0].lifestyle[x].brf + '
  • '; + $(".wea_con ul").append(wea_con); + } + $('.wea_comf span').text('舒适度'); + $('.wea_drsg span').text('穿衣'); + $('.wea_flu span').text('感冒'); + $('.wea_sport span').text('运动'); + $('.wea_trav span').text('旅游'); + $('.wea_uv span').text('紫外线'); + $('.wea_cw span').text('洗车'); + $('.wea_air span').text('空气'); + + + //未来3天天气 + var wea_foot; + for (var i = 0; i < 3; i++) { + wea_foot = '
  • ' + res.HeWeather6[0].daily_forecast[i].date + '

    ' + res.HeWeather6[0].daily_forecast[i].cond_txt_d + '
    ' + res.HeWeather6[0].daily_forecast[i].tmp_min + '°/' + res.HeWeather6[0].daily_forecast[i].tmp_max + '°' + '
  • '; + $(".wea_foot ul").append(wea_foot); + } + } +}); + +/*天气插件结束*/ \ No newline at end of file