forked from landalfYao/help
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
45 lines (44 loc) · 996 Bytes
/
app.js
File metadata and controls
45 lines (44 loc) · 996 Bytes
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
let com = require('./utils/util.js')
App({
com: com,
onLaunch: function () {
let _this = this
// this.login(function(res){
// _this.getRes(res.data.id)
// _this.getMoren(res.data.default_address)
// })
},
login(cb){
wx.login({
success(res) {
com.post('wx/user/login', { js_code: res.code }, function (res) {
if (res.code == 1) {
wx.setStorageSync("user", res.data)
wx.setStorageSync("token", res.token)
cb(res)
}
})
}
})
},
//获取默认地址
getMoren(id){
if(id){
com.post('user/address/get/id', { id: id }, function (res) {
if (res.code == 1) {
wx.setStorageSync("address", res.data)
}
})
}
},
getRes(id){
com.post('wx/user/get/info/wxid', { wx_id: id }, function (res) {
if (res.code == 1) {
wx.setStorageSync("res", res.data)
}
})
},
globalData: {
userInfo: null
}
})