全局配置
{
"pages": [
"pages/index/index",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "dark",
"navigationBarBackgroundColor": "#ddd",
"navigationBarTitleText": "快递查询",
"navigationBarTextStyle": "black",
"navigationsStyle":"default",
"backgroundColor": "#ffffff"
},
"tabBar": {
"color": "#000000",
"borderStyle": "blue",
"selectedColor": "#000000",
"backgroundColor": "#ffffff",
"list": [{
"pagePath": "pagePath",
"text": "text",
"iconPath": "iconPath",
"selectedIconPath": "selectedIconPath"
}]
},
"networkTimeout": {
"request": 20000,
"connectSocket": 20000,
"uploadFile": 20000,
"downloadFile": 20000
},
"debug":true,
"style": "v2",
"sitemapLocation": "sitemap.json"
}
微信小程序的生命周期与app对象的使用
App({
onLaunch: function () {
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
console.log("--onLanuch--");
wx.login({
success: res => {
}
})
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
wx.getUserInfo({
success: res => {
this.globalData.userInfo = res.userInfo
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
globalData: {
userInfo: null
}
,
onShow:function(){
console.log("--onShow--");
},
onHide:function(){
console.log("--onHide--");
},
onLoad:function(){
console.log("--onLoad--")
}
}
)