forked from pengMaster/marry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
47 lines (46 loc) · 1.09 KB
/
app.js
File metadata and controls
47 lines (46 loc) · 1.09 KB
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
//app.js
var api = require('/api/api.js')
var AppId = 'wxc028256ea6d51af1'
var AppSecret = '81f336c525fa5cf56384c9442e5735df'
App({
onLaunch: function () {
var that = this
//调用登录接口,获取 code
wx.login({
success: function (res) {
//发起网络请求
wx.request({
url: api.mobileIn,
data: {
appid: AppId,
secret: AppSecret,
code: res.code,
grant_type: 'authorization_code'
},
header: {
method: 'GET_OPENID'
},
method: 'GET',
success: function (res) {
// 将openId设成全局
that.globalData.openId = res.data.openid
console.log('res.data.openid', res.data.openid)
that.globalData.flag = res.data.flag
},
fail: function (res) { },
complete: function (res) {
}
});
}
})
},
globalData: {
userInfo: null,
openId: null,
user: null,
flag: null,
hostUserId:null,
isOfficial: true,
isCreate: true
}
})