This commit is contained in:
魏啾
2024-08-14 09:50:58 +08:00
7 changed files with 92 additions and 100 deletions

View File

@@ -64,44 +64,23 @@
usershopUserinfo: null,
}
},
onLoad(e) {
async onLoad(e) {
console.log(e)
if ( e.type == 'list' || e.type == 'index') {
this.shopId = e.shopId;
this.init();
}
// if ( e.type == 'list' || e.type == 'index') {
// this.shopId = e.shopId;
// this.init();
// }
if (e.q) {
this.shopId = this.getQueryString(decodeURIComponent(e.q), 'shopId')
this.tokenShow = false;
// 等待登录结果返回
if (!uni.cache.get('token')) {
uni.login({
provider: 'weixin',
success: async (data) => {
try {
uni.getUserInfo({
provider: 'weixin',
success: async (infoRes) => {
uni.cache.set('weixincode', data.code);
let res = await this.api.userwxlogin({
code: uni.cache.get('weixincode'), //临时登录凭证
rawData: infoRes.rawData
})
if (res.code == 0) {
uni.cache.set('token', res.data.token);
uni.cache.set('miniAppOpenId', res.data.userInfo
.miniAppOpenId)
uni.cache.set('userInfo', res.data.userInfo);
this.tokenShow = false;
this.init();
}
},
fail: (err) => {}
});
} catch (e) {}
}
});
} else {
this.init();
await this.$onLaunched;
}
this.init();
} else{
this.shopId = e.shopId;
this.init();
}
console.log(this.shopId)
},
@@ -240,14 +219,11 @@
uni.navigateBack()
}, 500)
} else {
uni.exitMiniProgram({
success: function () {
console.log('退出成功');
},
fail: function () {
console.log('退出失败');
}
});
setTimeout(res => {
uni.switchTab({
url: '/pages/index/index'
})
}, 500)
}
},