From 32b10def2b0944c4afbe4d89e55261c39a690f1d Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期四, 17 七月 2025 13:40:09 +0800 Subject: [PATCH] # --- pages/login/index.vue | 65 ++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 1 deletions(-) diff --git a/pages/login/index.vue b/pages/login/index.vue index 5f168da..c807b4b 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -55,7 +55,7 @@ </view> </view> <view class="itemView"> - <button class="loadingButton" :loading="loading">{{btnText}}</button> + <button class="loadingButton" @click="onLogin()" :loading="loading">{{btnText}}</button> </view> </view> </view> @@ -117,8 +117,71 @@ uni.onLocaleChange((e) => { this.applicationLocale = e.locale; }) + + this.user = uni.getStorageSync('user') + if (!this.user) { + this.user = { + userName: '', + password: '' + } + } }, methods:{ + async onLogin() { + const { + code, + data, + msg + } = await request('/login', { + username: this.user.userName, + password: this.user.password, + }) + if (code === 200) { + this.loading = true; + this.loginButton = 'login.loging'; + uni.setStorageSync('token', data.accessToken); + uni.setStorageSync('userData', data.user); + if (this.remberPassword) { + uni.setStorageSync('user', this.user); + } else { + uni.removeStorageSync('user'); + } + this.goHome() + } else { + uni.showToast({ + title: msg + }) + } + + }, + goHome() { + setTimeout(() => { + // this.getAuth2() + this.getFields() + uni.showToast({ + title: '鐧诲綍鎴愬姛' + }) + setTimeout(() => { + uni.reLaunch({ + url: '../home/index' + }); + }, 300) + }, 700) + }, + async getFields() { + const { + code, + data, + msg + } = await request('/dynamic/fields', {}, 'get') + if (code === 200) { + this.$store.commit('user/setFields', data) + } else { + uni.showToast({ + title: msg + }) + } + }, remberChange(e) { this.remberPassword = !this.remberPassword }, -- Gitblit v1.9.1