This commit is contained in:
aihe 2024-08-01 02:59:34 +08:00
parent 75cbfdcbaa
commit 598a3c1b0e
5 changed files with 25 additions and 11 deletions

View File

@ -2,5 +2,16 @@
import { goto } from "./untool"
export const goLogin = ()=> {
// goto("login/login", 2)
// #ifdef MP
setTimeout(()=> {
console.log("===uni===", uni)
debugger
}, 500)
debugger
// #endif
// #ifndef MP
goto("login/login", 2)
// #endif
}

View File

@ -259,6 +259,9 @@ const setNavigationBarTitle = (title)=> {
}
const reloadCurrentPage = (_thisPage)=> {
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
let curPage = routes[routes.length - 1] // 获取当前页面路由,也就是最后一个打开的页面路由
_thisPage = curPage || _thisPage
let { fullPath } = _thisPage.$page
uni.redirectTo({
url: fullPath

View File

@ -1,6 +1,6 @@
<template>
<tpx-dialog v-model:show="lgDialog.show" title="登录" :rootStyle="'min-height:auto;'">
<LoginComponent @succeedBack="handleLoginedBack" @needLoginInput="handleShowLogin"></LoginComponent>
<LoginComponent ref="lcRef" @succeedBack="handleLoginedBack" @needLoginInput="handleShowLogin"></LoginComponent>
</tpx-dialog>
</template>
@ -29,17 +29,23 @@
},
created() {
// setSessionXToken() // 登录前先清除xtoke
},
mounted(){
},
methods: {
async handleLoginedBack() {
await promiseTimeout(300)
await this.$store.dispatch(USERKEY.GETUSERINFO)
showToast("登录成功")
// showToast("登录成功")
this.reloadCurrentPage(this) // 刷新当前页面
},
handleShowLogin() {
this.lgDialog.show = true
},
triggerLogin(){
this.$refs.lcRef.initData()
}
}
}

View File

@ -63,7 +63,6 @@
phoneNumber: { required: true, requiredMsg: '手机号不能为空' },
},
token: '',
isLogined: !!getSessionXToken()
}
},
computed: {
@ -85,7 +84,8 @@
}
},
async initData(){
if(!this.isLogined) {
let isLogined = !!getSessionXToken()
if(!isLogined) {
await this.autoLogin()
if(this.token) {
// 如果用户信息已绑定,直接触发登录成功

View File

@ -10,13 +10,7 @@
import { encrypt } from "@/common/libs/jsencrypt_utils"
import { promiseTimeout, showToast } from "@/common/untool"
// #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 },