<template>
|
<view class="login">
|
<view class="content">
|
<view class="header">
|
<image :src="require('static/image/login.png')"></image>
|
</view>
|
<view class="main">
|
<wInput v-model="phoneData" type="text" maxlength="15" placeholder="用户名">
|
</wInput>
|
<wInput v-model="passData" type="password" maxlength="15" placeholder="密码">
|
</wInput>
|
<checkbox :checked="RememberThePassword" @click="Check">记住密码</checkbox>
|
</view>
|
<wButton class="wbutton" text="登 录" :rotate="isRotate" @click="startLogin"></wButton>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
var _this;
|
import wInput from '../../components/watch-login/watch-input.vue'
|
import wButton from '../../components/watch-login/watch-button.vue'
|
export default {
|
data() {
|
return {
|
phoneData: '', //用户/电话//admin
|
passData: '',//123456
|
isRotate: false,
|
RememberThePassword: false
|
}
|
},
|
components: {
|
wInput,
|
wButton,
|
},
|
mounted() {
|
_this = this;
|
|
const HCRtp = uni.getStorageSync('HCRtp');
|
if (HCRtp)
|
_this.RememberThePassword = true;
|
else
|
_this.RememberThePassword = false;
|
if (HCRtp) {
|
//缓存的账号
|
const HCuname = uni.getStorageSync('HCuname');
|
//缓存的密码
|
const HCpassw = uni.getStorageSync('HCpassw');
|
//有缓存就赋值给文本没有就清空
|
if (HCuname && HCpassw) {
|
_this.phoneData = HCuname;
|
_this.passData = HCpassw;
|
} else {
|
_this.phoneData = '';
|
_this.passData = '';
|
}
|
}
|
},
|
methods: {
|
startLogin(e) {
|
if (e.isRotate) //判断是否加载中,避免重复点击请求
|
return false;
|
|
let userName = this.phoneData;
|
if ('' == userName || null == userName) {
|
uni.showToast({
|
icon: 'none',
|
position: 'bottom',
|
title: '用户名不能为空'
|
})
|
return;
|
}
|
let pwd = this.passData;
|
if ('' == pwd || null == pwd || pwd.length < 5) {
|
uni.showToast({
|
icon: 'none',
|
position: 'bottom',
|
title: '密码不能小于五位数'
|
})
|
return;
|
}
|
_this.isRotate = true;
|
let data = {
|
'userName': userName,
|
'password': pwd,
|
'VerificationCode': 'App',
|
'UUID': 'App'
|
}
|
// uni.navigateTo({
|
// url: "../AssemblyArea/ProgressProducts/CallMaterial/index"
|
// })
|
// return;
|
this.$AjaxRequest.Params('post', 'Sys_User/login', data, null);
|
this.$AjaxRequest.Request().then(function(result) {
|
if (result.data.status) {
|
|
if (_this.RememberThePassword) {
|
uni.setStorageSync('HCuname', _this.phoneData);
|
uni.setStorageSync('HCpassw', _this.passData);
|
} else {
|
uni.removeStorageSync('HCuname');
|
uni.removeStorageSync('HCpassw');
|
}
|
uni.setStorageSync('HCRtp', _this.RememberThePassword);
|
uni.navigateTo({
|
url: "./main"
|
});
|
_this.$UserTool.setUserInfo(result.data.data);
|
_this.$UserTool.setAllUserInfo({
|
label: result.data.data.userName,
|
value: result.data.data.userName,
|
});
|
//console.log(_this.$UserTool);
|
} else {
|
uni.showToast({
|
icon: 'none',
|
title: result.data.message,
|
duration: 2000
|
});
|
}
|
}).catch(function(err) {
|
//console.log(err);
|
uni.showToast({
|
icon: 'none',
|
title: "请求后台异常,错误信息." + err.errMsg,
|
duration: 2000
|
});
|
//console.log(err);
|
});
|
_this.isRotate = false;
|
},
|
Check(e) {
|
_this.RememberThePassword = !_this.RememberThePassword;
|
}
|
}
|
}
|
</script>
|
|
<style>
|
@import url("../../components/watch-login/css/icon.css");
|
@import url("./css/main.css");
|
</style>
|