This commit is contained in:
魏啾 2024-07-22 14:11:54 +08:00
commit 16fa1dae73
6 changed files with 54 additions and 46 deletions

31
App.vue
View File

@ -19,32 +19,11 @@
// console.log('App Hide');
},
methods: {
async userlogin() {
uni.login({
provider: 'weixin',
success: (data) => {
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);
}
},
fail: (err) => {}
});
}
});
},
userlogin() {
if (!uni.cache.get('token')) {
this.$store.dispatch("loginEvent"); //shapid
}
}
}
};
</script>

View File

@ -1,7 +1,7 @@
import {
fill
} from "lodash"
import store from "../store"
const preCacheKeyClearFetch = 'storage:clear:fetch:'
uni.pro.interceptor('request', {
@ -104,17 +104,14 @@ async function request(options) {
if (res.code != 0) {
if (res.code == -4) {
uni.showToast({
title: res.message || res.msg,
icon: "none"
// success: () => {
// setTimeout(res => {
// uni.cache.set('token', '');
// uni.redirectTo({
// url: '/pages/login/login'
// });
// }, 1000)
// }
title: '',
// title: res.message || res.msg,
icon: "none",
success: () => {
setTimeout(res => {
store.dispatch("loginEvent"); //获取shapid
}, 1000)
}
})
} else if (res.code == 482) {
let nowTime = new Date() / 1000 | 0

View File

@ -14,7 +14,7 @@
</image>
<view class="contentboxitemright_itembox flex-colum">
<text>会员</text>
<text>入会权益</text>
<text>入会权益</text>
</view>
</view>
<view class="contentboxitemright_item flex-between" @click="memberindex(0)">
@ -67,9 +67,16 @@
}
})
} else {
uni.pro.navigateTo('member/memberdetails', {
shopId_id: uni.cache.get('shopUser'),
})
if (this.usershopUserinfo.isVip == 0) {
//
uni.navigateTo({
url: '/pages/member/activatedmemberone?shopId=' + uni.cache.get('shopUser')
})
} else {
uni.pro.navigateTo('member/memberdetails', {
shopId_id: uni.cache.get('shopUser'),
})
}
}
},
memberindex(i) {

View File

@ -381,8 +381,8 @@
},
goRecharge() { //
// ,,
console.log(uni.cache.get('userInfo').telephone, '调试1')
if (uni.cache.get('userInfo').telephone == '') {
// console.log(this.amountVIP.isVip, '1')
if (this.amountVIP.isVip == 0) {
//
uni.navigateTo({
url: '/pages/member/activatedmemberone?shopId=' + uni.cache.get('shopUser')
@ -480,7 +480,7 @@
let res = await this.api.accountPay({
orderId: this.listinfoid,
memberId: this.amountVIP.id,
pwd:pwd
pwd: pwd
})
if (res.code == 0) {
// data ->1

View File

@ -170,7 +170,7 @@
let res = await this.api.upUserInfo({
headImg: this.userHeadImg,
nickName: this.nickName,
telephone: this.phonetitle
telephone: this.phonetitle == '请授权手机号' ? '' : this.phonetitle
})
if (res.code == 0) {
uni.navigateBack()

View File

@ -61,6 +61,31 @@ const store = new Vuex.Store({
},
},
actions: {
loginEvent: () => {
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);
}
},
fail: (err) => {}
});
}
});
},
set_shopid: async ({
commit
}, data) => {