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