-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
65 lines (63 loc) · 1.82 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
// app.js
var config = require('./config/config.js');
var token = require('./js/token.js');
App({
onLaunch() {
wx.request({
url: config.host + '/authority/accesstoken?refresh_token=' + config.refresh_token,
method: 'POST',
success: (result) => {
config.access_token = result.data.data
wx.request({
url: config.host + '/user/info/get',
method: 'POST',
header: { 'token': result.data.data},
success: (res) => {
console.log(res.data.data)
this.globalData.userInfo = res.data.data
}
})
}
})
// wx.getSystemInfo({
// success: res => {
// this.globalData.bottomHeight = res.screenHeight - res.safeArea.bottom;
// },
// fail(err) {
// console.log(err);
// }
// })
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
wx.setStorageSync('config', config)
// 微信小程序登录接口
// wx.login({
// success: res => {
// console.log(config.host + '/authority/login?code=' + res.code)
// wx.request({
// url: config.host + '/authority/login?code=' + res.code,
// method: 'POST',
// success: (result) => {
// // 获取REFRESH_TOKEN
// if(result.data.code == 200){
// config.refresh_token = result.data.data
// }else{
// wx.showToast({
// title: 'Token 失效',
// icon: 'error',
// duration: 2000,
// })
// }
// }
// })
// }
// })
console.log(this.globalData.userInfo)
},
globalData: {
userInfo: [],
bottomHeight: 0,
}
})