|
@@ -51,11 +51,15 @@
|
|
|
encryptAESCBC
|
|
|
} from "@/utils/crypto.js"
|
|
|
import {
|
|
|
- register
|
|
|
+ register,
|
|
|
+ wxLoginOpenid
|
|
|
} from "@/api/login.js"
|
|
|
import {
|
|
|
useAuthStore
|
|
|
} from '@/store/authStore.js'
|
|
|
+ import {
|
|
|
+ me
|
|
|
+ } from '@/api/user.js'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -122,7 +126,8 @@
|
|
|
message: '请选择性别',
|
|
|
trigger: ['change']
|
|
|
}]
|
|
|
- }
|
|
|
+ },
|
|
|
+ redirect: null,
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
@@ -149,15 +154,51 @@
|
|
|
zhangHao
|
|
|
})
|
|
|
msgSuccess("注册成功");
|
|
|
- setTimeout(() => {
|
|
|
- uni.switchTab({
|
|
|
- url: "/pages/index/index"
|
|
|
- })
|
|
|
- }, 1000)
|
|
|
+ this.initUser()
|
|
|
+ // setTimeout(() => {
|
|
|
+ // if(this.redirect){
|
|
|
+ // uni.removeStorageSync("redirect")
|
|
|
+ // uni.reLaunch({
|
|
|
+ // url: this.redirect.url+'?id='+this.redirect.id+'&title='+this.redirect.title
|
|
|
+ // })
|
|
|
+ // }else{
|
|
|
+ // uni.switchTab({
|
|
|
+ // url: "/pages/index/index"
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }, 1000)
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ async initUser(){
|
|
|
+ const loginRes = await wx.login();
|
|
|
+ const code = loginRes.code;
|
|
|
+ let userRes = await me();
|
|
|
+ let wxRes = await wxLoginOpenid({code})
|
|
|
+ // 加载用户信息
|
|
|
+ if(userRes && userRes?.code===0){
|
|
|
+ this.useAuthStore.setUserInfo(userRes.data)
|
|
|
+ }
|
|
|
+ // 加载openid
|
|
|
+ if(wxRes && wxRes?.data){
|
|
|
+ const { openid, sessionKey } = wxRes.data
|
|
|
+ this.useAuthStore.setOpenid(openid)
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ if(this.redirect){
|
|
|
+ uni.removeStorageSync("redirect")
|
|
|
+ uni.reLaunch({
|
|
|
+ url: this.redirect.url+'?id='+this.redirect.id+'&title='+this.redirect.title
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ uni.switchTab({
|
|
|
+ url: "/pages/index/index"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ },
|
|
|
// 提示
|
|
|
showToast(msg, type) {
|
|
|
uni.showToast({
|
|
@@ -189,6 +230,10 @@
|
|
|
})
|
|
|
this.mode = 'register'
|
|
|
}
|
|
|
+ if(uni.getStorageSync("redirect")){
|
|
|
+ this.redirect = uni.getStorageSync("redirect")
|
|
|
+ }
|
|
|
+ console.log(this.redirect,"重定")
|
|
|
},
|
|
|
onReady() {
|
|
|
this.$refs.registerForm.setRules(this.rules);
|