|
@@ -218,18 +218,24 @@
|
|
|
uni.showLoading({
|
|
|
title: '正在登录...'
|
|
|
})
|
|
|
- loginPhone(this.phoneForm).then(res => {
|
|
|
- if (res.data.token) {
|
|
|
- msgSuccess("登录成功!")
|
|
|
- this.useAuthStore.setAuthToken(res.data.token)
|
|
|
+ let res = await loginPhone(this.phoneForm)
|
|
|
+ if (res.data.token) {
|
|
|
+ msgSuccess("登录成功!")
|
|
|
+ this.useAuthStore.setAuthToken(res.data.token)
|
|
|
+ const loginRes = await wx.login();
|
|
|
+ const code = loginRes.code;
|
|
|
+ wxLoginOpenid({code}).then(resp=>{
|
|
|
+ if(resp?.data){
|
|
|
+ const { openid, sessionKey } = resp.data
|
|
|
+ this.useAuthStore.setOpenid(openid)
|
|
|
+ }
|
|
|
setTimeout(() => {
|
|
|
uni.switchTab({
|
|
|
url: "/pages/index/index"
|
|
|
})
|
|
|
}, 1000)
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
// 账号登录
|
|
|
async userNameLoginHandle() {
|
|
@@ -249,18 +255,29 @@
|
|
|
...this.userNameForm
|
|
|
}
|
|
|
form.password = encryptAESCBC(form.password);
|
|
|
- usernameLogin(form).then(res => {
|
|
|
- // console.log(res, "登录")
|
|
|
- if (res.data.token) {
|
|
|
- msgSuccess("登录成功!")
|
|
|
- this.useAuthStore.setAuthToken(res.data.token)
|
|
|
+ let res = await usernameLogin(form)
|
|
|
+ if (res.data.token) {
|
|
|
+ msgSuccess("登录成功!")
|
|
|
+ this.useAuthStore.setAuthToken(res.data.token)
|
|
|
+ const loginRes = await wx.login();
|
|
|
+ const code = loginRes.code;
|
|
|
+ wxLoginOpenid({code}).then(resp=>{
|
|
|
+ if(resp?.data){
|
|
|
+ const { openid, sessionKey } = resp.data
|
|
|
+ this.useAuthStore.setOpenid(openid)
|
|
|
+ }
|
|
|
setTimeout(() => {
|
|
|
uni.switchTab({
|
|
|
url: "/pages/index/index"
|
|
|
})
|
|
|
}, 1000)
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ // setTimeout(() => {
|
|
|
+ // uni.switchTab({
|
|
|
+ // url: "/pages/index/index"
|
|
|
+ // })
|
|
|
+ // }, 1000)
|
|
|
+ }
|
|
|
},
|
|
|
toPage(url) {
|
|
|
uni.navigateTo({
|