master
wang@DESKTOP-VRHIPTL 2024-06-20 15:09:55 +08:00
parent 6bc49a7d68
commit 301da52213
4 changed files with 36252 additions and 605 deletions

View File

@ -11,7 +11,7 @@
<uni-easyinput type="password" v-model="formData.password" placeholder="请输入密码" /> <uni-easyinput type="password" v-model="formData.password" placeholder="请输入密码" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item> <uni-forms-item>
<checkbox :checked="false" @click="handleChange(formData)" /><text>记住用户名和密码</text> <checkbox :checked="formData.checked" @click="handleChange(formData)" /><text>记住用户名和密码</text>
</uni-forms-item> </uni-forms-item>
<button type="primary" class="button" @click="login(formData)"></button> <button type="primary" class="button" @click="login(formData)"></button>
</uni-forms> </uni-forms>
@ -20,9 +20,12 @@
<script> <script>
import CryptoJS from 'crypto-js' import CryptoJS from 'crypto-js'
import { onMounted } from "vue"
let checked = false let checked = false
export default { export default {
data() { data() {
return { return {
@ -34,6 +37,17 @@
} }
}, },
mounted(){
console.log(uni.getStorageSync('loginChecked'));
if (uni.getStorageSync('loginChecked')===true){
this.formData = {
username: uni.getStorageSync('loginName'),
password: uni.getStorageSync('password'),
checked: true,
}
}
},
methods: { methods: {
handleChange(formData){ handleChange(formData){
@ -60,11 +74,15 @@
// //
if (formData.checked === true){ if (formData.checked === true){
uni.setStorageSync('loginChecked', true)
uni.setStorageSync('loginName',postForm.loginName) uni.setStorageSync('loginName',postForm.loginName)
uni.setStorageSync('password',formData.password)
uni.setStorageSync('secretKey',postForm.secretKey) uni.setStorageSync('secretKey',postForm.secretKey)
} else { } else {
uni.setStorageSync('loginChecked', false)
uni.removeStorageSync('loginName') uni.removeStorageSync('loginName')
uni.removeStorageSync('secretKey') uni.removeStorageSync('secretKey')
uni.removeStorageSync('password')
this.formData.username = '' this.formData.username = ''
this.formData.password = '' this.formData.password = ''
} }
@ -96,7 +114,7 @@
console.log('-----avatar------',uni.getStorageSync('avatar')); console.log('-----avatar------',uni.getStorageSync('avatar'));
}) })
} else { } else {
uni.setStorageSync('avatar','../../static/tabs/touxing.png') uni.setStorageSync('avatar','../../static/tabs/touxiang.png')
} }
}) })
} }

View File

@ -81,14 +81,23 @@
// console.log('click',index,func[index].url) // console.log('click',index,func[index].url)
}, },
logout(){ logout(){
if(uni.getStorageSync('loginChecked')===true){
uni.redirectTo({
url: '/pages/login/login'
})
} else {
uni.removeStorageSync('loginName') uni.removeStorageSync('loginName')
uni.removeStorageSync('secretKey') uni.removeStorageSync('secretKey')
uni.removeStorageSync('Gs-Token') uni.removeStorageSync('Gs-Token')
uni.removeStorageSync('value') uni.removeStorageSync('value')
uni.removeStorageSync('password')
uni.redirectTo({ uni.redirectTo({
url: '/pages/login/login' url: '/pages/login/login'
}) })
} }
}
} }
} }
</script> </script>

File diff suppressed because one or more lines are too long

View File

@ -403,7 +403,7 @@ var render = function () {
{ attrs: { _i: 8 } }, { attrs: { _i: 8 } },
[ [
_c("v-uni-checkbox", { _c("v-uni-checkbox", {
attrs: { checked: false, _i: 9 }, attrs: { checked: _vm._$g(9, "a-checked"), _i: 9 },
on: { on: {
click: function ($event) { click: function ($event) {
return _vm.$handleViewEvent($event) return _vm.$handleViewEvent($event)