-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
55 lines (51 loc) · 1.38 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
49
50
51
52
53
54
55
App({
login: function () {
const host = this.globalData.baseUrl
// console.log('beginning login')
wx.login({
success: (res) => {
// console.log(res)
wx.request({
url: host + '/login',
method: 'post',
data: {
code: res.code
},
success: (res) => {
// console.log(res)
this.globalData.userId = res.data.userId
// console.log("login successful, user ID is:", this.globalData)
wx.setStorageSync('hasUserInfo', res.data.hasUserInfo)
wx.setStorageSync('currentUser', res.data.currentUser)
}
})
}
})
},
onLaunch: function () {
// checking if the user is in Storage
let user = wx.getStorageSync('currentUser')
if (user) {
// console.log('user is in the storage')
this.globalData.userId = user.id
} else {
this.login()
}
},
onLaunch: function () {
// checking if the user is in Storage
let user = wx.getStorageSync('currentUser')
if (user) {
// console.log('user is in the storage')
this.globalData.userId = user.id
} else {
this.login()
}
},
globalData: {
// userInfo: null,
// baseUrl: 'http://localhost:3000/api/v1'
// baseUrl: 'https://t-a-l-o-n.herokuapp.com/api/v1'
baseUrl: 'https://talon.wogengapp.cn/api/v1'
},
})