Commit 0634c638 authored by ziyu's avatar ziyu

返回页面调用接口

parent 6a36d7dc
...@@ -351,7 +351,7 @@ ...@@ -351,7 +351,7 @@
// 有效值 develop(开发版),trial(体验版),release(正式版) // 有效值 develop(开发版),trial(体验版),release(正式版)
envVersion: 'release', envVersion: 'release',
success(res) { success(res) {
console.log('跳转成功'); // console.log('跳转成功');
} }
}); });
/* wx.navigateTo({ /* wx.navigateTo({
...@@ -509,7 +509,6 @@ ...@@ -509,7 +509,6 @@
let shareId = res.shareTickets[0]; let shareId = res.shareTickets[0];
console.log('shareId', shareId); console.log('shareId', shareId);
// 转发成功 // 转发成功
console.log(res);
}, },
fail: function(res) { fail: function(res) {
// 转发失败 // 转发失败
...@@ -573,35 +572,20 @@ ...@@ -573,35 +572,20 @@
if (options.openid) { if (options.openid) {
this.inviter = options.openid; this.inviter = options.openid;
} }
let statusHeight = this.$app.$options.globalData.statusBarHeight || '';
wx.setStorageSync('openId', false); statusHeight && (this.userImgStyle = 'top:' + statusHeight + 'px');
},
async onShow() {
if (!wx.getStorageSync('openId')) { if (!wx.getStorageSync('openId')) {
const { code } = await wepy.wx.login(); const { code } = await wepy.wx.login();
const userInfo = await login(code); const userInfo = await login(code);
wx.setStorageSync('openId', userInfo.openid); wx.setStorageSync('openId', userInfo.openid);
wx.setStorageSync('isRegister', userInfo.register); wx.setStorageSync('isRegister', userInfo.register);
} }
let self = this;
let statusHeight = this.$app.$options.globalData.statusBarHeight || '';
statusHeight && (this.userImgStyle = 'top:' + statusHeight + 'px');
if (store.state.userInfo) { if (store.state.userInfo) {
this.userInfo = store.state.userInfo; this.userInfo = store.state.userInfo;
this.registUser(this.userInfo);
} else { } else {
wx.getUserInfo({
success (res) {
self.userInfo = res.userInfo;
store.dispatch('setUserInfo', res.userInfo);
}
});
}
await this.getMainInfo();
this.videoList = await getPrizeList();
this.adlist = await getActivityFeed({ count: 50 });
// 如果已经存在store里就不用再获取用户信息了
if (!this.userInfo) {
const setting = await wepy.wx.getSetting(); const setting = await wepy.wx.getSetting();
if (setting.authSetting['scope.userInfo']) { if (setting.authSetting['scope.userInfo']) {
const { userInfo } = await wepy.wx.getUserInfo(); const { userInfo } = await wepy.wx.getUserInfo();
...@@ -610,13 +594,10 @@ ...@@ -610,13 +594,10 @@
} else { } else {
this.authmodal = true; this.authmodal = true;
} }
} else {
this.registUser(this.userInfo);
} }
}, await this.getMainInfo();
onShow() { this.videoList = await getPrizeList();
// 从其他小程序回来可以在当前生命周期检测到,但是这个方法,自己的小程序页面返回也会进入 this.adlist = await getActivityFeed({ count: 50 });
// console.log('页面show!!');
} }
}); });
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment