-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
48 lines (38 loc) · 932 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// app.js
const sdk = require('./wafer2-client-sdk/index')
const config = require('./config')
import EventChannel from '/common/EventChannel'
import updateManager from '/common/updateManager';
const eventChannel = new EventChannel();
App({
onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
},
onShow() {
updateManager();
},
globalData: {
userInfo: null
},
$emit: (eventName, ...args) => {
eventChannel.emit(eventName, ...args);
},
$off: (eventName, fn) => {
eventChannel.off(eventName, fn);
},
$on: (eventName, fn) => {
eventChannel.on(eventName, fn);
},
$once: (eventName, fn) => {
eventChannel.once(eventName, fn);
}
})