91 lines
2.5 KiB
Vue
91 lines
2.5 KiB
Vue
<template>
|
|
<tpx-dialog v-model:show="lgDialog.show" :renderDefaultSlot="true" title="登录" :rootStyle="'min-height:auto;'">
|
|
<LoginComponent ref="lcRef" @succeedBack="handleLoginedBack"
|
|
@userinfoUpdateBack="handleUpdateUserInfoBanck"/>
|
|
</tpx-dialog>
|
|
</template>
|
|
|
|
<script>
|
|
import { USERKEY } from "@/store/actionKey"
|
|
import { getSessionLoginInfo, setSessionLoginInfo, setSessionXToken } from "@/session"
|
|
import { encrypt } from "@/common/libs/jsencrypt_utils"
|
|
import { promiseTimeout, showToast } from "@/common/untool"
|
|
import { getCurrentInstance } from "vue"
|
|
import { sysEventNames } from "@/common/enum"
|
|
import { checkParams } from "@/common/validate"
|
|
|
|
// #ifdef MP
|
|
import LoginComponent from "@/components/buns-api/login/mp-login"
|
|
// #endif
|
|
|
|
// #ifndef MP
|
|
import LoginComponent from "@/components/buns-api/login/com-login"
|
|
// #endif
|
|
|
|
export default {
|
|
components: { LoginComponent },
|
|
data() {
|
|
return {
|
|
lgDialog: { show: false },
|
|
submitValidConfig: {
|
|
nickName: { required: true, requiredMsg: '昵称不能为空' },
|
|
// avatarUrl: { required: true, requiredMsg: '头像不能为空' },
|
|
phoneNumber: { required: true, requiredMsg: '手机号不能为空' },
|
|
},
|
|
}
|
|
},
|
|
computed: {
|
|
|
|
},
|
|
created() {
|
|
uni.$on(sysEventNames.login, this.triggerLogin)
|
|
},
|
|
mounted(){
|
|
|
|
},
|
|
unmounted(){
|
|
uni.$off(sysEventNames.login, this.triggerLogin)
|
|
},
|
|
methods: {
|
|
async handleLoginedBack() {
|
|
await promiseTimeout(300)
|
|
await this.$store.dispatch(USERKEY.GETUSERINFO)
|
|
this.reloadCurrentPage(this) // 刷新当前页面
|
|
},
|
|
async handleUpdateUserInfoBanck(){
|
|
this.lgDialog.show = false
|
|
await this.$store.dispatch(USERKEY.GETUSERINFO)
|
|
this.reloadCurrentPage(this) // 刷新当前页面
|
|
},
|
|
async handleCheckUserInfo() {
|
|
let bl = false
|
|
const userInfo = this.$store.getters.userInfo
|
|
let data = {
|
|
nickName: userInfo.nickName,
|
|
avatarUrl: userInfo.avatar,
|
|
phoneNumber: userInfo.phonenumber,
|
|
}
|
|
try{
|
|
await checkParams(data, this.submitValidConfig, false)
|
|
bl = true
|
|
}catch(err){
|
|
console.error("auto login checkParams err=====", err)
|
|
}
|
|
this.lgDialog.show = !bl
|
|
if(this.lgDialog.show) { // 更新用户信息到组件中
|
|
this.$refs.lcRef?.updateSubmitLoginInfo?.(data)
|
|
}
|
|
return bl
|
|
},
|
|
async triggerLogin(){
|
|
setSessionXToken() // 登录前先清除xtoke
|
|
await this.$refs.lcRef.initData()
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
|
|
</style>
|