Browse Source

登录页面添加记住账号

master
邓宏 1 year ago
parent
commit
50bf97fab2
  1. 16
      pages/home/login.vue

16
pages/home/login.vue

@ -22,7 +22,8 @@
} }
} }
.u-checkbox-group{ .u-checkbox-group{
margin-left:30rpx; justify-content: flex-end;
margin:0 30rpx;
} }
.res{ .res{
@ -49,9 +50,9 @@
<view class="item"> <view class="item">
<text class="plant-icon2"/> <input placeholder="请输入密码" type="password" v-model="formData.password"/> <text class="plant-icon2"/> <input placeholder="请输入密码" type="password" v-model="formData.password"/>
</view> </view>
<!-- <u-checkbox-group v-model="demo" shape="circle"> <u-checkbox-group shape="circle">
<u-checkbox label="使用溯源系统账号登录并同步企业信息"/> <u-checkbox :checked="remember" label="记住账号" @click="remember=!remember"/>
</u-checkbox-group> --> </u-checkbox-group>
<button class="cu-btn round bg-green shadow submit" @click="login">登录</button> <button class="cu-btn round bg-green shadow submit" @click="login">登录</button>
@ -80,7 +81,7 @@ import request,{host} from "@/common/request"
export default { export default {
data(){ data(){
return{ return{
demo:[], remember:false,
formData:{ formData:{
password:"", password:"",
@ -103,7 +104,7 @@ export default {
} }
}, },
onLoad(options){ onLoad(options){
this.formData.username=options.phone||"" this.formData.username=options.phone||uni.getStorageSync('username')||""
if(process.env.NODE_ENV === 'development'){ if(process.env.NODE_ENV === 'development'){
this.formData.username="18788469459" this.formData.username="18788469459"
this.formData.password="1qaz@WSX" this.formData.password="1qaz@WSX"
@ -124,6 +125,9 @@ export default {
}) })
if(res.statu){ if(res.statu){
this.$store.dispatch("getUserInfo",res.data.token) this.$store.dispatch("getUserInfo",res.data.token)
if(this.remember){
uni.setStorageSync('username',this.formData.username)
}
}else{ }else{
uni.showModal({ uni.showModal({
title:"提示", title:"提示",

Loading…
Cancel
Save