/
app.js
40 lines (35 loc) · 871 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
//app.js
App({
globalData:{
globalUrl: 'https://www.profguider.com/bktServer'
//globalUrl: 'http://localhost:8080'
},
onLaunch: function () {
// 展示本地存储能力
var that=this
// 登录
wx.login({
success: function (res) {
that.getOpenId(res.code)
}
})
},
getOpenId: function (code) {
var that = this
var params = {
'appid': "wx1330e42447ea45ef",
'secret': 'cc6449edb688ea6d8f162f6322c3eee8',
'grant_type': 'authorization_code',
'js_code': code, }
wx.request({
url: this.globalData.globalUrl+'/GetOpenId',
header: { 'content-type': 'application/x-www-form-urlencoded' },
method: 'POST',
data: params,
success: function (res) {
console.log(res)
wx.setStorageSync('openId', res.data.openid)
}
})
},
})