<template>
|
<uni-base-page>
|
<view slot="page" class="example-body"
|
style="background-color:#e6e6e6;margin-top: 5%;margin-left:15px;margin-right:15px;padding: 20px;border-radius: 10px;">
|
<view class="image-container">
|
<image src="../../static/img/bj/bg2.png" style=" max-width: 99%;"></image>
|
</view>
|
<uni-input-row type="text" title="账号" v-model="account" :focus="accountFocus"
|
@resetFocus="e=>{accountFocus=e;}" clearable placeholder="请输入账号"></uni-input-row>
|
<uni-input-row type="password" title="密码" v-model="password" :focus="passwordFocus"
|
@resetFocus="e=>{passwordFocus=e}" displayable @confirm="bindLogin" placeholder="请输入密码"></uni-input-row>
|
<view class="btn-row">
|
<button type="primary" class="primary" @tap="bindLogin">登录</button>
|
</view>
|
</view>
|
</uni-base-page>
|
</template>
|
|
<script>
|
import {
|
downWgt
|
} from '../../common/update.js';
|
|
export default {
|
data() {
|
return {
|
accountFocus: false,
|
passwordFocus: false,
|
tokenId: '',
|
account: '',
|
userName: '',
|
password: '',
|
factoryArray: [],
|
//selectFactory: { value: this.$loginInfo.factoryKey||'',text:this.$loginInfo.factoryName||'',index: this.$loginInfo.factoryIndex}, //选择的账套信息
|
selectFactory: {},
|
selectLanguage: {}, //选择的语言
|
};
|
},
|
async onReady() {
|
this.account = this.$loginInfo.account || '';
|
this.selectFactory = this.$loginInfo.factory || 0;
|
this.selectLanguage = this.$loginInfo.language || 0;
|
},
|
methods: {
|
bindLogin() {
|
if (!this.account) {
|
uni.showToast({ icon: 'none', title: '请输入账号' });
|
this.$nextTick(() => this.accountFocus = true); // 确保DOM更新后触发焦点
|
return;
|
}
|
if (!this.password) {
|
uni.showToast({
|
icon: 'none',
|
title: '请输入密码'
|
});
|
this.passwordFocus = true;
|
return;
|
}
|
uni.showLoading({
|
mask: true,
|
title: "登录中..."
|
});
|
uni.request({
|
url: this.$store.state.serverInfo.serverAPI + '/login/login',
|
method: "POST",
|
header: {
|
'content-type': "application/json"
|
},
|
data: {
|
userID: this.account,
|
userPass: this.password
|
},
|
success: res => {
|
console.log(res.data.status);
|
if (res.data.status == 0) {
|
this.$loginInfo.forcedLogin = 1;
|
console.log(res.data.data.tbBillList[0]);
|
this.toMain(res.data.data.tbBillList[0]);
|
} else {
|
uni.showToast({
|
icon: 'none',
|
title: res.data.message
|
});
|
}
|
},
|
fail(err) {
|
uni.showToast({
|
icon: 'none',
|
title: "服务器断开"
|
});
|
},
|
complete: () => {
|
uni.hideLoading();
|
}
|
});
|
},
|
toMain(user) {
|
this.$loginInfo.account = this.account;
|
this.$loginInfo.userName = this.userName;
|
this.$loginInfo.factory = this.selectFactory;
|
this.$loginInfo.language = this.selectLanguage;
|
this.$loginInfo.menu = this.menu;
|
this.$loginInfo.deptNo = '';
|
this.$loginInfo.chineseName = user.username;
|
this.$loginInfo.id = user.isid;
|
this.$login();
|
if (this.$loginInfo.forcedLogin) {
|
uni.reLaunch({
|
url: 'main'
|
});
|
} else {
|
uni.navigateBack();
|
}
|
}
|
}
|
};
|
</script>
|
|
<style>
|
.action-row {
|
display: flex;
|
flex-direction: row;
|
justify-content: center;
|
}
|
|
.action-row navigator {
|
color: #007aff;
|
padding: 0 10px;
|
}
|
|
.btn-row {
|
/* margin-top: 20px; */
|
padding: 10px;
|
}
|
|
button.primary {
|
background-color: #0faeff;
|
}
|
|
.img-container {
|
width: 100%;
|
height: auto;
|
max-width: 100%;
|
}
|
|
.image-container {
|
width: 100%;
|
text-align: center;
|
margin-bottom: 20px;
|
}
|
|
.example-body {
|
background-color: #e6e6e6;
|
margin: 5% 15px 0 15px;
|
padding: 20px;
|
border-radius: 10px;
|
box-sizing: border-box; /* 新增 */
|
}
|
|
@media (min-width: 768px) {
|
.example-body {
|
width: 50%;
|
max-width: 500px;
|
margin: 0 auto !important; /* 居中 */
|
}
|
}
|
|
/* 移动端优化 */
|
@media (max-width: 767px) {
|
.example-body {
|
margin: 5% 15px 0 15px;
|
}
|
}
|
</style>
|