From ae7025e66f18300e32ac46ec63a0663b6995583c Mon Sep 17 00:00:00 2001 From: "453530270@qq.com" Date: Thu, 2 Nov 2023 20:32:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/login/index.vue | 15 +++++++++++++- pages/verfiy/index.vue | 45 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/pages/login/index.vue b/pages/login/index.vue index 6a91d12..7faa34f 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -56,6 +56,8 @@ import * as LoginApi from '@/api/login' import * as Verify from '@/utils/verify' import store from '@/store' +// 校验登录 +import { checkLogin, showError } from '@/core/app' export default { @@ -80,8 +82,19 @@ import store from '@/store' async onLoad(options) { // do nothing }, - + mounted() { + this.init() + }, methods: { + + // 系统初始化 + init(){ + if(checkLogin()==true){ + this.isLogin = true + // 登录了的话 就跳转到相应的页面 + this.$navTo("pages/home") + } + }, //goto smslogin gtsms(){ this.$navTo("pages/login/loginsms") diff --git a/pages/verfiy/index.vue b/pages/verfiy/index.vue index 321fb9e..62e7022 100644 --- a/pages/verfiy/index.vue +++ b/pages/verfiy/index.vue @@ -25,6 +25,7 @@ --> + @@ -38,6 +39,8 @@ import * as UploadApi from '@/api/upload' import * as Verify from '@/utils/verify' import store from '@/store' + import * as UserApi from '@/api/user' + import { checkLogin, showError } from '@/core/app' // 最大图片数量 const maxImageLength = 2 @@ -51,10 +54,50 @@ rid:"", // 图片列表 imageList: [], + //用户信息 + userInfo:[] } }, + mounted() { + this.init() + }, methods: { - // 点击登录 + // 系统初始化 + init(){ + if(checkLogin()==true){ + this.isLogin = true + this.getUserInfo() + }else{ + this.isLogin= false + showError("请登录后再操作",this.gotologin()) + } + }, + gotologin(){ + this.$navTo("pages/login/index") + }, + // 获取当前用户信息 + getUserInfo() { + const app = this + return new Promise((resolve, reject) => { + !app.isLogin ? resolve(null) : UserApi.info({}, { load: app.isFirstload }) + .then(result => { + app.userInfo = result.data.userInfo + if(app.userInfo.real_name!=""){ + this.$navTo("pages/home") + } + resolve(app.userInfo) + }) + .catch(err => { + if (err.result && err.result.status == 401) { + app.isLogin = false + resolve(null) + } else { + reject(err) + } + }) + }) + }, + // 提交认证信息 chkst() { const app = this if (!app.isLoading && app.formValidationName(app.rname) && app.formValidationId(app.rid)) {