-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
70 lines (70 loc) · 1.52 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
//app.js
App({
globalData: {
userInfo: null
},
onLaunch: function () {
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
};
}
})
}
}
});
},
//获取
getOneDayData(dayId){
let obj = wx.getStorageSync(dayId);
return obj;
},
getOneItemData(dayId,itemId){
let dayData = wx.getStorageSync(dayId);
for(let i in dayData){
if(i == itemId){
return dayData[itemId];
};
};
},
//添加
addOneDayData(dayId,obj){
},
addOneItemData(dayId,itemId,obj,fun){
let dayData = wx.getStorageSync(dayId) || {};
dayData[itemId] = obj;
wx.setStorage({
key:dayId,
data:dayData,
success(){
if(fun) fun();
}
});
},
//设置
setOneDayData(dayId,obj){
},
setOneItemData(dayId,itemId,obj){
},
//删除
removeOneDayData(dayId){
},
removeOneItemData(dayId,itemId,fun){
let dayData = wx.getStorageSync(dayId) || {};
delete dayData[itemId];
wx.setStorage({
key:dayId,
data:dayData,
success(){
if(fun) fun();
}
});
}
});