-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
46 lines (39 loc) · 1.31 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
//app.js
App({
onLaunch: function () {
//调用API从本地缓存中获取数据
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now());
wx.setStorageSync('logs', logs);
// 从本地缓存中获取session信息,如果找到,携带session信息登录
},
getUserInfo:function(cb){
var that = this
if(this.globalData.userInfo){
typeof cb == "function" && cb(this.globalData.userInfo)
}else{
//调用登录接口
wx.login({
success: function () {
wx.getUserInfo({
success: function (res) {
that.globalData.userInfo = res.userInfo
typeof cb == "function" && cb(that.globalData.userInfo)
}
})
}
})
}
},
globalData:{
userInfo:null,
api_host: "https://glrh11.com"
}
})
// login_openid 获取openid后存在这里
// login_username 用户输入username后存在这里
// login_ass_stage 关联第一步之后的code
// session 这时用户的登录凭证。
// offset_post_timeline 请求timeline_post 的数据偏移量
// timeline_bottom_is_refreshing 由于触底刷新事件bug,所以手动限制触发频率。设置为true或者false
// look_post_id 这个表示,在postlist上点击了哪一个post_id, 到详情页面的时候,取出来显示。