forked from zhongkai/wxtodo-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
30 lines (28 loc) · 761 Bytes
/
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
App({
onLaunch: function() {
var name = wx.getStorageSync('name');
var avatar = wx.getStorageSync('avatar');
if (!name || !avatar) {
wx.getUserInfo({
success: function (res) {
var userInfo = res.userInfo;
wx.setStorageSync('name', userInfo.nickName);
wx.setStorageSync('avatar', userInfo.avatarUrl);
}
});
}
},
writeHistory: function (todo, action, timestamp) {
var history = wx.getStorageSync('history') || [];
history.push({
todo: todo ? {
content: todo.content || '',
tags: todo.tags || [],
extra: todo.extra || ''
} : null,
action: action,
timestamp: timestamp
});
wx.setStorageSync('history', history);
}
})