<template>
|
<view class="login">
|
<view class="login-main">
|
<text class="login-main-title">欢迎登录</text>
|
<view class="login-main-subtitle">耀能新能源PDA程序</view>
|
<view class="login-main-body">
|
<!-- <login-input key="username" v-model="user" clearable placeholder="用户名"
|
:maxlength="20"></login-input> -->
|
<uni-easyinput v-model="user" focus placeholder="请输入用户名"></uni-easyinput>
|
<view class="login-password">
|
<!-- <login-input key="password" v-model="password" password clearable placeholder="密码"
|
:maxlength="20"></login-input> -->
|
<uni-easyinput type="password" v-model="pass" placeholder="请输入密码"></uni-easyinput>
|
</view>
|
<view class="verCode" v-if="SYS_DEFAULT_CAPTCHA_OPEN">
|
<uni-easyinput key="code" v-model="code" clearable placeholder="请输入右边验证码"
|
:maxlength="10"></uni-easyinput>
|
<view class="canvas-img-code" @click="refresh()">
|
<img :src="validCodeBase64" :style="{ width: width + 'px', height: height + 'px' }"
|
class="login-validCode-img"/>
|
<!-- <img v-show="validCodeBase64 != ''" :src="validCodeBase64" :style="{ width: width + 'px', height: height + 'px' }"/> -->
|
</view>
|
</view>
|
|
<u-button type="success" size="default" shape="circle" :ripple="true" ripple-bg-color="#909399"
|
@click="login">
|
登录
|
</u-button>
|
<!-- <hd-button size="large" type="primary" :disabled="disabled" @click="doLogin">登录</hd-button> -->
|
</view>
|
</view>
|
<!-- <view class="login-footer">
|
<text>fant-mini-plus</text>
|
</view> -->
|
</view>
|
</template>
|
|
<script>
|
var app = getApp();
|
import smCrypto from '@/common/smCrypto.js'
|
export default {
|
data() {
|
return {
|
width: 120,
|
height: 45,
|
pass: '123456',
|
user: 'Admin',
|
SYS_DEFAULT_CAPTCHA_OPEN: true,
|
validCodeBase64: '',
|
validCodeReqNo: '',
|
code:'1234'
|
}
|
},
|
onLoad(options) {
|
this.configSysBaseList()
|
},
|
methods: {
|
configSysBaseList() {
|
// this.$u.get('/api/User/getVierificationCode', null).then(res => {
|
// if (res.code == 200) {
|
// res.data.forEach((item) => {
|
// if (item.configKey == "SYS_DEFAULT_CAPTCHA_OPEN") {
|
// if (item.configValue === 'true') {
|
// this.SYS_DEFAULT_CAPTCHA_OPEN = true;
|
// } else {
|
// this.SYS_DEFAULT_CAPTCHA_OPEN = false;
|
// }
|
// }
|
// })
|
//如果验证码开关是开就加载验证码
|
if (this.SYS_DEFAULT_CAPTCHA_OPEN) {
|
this.loginCaptcha()
|
}
|
// }
|
// })
|
},
|
loginCaptcha() {
|
this.$u.get('/api/User/getVierificationCode', null).then(res => {
|
|
this.validCodeBase64 = "data:image/png;base64," + res.img;
|
this.validCodeReqNo = res.uuid
|
|
})
|
},
|
refresh() {
|
|
this.loginCaptcha();
|
},
|
login() {
|
if (this.pass == '') {
|
this.$t.message.toast('请输入密码')
|
return;
|
} else if (this.user == '') {
|
this.$t.message.toast('请输入用户名')
|
return;
|
} else if (this.pass.length < 6) {
|
this.$t.message.toast('密码应大于6位')
|
return;
|
} else {
|
this.$t.message.loading('正在登录')
|
// let userifno = {
|
// UUID: this.SYS_DEFAULT_CAPTCHA_OPEN ? this.validCodeReqNo : null,
|
// PassWord: smCrypto.doSm2Encrypt(this.pass),
|
// UserName: this.user,
|
// VerificationCode: this.SYS_DEFAULT_CAPTCHA_OPEN ? this.code : null
|
// }
|
this.$u.post('/api/User/login',
|
{UUID: this.validCodeReqNo,
|
passWord: this.pass,
|
userName: this.user,
|
verificationCode: this.code}
|
).then(res => {
|
console.log(res)
|
this.$t.message.toast("登录成功")
|
this.$t.message.closeLoading()
|
uni.setStorage({
|
key: 'jo_id_token',
|
data: res.data.token,
|
});
|
uni.setStorage({
|
key: 'jo_user',
|
data: res.data,
|
});
|
setTimeout(() => {
|
this.$u.route({
|
type: 'reLaunch',
|
url: 'pages/index/index'
|
})
|
}, 300)
|
});
|
|
}
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.login {
|
// font-family: PingFangSC-Regular, PingFang SC;
|
// background-color: $color-white;
|
height: calc(100vh - var(--window-top));
|
width: 100vw;
|
box-sizing: border-box;
|
|
&-main {
|
padding: 112rpx 75rpx 0 75rpx;
|
position: relative;
|
|
&-title {
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
height: 64rpx;
|
font-size: 48rpx;
|
font-weight: 600;
|
// color: $color-text-secondary;
|
line-height: 64rpx;
|
letter-spacing: 8rpx;
|
}
|
|
&-subtitle {
|
font-size: 28rpx;
|
// color: $color-text-thirdly;
|
line-height: 40rpx;
|
letter-spacing: 12rpx;
|
text-align: center;
|
margin: 8rpx 0 104rpx;
|
}
|
|
&-body {
|
position: relative;
|
box-sizing: border-box;
|
width: 600rpx;
|
height: 548rpx;
|
|
.login-password {
|
position: relative;
|
padding: 40rpx 0 40rpx;
|
}
|
|
.verCode {
|
position: relative;
|
padding: 0rpx 0 140rpx;
|
display: flex;
|
flex-direction: row;
|
align-items: center;
|
justify-content: center;
|
}
|
}
|
}
|
|
&-footer {
|
display: flex;
|
flex-direction: column;
|
width: 100%;
|
height: 300rpx;
|
text-align: center;
|
line-height: 28rpx;
|
font-size: 20rpx;
|
font-weight: 500;
|
}
|
}
|
</style>
|