接口顺序调整,会员充值调整

This commit is contained in:
GaoHao
2024-08-09 10:31:45 +08:00
parent 8ca9a73775
commit bf5460c304
6 changed files with 60 additions and 66 deletions

34
App.vue
View File

@@ -1,14 +1,17 @@
<template>
</template>
<script>
import Api from '@/common/js/api.js'
export default {
onLaunch: function() {
// #ifdef MP-WEIXIN
uni.cache.set('menuInfo', uni.getMenuButtonBoundingClientRect());
// #endif
uni.cache.set('NAME', '零点八零');
this.userlogin()
},
onLoad() {
},
onLoad() {},
onShow: function() {
this.$store.dispatch("HeightActions"); //获取随时获取页面的高度
// #ifdef MP-WEIXIN
@@ -48,6 +51,35 @@
onHide: function() {
// console.log('App Hide');
},
methods: {
userlogin() {
if (!uni.cache.get('token')) {
uni.login({
provider: 'weixin',
success: (data) => {
uni.getUserInfo({
provider: 'weixin',
success: async (infoRes) => {
uni.cache.set('weixincode', data.code);
let res = await 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.$isResolve()
}
},
fail: (err) => {}
});
},
})
}
}
}
};
</script>