根据token静默登录

This commit is contained in:
duan
2024-07-20 15:33:54 +08:00
parent 638ffcb824
commit 85bba7828c
5 changed files with 41 additions and 40 deletions

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) => {