登录弹框逻辑修改
This commit is contained in:
parent
9146a07e6e
commit
fa947ee625
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<tpx-dialog v-model:show="lgDialog.show" title="登录" :rootStyle="'min-height:auto;'">
|
||||
<LoginComponent ref="lcRef" @succeedBack="handleLoginedBack" @needLoginInput="handleShowLogin"></LoginComponent>
|
||||
<tpx-dialog v-model:show="lgDialog.show" :renderDefaultSlot="true" title="登录" :rootStyle="'min-height:auto;'">
|
||||
<LoginComponent ref="lcRef" @succeedBack="handleLoginedBack"
|
||||
@userinfoUpdateBack="handleUpdateUserInfoBanck"/>
|
||||
</tpx-dialog>
|
||||
</template>
|
||||
|
||||
@ -42,15 +43,21 @@
|
||||
async handleLoginedBack() {
|
||||
await promiseTimeout(300)
|
||||
await this.$store.dispatch(USERKEY.GETUSERINFO)
|
||||
this.lgDialog.show = false
|
||||
// showToast("登录成功")
|
||||
this.reloadCurrentPage(this) // 刷新当前页面
|
||||
},
|
||||
handleShowLogin() {
|
||||
this.lgDialog.show = true
|
||||
async handleUpdateUserInfoBanck(){
|
||||
this.lgDialog.show = false
|
||||
await this.$store.dispatch(USERKEY.GETUSERINFO)
|
||||
this.reloadCurrentPage(this) // 刷新当前页面
|
||||
},
|
||||
triggerLogin(){
|
||||
this.$refs.lcRef.initData()
|
||||
async handleCheckUserInfo() {
|
||||
let bl = await this.$refs.lcRef.handleCheckUserInfo()
|
||||
this.lgDialog.show = !bl
|
||||
return bl
|
||||
},
|
||||
async triggerLogin(){
|
||||
setSessionXToken() // 登录前先清除xtoke
|
||||
await this.$refs.lcRef.initData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
</template>
|
||||
|
||||
<template #footer>
|
||||
<u-button v-if="!pageLoading" @click="handleConfirmLogin" type="primary" custom-style="height:66rpx;font-size:32rpx;border-radius: 16rpx;">登录</u-button>
|
||||
<u-button v-if="!pageLoading" @click="handleUpdateUserinfo" type="primary" custom-style="height:66rpx;font-size:32rpx;border-radius: 16rpx;">登录</u-button>
|
||||
</template>
|
||||
</tpx-layout>
|
||||
</view>
|
||||
@ -81,7 +81,6 @@
|
||||
commodHeaders(){
|
||||
return {
|
||||
...getCommonReqData().header,
|
||||
"Oms-X-Token": this.token,
|
||||
}
|
||||
},
|
||||
async initData(){
|
||||
@ -94,23 +93,7 @@
|
||||
if(!isLogined) {
|
||||
try{
|
||||
await this.autoLogin()
|
||||
if(this.token) {
|
||||
// 如果用户信息已绑定,直接触发登录成功
|
||||
const res = await apiService.getInfoByApp({ _loading: true }, this.commodHeaders())
|
||||
let userInfo = res?.user || {}
|
||||
Object.assign(this.submitLogin , {
|
||||
nickName: userInfo.nickName,
|
||||
avatarUrl: userInfo.avatar,
|
||||
phoneNumber: userInfo.phonenumber,
|
||||
})
|
||||
try{
|
||||
await checkParams(this.submitLogin, this.submitValidConfig, false)
|
||||
this.loginSucceed()
|
||||
}catch(err){
|
||||
this.$emit("needLoginInput")
|
||||
console.error("auto login checkParams err=====", err)
|
||||
}
|
||||
}
|
||||
this.loginSucceed()
|
||||
}catch(err){
|
||||
console.error("isLogined ==== err", err)
|
||||
}
|
||||
@ -145,15 +128,32 @@
|
||||
handleNicknamereview(e){
|
||||
console.log(e)
|
||||
},
|
||||
async handleConfirmLogin() {
|
||||
async handleUpdateUserinfo() {
|
||||
await checkParams(this.submitLogin, this.submitValidConfig)
|
||||
// 更新用户信息
|
||||
await this.autoLogin()
|
||||
this.loginSucceed()
|
||||
this.$emit("userinfoUpdateBack")
|
||||
},
|
||||
async loginSucceed(){
|
||||
let token = this.token
|
||||
await this.$store.dispatch(USERKEY.UPDATETOKEN, { token })
|
||||
this.$emit("succeedBack")
|
||||
},
|
||||
async handleCheckUserInfo(){
|
||||
const res = await apiService.getInfoByApp({ _loading: true })
|
||||
let userInfo = res?.user || {}
|
||||
Object.assign(this.submitLogin , {
|
||||
// nickName: userInfo.nickName,
|
||||
// avatarUrl: userInfo.avatar,
|
||||
// phoneNumber: userInfo.phonenumber,
|
||||
})
|
||||
try{
|
||||
await checkParams(this.submitLogin, this.submitValidConfig, false)
|
||||
}catch(err){
|
||||
return false
|
||||
console.error("auto login checkParams err=====", err)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user