forked from pengMaster/marry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
48 lines (47 loc) · 1.11 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
//app.js
var api = require('/api/api.js')
var AppId = 'wxc028256ea6d51af1'
var AppSecret = '9f8d745b3f3f5eb1497807be8ec0ead7'
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,
isShowAd:null
}
})