620
parent
6bc49a7d68
commit
301da52213
|
|
@ -11,7 +11,7 @@
|
|||
<uni-easyinput type="password" v-model="formData.password" placeholder="请输入密码" />
|
||||
</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>
|
||||
<button type="primary" class="button" @click="login(formData)">登录</button>
|
||||
</uni-forms>
|
||||
|
|
@ -20,9 +20,12 @@
|
|||
|
||||
<script>
|
||||
import CryptoJS from 'crypto-js'
|
||||
import { onMounted } from "vue"
|
||||
|
||||
let checked = false
|
||||
|
||||
|
||||
|
||||
export default {
|
||||
data() {
|
||||
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: {
|
||||
|
||||
handleChange(formData){
|
||||
|
|
@ -60,11 +74,15 @@
|
|||
|
||||
//记住密码功能
|
||||
if (formData.checked === true){
|
||||
uni.setStorageSync('loginChecked', true)
|
||||
uni.setStorageSync('loginName',postForm.loginName)
|
||||
uni.setStorageSync('password',formData.password)
|
||||
uni.setStorageSync('secretKey',postForm.secretKey)
|
||||
} else {
|
||||
uni.setStorageSync('loginChecked', false)
|
||||
uni.removeStorageSync('loginName')
|
||||
uni.removeStorageSync('secretKey')
|
||||
uni.removeStorageSync('password')
|
||||
this.formData.username = ''
|
||||
this.formData.password = ''
|
||||
}
|
||||
|
|
@ -96,7 +114,7 @@
|
|||
console.log('-----avatar------',uni.getStorageSync('avatar'));
|
||||
})
|
||||
} else {
|
||||
uni.setStorageSync('avatar','../../static/tabs/touxing.png')
|
||||
uni.setStorageSync('avatar','../../static/tabs/touxiang.png')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,13 +81,22 @@
|
|||
// console.log('click',index,func[index].url)
|
||||
},
|
||||
logout(){
|
||||
uni.removeStorageSync('loginName')
|
||||
uni.removeStorageSync('secretKey')
|
||||
uni.removeStorageSync('Gs-Token')
|
||||
uni.removeStorageSync('value')
|
||||
uni.redirectTo({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
if(uni.getStorageSync('loginChecked')===true){
|
||||
uni.redirectTo({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
} else {
|
||||
uni.removeStorageSync('loginName')
|
||||
uni.removeStorageSync('secretKey')
|
||||
uni.removeStorageSync('Gs-Token')
|
||||
uni.removeStorageSync('value')
|
||||
uni.removeStorageSync('password')
|
||||
uni.redirectTo({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -403,7 +403,7 @@ var render = function () {
|
|||
{ attrs: { _i: 8 } },
|
||||
[
|
||||
_c("v-uni-checkbox", {
|
||||
attrs: { checked: false, _i: 9 },
|
||||
attrs: { checked: _vm._$g(9, "a-checked"), _i: 9 },
|
||||
on: {
|
||||
click: function ($event) {
|
||||
return _vm.$handleViewEvent($event)
|
||||
|
|
|
|||
Loading…
Reference in New Issue