问题优化

This commit is contained in:
BianLzhaoMin 2025-04-27 16:32:04 +08:00
parent 87ea672899
commit 42995165b7
5 changed files with 58 additions and 7 deletions

View File

@ -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

View File

@ -1 +1 @@
VITE_API_BASE_URL = http://192.168.0.14:11997
VITE_API_BASE_URL = http://112.29.103.165:1616

View File

@ -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" : {},

View File

@ -43,6 +43,22 @@
</up-input>
</up-form-item>
<up-form-item prop="remember">
<!-- <up-checkbox v-model="opinionModel.remember" label="记住密码" /> -->
<!-- <up-checkbox-group v-model="opinionModel.remember" @change="checkboxChange">
<up-checkbox :name="false" label="记住密码" />
</up-checkbox-group> -->
<up-checkbox
label="记住密码"
name="agree"
usedAlone
v-model:checked="opinionModel.remember"
>
</up-checkbox>
</up-form-item>
<up-form-item>
<up-button type="primary" text="登录" @tap="onSubmitLogin" shape="circle" />
</up-form-item>
@ -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
}
})
</script>
<style lang="scss" scoped>

View File

@ -12,7 +12,7 @@ export default defineConfig({
// target: 'http://192.168.0.137:11997', // 方亮
// target: 'http://192.168.0.60:11997', // 赵福海
// target: 'http://192.168.0.39:11997', // 陈长文
target: 'http://192.168.0.14:11997', // 测试环境
target: 'http://112.29.103.165:1616', // 测试环境
changeOrigin: true,
rewrite: (path) => {
return path.replace(/\/api/, '')