-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathapp.js
42 lines (42 loc) · 894 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
//app.js
let {
requestData
} = require("./utils/util.js");
let {
domain,
dev_domain
} = require('config.js');
App({
onLaunch: function() {
// // 展示本地存储能力
// var logs = wx.getStorageSync('logs') || []
// logs.unshift(Date.now())
// wx.setStorageSync('logs', logs)
if (this.debug) {
this.globalData.domain = dev_domain;
}
},
debug: true,
globalData: {
domain
},
login() {
// 登录
return new Promise(resolve => {
wx.login({
success: res => {
requestData('/api/wx/jsoncode2session', {
js_code: res.code
}).then(d => {
var OPEN_ID = d.openid; //获取到的openid
var SESSION_KEY = d.session_key; //获取到session_key
resolve({
OPEN_ID,
SESSION_KEY
})
})
}
})
})
}
})