integrated_traffic_uniapp/pages/login/home.vue

474 lines
11 KiB
Vue
Raw Normal View History

2024-01-16 17:24:49 +08:00
<template>
<view
style="background: url(../../static/bg-login.png) no-repeat;background-size:100% auto;height:100vh;background-color: #058cf5; position: fixed; width: 100%;">
2024-01-16 17:24:49 +08:00
<!-- <view class="bottom-img">
<image src="../../static/hg-bottom.png" mode=""></image>
</view> -->
<view class="login-box">
<view class="login-title">
<view class="login-logo">
<image src="../../static/image/logo.png" mode=""></image>
</view>
<view class="login-text">
<text>欢迎使用</text>
2024-03-22 15:08:55 +08:00
<text>交通运输安全生产综合管理平台!</text>
2024-01-16 17:24:49 +08:00
</view>
</view>
<view class="login-content">
<view class="input-row">
<view class="title">
2024-03-22 15:08:55 +08:00
<text class="">登录帐号</text>
2024-01-16 17:24:49 +08:00
</view>
<view class="m-input-view">
<input v-model="userName" class="m-input" placeholder-style="color: #5caceb;font-size: 34upx;"
2024-03-22 15:08:55 +08:00
placeholder="请输入身份证号..." />
2024-01-16 17:24:49 +08:00
</view>
</view>
<view class="input-row mt30">
<view class="title">
<text class="">密码</text>
</view>
<view class="m-input-view">
<input v-model="userPwd" class="m-input" placeholder-style="color: #5caceb;font-size: 34upx;"
password type="text" placeholder="请输入密码..." />
2024-01-16 17:24:49 +08:00
</view>
</view>
</view>
<view class="btn-row">
<button class="cu-btn bg-login margin-tb-sm lg" @click="$noMultipleClicks(login)"> </button>
</view>
<view class="bar-forget">
<!-- <navigator class="title" url="/pages/login/forget/forget">
2024-01-16 17:24:49 +08:00
忘记密码
</navigator> -->
2024-03-22 15:08:55 +08:00
<navigator class="title" url="/pages/login/register/index">
从业人员注册
</navigator>
2024-01-16 17:24:49 +08:00
</view>
</view>
2024-04-17 00:29:20 +08:00
<!-- <view
style="width: 100%;color: #fff;position: absolute;left: 50%;transform: translateX(-50%);bottom: 50upx;display: flex;justify-content: center;align-items: center">
<radio-group>
<radio :checked="radio === '1'" @click="radioChange"></radio>
</radio-group>
<view style="margin-left: 20upx;display: flex">
<text>我已阅读并同意</text>
<navigator style="color: #041d8c" url="/pages/my/agreement/agreement">
服务协议
</navigator>
<text></text>
<navigator style="color: #041d8c" url="/pages/my/privacy/privacy">
隐私政策
</navigator>
</view>
2024-04-17 00:29:20 +08:00
</view>-->
2024-01-16 17:24:49 +08:00
</view>
</template>
<script>
import {
basePath,
setloginUserId,
setCorpinfoId,
setloginUser,
setDeptId,
setDeptLevel,
adminPath,
corpinfoId,
setBasePath,
setIsRest,
isRest,
loginUser,
setPremission,
publicKey
2024-01-16 17:24:49 +08:00
} from '@/common/tool.js';
import JSEncrypt from '../../static/js/jsencrypt.min'
2024-01-16 17:24:49 +08:00
export default {
data() {
return {
noClick: true,
2024-04-01 09:26:01 +08:00
userName: '',
userPwd: '',
radio: ''
2024-01-16 17:24:49 +08:00
}
},
async onLoad() {
this.getRemember()
2024-02-21 10:49:36 +08:00
this.getLoginUser()
2024-01-16 17:24:49 +08:00
// this.getLoginUser()
//this.getUrlVersion();
},
methods: {
getRemember() {
uni.getStorage({
key: 'remember',
success: async (res) => {
if (res.data && res.data.username) {
this.userName = res.data.username
this.userPwd = res.data.userPwd
}
}
});
},
2024-01-16 17:24:49 +08:00
getLoginUser() {
uni.getStorage({
key: 'USER',
success: async (res) => {
if (res.data && res.data.USER_ID) {
setloginUserId(res.data.USER_ID);
setCorpinfoId(res.data.CORPINFO_ID);
setDeptId(res.data.DEPARTMENT_ID);
setDeptLevel(res.data.DEPARTMENT_LEVEL);
setloginUser(res.data);
2024-03-22 15:08:55 +08:00
if (loginUser.CORPINFO_ID) {
// 查看是否离岗
this.handleLoginCheck(res.data.USER_ID).then(() => {
uni.navigateTo({
url: '/pages/index/index',
});
})
} else {
uni.navigateTo({
url: '/pages/index/index',
});
}
2024-01-16 17:24:49 +08:00
}
}
});
},
handleLoginCheck(USER_ID) {
return new Promise((resolve, reject) => {
2024-01-16 17:24:49 +08:00
uni.request({
url: basePath + '/app/offduty/isRest',
method: 'POST',
dataType: 'json',
header: {
'Content-type': 'application/x-www-form-urlencoded'
},
data: {
CORPINFO_ID: corpinfoId,
USER_ID: loginUser.USER_ID,
},
success: (res1) => {
if ("success" == res1.data.result) {
if (res1.data.ISREST != null) {
setIsRest(res1.data.ISREST);
} else {
setIsRest(res.data.ISREST);
}
resolve()
} else if ("usercorperror" == res1.data.result) {
2024-01-16 17:24:49 +08:00
uni.showToast({
icon: 'none',
title: "您的企业已停用,请联系管理员",
duration: 2000
});
reject()
} else if ("userUSEerror" == res1.data.result) {
2024-01-16 17:24:49 +08:00
uni.showToast({
icon: 'none',
title: "您的企业已到使用期限,请联系管理员",
duration: 2000
});
reject()
}
},
fail: (res2) => {
uni.showToast({
icon: 'none',
title: "服务器正在升级,请稍后再试。",
duration: 2000
});
}
});
})
},
radioChange() {
if (this.radio) this.radio = ''
else this.radio = '1'
},
userNameinp(e) {
this.userName = e.detail.value
},
userPwdinp(e) {
this.userPwd = e.detail.value
},
login() {
2024-04-17 00:29:20 +08:00
/*if (this.radio !== '1') {
2024-01-16 17:24:49 +08:00
uni.showToast({
title: '请先阅读并同意《服务协议》和《隐私政策》',
icon: 'none'
})
return;
2024-04-17 00:29:20 +08:00
}*/
2024-01-16 17:24:49 +08:00
var _this = this;
var userName = _this.userName;
var userPwd = _this.userPwd;
var jsencrypt = new JSEncrypt()
jsencrypt.setPublicKey(publicKey)
const keydataVal = jsencrypt.encrypt('zcloudchina' + userName + ',zy,' + userPwd)
// var keydataVal = 'zcloudchina' + userName + ',zy,' + userPwd;
2024-03-22 15:08:55 +08:00
var myreg = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[0-2])(([0-2][1-9])|10|20|30|31)\d{3}(\d|X|x)$/;
2024-01-16 17:24:49 +08:00
if (userName == '') {
uni.showToast({
icon: 'none',
title: '请输入用户名',
duration: 2000
});
return;
} else if (userName.length != 11 && !myreg.test(userName)) {
uni.showToast({
icon: 'none',
2024-03-22 15:08:55 +08:00
title: '身份证号格式不正确',
2024-01-16 17:24:49 +08:00
duration: 2000
});
return;
}
if (userPwd == '') {
uni.showToast({
title: '密码不能为空',
icon: 'none',
duration: 2000
});
return;
}
uni.showLoading({
mask: true,
title: '请稍候'
})
uni.request({
2024-03-22 15:08:55 +08:00
url: basePath + '/admin/checkPractitioner',
2024-01-16 17:24:49 +08:00
method: 'POST',
dataType: 'json',
header: {
'Content-type': 'application/x-www-form-urlencoded'
},
data: {
KEYDATA: keydataVal,
SOURCE: '2',
tm: new Date().getTime(),
},
success: (res) => {
var result = res.data.result;
uni.showToast({
icon: 'none',
title: res.data.msg,
duration: 2000
});
if ("success" == result) {
setloginUserId(res.data.USER_ID);
setCorpinfoId(res.data.CORPINFO_ID);
setDeptId(res.data.DEPARTMENT_ID);
setDeptLevel(res.data.DEPARTMENT_LEVEL);
setIsRest(res.data.ISREST);
setloginUser(res.data);
uni.setStorage({
key: 'USER',
data: res.data
});
const remember = {}
remember.username = userName
remember.userPwd = userPwd
uni.setStorage({
key: 'remember',
data: remember
});
2024-02-21 10:49:36 +08:00
uni.hideLoading();
uni.showToast({
title: "登录成功",
duration: 1000
});
uni.redirectTo({
url: '/pages/index/index'
});
2024-01-16 17:24:49 +08:00
} else if ("usererror" == result) {
uni.showToast({
icon: 'none',
title: "用户名或密码有误",
duration: 2000
});
} else if ("error" == result) {
uni.showToast({
icon: 'none',
title: "缺少参数",
duration: 2000
});
} else if ("invalid" == result) {
uni.showToast({
icon: 'none',
title: "账号已被冻结,请联系管理员",
duration: 2000
});
} else if ("usercorperror" == result) {
uni.showToast({
icon: 'none',
title: res.data.msg,
duration: 2000
});
} else if ("userUSEerror" == result) {
uni.showToast({
icon: 'none',
title: res.data.msg,
duration: 2000
});
} else if ("maintainDeactivateError" == result) {
2024-01-16 17:24:49 +08:00
uni.showToast({
icon: 'none',
title: "企业处于维护停用阶段,暂时无法登录",
duration: 2000
});
} else if ("exception" == result) {
2024-01-16 17:24:49 +08:00
uni.showToast({
icon: 'none',
title: res.data.exception,
duration: 2000
});
}
},
fail: (res) => {
uni.showToast({
icon: 'none',
title: "服务器正在升级,请稍后再试。",
duration: 2000
});
}
});
},
getUrlVersion() {
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
2024-01-16 17:24:49 +08:00
var _this = this;
// 路径
uni.request({
url: basePath + '/app/versionurl/goUrlByVersion',
method: 'POST',
dataType: 'json',
header: {
'Content-type': 'application/x-www-form-urlencoded'
},
data: {
VERSION: inf.version,
},
success: (res) => {
if (res.data.pd != null) {
console.info(inf.version);
setBasePath(res.data.pd.URL);
}
},
fail: (res) => {
uni.showToast({
icon: 'none',
title: "服务器正在升级,请稍后再试。",
duration: 2000
});
}
});
});
},
}
}
</script>
<style>
.bottom-img {
2024-01-16 17:24:49 +08:00
height: 298upx;
width: 100%;
position: fixed;
bottom: 0;
}
.bottom-img image {
2024-01-16 17:24:49 +08:00
width: 100%;
height: 100%;
}
2024-01-16 17:24:49 +08:00
.bg-login {
background-color: #72b0ed;
color: #1f63ae;
font-weight: bold;
}
.btn-row {
display: flex;
flex-direction: column;
}
.login-box {
padding: 105upx 55upx;
}
.login-img {
width: 90upx;
height: 90upx;
margin-bottom: 50upx;
}
.login-img image {
width: 100%;
height: 100%;
}
.login-title {
display: flex;
align-items: center;
padding-top: 46upx;
}
.login-logo {
2024-01-16 17:24:49 +08:00
margin-right: 26upx;
margin-top: 10upx;
}
.login-logo image {
2024-01-16 17:24:49 +08:00
width: 100upx;
height: 100upx;
}
.login-text {
2024-01-16 17:24:49 +08:00
color: #fff;
font-size: 44upx;
font-weight: 500;
display: flex;
flex-direction: column;
line-height: 1.6;
}
.login-content {
margin-top: 100upx;
margin-bottom: 50upx;
}
.input-row .title {
color: #8ee6ff;
2024-03-22 15:08:55 +08:00
margin-top: 10upx;
right: 0;
2024-01-16 17:24:49 +08:00
}
.bar-forget {
display: flex;
padding-top: 30upx;
justify-content: space-between;
color: #8ee6ff;
}
.m-input-view {}
.m-input-view .m-input {
height: 80upx;
line-height: 1;
color: #fff;
font-size: 40upx;
border-bottom: 1upx solid #62abf7;
}
</style>