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

34
App.vue
View File

@@ -1,6 +1,7 @@
<template>
</template>
<script>
import Api from '@/common/js/api.js'
export default {
onLaunch: function() {
// #ifdef MP-WEIXIN
@@ -8,7 +9,8 @@
// #endif
uni.cache.set('NAME', '零点八零');
},
onLoad() {},
onLoad() {
},
onShow: function() {
this.$store.dispatch("HeightActions"); //获取随时获取页面的高度
// #ifdef MP-WEIXIN
@@ -48,6 +50,36 @@
onHide: function() {
// console.log('App Hide');
},
methods: {
userlogin() {
if (!uni.cache.get('token')) {
// this.$store.dispatch("loginEvent"); //获取shapid
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>