|
<style>
|
input::-webkit-input-placeholder {
|
font-size: 12rpx;
|
}
|
#headr {
|
background: #434343;
|
/* width: 375px; */
|
height: 250rpx;
|
text-align: center;
|
background-color: #438EB9;
|
/* background-image: url(../../images/login/root.png) !important;
|
background-size: cover !important;
|
background-repeat: no-repeat !important; */
|
}
|
.SetServer{
|
float: left;
|
margin-left: 20rpx;
|
}
|
.check_rememberPwd{
|
margin-top: 20rpx;
|
margin-left: 20rpx;
|
}
|
.logo {
|
height: 180rpx;
|
width: 180rpx;
|
margin-top: 170rpx;
|
}
|
.logo_input {
|
height: 40rpx;
|
width: 40rpx;
|
margin-left: 40rpx;
|
}
|
.logo_icon {
|
height: 50rpx;
|
width: 50rpx;
|
margin-left: 15rpx;
|
margin-top: 20rpx;
|
}
|
.mui-content{
|
height: 100%;
|
padding-top: 140rpx;
|
background: #FFFFFF;
|
z-index: 1;
|
}
|
.mui-input-group .la_icon {
|
width: 100rpx;
|
text-align: center;
|
font-family: 'Helvetica Neue',Helvetica,sans-serif;
|
line-height: 1.5;
|
float: left;
|
padding: 7px 13px;
|
}
|
.mui-input-group .mui-input-row {
|
height: 85rpx;
|
position: relative;
|
clear: left;
|
overflow: hidden;
|
}
|
.mui-input-row:first-child {
|
border-top: 1px solid #c8c7cc;
|
}
|
.mui-input-row:last-child {
|
border-bottom: 1px solid #c8c7cc;
|
}
|
.mui-input-group .mui-input-row:last-child:after {
|
background-color:#fff;
|
}
|
.mui-input-group .mui-input-row:after {
|
position: absolute;
|
right: 0;
|
bottom: 0;
|
left: 15px;
|
height: 1px;
|
content: '';
|
transform: scaleY(.5);
|
background-color: #c8c7cc;
|
}
|
.mui-input-row input {
|
font-family: 'Helvetica Neue',Helvetica,sans-serif;
|
font-size: 15px;
|
width: 480rpx;
|
/* float: right; */
|
margin-bottom: 0;
|
padding-left: 20rpx;
|
/* padding-right: 10rpx; */
|
/* line-height: 30rpx; */
|
height: 85rpx;
|
/* padding: 7px 40px 7px 0px; */
|
-webkit-user-select: text;
|
/* border: 0; */
|
/* border-radius: 0; */
|
box-shadow: none;
|
outline: 0;
|
background: 0 0;
|
-webkit-appearance: none;
|
}
|
|
.mui-input-group label.mui-navigate-right {
|
font-size: 25px;
|
float: right;
|
padding: 0;
|
width: 80rpx;
|
margin-right: 5rpx;
|
margin-top: -88rpx;
|
display: inline-block;
|
}
|
|
button.btn_login {
|
margin-top: 50rpx;
|
padding: 20rpx;
|
line-height: 1.5;
|
background: #27A6E1;
|
border: none;
|
color: #fff;
|
}
|
</style>
|
|
|
<template>
|
<view class="" style="width: 100vw;height: 64vh;">
|
<div id="headr" class="mui-bar mui-bar-nav">
|
<image class="logo" src="../../images/login/mobox_log_200.png"></image>
|
</div>
|
<div class="mui-content">
|
<form id='login-form' class="mui-input-group">
|
<a href="javascript:;" class="SetServer" @click="inputDialogToggle">配置</a>
|
<!-- <div class="mui-input-row">
|
<label class="la_icon"><image class="logo_input" src="../../images/login/svr_30.png"></image></label>
|
<input type="text" class="mui-input" v-model="userServer" placeholder="服务器地址">
|
<label class="mui-navigate-right" id="sersel"><image class="logo_icon" src="../../images/login/sel_left.png" ></image></label>
|
</div> -->
|
<div class="mui-input-row">
|
<label class="la_icon" ><image class="logo_input" src="../../images/login/person_30.png"></image></label>
|
<input type="text" class="mui-input" v-model="userName" placeholder="请输入账号">
|
<!-- <label class="mui-navigate-right" id="namsel"><image class="logo_icon" src="../../images/login/user-photo.png</image></label> -->
|
</div>
|
<div class="mui-input-row">
|
<label class="la_icon" ><image class="logo_input" src="../../images/login/lock_30.png"></image></label>
|
<input type="password" class="mui-input" v-model="userPwd" placeholder="请输入密码">
|
</div>
|
<checkbox-group class="check_rememberPwd" @change="rememberPwd">
|
<label>
|
<checkbox value="1" :checked="ischecked"/>
|
<text>记住密码</text>
|
</label>
|
</checkbox-group>
|
</form>
|
<button id='login' type="default" @tap="logind" class="btn_login">{{login}}</button>
|
<p style="float:right; margin: 10px 10px;color:#c8c7cc">
|
<span>版本号:</span>
|
<span>{{version}}</span>
|
</p>
|
<div class="" style="text-align: center;background: white;border-top: 0px solid #C0C0C0;color: #7cd0f8;position: absolute;bottom: 0;width: 100%;height: 24px;padding-top:3px;font-size: 11px;">
|
</div>
|
</div>
|
<view>
|
<!-- 输入框示例 -->
|
<uni-popup ref="inputDialog" type="dialog">
|
<uni-popup-dialog ref="inputClose" mode="input" title="设置" :value="userServer"
|
placeholder="请输入内容" @confirm="dialogInputConfirm"></uni-popup-dialog>
|
</uni-popup>
|
</view>
|
</view>
|
|
</template>
|
|
<script>
|
// import {
|
// mapState,
|
// mapMutations,
|
// mapActions ,
|
// } from 'vuex'
|
export default {
|
data(){
|
//获取全局参数:url-服务器地址
|
var server = uni.getStorageSync('server');
|
var account = uni.getStorageSync('account');
|
var password = uni.getStorageSync('password');
|
var url = this.$store.state.url;
|
var username = this.$store.state.username;
|
var userpwd = this.$store.state.userpwd;
|
var ischecked=false;
|
if(!server)
|
server = url;
|
if(!account)
|
account = username;
|
if(account && password)
|
ischecked=true;
|
// console.log(url);
|
return {
|
login:"开始登录",
|
userServer:server,
|
userName:account,
|
userPwd:password,
|
ischecked:ischecked,
|
version:"1.0.0",
|
}
|
},
|
// computed: mapState({
|
// // 从state中拿到数据 箭头函数可使代码更简练
|
// hasLogin: state => state.hasLogin,
|
// loginprovider: state => state.loginProvider,
|
// appinfo:state=>state.appInfo
|
// }),
|
methods:{
|
// ...mapMutations({
|
// mutatLogin:'login'
|
// }),
|
// ...mapActions({
|
// actionLogin:'login'
|
// }),
|
inputDialogToggle() {
|
this.$refs.inputDialog.open()
|
},
|
dialogInputConfirm(val) {
|
// console.log(val);
|
// uni.showLoading({
|
// title: '3秒后会关闭'
|
// })
|
// setTimeout(() => {
|
// uni.hideLoading();
|
this.userServer = val;
|
uni.setStorageSync('server',val);
|
// this.value = val
|
// 关闭窗口后,恢复默认内容
|
this.$refs.inputDialog.close()
|
// }, 3000)
|
},
|
rememberPwd(e){ //记住密码
|
console.log(e.target);
|
uni.setStorageSync('account','');
|
uni.setStorageSync('password','');
|
if(e.target.value[0]=='1'){
|
uni.setStorageSync('account',this.userName);
|
uni.setStorageSync('password',this.userPwd);
|
}
|
},
|
// getCookie(key){
|
// if(document.cookie.length>0){
|
// var start = document.cookie.indexOf(key +'=');
|
// if(start !== -1){
|
// start = start+key.length+1;
|
// var end = document.cookie.indexOf(';',start);
|
// if(end === -1) end=document.cookie.length;
|
// return document.cookie.substring(start,end);
|
// }
|
// }
|
// return '';
|
// },
|
// setCookie(cName,value,expiredays){
|
// var exdate = new Date();
|
// exdate.setDate(exdate.getDate(),expiredays)
|
// document.cookie = cName+'='+ documentURLComponent(value)+
|
// ((expiredays==null)?'':';expires='+exdate.toGMTString());
|
|
// },
|
logind(){
|
if(!this.userServer){
|
uni.showModal({title:"提示",content:"未输入网站地址,请重新配置输入!",showCancel:false,confirmText:"取消"});
|
return;
|
}
|
if(!this.userName){
|
uni.showModal({title:"提示",content:"未输入用户名,请重新输入!",showCancel:false,confirmText:"取消"});
|
return;
|
}
|
if(!this.userPwd){
|
uni.showModal({title:"提示",content:"未输入密码,请重新输入!",showCancel:false,confirmText:"取消"});
|
return;
|
}
|
//检查 "登录状态/锁屏状态" 结束
|
var loginInfo = {
|
server: this.userServer,
|
uname: this.userName,
|
pwd: this.userPwd,
|
cname: plus.device.model,
|
type:"0"
|
};
|
console.log(loginInfo);
|
|
this.$data.login="loading......";
|
//登录
|
this.$store.dispatch('login',loginInfo).then(success=>{
|
console.log(success);
|
if (success.code == '00000') {
|
//设置全局参数:user-用户信息
|
uni.setStorageSync('server',loginInfo.server);
|
// uni.setStorageSync('account',loginInfo.uname);
|
// uni.setStorageSync('password',loginInfo.pwd);
|
// this.mutatLogin({loginid:success});
|
this.$store.commit('login',{
|
loginid:success
|
});
|
uni.navigateTo({
|
url:'../index/index?args=9999999999'
|
})
|
// uni.redirectTo({
|
// url:'../index/index?args=9999999999'
|
// });
|
this.login="开始登录";
|
}else{
|
uni.showModal({title:"错误",content:success.msg,showCancel:false,confirmText:"取消"});
|
this.login="开始登录";
|
}
|
}).catch(ex=>{
|
console.log(ex);
|
uni.showModal({title:"错误",content:ex.errMsg,showCancel:false,confirmText:"取消"});
|
this.login="开始登录";
|
});
|
}
|
},
|
onLoad() {
|
plus.runtime.getProperty(plus.runtime.appid,(info)=>{
|
// console.log(info);
|
this.$data.version=info.version;
|
});
|
}
|
}
|
</script>
|