-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
77 lines (69 loc) · 1.85 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// app.js
const API = require('./utils/api.js')
const utils = require('./utils/util')
App({
onLaunch() {
console.log('app onLaunch')
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// console.log(res.hasUpdate)
})
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
updateManager.applyUpdate()
}
}
})
})
const storageTags = {
nickName: API.STORAGE_TAG.nickName,
openId: API.STORAGE_TAG.openId,
avatar: API.STORAGE_TAG.avatar,
pushKeyJson: API.STORAGE_TAG.pushKeyJson,
config: API.STORAGE_TAG.config,
photosJson:API.STORAGE_TAG.photosJson
};
const globalUserInfo = this.globalData.userInfo;
Object.keys(storageTags).forEach(key => {
const value = wx.getStorageSync(storageTags[key]);
if (utils.isStringValid(value)) {
globalUserInfo[key] = value;
}
});
if(utils.isStringValid(globalUserInfo.pushKeyJson))
{
const pushKey = JSON.parse(this.globalData.userInfo.pushKeyJson)
this.globalData.userInfo.pushKey = pushKey
}
if(utils.isStringValid(globalUserInfo.photosJson))
{
console.log(globalUserInfo.photosJson)
const photos = JSON.parse(globalUserInfo.photosJson)
if(photos){
this.globalData.userInfo.photos = photos
}
}
console.log(this.globalData)
},
onShow(){
console.log('app on show')
console.log(this.globalData)
},
globalData: {
hasChangePushKey:false,
choose:'',
userInfo: {
nickName:'',
avatar:'',
openId:'',
pushKey:[],
config:'',
photos:[],
pushKeyJson:''
}
}
})