uu
This commit is contained in:
parent
598a3c1b0e
commit
0055c72918
@ -28,6 +28,10 @@ const pageEventNames = {
|
|||||||
addressSaveSuccess: "addressSaveSuccess", // 地址保存成功
|
addressSaveSuccess: "addressSaveSuccess", // 地址保存成功
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sysEventNames = {
|
||||||
|
login: "login", // 触发登录
|
||||||
|
}
|
||||||
|
|
||||||
const addressNameCodeMap = [
|
const addressNameCodeMap = [
|
||||||
{ nameKey: 'countryName', codeKey: 'country' },
|
{ nameKey: 'countryName', codeKey: 'country' },
|
||||||
{ nameKey: 'provinceName', codeKey: 'province' },
|
{ nameKey: 'provinceName', codeKey: 'province' },
|
||||||
@ -52,6 +56,7 @@ export {
|
|||||||
addressNameCodeMap,
|
addressNameCodeMap,
|
||||||
dateRangeList,
|
dateRangeList,
|
||||||
pageEventNames,
|
pageEventNames,
|
||||||
|
sysEventNames,
|
||||||
authCodeEnum,
|
authCodeEnum,
|
||||||
dealBtnMap,
|
dealBtnMap,
|
||||||
dateTypeEnum,
|
dateTypeEnum,
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
|
|
||||||
import { goto } from "./untool"
|
import { goto } from "./untool"
|
||||||
|
import { getCurrentInstance } from "vue"
|
||||||
|
import { sysEventNames } from "@/common/enum"
|
||||||
|
|
||||||
export const goLogin = ()=> {
|
export const goLogin = ()=> {
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
setTimeout(()=> {
|
uni.$emit(sysEventNames.login, { })
|
||||||
console.log("===uni===", uni)
|
|
||||||
|
|
||||||
debugger
|
|
||||||
}, 500)
|
|
||||||
debugger
|
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifndef MP
|
// #ifndef MP
|
||||||
|
|||||||
@ -9,6 +9,8 @@
|
|||||||
import { getSessionLoginInfo, setSessionLoginInfo, setSessionXToken } from "@/session"
|
import { getSessionLoginInfo, setSessionLoginInfo, setSessionXToken } from "@/session"
|
||||||
import { encrypt } from "@/common/libs/jsencrypt_utils"
|
import { encrypt } from "@/common/libs/jsencrypt_utils"
|
||||||
import { promiseTimeout, showToast } from "@/common/untool"
|
import { promiseTimeout, showToast } from "@/common/untool"
|
||||||
|
import { getCurrentInstance } from "vue"
|
||||||
|
import { sysEventNames } from "@/common/enum"
|
||||||
|
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
import LoginComponent from "@/components/buns-api/login/mp-login"
|
import LoginComponent from "@/components/buns-api/login/mp-login"
|
||||||
@ -29,11 +31,13 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
uni.$on(sysEventNames.login, this.triggerLogin)
|
||||||
// setSessionXToken() // 登录前先清除xtoke
|
|
||||||
},
|
},
|
||||||
mounted(){
|
mounted(){
|
||||||
},
|
},
|
||||||
|
unmounted(){
|
||||||
|
uni.$off(sysEventNames.login, this.triggerLogin)
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async handleLoginedBack() {
|
async handleLoginedBack() {
|
||||||
await promiseTimeout(300)
|
await promiseTimeout(300)
|
||||||
|
|||||||
@ -50,7 +50,7 @@
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
pageLoading: true,
|
pageLoading: false,
|
||||||
submitLogin: {
|
submitLogin: {
|
||||||
code: '',
|
code: '',
|
||||||
nickName: '',
|
nickName: '',
|
||||||
@ -70,11 +70,11 @@
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
try{
|
try{
|
||||||
this.initData()
|
// this.initData()
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.error("created -- initData ==========", e)
|
console.error("created -- initData ==========", e)
|
||||||
}
|
}
|
||||||
this.pageLoading = false
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
commodHeaders(){
|
commodHeaders(){
|
||||||
@ -84,8 +84,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async initData(){
|
async initData(){
|
||||||
|
// 防止多次触发
|
||||||
|
if(this.pageLoading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.pageLoading = true
|
||||||
let isLogined = !!getSessionXToken()
|
let isLogined = !!getSessionXToken()
|
||||||
if(!isLogined) {
|
if(!isLogined) {
|
||||||
|
try{
|
||||||
await this.autoLogin()
|
await this.autoLogin()
|
||||||
if(this.token) {
|
if(this.token) {
|
||||||
// 如果用户信息已绑定,直接触发登录成功
|
// 如果用户信息已绑定,直接触发登录成功
|
||||||
@ -104,7 +110,11 @@
|
|||||||
console.error("auto login checkParams err=====", err)
|
console.error("auto login checkParams err=====", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}catch(err){
|
||||||
|
console.error("isLogined ==== err", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
this.pageLoading = false
|
||||||
},
|
},
|
||||||
async onChooseAvatar(res) {
|
async onChooseAvatar(res) {
|
||||||
let tmpFilePath = res.detail.avatarUrl
|
let tmpFilePath = res.detail.avatarUrl
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user