From 42995165b717062c8c073b08bb983831ac2dd63d Mon Sep 17 00:00:00 2001
From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com>
Date: Sun, 27 Apr 2025 16:32:04 +0800
Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.env.development | 2 +-
.env.production | 2 +-
src/manifest.json | 5 ++--
src/pages/login/index.vue | 54 +++++++++++++++++++++++++++++++++++++--
vite.config.js | 2 +-
5 files changed, 58 insertions(+), 7 deletions(-)
diff --git a/.env.development b/.env.development
index d786ffd..d6e4756 100644
--- a/.env.development
+++ b/.env.development
@@ -1,2 +1,2 @@
-# VITE_API_BASE_URL = http://192.168.0.14:11997
+# VITE_API_BASE_URL = http://112.29.103.165:1616
VITE_API_BASE_URL = /api
diff --git a/.env.production b/.env.production
index d7faf5b..931ce53 100644
--- a/.env.production
+++ b/.env.production
@@ -1 +1 @@
-VITE_API_BASE_URL = http://192.168.0.14:11997
\ No newline at end of file
+VITE_API_BASE_URL = http://112.29.103.165:1616
\ No newline at end of file
diff --git a/src/manifest.json b/src/manifest.json
index f399b91..c06820f 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -3,7 +3,7 @@
"appid" : "__UNI__F75AFA9",
"description" : "",
"versionName" : "1.0.0",
- "versionCode" : "100",
+ "versionCode" : 101,
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
@@ -58,7 +58,8 @@
"photo-library" : {
"description" : "需要相册权限选择照片"
}
- }
+ },
+ "idfa" : false
},
/* SDK配置 */
"sdkConfigs" : {},
diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue
index 7bc311a..882460e 100644
--- a/src/pages/login/index.vue
+++ b/src/pages/login/index.vue
@@ -43,6 +43,22 @@
+
+
+
+
+
+
+
+
+
@@ -63,6 +79,7 @@ import { ref } from 'vue'
import { debounce } from 'lodash-es' // 引入防抖函数
import { useMemberStore } from '@/stores'
import { loginApi, getUserInfoApi } from '@/services/login.js'
+import { onLoad } from '@dcloudio/uni-app'
const showPassword = ref(false) // 密码是否可见
const sendLoading = ref(false) // 加载中
@@ -70,8 +87,11 @@ const memberStore = useMemberStore() // 用户信息
// 表单数据源
const opinionModel = ref({
- username: '!Admin',
- password: 'Bonus@admin123',
+ username: '',
+ password: '',
+ remember: false,
+ // username: '!Admin',
+ // password: 'Bonus@admin123',
})
const opinionRules = ref({
@@ -134,6 +154,23 @@ const onSubmitLogin = debounce(() => {
sendLoading.value = false
if (res.code === 200) {
memberStore.setToken(res.token)
+
+ console.log(opinionModel.value.remember, 'opinionModel.value.remember')
+
+ if (opinionModel.value.remember) {
+ const encryptedPwd = btoa(opinionModel.value.password)
+ uni.setStorageSync('userInfo', {
+ username: opinionModel.value.username,
+ password: encryptedPwd,
+ })
+ } else {
+ const userInfo = uni.getStorageSync('userInfo')
+ if (userInfo) {
+ console.log('移除--')
+ uni.removeStorage('userInfo')
+ uni.removeStorageSync('userInfo')
+ }
+ }
getUserInfo()
} else {
uni.$u.toast('登录失败' + res.message)
@@ -149,6 +186,10 @@ const onSubmitLogin = debounce(() => {
})
}, 500)
+const checkboxChange = (value) => {
+ console.log(value, 'checkboxChange')
+}
+
// 获取用户信息
const getUserInfo = () => {
getUserInfoApi().then((res) => {
@@ -169,6 +210,15 @@ const getUserInfo = () => {
}
})
}
+
+onLoad(() => {
+ const userInfo = uni.getStorageSync('userInfo')
+ if (userInfo) {
+ opinionModel.value.username = userInfo.username
+ opinionModel.value.password = atob(userInfo.password)
+ opinionModel.value.remember = true
+ }
+})