1 Star 0 Fork 0

陈杨/小程序-资讯

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
app.js 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
15012950366 提交于 2018-04-17 23:22 . commit info
//app.js
const utils = require('./utils/util.js')
App({
onLaunch: function() {
//加载天气数据
this.loadWeatherData();
// 获取用户信息
this.getUserInfo();
},
loadWeatherData: function () {
var citySelected = wx.getStorageSync('citySelected') || [];
if (citySelected.length == 0) {
citySelected.unshift("__location__");
wx.setStorageSync('citySelected', citySelected);
}
var that = this
for (var idx in citySelected) {
var cityCode = citySelected[idx];
api.loadWeatherData(cityCode, function (cityCode, data) {
var weatherData = wx.getStorageSync('weatherData') || {};
weatherData[cityCode] = data;
wx.setStorageSync('weatherData', weatherData);
});
}
},
getUserInfo(){
return new utils.Promise((resolve,reject) => {
if(this.globalData.userInfo){
resolve(this.globalData.userInfo)
}
return utils.getUserInfo().then(res => {
resolve(this.globalData.userInfo = res.userInfo)
})
})
},
globalData:{
userInfo:null,
categoryChanged:true
},
cacheSubscibe:[],
utils
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dadishidai/small_programs__information.git
[email protected]:dadishidai/small_programs__information.git
dadishidai
small_programs__information
小程序-资讯
master

搜索帮助