-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
45 lines (43 loc) · 1.06 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
//app.js
App({
onLaunch: function () {
},
onLogin: function(){
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
if (res.code) {
console.log(res.code);
//发起网络请求
wx.request({
url: 'https://netwx.c-leon.top/auth/login',
data: {
code: res.code
},
header: {
'content-type': 'application/json'
},
method: 'POST',
success: res => {
this.globalData.openid = res.data.openid;
// if (this.loginCallback) {
// this.loginCallback(res.data.openid)
// }
wx.setStorageSync("openid", res.data.openid)
}
})
} else {
console.log('登录失败!' + res.errMsg);
}
}
})
},
globalData: {
imageurl:null,
userInfo: null,
openid: '',
uploadSuccess: false,
prefix_url: "https://netwx.c-leon.top/api/"
}
})