11月29号

///JavaScript


$$(function(){

var currMonth = new Date().getMonth()+1;
if(2<=currMonth&&currMonth<=4){
    $$('.weather-cover')[0].className +=' '+'weather-cover-spring';
	}else if(5<=currMonth&&currMonth<=7){
		$$('.weather-cover')[0].className +=' '+'weather-cover-summer';
	}else if(8<=currMonth&&currMonth<=10){
		$$('.weather-cover')[0].className +=' '+'weather-cover-autumn';
	}else{
		$$('.weather-cover')[0].className +=' '+'weather-cover-winter';
}

mui.init({
  pullRefresh : {
    container:"#refreshContainer",//下拉刷新容器标识,querySelector能定位的css选择器均可,比如:id、.class等
    down : {
      style:'circle',//必选,下拉刷新样式,目前支持原生5+ ‘circle’ 样式
      //color:'#2BD009', //可选,默认“#2BD009” 下拉刷新控件颜色
      //height:'50px',//可选,默认50px.下拉刷新控件的高度,
      //range:'100px', //可选 默认100px,控件可下拉拖拽的范围
      //offset:'0px', //可选 默认0px,下拉刷新控件的起始位置
      callback :processPullRefresh //必选,刷新函数,根据具体业务来编写,比如通过ajax从服务器获取新数据;
    }
  }
});



function getData(){
    $$.ajax({
			 	url:preUrl,
			 	type:'GET',
			 	dataType:'JSONP',
			 	async: false,
			 	success:function(data){
			 		console.log(data);
			 		$$('.weather-citynm').text('南通');
					$$('#weatherInfo-temperature_curr').text(data.result.hourly.temperature[0].value);
					$$('.weatherInfo-wind').text('风速');

                $$('.weatherInfo-humidity').text(data.result.daily.humidity[0].avg+'%');
					$$('#weatherInfo-winp').text(data.result.daily.wind[0].avg.speed+'km/h');
                $$('#weatherInfo-temp_high').text(data.result.daily.temperature[0].max+'℃');
					$$('#weatherInfo-temp_low').text(data.result.daily.temperature[0].min+'℃');

            }
        });
}

getData();

function processPullRefresh(){
    getData();
    console.log('下拉成功');
    mui('#refreshContainer').pullRefresh().endPulldownToRefresh();

 }

利用所学的知识来实现天气的功能

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值