-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
45 lines (43 loc) · 1.14 KB
/
app.js
File metadata and controls
45 lines (43 loc) · 1.14 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
/**
* @fileOverview 微信小程序的入口文件
*/
var qcloud = require('./vendor/qcloud-weapp-client-sdk/index');
var config = require('./config');
App({
/**
* 小程序初始化时执行,我们初始化客户端的登录地址,以支持所有的会话操作
*/
onLaunch() {
qcloud.setLoginUrl(config.service.loginUrl);
},
getUserInfo: function (cb){
var that = this
if(this.globalData.userInfo){
typeof cb == "function" && cb(this.globalData.userInfo)
}else{
//调用登录接口
wx.login({
success: function (login) {
wx.getUserInfo({
success: function (res) {
if (login.code) {
that.globalData.code = login.code
}
that.globalData.userInfo = res.userInfo
typeof cb == "function" && cb(that.globalData.userInfo)
}
})
}
})
}
},
setCity: function ({city}) {
if (!city) return
this.globalData.city = city
},
globalData:{
code: null,
userInfo:null,
city:null
}
});