From 4c9525b77cb86da7c5b477dcafffc78360c5b850 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期一, 16 六月 2025 14:20:06 +0800 Subject: [PATCH] # --- pages/login/index.vue | 57 ++++++++++++++++++++++++++++ pages/home/index.vue | 2 common/request.js | 2 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/common/request.js b/common/request.js index 53b11d5..1b762d2 100644 --- a/common/request.js +++ b/common/request.js @@ -16,7 +16,7 @@ const token = uni.getStorageSync('token'); // const URL = 'http://47.76.147.249:8080/rsf-server/pda' + url; // const URL = 'http://test.zoneyung.net:8080/rsf-server/pda' + url; - const URL = 'http://127.0.0.1:8080/rsf-server/pda' + url; + const URL = 'http://192.168.4.50:8080/rsf-server/pda' + url; uni.request({ url: URL, data: postData, diff --git a/pages/home/index.vue b/pages/home/index.vue index e85ba2e..e94efa4 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -179,7 +179,7 @@ setTimeout(() => { uni.removeStorageSync('token'); uni.reLaunch({ - url: "/pages/login/login" + url: "/pages/login/index" }); }, 1000); } diff --git a/pages/login/index.vue b/pages/login/index.vue index 5f168da..27b6766 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> @@ -119,6 +119,61 @@ }) }, 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