-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathapp.js
68 lines (67 loc) · 2.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
App({
globalData: {
userInfo: undefined,
latitude: undefined,
longitude: undefined,
windowWidth: undefined,
windowHeight: undefined,
locs: undefined,
currentLoc: undefined,
city: undefined,
reflesh: false,
locId: undefined,
eventCategory: undefined,
slogan: "在这陌生的城市里能与你相遇,真好",
doubanBase: "https://www.easy-mock.com/mock/5cd0faf6e1fe52746e062d07/weapp/douban/",
loc_list_url: "loc/list",
loc_url: "loc/",
event_list_url: "event/list",
event_url: "event/detail/"
},
onLaunch: function () {
// Do something initial when launch.
var that = this;
wx.getSystemInfo({
success: function (res) {
that.globalData.windowWidth = res.windowWidth;
that.globalData.windowHeight = res.windowHeight;
}
});
},
onShow: function () {
// Do something when show.
},
onHide: function () {
// Do something when hide.
},
onError: function (msg) {
console.log(msg)
},
getUserInfo: function (cb) {
var that = this;
if (this.globalData.userInfo) {
typeof cb == "function" && cb(this.globalData.userInfo);
} else {
wx.login({
success: function (res) {
// wx.getUserInfo({
// success: function (res) {
// that.globalData.userInfo = res.userInfo;
// typeof cb == "function" && cb(that.globalData.userInfo);
// }
// });
}
});
}
},
getLocation: function () {
var that = this;
wx.getLocation({
type: 'wgs84', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
success: function (res) {
that.globalData.latitude = res.latitude;
that.globalData.longitude = res.longitude;
}
})
},
})