//index.js
//获取应用实例
var app = getApp()
Page({
data: {
location: {
id: "WS10730EM8EV",
name: "下拉刷新",
country: "CN",
path: "深圳,深圳,广东,中国",
timezone: "Asia/Shanghai",
timezone_offset: "+08:00"
},
now: {
nowPic: "http://omh7cqphx.bkt.clouddn.com/",
text: "...",
code: "0",
temperature: "26"
},
last_update: "",
currentQueryObj: {
key: "bixmpxjottltdf7l",
location: "shenzhen",
language: "zh-Hans",
unit: "c"
},
api: {
nowUrl: "https://api.thinkpage.cn/v3/weather/now.json",
dailyUrl: "https://api.thinkpage.cn/v3/weather/daily.json",
suggestion: "https://api.thinkpage.cn/v3/life/suggestion.json"
}
},
//发送请求数据
sendRequest: function(url, queryObj, callback) {
wx.request({
url: url,
data: queryObj,
method: 'GET',
success: function(res) {
callback(res);
},
fail: function(e) {
console.log("******error******: ", e);
},
complete: function(e) {
console.log("******请求完成****** ", e);
}
})
},
//发送请求数据
//下拉刷新
refreashNow: function(e) {
var that = this;
console.log(that.data.location);
//更新实况天气
this.sendRequest(this.data.api.nowUrl, this.data.currentQueryObj, function(res) {
var result = res.data.results[0];
that.refreashData(result); //下拉更新动作后的数据刷新
});
//更新实况天气
},
//下拉刷新
//更新数据
refreashData: function(result) {
// 更新实况天气数据
var result = result;
result.last_update = result.last_update.slice(-14, -9);
result.now.nowPic = "http://omh7cqphx.bkt.clouddn.com/";
// 更新实况天气数据
//刷新数据
this.setData({
location: result.location,
now: result.now,
last_update: result.last_update
});
//刷新数据
},
//更新数据
//改变地点
changeLoc: function(e) {
var that = this;
wx.chooseLocation({
success: function(res){
console.log(JSON.stringify(res)); //{"name":"天安门广场","address":"北京市东城区广场东侧路","latitude":39.90323,"longitude":116.39772,"errMsg":"chooseLocation:ok"}
var currentQueryObj = {
key: "bixmpxjottltdf7l",
location: res.latitude + ":" + res.longitude,
language: "zh-Hans",
unit: "c"
};
that.setData({
currentQueryObj: currentQueryObj
});
that.refreashNow();
}
})
},
//改变地点
//定位地点
autoLoc: function(e) {
var that = this;
wx.getLocation({
type: 'wgs84', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
success: function(res){
var currentQueryObj = {
key: "bixmpxjottltdf7l",
location: res.latitude + ":" + res.longitude,
language: "zh-Hans",
unit: "c"
};
that.setData({
currentQueryObj: currentQueryObj
});
that.refreashNow();
},
fail: function() {
// fail
},
complete: function() {
// complete
}
})
},
//定位地点
onShow: function(e) {
},
logmsg: function(res) {
console.log(res);
},
onPullDownRefresh: function(){
this.refreashNow();
wx.stopPullDownRefresh();
}
})
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
微信小程序凭借其独特的优势,在移动应用市场中占据了一席之地。首先,微信小程序无需下载安装,用户通过微信即可直接使用,极大地降低了使用门槛。其次,小程序拥有与原生应用相近的用户体验,同时加载速度快,响应迅速,保证了良好的使用感受。此外,微信小程序还提供了丰富的API接口,支持开发者轻松接入微信支付、用户授权等功能,为开发者提供了更多的可能性。 微信小程序-项目源码-原生开发框架。想要快速打造爆款小程序吗?这里有一份原生开发框架的项目源码等你来探索!基于微信小程序的强大生态,这份源码将带你领略原生开发的魅力,实现快速迭代与高效开发。从用户授权到微信支付,从界面设计到功能实现,一切尽在掌握。赶快下载查看,让你的小程序项目在竞争激烈的市场中脱颖而出!
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 12 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/196b0ad537b04e688a2a9ae3fce83c0a_black_cat7.jpg!1)
DTcode7
- 粉丝: 2w+
- 资源: 4986
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)