登录弹框逻辑修改
This commit is contained in:
parent
9146a07e6e
commit
fa947ee625
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<tpx-dialog v-model:show="lgDialog.show" title="登录" :rootStyle="'min-height:auto;'">
|
<tpx-dialog v-model:show="lgDialog.show" :renderDefaultSlot="true" title="登录" :rootStyle="'min-height:auto;'">
|
||||||
<LoginComponent ref="lcRef" @succeedBack="handleLoginedBack" @needLoginInput="handleShowLogin"></LoginComponent>
|
<LoginComponent ref="lcRef" @succeedBack="handleLoginedBack"
|
||||||
|
@userinfoUpdateBack="handleUpdateUserInfoBanck"/>
|
||||||
</tpx-dialog>
|
</tpx-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -42,15 +43,21 @@
|
|||||||
async handleLoginedBack() {
|
async handleLoginedBack() {
|
||||||
await promiseTimeout(300)
|
await promiseTimeout(300)
|
||||||
await this.$store.dispatch(USERKEY.GETUSERINFO)
|
await this.$store.dispatch(USERKEY.GETUSERINFO)
|
||||||
this.lgDialog.show = false
|
|
||||||
// showToast("登录成功")
|
|
||||||
this.reloadCurrentPage(this) // 刷新当前页面
|
this.reloadCurrentPage(this) // 刷新当前页面
|
||||||
},
|
},
|
||||||
handleShowLogin() {
|
async handleUpdateUserInfoBanck(){
|
||||||
this.lgDialog.show = true
|
this.lgDialog.show = false
|
||||||
|
await this.$store.dispatch(USERKEY.GETUSERINFO)
|
||||||
|
this.reloadCurrentPage(this) // 刷新当前页面
|
||||||
},
|
},
|
||||||
triggerLogin(){
|
async handleCheckUserInfo() {
|
||||||
this.$refs.lcRef.initData()
|
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>
|
||||||
|
|
||||||
<template #footer>
|
<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>
|
</template>
|
||||||
</tpx-layout>
|
</tpx-layout>
|
||||||
</view>
|
</view>
|
||||||
@ -81,7 +81,6 @@
|
|||||||
commodHeaders(){
|
commodHeaders(){
|
||||||
return {
|
return {
|
||||||
...getCommonReqData().header,
|
...getCommonReqData().header,
|
||||||
"Oms-X-Token": this.token,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async initData(){
|
async initData(){
|
||||||
@ -94,23 +93,7 @@
|
|||||||
if(!isLogined) {
|
if(!isLogined) {
|
||||||
try{
|
try{
|
||||||
await this.autoLogin()
|
await this.autoLogin()
|
||||||
if(this.token) {
|
this.loginSucceed()
|
||||||
// 如果用户信息已绑定,直接触发登录成功
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch(err){
|
}catch(err){
|
||||||
console.error("isLogined ==== err", err)
|
console.error("isLogined ==== err", err)
|
||||||
}
|
}
|
||||||
@ -145,15 +128,32 @@
|
|||||||
handleNicknamereview(e){
|
handleNicknamereview(e){
|
||||||
console.log(e)
|
console.log(e)
|
||||||
},
|
},
|
||||||
async handleConfirmLogin() {
|
async handleUpdateUserinfo() {
|
||||||
await checkParams(this.submitLogin, this.submitValidConfig)
|
await checkParams(this.submitLogin, this.submitValidConfig)
|
||||||
|
// 更新用户信息
|
||||||
await this.autoLogin()
|
await this.autoLogin()
|
||||||
this.loginSucceed()
|
this.$emit("userinfoUpdateBack")
|
||||||
},
|
},
|
||||||
async loginSucceed(){
|
async loginSucceed(){
|
||||||
let token = this.token
|
let token = this.token
|
||||||
await this.$store.dispatch(USERKEY.UPDATETOKEN, { token })
|
await this.$store.dispatch(USERKEY.UPDATETOKEN, { token })
|
||||||
this.$emit("succeedBack")
|
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