1
This commit is contained in:
34
App.vue
34
App.vue
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user