|
|
|
<template>
|
|
|
|
<div class="login-wrap">
|
|
|
|
<div class="header">
|
|
|
|
<div class="logo">
|
|
|
|
<img src="../assets/img/logo.png">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="ms-login">
|
|
|
|
<div class="ms-title">
|
|
|
|
<!-- <p class="title">账号登录</p> -->
|
|
|
|
<el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
|
|
|
|
<el-menu-item index="1">账号登录</el-menu-item>
|
|
|
|
<el-menu-item index="2">手机号/邮箱登录</el-menu-item>
|
|
|
|
</el-menu>
|
|
|
|
<el-form v-show="activeIndex==='1'" :model="param" :rules="rules" ref="login" label-width="0px" style="margin-top: 40px">
|
|
|
|
<el-form-item prop="account">
|
|
|
|
<el-input @blur="blur" v-model="param.account" placeholder="请输入账号"></el-input>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item prop="password">
|
|
|
|
<el-input
|
|
|
|
type="password"
|
|
|
|
placeholder="请输入密码"
|
|
|
|
v-model="param.password"
|
|
|
|
>
|
|
|
|
</el-input>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item prop="code" v-if="showVerify">
|
|
|
|
<el-input
|
|
|
|
placeholder="请输入验证码"
|
|
|
|
v-model="param.code"
|
|
|
|
@keyup.enter.native="submitForm()"
|
|
|
|
>
|
|
|
|
</el-input>
|
|
|
|
<img @click="blur" :src="verificationIMG" class="verification" alt="">
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<div style="width:100%;display:flex;justify-content: flex-end;">
|
|
|
|
<el-button type="text" class="forget">忘记密码?</el-button>
|
|
|
|
</div>
|
|
|
|
<div class="login-btn">
|
|
|
|
<el-button type="primary" @click="submitForm()">马上登录</el-button>
|
|
|
|
</div>
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
<el-form v-show="activeIndex==='2'" :model="phoneOrEmail" :rules="phoneOrEmailrules" ref="phoneOrEmail" label-width="0px" style="margin-top: 40px">
|
|
|
|
<el-form-item prop="account">
|
|
|
|
<el-input @blur="phoneBlur" v-model="phoneOrEmail.account" placeholder="请输入电话/邮箱"></el-input>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item prop="password">
|
|
|
|
<el-input
|
|
|
|
type="password"
|
|
|
|
placeholder="请输入密码"
|
|
|
|
v-model="phoneOrEmail.password"
|
|
|
|
>
|
|
|
|
</el-input>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item prop="code" v-if="showPhoneVerify">
|
|
|
|
<el-input
|
|
|
|
placeholder="请输入验证码"
|
|
|
|
v-model="phoneOrEmail.code"
|
|
|
|
@keyup.enter.native="submitForm('phone')"
|
|
|
|
>
|
|
|
|
</el-input>
|
|
|
|
<img @click="phoneBlur" :src="PhoneVerificationIMG" class="verification" alt="">
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<div style="width:100%;display:flex;justify-content: flex-end;">
|
|
|
|
<el-button type="text" class="forget">忘记密码?</el-button>
|
|
|
|
</div>
|
|
|
|
<div class="login-btn">
|
|
|
|
<el-button type="primary" @click="submitForm('phone')">马上登录</el-button>
|
|
|
|
</div>
|
|
|
|
</el-form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<el-dialog title="绑定手机号" :visible.sync="phoneVisible" :close-on-click-modal="false" width="576px">
|
|
|
|
<p class="tips">依据国家政策法规,需绑定手机号进行网络实名才可登录使用本平台</p>
|
|
|
|
<el-form ref="form" label-width="60px">
|
|
|
|
<el-form-item label="手机号">
|
|
|
|
<el-input placeholder="请输入手机号" v-model="phone" maxlength="11"></el-input>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="验证码">
|
|
|
|
<div style="display:flex;">
|
|
|
|
<el-input v-model="phoneCode" placeholder="请输入验证码" maxlength="6"></el-input>
|
|
|
|
<el-button style="margin-left:10px" @click="sendPhoneCode" :disabled="phoneDisabled">{{phoneBtnText}}</el-button>
|
|
|
|
</div>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
<el-button @click="phoneVisible = false">取 消</el-button>
|
|
|
|
<el-button type="primary" @click="phoneSubmit">确 定</el-button>
|
|
|
|
</span>
|
|
|
|
</el-dialog>
|
|
|
|
<v-footer class="footer" ref="footer"></v-footer>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import vFooter from '../components/Footer'
|
|
|
|
import Setting from '@/setting'
|
|
|
|
export default {
|
|
|
|
data: function() {
|
|
|
|
var regPhoneOrEmail = (rule, value, callback) => {// 验证手机或邮箱
|
|
|
|
let emailReg = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
|
|
|
let phoneReg = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/
|
|
|
|
if (value === '') {
|
|
|
|
callback(new Error('请输入手机或邮箱!'));
|
|
|
|
} else if (!emailReg.test(value)&&!phoneReg.test(value)) {
|
|
|
|
callback(new Error('输入的手机/邮箱格式不正确!'));
|
|
|
|
} else {
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return {
|
|
|
|
activeIndex:"1",
|
|
|
|
|
|
|
|
showVerify: true,// 账号-验证码展示
|
|
|
|
verificationIMG:'',// 账号验证码拼接链接
|
|
|
|
|
|
|
|
// 账号
|
|
|
|
param: {
|
|
|
|
account: '',
|
|
|
|
password: '',
|
|
|
|
code:'',
|
|
|
|
platform:3,
|
|
|
|
random:'',
|
|
|
|
distinguish:1,
|
|
|
|
type: 2
|
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
account: [{ required: true, message: '请输入账号', trigger: 'blur' }],
|
|
|
|
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
|
|
|
|
code: [{ required: true, message: '请输入验证码', trigger: 'blur' }],
|
|
|
|
},
|
|
|
|
|
|
|
|
// 手机+邮箱
|
|
|
|
showPhoneVerify:true,// 邮箱-验证码展示
|
|
|
|
PhoneVerificationIMG:'',// 电话或邮箱验证码拼接链接
|
|
|
|
phoneOrEmail: {
|
|
|
|
account: '',
|
|
|
|
password: '',
|
|
|
|
code:'',
|
|
|
|
platform:3,
|
|
|
|
random:'',
|
|
|
|
distinguish:2,
|
|
|
|
type: 2
|
|
|
|
},
|
|
|
|
phoneOrEmailrules:{
|
|
|
|
account: [{ validator: regPhoneOrEmail, trigger: 'blur' }],
|
|
|
|
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
|
|
|
|
code: [{ required: true, message: '请输入验证码', trigger: 'blur' }],
|
|
|
|
},
|
|
|
|
|
|
|
|
phoneVisible:false,
|
|
|
|
phone:'',
|
|
|
|
phoneCode:'',
|
|
|
|
phoneDisabled:false,
|
|
|
|
phoneBtnText: '发送验证码',
|
|
|
|
phoneTimer:'',
|
|
|
|
phoneOpener:''
|
|
|
|
|
|
|
|
};
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
vFooter
|
|
|
|
},
|
|
|
|
watch:{
|
|
|
|
verificationIMG:function(val){// 监听账号--展示验证码框
|
|
|
|
if(val){
|
|
|
|
this.showVerify = true
|
|
|
|
}else{
|
|
|
|
this.showVerify = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
PhoneVerificationIMG:function(val){// 监听账号--展示验证码框
|
|
|
|
if(val){
|
|
|
|
this.showPhoneVerify = true
|
|
|
|
}else{
|
|
|
|
this.showPhoneVerify = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created(){
|
|
|
|
if(this.param.account){
|
|
|
|
this.showVerify = true
|
|
|
|
}
|
|
|
|
this.blur()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
submitForm(val) {
|
|
|
|
let ref = val==='phone'?'phoneOrEmail':'login'
|
|
|
|
let param = val==='phone'?this.phoneOrEmail:this.param
|
|
|
|
this.$refs[ref].validate(valid => {
|
|
|
|
if (valid) {
|
|
|
|
this.$post(this.api.logins,param).then(res => {
|
|
|
|
const { message } = res
|
|
|
|
sessionStorage.setItem('token',res.data.token)
|
|
|
|
this.$get(`${this.api.getUserRolesPermissionMenu}?platformId=${Setting.platformId}`).then(res => {
|
|
|
|
const list = res.permissionMenu
|
|
|
|
this.$message.success(message);
|
|
|
|
this.$router.push({
|
|
|
|
path: list[0].children[0].path
|
|
|
|
});
|
|
|
|
localStorage.setItem('ms_username', this.param.username);
|
|
|
|
}).catch(err => {
|
|
|
|
if (err.status === 500) {
|
|
|
|
sessionStorage.clear()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}).catch(err => {
|
|
|
|
if(err.status===30001){
|
|
|
|
this.phoneVisible = true
|
|
|
|
}else if(err.status == 10004){
|
|
|
|
this.blur()
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.$message.error('请输入账号/密码/验证码');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
blur(){
|
|
|
|
this.param.random = Math.floor(Math.random()*999999999)
|
|
|
|
this.verificationIMG = this.api.verification+'?random='+`${this.param.random}`
|
|
|
|
},
|
|
|
|
phoneBlur(){
|
|
|
|
this.phoneOrEmail.random = Math.floor(Math.random()*999999999)
|
|
|
|
this.PhoneVerificationIMG = this.api.verification+'?random='+`${this.phoneOrEmail.random}`
|
|
|
|
},
|
|
|
|
handleSelect(val){
|
|
|
|
this.activeIndex = val
|
|
|
|
this.param.account = "";
|
|
|
|
this.param.password = "";
|
|
|
|
this.param.code = "";
|
|
|
|
this.phoneOrEmail.account = "";
|
|
|
|
this.phoneOrEmail.password = "";
|
|
|
|
this.phoneOrEmail.code = "";
|
|
|
|
this.$refs.phoneOrEmail.clearValidate()
|
|
|
|
// this.blur()
|
|
|
|
this.phoneBlur()
|
|
|
|
},
|
|
|
|
sendPhoneCode(){
|
|
|
|
if(!this.phone) return this.$message.warning('请输入手机号')
|
|
|
|
if(!/^1[3456789]\d{9}$/.test(this.phone)) return this.$message.warning('请输入正确的手机号')
|
|
|
|
let data = {
|
|
|
|
phone: this.phone,
|
|
|
|
types: 2
|
|
|
|
}
|
|
|
|
this.$post(this.api.sendPhoneOrEmailCode,data).then(res => {
|
|
|
|
this.phoneCountdown()// 倒计时
|
|
|
|
if(res.message.opener){
|
|
|
|
this.phoneOpener = res.message.opener
|
|
|
|
}else{
|
|
|
|
this.$message(res.message)
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catch(res => {})
|
|
|
|
},
|
|
|
|
phoneSubmit(){
|
|
|
|
if(!this.phone) return this.$message.warning('请输入手机号')
|
|
|
|
if(!/^1[3456789]\d{9}$/.test(this.phone)) return this.$message.warning('请输入正确的手机号')
|
|
|
|
if(!this.phoneCode) return this.$message.warning('请输入验证码')
|
|
|
|
let data = {
|
|
|
|
phone: this.phone,
|
|
|
|
types: 2,
|
|
|
|
code: this.phoneCode,
|
|
|
|
opener: this.phoneOpener,
|
|
|
|
platform: 3,
|
|
|
|
account: this.param.account
|
|
|
|
}
|
|
|
|
this.$post(this.api.bindPhoneOrEmail,data).then(res => {
|
|
|
|
sessionStorage.setItem('token',res.token)
|
|
|
|
this.$router.push({
|
|
|
|
path:'/customer'
|
|
|
|
});
|
|
|
|
localStorage.setItem('ms_username', this.param.username);
|
|
|
|
this.$message.success('绑定成功')
|
|
|
|
// this.form.phone = this.phone
|
|
|
|
// this.phoneVisible = false
|
|
|
|
}).catch(res => {})
|
|
|
|
},
|
|
|
|
phoneCountdown(){
|
|
|
|
let count = 60
|
|
|
|
if(!this.phoneTimer){
|
|
|
|
this.phoneDisabled = true
|
|
|
|
this.phoneTimer = setInterval(() => {
|
|
|
|
if(count > 0){
|
|
|
|
count--
|
|
|
|
this.phoneBtnText = `${count}秒后重试`
|
|
|
|
}else{
|
|
|
|
this.phoneDisabled = false
|
|
|
|
clearInterval(this.phoneTimer)
|
|
|
|
this.phoneTimer = null
|
|
|
|
this.phoneBtnText = `发送验证码`
|
|
|
|
}
|
|
|
|
},1000)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.login-wrap {
|
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
|
|
|
background-image: url(../assets/img/login-bg.png);
|
|
|
|
background-size: 100%;
|
|
|
|
}
|
|
|
|
.ms-title {
|
|
|
|
width: 548px;
|
|
|
|
position: absolute;
|
|
|
|
left: 50%;
|
|
|
|
top: 50px;
|
|
|
|
transform: translate(-50%,0);
|
|
|
|
}
|
|
|
|
/deep/ .ms-login {
|
|
|
|
position: relative;
|
|
|
|
width: 1200px;
|
|
|
|
height: calc(92vh - 40px);
|
|
|
|
margin: 60px auto 0;
|
|
|
|
background-image: url(../assets/img/login-input.png);
|
|
|
|
box-shadow:0px 0px 79px 0px rgba(11,15,65,0.36);
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
overflow: hidden;
|
|
|
|
.el-input__inner {
|
|
|
|
height: 80px;
|
|
|
|
line-height: 80px;
|
|
|
|
border: 1px solid rgba(220, 220, 220, 1);
|
|
|
|
border-radius: 2px;
|
|
|
|
}
|
|
|
|
.verification{
|
|
|
|
position: absolute;
|
|
|
|
top: 1px;
|
|
|
|
right: 1px;
|
|
|
|
width: 160px;
|
|
|
|
height: 78px;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.title{
|
|
|
|
font-size: 16px;
|
|
|
|
text-align: center;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
.login-btn {
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
.login-btn button {
|
|
|
|
width: 100%;
|
|
|
|
height: 88px;
|
|
|
|
margin-bottom: 50px;
|
|
|
|
font-weight: bold;
|
|
|
|
background:linear-gradient(90deg,rgba(94,206,253,1),rgba(91,67,231,1));
|
|
|
|
box-shadow:0px 7px 27px 0px rgba(50,129,255,0.51);
|
|
|
|
border-radius:10px;
|
|
|
|
}
|
|
|
|
.login-tips {
|
|
|
|
text-align: center;
|
|
|
|
color: #999;
|
|
|
|
font-weight:bold;
|
|
|
|
}
|
|
|
|
.forget{
|
|
|
|
margin-bottom: 28px;
|
|
|
|
text-align: right;
|
|
|
|
color: #999;
|
|
|
|
font-weight:bold;
|
|
|
|
&:hover{
|
|
|
|
color: #0092FF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.thirdParty{
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
margin-top: 33px;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 头部 */
|
|
|
|
.header{
|
|
|
|
height: 60px;
|
|
|
|
background-color: #fff;
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
font-size: 18px;
|
|
|
|
}
|
|
|
|
.logo{
|
|
|
|
width: 171px;
|
|
|
|
height: 40px;
|
|
|
|
margin-left: 20px;
|
|
|
|
}
|
|
|
|
img{
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
.header_title{
|
|
|
|
width: 33%;
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
.header_title a{
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
.header_title a:hover{
|
|
|
|
color: blueviolet;
|
|
|
|
}
|
|
|
|
.nul{
|
|
|
|
width:80px;
|
|
|
|
margin-right: 30px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.el-menu-demo{
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
border-bottom: 0;
|
|
|
|
background-color: transparent;
|
|
|
|
}
|
|
|
|
.tips {
|
|
|
|
margin: -20px 0 20px 5px;
|
|
|
|
font-size: 14px;
|
|
|
|
text-align: center;
|
|
|
|
color: #666;
|
|
|
|
}
|
|
|
|
</style>
|