Initial commit
This commit is contained in:
@@ -0,0 +1,480 @@
|
||||
<template>
|
||||
<div class="main">
|
||||
<a-form v-if="!mobile" :form="form" class="user-layout-login" ref="formLogin" id="formLogin">
|
||||
<div class="user-box">
|
||||
<span class="title">用户登录</span>
|
||||
<a-row>
|
||||
<a-col :span="3"></a-col>
|
||||
<a-col :span="18">
|
||||
<a-form-item>
|
||||
<a-input
|
||||
size="large"
|
||||
v-decorator="['username',{initialValue:'', rules: validatorRules.username.rules,validateTrigger: 'blur'}]"
|
||||
type="text"
|
||||
placeholder="请输入帐号">
|
||||
<a-icon slot="prefix" type="user" :style="{ color: '#B3B7C2',fontSize:'20px' }"/>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="3"></a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="3"></a-col>
|
||||
<a-col :span="18">
|
||||
<a-form-item>
|
||||
<a-input
|
||||
v-decorator="['password',{initialValue:'', rules: validatorRules.password.rules,validateTrigger: 'blur'}]"
|
||||
size="large"
|
||||
:type="passwordType"
|
||||
autocomplete="false"
|
||||
placeholder="请输入密码"
|
||||
>
|
||||
<a-icon title="显示密码" @click="passwordType='text'" slot="suffix" v-if="passwordType==='password'" type="eye" :style="{ color: '#B3B7C2',fontSize:'20px' }"/>
|
||||
<a-icon title="隐藏密码" @click="passwordType='password'" slot="suffix" v-else type="eye-invisible" :style="{ color: '#B3B7C2',fontSize:'20px' }"/>
|
||||
<a-icon slot="prefix" type="lock" :style="{ color: '#B3B7C2',fontSize:'20px' }"/>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="3"></a-col>
|
||||
</a-row>
|
||||
<a-row style="margin-bottom: 2%;">
|
||||
<a-col :span="3"></a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item>
|
||||
<a-input
|
||||
v-decorator="['inputCode',validatorRules.inputCode]"
|
||||
size="large"
|
||||
type="text"
|
||||
@change="inputCodeChange"
|
||||
autocomplete="off"
|
||||
placeholder="请输入验证码">
|
||||
<a-icon slot="prefix" type="safety" :style="{ color: '#B3B7C2',fontSize:'20px'}"/>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="6" style="text-align: right">
|
||||
<img v-if="requestCodeSuccess" style="margin-top: 2px;" :src="randCodeImage" @click="handleChangeCheckCode" alt=""/>
|
||||
<img v-else style="margin-top: 2px;" src="../../assets/checkcode.png" @click="handleChangeCheckCode" alt=""/>
|
||||
</a-col>
|
||||
<a-col :span="3"></a-col>
|
||||
</a-row>
|
||||
<!--<a-row style="margin-bottom: 2%;">-->
|
||||
<!-- <a-col :span="3"></a-col>-->
|
||||
<!-- <a-col :span="7">-->
|
||||
<!-- <a-form-item>-->
|
||||
<!-- <a-checkbox v-decorator="['rememberMe', {initialValue: true, valuePropName: 'checked'}]">自动登录</a-checkbox>-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-col>-->
|
||||
<!-- <a-col :span="6"></a-col>-->
|
||||
<!-- <a-col :span="5" style="text-align: right;color: #1891FF;">-->
|
||||
<!-- <a-form-item>-->
|
||||
<!-- <router-link :to="{ name: 'alteration'}" class="forge-password" style="float: right;">-->
|
||||
<!-- 忘记密码-->
|
||||
<!-- </router-link>-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-col>-->
|
||||
<!--</a-row>-->
|
||||
<a-row class="login-btn">
|
||||
<a-col :span="3"></a-col>
|
||||
<a-col :span="18">
|
||||
<a-form-item>
|
||||
<a-button
|
||||
block
|
||||
size="large"
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
:loading="loginBtn"
|
||||
@click.stop.prevent="handleSubmit"
|
||||
:disabled="loginBtn">
|
||||
{{ loginBtn ? "登录中" : "登录" }}
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="3"></a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</a-form>
|
||||
<a-form v-if="mobile" :form="form" class="user-layout-login user-layout-login-mobile" ref="formLogin" id="formLogin">
|
||||
<div class="user-box user-box-mobile">
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item>
|
||||
<a-input
|
||||
size="large"
|
||||
v-decorator="['username',{initialValue:'', rules: validatorRules.username.rules,validateTrigger: 'blur'}]"
|
||||
type="text"
|
||||
placeholder="请输入帐号">
|
||||
<a-icon slot="prefix" type="user" :style="{ color: '#B3B7C2',fontSize:'20px' }"/>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item>
|
||||
<a-input
|
||||
v-decorator="['password',{initialValue:'', rules: validatorRules.password.rules,validateTrigger: 'blur'}]"
|
||||
size="large"
|
||||
type="password"
|
||||
autocomplete="false"
|
||||
placeholder="请输入密码"
|
||||
>
|
||||
<a-icon slot="prefix" type="lock" :style="{ color: '#B3B7C2',fontSize:'20px' }"/>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="14">
|
||||
<a-form-item>
|
||||
<a-input
|
||||
v-decorator="['inputCode',validatorRules.inputCode]"
|
||||
size="large"
|
||||
type="text"
|
||||
@change="inputCodeChange"
|
||||
placeholder="请输入验证码">
|
||||
<a-icon slot="prefix" type="safety" :style="{ color: '#B3B7C2',fontSize:'20px'}"/>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="10" style="text-align: right">
|
||||
<img v-if="requestCodeSuccess" style="margin-top: 2px;" :src="randCodeImage" @click="handleChangeCheckCode" alt=""/>
|
||||
<img v-else style="margin-top: 2px;" src="../../assets/checkcode.png" @click="handleChangeCheckCode" alt=""/>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="10">
|
||||
<a-form-item>
|
||||
<a-checkbox v-decorator="['rememberMe', {initialValue: true, valuePropName: 'checked'}]">自动登录</a-checkbox>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="4"></a-col>
|
||||
<a-col :span="9" style="text-align: right;color: #1891FF;">
|
||||
<a-form-item>
|
||||
<router-link :to="{ name: 'alteration'}" class="forge-password" style="float: right;">
|
||||
忘记密码
|
||||
</router-link>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row class="login-btn">
|
||||
<a-col :span="24">
|
||||
<a-form-item>
|
||||
<a-button
|
||||
block
|
||||
size="large"
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
:loading="loginBtn"
|
||||
@click.stop.prevent="handleSubmit"
|
||||
:disabled="loginBtn">
|
||||
{{ loginBtn ? "登录中" : "登录" }}
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { mapActions } from 'vuex'
|
||||
import { timeFix } from '@/utils/util'
|
||||
import Vue from 'vue'
|
||||
import { ACCESS_TOKEN/* , ENCRYPTED_STRING, USER_INFO */ } from '@/store/mutation-types'
|
||||
import { postAction, getAction } from '@/api/manage'
|
||||
|
||||
import { getRSAPublicKey } from '@/utils/encryption.js'
|
||||
import { JSEncrypt } from 'jsencrypt'
|
||||
// const Base64 = require('js-base64').Base64
|
||||
|
||||
export default {
|
||||
components: {},
|
||||
data () {
|
||||
return {
|
||||
loginBtn: false,
|
||||
mobile: isMobile(),
|
||||
// login type: 0 email, 1 username, 2 telephone
|
||||
loginType: 0,
|
||||
stepCaptchaVisible: false,
|
||||
form: this.$form.createForm(this),
|
||||
state: {
|
||||
time: 60,
|
||||
smsSendBtn: false
|
||||
},
|
||||
validatorRules: {
|
||||
username: { rules: [{ required: true, message: '请输入用户名!' }, { validator: this.handleUsernameOrEmail }] },
|
||||
password: { rules: [{ required: true, message: '请输入密码!', validator: 'click' }] },
|
||||
mobile: { rules: [{ validator: this.validateMobile }] },
|
||||
captcha: { rule: [{ required: true, message: '请输入验证码!' }] },
|
||||
inputCode: { rules: [{ required: true, message: '请输入验证码!' }] }
|
||||
},
|
||||
velorifiedCode: '',
|
||||
inputCodeContent: '',
|
||||
inputCodeNull: true,
|
||||
currentUsername: '',
|
||||
currdatetime: '',
|
||||
randCodeImage: '',
|
||||
requestCodeSuccess: false,
|
||||
rsaPublicKey: '',
|
||||
passwordType: 'password' // passwordType : password , text
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.currdatetime = new Date().getTime()
|
||||
Vue.ls.remove(ACCESS_TOKEN)
|
||||
this.getRouterData()
|
||||
this.handleChangeCheckCode()
|
||||
this.getPublicKey() // 获取秘钥
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['Login', 'Logout', 'PhoneLogin']),
|
||||
handleUsernameOrEmail (rule, value, callback) {
|
||||
const regex = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/
|
||||
if (regex.test(value)) {
|
||||
this.loginType = 0
|
||||
} else {
|
||||
this.loginType = 1
|
||||
}
|
||||
callback()
|
||||
},
|
||||
handleSubmit () {
|
||||
const that = this
|
||||
const loginParams = {}
|
||||
that.loginBtn = true
|
||||
that.form.validateFields(['username', 'password', 'inputCode', 'rememberMe'], { force: true }, (err, values) => {
|
||||
if (!err) {
|
||||
loginParams.remember_me = values.rememberMe
|
||||
loginParams.captcha = that.inputCodeContent
|
||||
loginParams.checkKey = that.currdatetime
|
||||
loginParams.rsaPublicKey = that.rsaPublicKey
|
||||
// 新建JSEncrypt对象
|
||||
const encrypt = new JSEncrypt()
|
||||
encrypt.setPublicKey(loginParams.rsaPublicKey)
|
||||
// 公钥加密
|
||||
loginParams.username = encrypt.encrypt(values.username)
|
||||
loginParams.password = encrypt.encrypt(values.password)
|
||||
// 登录
|
||||
that.Login(loginParams).then((/* res */) => {
|
||||
this.loginSuccess()
|
||||
}).catch((err) => {
|
||||
if (err.code === 500) {
|
||||
// 刷新验证码
|
||||
this.handleChangeCheckCode()
|
||||
}
|
||||
that.requestFailed(err)
|
||||
})
|
||||
} else {
|
||||
that.loginBtn = false
|
||||
}
|
||||
})
|
||||
},
|
||||
getCaptcha (e) {
|
||||
e.preventDefault()
|
||||
const that = this
|
||||
this.form.validateFields(['mobile'], { force: true }, (err, values) => {
|
||||
if (!values.mobile) {
|
||||
that.cmsFailed('请输入手机号')
|
||||
} else if (!err) {
|
||||
this.state.smsSendBtn = true
|
||||
const interval = window.setInterval(() => {
|
||||
if (that.state.time-- <= 0) {
|
||||
that.state.time = 60
|
||||
that.state.smsSendBtn = false
|
||||
window.clearInterval(interval)
|
||||
}
|
||||
}, 1000)
|
||||
|
||||
const hide = this.$message.loading('验证码发送中..', 0)
|
||||
const smsParams = {}
|
||||
smsParams.mobile = values.mobile
|
||||
smsParams.smsmode = '0'
|
||||
postAction('/sys/sms', smsParams)
|
||||
.then(res => {
|
||||
if (!res.success) {
|
||||
setTimeout(hide, 0)
|
||||
this.cmsFailed(res.message)
|
||||
}
|
||||
setTimeout(hide, 500)
|
||||
})
|
||||
.catch(err => {
|
||||
setTimeout(hide, 1)
|
||||
clearInterval(interval)
|
||||
that.state.time = 60
|
||||
that.state.smsSendBtn = false
|
||||
this.requestFailed(err)
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
handleChangeCheckCode () {
|
||||
this.form.setFieldsValue({ inputCode: '' })
|
||||
this.currdatetime = new Date().getTime()
|
||||
getAction(`/sys/randomImage/${this.currdatetime}`).then(res => {
|
||||
if (res.success) {
|
||||
this.randCodeImage = res.result
|
||||
this.requestCodeSuccess = true
|
||||
} else {
|
||||
this.$message.warning(res.message)
|
||||
this.requestCodeSuccess = false
|
||||
}
|
||||
}).catch(() => {
|
||||
this.requestCodeSuccess = false
|
||||
})
|
||||
},
|
||||
// 获取RSA公钥
|
||||
getPublicKey () {
|
||||
// 获取公钥
|
||||
getRSAPublicKey().then(res => {
|
||||
this.rsaPublicKey = res.result
|
||||
})
|
||||
},
|
||||
loginSuccess () {
|
||||
this.$router.push({ path: '/' }).catch((/* res */) => {})
|
||||
this.$notification.success({
|
||||
message: '欢迎',
|
||||
description: `${timeFix()},欢迎回来`
|
||||
})
|
||||
},
|
||||
cmsFailed (err) {
|
||||
this.$notification.error({
|
||||
message: '验证码发送失败',
|
||||
description: err,
|
||||
duration: 4
|
||||
})
|
||||
},
|
||||
requestFailed (err) {
|
||||
this.$notification.error({
|
||||
message: '登录失败',
|
||||
description: ((err.response || {}).data || {}).message || err.message || '请求出现错误,请稍后再试',
|
||||
duration: 4
|
||||
})
|
||||
|
||||
// 如果是RSA过期,延迟1.5秒刷新页面
|
||||
if (err.code && err.code === 600) {
|
||||
setTimeout(function () {
|
||||
location.reload()
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
this.loginBtn = false
|
||||
},
|
||||
validateMobile (rule, value, callback) {
|
||||
if (!value || new RegExp(/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/).test(value)) {
|
||||
callback()
|
||||
} else {
|
||||
callback(new Error('您的手机号码格式不正确!'))
|
||||
}
|
||||
},
|
||||
validateInputCode (rule, value, callback) {
|
||||
if (!value || this.verifiedCode === this.inputCodeContent) {
|
||||
callback()
|
||||
} else {
|
||||
callback(new Error('您输入的验证码不正确!'))
|
||||
}
|
||||
},
|
||||
generateCode (value) {
|
||||
this.verifiedCode = value.toLowerCase()
|
||||
},
|
||||
inputCodeChange (e) {
|
||||
this.inputCodeContent = e.target.value
|
||||
},
|
||||
getRouterData () {
|
||||
this.$nextTick(() => {
|
||||
if (this.$route.params.username) {
|
||||
this.form.setFieldsValue({
|
||||
username: this.$route.params.username
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
// 判断当前设备
|
||||
function isMobile () {
|
||||
const userAgentInfo = navigator.userAgent
|
||||
|
||||
const mobileAgents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod']
|
||||
|
||||
let mobileFlag = false
|
||||
|
||||
// 根据userAgent判断是否是手机
|
||||
for (let v = 0; v < mobileAgents.length; v++) {
|
||||
if (userAgentInfo.indexOf(mobileAgents[v]) > 0) {
|
||||
mobileFlag = true
|
||||
break
|
||||
}
|
||||
}
|
||||
const screenWidth = window.screen.width
|
||||
const screenHeight = window.screen.height
|
||||
|
||||
// 根据屏幕分辨率判断是否是手机
|
||||
if (screenWidth < 500 && screenHeight < 800) {
|
||||
mobileFlag = true
|
||||
}
|
||||
return mobileFlag
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.ant-input-affix-wrapper/deep/ .ant-input:not(:first-child){
|
||||
padding-left: 40px;
|
||||
}
|
||||
.ant-row{
|
||||
margin-bottom: 4%;
|
||||
}
|
||||
.main{
|
||||
height: 100%;
|
||||
.user-layout-login{
|
||||
z-index: 99;
|
||||
width: 24%;
|
||||
height: 50%;
|
||||
padding: 3% 0 3% 0;
|
||||
min-width: 332px;
|
||||
min-height: 460px;
|
||||
background: #fff;
|
||||
border-radius: 20px;
|
||||
position: absolute;
|
||||
right: 8%;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
.user-box{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex-direction: column;
|
||||
.title{
|
||||
display: block;
|
||||
color: #1891FF;
|
||||
font-size: 28px;
|
||||
font-weight: 500;
|
||||
margin: 0 0 5% 0;
|
||||
text-align: center;
|
||||
}
|
||||
.login-btn{
|
||||
margin-bottom: 0;
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.user-layout-login-mobile{
|
||||
right: 0;
|
||||
width: 100%;
|
||||
min-width: 0 !important;
|
||||
height: 46% !important;
|
||||
background: transparent;
|
||||
min-height: 0;
|
||||
padding: 0 2rem 0 2rem;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
margin-top: 6rem;
|
||||
transform: translateY(-50%);
|
||||
.ant-row{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,215 @@
|
||||
<template>
|
||||
<j-modal
|
||||
:title="title"
|
||||
:width="450"
|
||||
:visible="visible"
|
||||
:closable="false"
|
||||
switchFullscreen
|
||||
:maskClosable="false">
|
||||
|
||||
<template slot="footer">
|
||||
<a-button type="primary" @click="selectOk">确认</a-button>
|
||||
</template>
|
||||
|
||||
<a-form>
|
||||
<a-form-item v-if="isMultiTenant" :labelCol="{span:4}" :wrapperCol="{span:20}" style="margin-bottom:10px" :validate-status="validate_status1">
|
||||
<a-tooltip placement="topLeft">
|
||||
<template slot="title">
|
||||
<span>您有多个租户,请选择登录租户</span>
|
||||
</template>
|
||||
<a-avatar style="background-color:#87d068" icon="gold" />
|
||||
</a-tooltip>
|
||||
|
||||
<a-select @change="handleTenantChange"
|
||||
:class="{'valid-error':validate_status1==='error'}"
|
||||
placeholder="请选择登录租户"
|
||||
style="margin-left:10px;width: 80%">
|
||||
<a-icon slot="suffixIcon" type="gold" />
|
||||
<a-select-option v-for="d in tenantList" :key="d.id" :value="d.id">
|
||||
{{ d.name }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item v-if="isMultiDepart" :labelCol="{span:4}" :wrapperCol="{span:20}" style="margin-bottom:10px" :validate-status="validate_status2">
|
||||
<a-tooltip placement="topLeft">
|
||||
<template slot="title">
|
||||
<span>您有多个部门,请选择登录部门</span>
|
||||
</template>
|
||||
<a-avatar style="background-color:rgb(104, 208, 203);" icon="gold" />
|
||||
</a-tooltip>
|
||||
|
||||
<a-select @change="handleDepartChange"
|
||||
:class="{'valid-error':validate_status2==='error'}"
|
||||
placeholder="请选择登录部门"
|
||||
style="margin-left:10px;width: 80%">
|
||||
<a-icon slot="suffixIcon" type="gold" />
|
||||
<a-select-option v-for="d in departList" :key="d.id" :value="d.orgCode">
|
||||
{{ d.departName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
</a-form>
|
||||
</j-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import Vue from 'vue'
|
||||
import { postAction } from '@/api/manage'
|
||||
import { USER_INFO } from '@/store/mutation-types'
|
||||
|
||||
export default {
|
||||
name: 'LoginSelectTenant',
|
||||
data () {
|
||||
return {
|
||||
visible: false,
|
||||
isMultiDepart: false,
|
||||
departList: [],
|
||||
|
||||
isMultiTenant: false,
|
||||
tenantList: [],
|
||||
|
||||
username: '',
|
||||
orgCode: '',
|
||||
tenant_id: '',
|
||||
|
||||
validate_status1: '',
|
||||
validate_status2: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
title () {
|
||||
if (this.isMultiDepart && this.isMultiTenant) {
|
||||
return '请选择租户和部门'
|
||||
} else if (this.isMultiDepart && !this.isMultiTenant) {
|
||||
return '请选择部门'
|
||||
} else if (!this.isMultiDepart && this.isMultiTenant) {
|
||||
return '请选择租户'
|
||||
}
|
||||
return ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clear () {
|
||||
this.departList = []
|
||||
this.tenantList = []
|
||||
this.visible = false
|
||||
this.validate_status1 = ''
|
||||
this.validate_status2 = ''
|
||||
},
|
||||
bizDepart (loginResult) {
|
||||
const multiDepart = loginResult.multi_depart + ''
|
||||
// 0:无部门 1:一个部门 2:多个部门
|
||||
if (multiDepart === '0') {
|
||||
this.$notification.warn({
|
||||
message: '提示',
|
||||
description: `您尚未归属部门,请确认账号信息`,
|
||||
duration: 3
|
||||
})
|
||||
this.isMultiDepart = false
|
||||
} else if (multiDepart === '2') {
|
||||
this.visible = true
|
||||
this.isMultiDepart = true
|
||||
this.departList = loginResult.departs
|
||||
} else {
|
||||
this.isMultiDepart = false
|
||||
}
|
||||
},
|
||||
bizTenantList (loginResult) {
|
||||
const tenantList = loginResult.tenantList
|
||||
if (Array.isArray(tenantList)) {
|
||||
if (tenantList.length === 0) {
|
||||
this.isMultiTenant = false
|
||||
} else if (tenantList.length === 1) {
|
||||
this.tenant_id = tenantList[0].id
|
||||
this.isMultiTenant = false
|
||||
} else {
|
||||
this.visible = true
|
||||
this.isMultiTenant = true
|
||||
this.tenantList = tenantList
|
||||
}
|
||||
}
|
||||
},
|
||||
show (loginResult) {
|
||||
this.clear()
|
||||
this.bizDepart(loginResult)
|
||||
|
||||
const user = Vue.ls.get(USER_INFO)
|
||||
this.username = user.username
|
||||
this.bizTenantList(loginResult)
|
||||
|
||||
if (this.visible === false) {
|
||||
this.$store.dispatch('saveTenant', this.tenant_id)
|
||||
this.$emit('success')
|
||||
}
|
||||
},
|
||||
requestFailed (err) {
|
||||
this.$notification.error({
|
||||
message: '登录失败',
|
||||
description: ((err.response || {}).data || {}).message || err.message || '请求出现错误,请稍后再试',
|
||||
duration: 4
|
||||
})
|
||||
this.loginBtn = false
|
||||
},
|
||||
departResolve () {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.isMultiDepart === false) {
|
||||
resolve()
|
||||
} else {
|
||||
const obj = {
|
||||
orgCode: this.orgCode,
|
||||
username: this.username
|
||||
}
|
||||
postAction('/sys/selectDepart', obj).then(res => {
|
||||
if (res.success) {
|
||||
const userInfo = res.result.userInfo
|
||||
Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
|
||||
this.$store.commit('SET_INFO', userInfo)
|
||||
// console.log("---切换组织机构---userInfo-------",store.getters.userInfo.orgCode);
|
||||
resolve()
|
||||
} else {
|
||||
this.requestFailed(res)
|
||||
this.$store.dispatch('Logout')
|
||||
reject()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
selectOk () {
|
||||
if (this.isMultiTenant && !this.tenant_id) {
|
||||
this.validate_status1 = 'error'
|
||||
return false
|
||||
}
|
||||
if (this.isMultiDepart && !this.orgCode) {
|
||||
this.validate_status2 = 'error'
|
||||
return false
|
||||
}
|
||||
this.departResolve().then(() => {
|
||||
this.$store.dispatch('saveTenant', this.tenant_id)
|
||||
if (this.isMultiTenant) {
|
||||
this.$emit('success')
|
||||
} else {
|
||||
this.$emit('success')
|
||||
}
|
||||
}).catch(() => {
|
||||
console.log('登录选择出问题')
|
||||
})
|
||||
},
|
||||
handleTenantChange (e) {
|
||||
this.validate_status1 = ''
|
||||
this.tenant_id = e
|
||||
},
|
||||
handleDepartChange (e) {
|
||||
this.validate_status2 = ''
|
||||
this.orgCode = e
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<a-card :bordered="false" style="width: 100%;text-align: center;">
|
||||
<a-steps class="steps" :current="currentTab">
|
||||
<a-step title="手机验证"/>
|
||||
<a-step title="密码"/>
|
||||
<a-step title="完成"/>
|
||||
</a-steps>
|
||||
<div class="content">
|
||||
<step2 v-if="currentTab === 0" @nextStep="nextStep"/>
|
||||
<step3 v-if="currentTab === 1" @nextStep="nextStep" @prevStep="prevStep" :userList="userList"/>
|
||||
<step4 v-if="currentTab === 2" @prevStep="prevStep" @finish="finish" :userList="userList"/>
|
||||
</div>
|
||||
</a-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import Step1 from './Step1'
|
||||
import Step2 from './Step2'
|
||||
import Step3 from './Step3'
|
||||
import Step4 from './Step4'
|
||||
|
||||
export default {
|
||||
name: 'Alteration',
|
||||
components: {
|
||||
// Step1,
|
||||
Step2,
|
||||
Step3,
|
||||
Step4
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
description: '将一个冗长或用户不熟悉的表单任务分成多个步骤,指导用户完成。',
|
||||
currentTab: 0,
|
||||
userList: {},
|
||||
// form
|
||||
form: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
// handler
|
||||
nextStep (data) {
|
||||
this.userList = data
|
||||
if (this.currentTab < 4) {
|
||||
this.currentTab += 1
|
||||
}
|
||||
},
|
||||
prevStep (data) {
|
||||
this.userList = data
|
||||
if (this.currentTab > 0) {
|
||||
this.currentTab -= 1
|
||||
}
|
||||
},
|
||||
finish () {
|
||||
this.currentTab = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.steps {
|
||||
max-width: 750px;
|
||||
margin: 16px auto;
|
||||
}
|
||||
.ant-steps-item{
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,185 @@
|
||||
<template>
|
||||
<div class="main">
|
||||
|
||||
<a-form style="max-width: 500px; margin: 40px auto 0;" :form="form" @keyup.enter.native="nextStep">
|
||||
<a-form-item>
|
||||
<a-input
|
||||
v-decorator="['username',validatorRules.username]"
|
||||
size="large"
|
||||
type="text"
|
||||
autocomplete="false"
|
||||
placeholder="请输入用户账号或手机号">
|
||||
<a-icon slot="prefix" type="lock" :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-row :gutter="0">
|
||||
<a-col :span="14">
|
||||
<a-form-item>
|
||||
<a-input
|
||||
v-decorator="['inputCode',validatorRules.inputCode]"
|
||||
size="large"
|
||||
type="text"
|
||||
@change="inputCodeChange"
|
||||
placeholder="请输入验证码">
|
||||
<a-icon slot="prefix" v-if=" inputCodeContent===verifiedCode " type="smile"
|
||||
:style="{ color: 'rgba(0,0,0,.25)' }" alt=''/>
|
||||
<a-icon slot="prefix" v-else type="frown" :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="10" style="text-align: right">
|
||||
<img v-if="requestCodeSuccess" style="margin-top: 2px;" :src="randCodeImage" @click="handleChangeCheckCode" alt=""/>
|
||||
<img v-else style="margin-top: 2px;" src="../../../assets/checkcode.png" @click="handleChangeCheckCode" alt=""/>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-form-item :wrapperCol="{span: 19, offset: 5}">
|
||||
<router-link style="float: left;line-height: 40px;" :to="{ name: 'login' }">使用已有账户登录</router-link>
|
||||
<a-button type="primary" @click="nextStep">下一步</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getAction, postAction } from '@/api/manage'
|
||||
import { checkOnlyUser } from '@/api/api'
|
||||
|
||||
export default {
|
||||
name: 'Step1',
|
||||
data () {
|
||||
return {
|
||||
form: this.$form.createForm(this),
|
||||
inputCodeContent: '',
|
||||
inputCodeNull: true,
|
||||
verifiedCode: '',
|
||||
validatorRules: {
|
||||
username: { rules: [{ required: false }, { validator: this.validateInputUsername }] },
|
||||
inputCode: { rules: [{ required: true, message: '请输入验证码!' }] }
|
||||
},
|
||||
randCodeImage: '',
|
||||
requestCodeSuccess: true,
|
||||
currdatetime: ''
|
||||
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.handleChangeCheckCode()
|
||||
},
|
||||
methods: {
|
||||
handleChangeCheckCode () {
|
||||
this.currdatetime = new Date().getTime()
|
||||
getAction(`/sys/randomImage/${this.currdatetime}`).then(res => {
|
||||
if (res.success) {
|
||||
this.randCodeImage = res.result
|
||||
this.requestCodeSuccess = true
|
||||
} else {
|
||||
this.$message.warning(res.message)
|
||||
this.requestCodeSuccess = false
|
||||
}
|
||||
}).catch(() => {
|
||||
this.requestCodeSuccess = false
|
||||
})
|
||||
},
|
||||
nextStep () {
|
||||
const that = this
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
let isPhone = false
|
||||
const params = {}
|
||||
const reg = /^[1-9]\d*$|^0$/
|
||||
const username = values.username
|
||||
if (reg.test(username) === true) {
|
||||
params.phone = username
|
||||
isPhone = true
|
||||
} else {
|
||||
params.username = username
|
||||
}
|
||||
that.validateInputCode().then(() => {
|
||||
getAction('/sys/user/querySysUser', params).then((res) => {
|
||||
if (res.success) {
|
||||
const userList = {
|
||||
username: res.result.username,
|
||||
phone: res.result.phone,
|
||||
isPhone: isPhone
|
||||
}
|
||||
setTimeout(function () {
|
||||
that.$emit('nextStep', userList)
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(err => {
|
||||
this.$message.warning(err.message)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
validateInputCode () {
|
||||
return new Promise((resolve, reject) => {
|
||||
postAction('/sys/checkCaptcha', {
|
||||
captcha: this.inputCodeContent,
|
||||
checkKey: this.currdatetime
|
||||
}).then(res => {
|
||||
if (res.success) {
|
||||
resolve()
|
||||
} else {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
inputCodeChange (e) {
|
||||
this.inputCodeContent = e.target.value
|
||||
console.log(this.inputCodeContent)
|
||||
// TODO eslint:这里value是字符串,不会等于数字0
|
||||
// if (!e.target.value || e.target.value == 0) {
|
||||
if (!e.target.value) {
|
||||
this.inputCodeNull = true
|
||||
} else {
|
||||
this.inputCodeContent = this.inputCodeContent.toLowerCase()
|
||||
this.inputCodeNull = false
|
||||
}
|
||||
},
|
||||
generateCode (value) {
|
||||
this.verifiedCode = value.toLowerCase()
|
||||
console.log(this.verifiedCode)
|
||||
},
|
||||
validateInputUsername (rule, value, callback) {
|
||||
console.log(value)
|
||||
const reg = /^[0-9]+.?[0-9]*/
|
||||
if (!value) {
|
||||
callback(new Error('请输入用户名和手机号!'))
|
||||
}
|
||||
|
||||
// 判断用户输入账号还是手机号码
|
||||
if (reg.test(value)) {
|
||||
const phoneParams = {
|
||||
phone: value
|
||||
}
|
||||
checkOnlyUser(phoneParams).then((res) => {
|
||||
if (res.success) {
|
||||
callback(new Error('用户名不存在!'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const usernameParams = {
|
||||
username: value
|
||||
}
|
||||
checkOnlyUser(usernameParams).then((res) => {
|
||||
if (res.success) {
|
||||
callback(new Error('用户名不存在!'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,201 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-form :form="form" style="max-width: 500px; margin: 40px auto 0;" @keyup.enter.native="nextStep">
|
||||
<a-form-item
|
||||
label="手机"
|
||||
:labelCol="{span: 5}"
|
||||
:wrapperCol="{span: 16}"
|
||||
style="text-align: left"
|
||||
>
|
||||
<a-input
|
||||
type="text"
|
||||
autocomplete="false"
|
||||
v-decorator="['phone',{ rules: validatorRules.phone.rule}]"
|
||||
placeholder="请输入手机号">
|
||||
<a-icon slot="prefix" type="phone" :style="{ color: 'rgba(0,0,0,.25)'}"/>
|
||||
</a-input>
|
||||
<a-col :span="3"></a-col>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="验证码"
|
||||
:labelCol="{span: 5}"
|
||||
:wrapperCol="{span: 19}"
|
||||
v-if="show">
|
||||
<a-row :gutter="24">
|
||||
<a-col :span="13">
|
||||
<a-input
|
||||
v-decorator="['captcha',validatorRules.captcha]"
|
||||
type="text"
|
||||
placeholder="手机短信验证码">
|
||||
</a-input>
|
||||
</a-col>
|
||||
<a-col :span="8">
|
||||
<a-button
|
||||
tabindex="-1"
|
||||
size="default"
|
||||
:disabled="state.smsSendBtn"
|
||||
@click.stop.prevent="getCaptcha"
|
||||
v-text="!state.smsSendBtn && '获取验证码' || (state.time+' s')"></a-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form-item>
|
||||
<a-form-item :wrapperCol="{span: 19, offset: 5}">
|
||||
<router-link style="float: left;line-height: 40px;" :to="{ name: 'login' }">使用已有账户登录</router-link>
|
||||
<a-button type="primary" @click="nextStep" style="margin-left: 20px">下一步</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { postAction } from '@/api/manage'
|
||||
|
||||
export default {
|
||||
name: 'Step2',
|
||||
props: ['userList'],
|
||||
data () {
|
||||
return {
|
||||
form: this.$form.createForm(this),
|
||||
loading: false,
|
||||
// accountName: this.userList.username,
|
||||
dropList: '0',
|
||||
captcha: '',
|
||||
show: true,
|
||||
state: {
|
||||
time: 60,
|
||||
smsSendBtn: false
|
||||
},
|
||||
formLogin: {
|
||||
captcha: '',
|
||||
mobile: ''
|
||||
},
|
||||
validatorRules: {
|
||||
captcha: { rule: [{ required: true, message: '请输入短信验证码!' }, { validator: this.validateCaptcha }] },
|
||||
phone: { rule: [{ required: true, message: '请输入手机号码!' }, { validator: this.validatePhone }] }
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
methods: {
|
||||
nextStep () {
|
||||
const that = this
|
||||
that.loading = true
|
||||
this.form.validateFields((err, values) => {
|
||||
console.log(values)
|
||||
if (!err) {
|
||||
if ((that.dropList + '') === '0') {
|
||||
if (values.captcha === undefined) {
|
||||
this.cmsFailed('请输入短信验证码!')
|
||||
} else {
|
||||
const params = {}
|
||||
params.phone = values.phone
|
||||
params.smscode = values.captcha
|
||||
postAction('/sys/user/phoneVerification', params).then((res) => {
|
||||
if (res.success) {
|
||||
console.log(res)
|
||||
const userList = {
|
||||
username: res.result.username,
|
||||
phone: values.phone,
|
||||
smscode: res.result.smscode
|
||||
}
|
||||
setTimeout(function () {
|
||||
that.$emit('nextStep', userList)
|
||||
}, 0)
|
||||
} else {
|
||||
this.cmsFailed(res.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
getCaptcha (e) {
|
||||
e.preventDefault()
|
||||
const that = this
|
||||
const phone = that.form.getFieldValue('phone')
|
||||
if (!phone) {
|
||||
this.cmsFailed('手机号不能为空!')
|
||||
return
|
||||
}
|
||||
this.state.smsSendBtn = true
|
||||
const interval = window.setInterval(() => {
|
||||
if (that.state.time-- <= 0) {
|
||||
that.state.time = 60
|
||||
that.state.smsSendBtn = false
|
||||
window.clearInterval(interval)
|
||||
}
|
||||
}, 1000)
|
||||
|
||||
const hide = this.$message.loading('验证码发送中..', 0)
|
||||
const smsParams = {
|
||||
mobile: phone,
|
||||
smsmode: '2'
|
||||
}
|
||||
postAction('/sys/sms', smsParams).then(res => {
|
||||
if (!res.success) {
|
||||
setTimeout(hide, 1)
|
||||
this.cmsFailed(res.message)
|
||||
}
|
||||
setTimeout(hide, 500)
|
||||
})
|
||||
},
|
||||
cmsFailed (err) {
|
||||
this.$notification.error({
|
||||
message: '验证错误',
|
||||
description: err,
|
||||
duration: 4
|
||||
})
|
||||
},
|
||||
handleChangeSelect (value) {
|
||||
const that = this
|
||||
console.log(value)
|
||||
if (value === 0) {
|
||||
that.dropList = '0'
|
||||
that.show = true
|
||||
} else {
|
||||
that.dropList = '1'
|
||||
that.show = false
|
||||
}
|
||||
},
|
||||
validatePhone (rule, value, callback) {
|
||||
if (value) {
|
||||
const myreg = /^1[34578][0-9]{9}$/
|
||||
if (!myreg.test(value)) {
|
||||
callback(new Error('请输入正确的手机号'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.stepFormText {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.ant-row{
|
||||
margin-left: 0 !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
.ant-col{
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.ant-form-item-label,
|
||||
.ant-form-item-control {
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.getCaptcha {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-form :form="form" style="max-width: 500px; margin: 40px auto 0;">
|
||||
<a-form-item
|
||||
label="账号名"
|
||||
:labelCol="{span: 5}"
|
||||
:wrapperCol="{span: 19}"
|
||||
>
|
||||
<a-input
|
||||
type="text"
|
||||
autocomplete="false" :value="accountName" disabled>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="新密码"
|
||||
:labelCol="{span: 5}"
|
||||
:wrapperCol="{span: 19}"
|
||||
class="stepFormText">
|
||||
<a-input
|
||||
v-decorator="['password',validatorRules.password]"
|
||||
type="password"
|
||||
autocomplete="false">
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="确认密码"
|
||||
:labelCol="{span: 5}"
|
||||
:wrapperCol="{span: 19}"
|
||||
class="stepFormText">
|
||||
<a-input
|
||||
v-decorator="['confirmPassword',validatorRules.confirmPassword]"
|
||||
type="password"
|
||||
autocomplete="false">
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item :wrapperCol="{span: 19, offset: 5}">
|
||||
<a-button style="margin-left: 8px" @click="prevStep">上一步</a-button>
|
||||
<a-button :loading="loading" type="primary" @click="nextStep" style="margin-left:20px">提交</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getAction } from '@/api/manage'
|
||||
export default {
|
||||
name: 'Step3',
|
||||
// components: {
|
||||
// Result
|
||||
// },
|
||||
props: ['userList'],
|
||||
data () {
|
||||
return {
|
||||
loading: false,
|
||||
form: this.$form.createForm(this),
|
||||
accountName: this.userList.username,
|
||||
validatorRules: {
|
||||
username: { rules: [{ required: true, message: '用户名不能为空!' }] },
|
||||
password: {
|
||||
rules: [{
|
||||
required: true,
|
||||
pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/,
|
||||
message: '密码由8位数字、大小写字母和特殊符号组成!!'
|
||||
}, { validator: this.handlePasswordLevel }]
|
||||
},
|
||||
confirmPassword: { rules: [{ required: true, message: '密码不能为空!' }, { validator: this.handlePasswordCheck }] }
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
nextStep () {
|
||||
const that = this
|
||||
that.loading = true
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
const params = {}
|
||||
params.username = this.userList.username
|
||||
params.password = values.password
|
||||
params.smscode = this.userList.smscode
|
||||
params.phone = this.userList.phone
|
||||
getAction('/sys/user/passwordChange', params).then((res) => {
|
||||
if (res.success) {
|
||||
const userList = {
|
||||
username: this.userList.username
|
||||
}
|
||||
console.log(userList)
|
||||
setTimeout(function () {
|
||||
that.$emit('nextStep', userList)
|
||||
}, 1500)
|
||||
} else {
|
||||
this.passwordFailed(res.message)
|
||||
that.loading = false
|
||||
}
|
||||
})
|
||||
} else {
|
||||
that.loading = false
|
||||
}
|
||||
})
|
||||
},
|
||||
prevStep () {
|
||||
this.$emit('prevStep', this.userList)
|
||||
},
|
||||
|
||||
handlePasswordCheck (rule, value, callback) {
|
||||
const password = this.form.getFieldValue('password')
|
||||
if (value && password && value.trim() !== password.trim()) {
|
||||
callback(new Error('两次密码不一致'))
|
||||
}
|
||||
callback()
|
||||
},
|
||||
passwordFailed (err) {
|
||||
this.$notification.error({
|
||||
message: '更改密码失败',
|
||||
description: err,
|
||||
duration: 4
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.stepFormText {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.ant-form-item-label,
|
||||
.ant-form-item-control {
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-form style="margin: 40px auto 0;">
|
||||
<result title="更改密码成功" :is-success="true">
|
||||
<div class="toLogin">
|
||||
<h3>将在<span>{{time}}</span>秒后返回登录页面.</h3>
|
||||
</div>
|
||||
</result>
|
||||
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Result from '@/views/result/Result'
|
||||
export default {
|
||||
name: 'Step4',
|
||||
props: ['userList'],
|
||||
components: {
|
||||
Result
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
loading: false,
|
||||
time: 0
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
countDown () {
|
||||
const that = this
|
||||
that.time--
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
const that = this
|
||||
that.time = 5
|
||||
setInterval(that.countDown, 1000)
|
||||
},
|
||||
watch: {
|
||||
time: function (newVal/* , oldVal */) {
|
||||
if (newVal === 0) {
|
||||
const params = {
|
||||
username: this.userList.username
|
||||
}
|
||||
this.$router.push({ name: 'login', params })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.toLogin{
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,130 @@
|
||||
<template>
|
||||
<div>
|
||||
<div id="loader-wrapper">
|
||||
<div id="loader"></div>
|
||||
<div class="loader-section section-left"></div>
|
||||
<div class="loader-section section-right"></div>
|
||||
<div class="load_title">正在登录,请耐心等待</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions } from 'vuex'
|
||||
import { isOAuth2AppEnv, timeFix } from '@/utils/util'
|
||||
import { INDEX_MAIN_PAGE_PATH } from '@/store/mutation-types'
|
||||
|
||||
export default {
|
||||
name: 'OAuth2Login',
|
||||
data () {
|
||||
return {
|
||||
env: {
|
||||
thirdApp: false,
|
||||
wxWork: false,
|
||||
dingtalk: false
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeCreate () {
|
||||
// 如果当前 不是 OAuth2APP环境,就重定向到 /user/login 页面
|
||||
if (!isOAuth2AppEnv()) {
|
||||
this.$router.replace({ path: '/user/login' })
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.checkEnv()
|
||||
this.doOAuth2Login()
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['ThirdLogin']),
|
||||
|
||||
/** 检测当前的环境 */
|
||||
checkEnv () {
|
||||
// 判断当时是否是企业微信环境
|
||||
if (/wxwork/i.test(navigator.userAgent)) {
|
||||
this.env.thirdApp = true
|
||||
this.env.wxWork = true
|
||||
}
|
||||
// 判断当时是否是钉钉环境
|
||||
if (/dingtalk/i.test(navigator.userAgent)) {
|
||||
this.env.thirdApp = true
|
||||
this.env.dingtalk = true
|
||||
}
|
||||
},
|
||||
|
||||
/** 进行OAuth2登录操作 */
|
||||
doOAuth2Login () {
|
||||
if (this.env.thirdApp) {
|
||||
// 判断是否携带了Token,是就说明登录成功
|
||||
if (this.$route.query.oauth2LoginToken) {
|
||||
this.thirdType = this.$route.query.thirdType
|
||||
const token = this.$route.query.oauth2LoginToken
|
||||
this.doThirdLogin(token)
|
||||
} else if (this.env.wxWork) {
|
||||
this.doWechatEnterpriseOAuth2Login()
|
||||
} else if (this.env.dingtalk) {
|
||||
this.doDingTalkOAuth2Login()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 根据token执行登录
|
||||
doThirdLogin (token) {
|
||||
const param = {}
|
||||
param.thirdType = this.thirdType
|
||||
param.token = token
|
||||
this.ThirdLogin(param).then(res => {
|
||||
if (res.success) {
|
||||
this.loginSuccess()
|
||||
} else {
|
||||
this.requestFailed(res)
|
||||
}
|
||||
})
|
||||
},
|
||||
loginSuccess () {
|
||||
// 登陆成功,重定向到主页
|
||||
this.$router.replace({ path: INDEX_MAIN_PAGE_PATH })
|
||||
// TODO 这个提示是否还需要?
|
||||
this.$notification.success({
|
||||
message: '欢迎',
|
||||
description: `${timeFix()},欢迎回来`
|
||||
})
|
||||
},
|
||||
requestFailed (err) {
|
||||
this.$error({
|
||||
title: '登录失败',
|
||||
content: ((err.response || {}).data || {}).message || err.message || '请求出现错误,请稍后再试',
|
||||
okText: '重新登陆',
|
||||
onOk () {
|
||||
window.location.reload()
|
||||
},
|
||||
onCancel () {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/** 企业微信OAuth2登录 */
|
||||
doWechatEnterpriseOAuth2Login () {
|
||||
this.sysOAuth2Login('wechat_enterprise')
|
||||
},
|
||||
|
||||
/** 钉钉OAuth2登录 */
|
||||
doDingTalkOAuth2Login () {
|
||||
this.sysOAuth2Login('dingtalk')
|
||||
},
|
||||
|
||||
/** 后台构造oauth2登录地址 */
|
||||
sysOAuth2Login (source) {
|
||||
let url = `${window._CONFIG.domianURL}/sys/thirdLogin/oauth2/${source}/login`
|
||||
url += `?state=${encodeURIComponent(window.location.origin)}`
|
||||
window.location.href = url
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,378 @@
|
||||
<template>
|
||||
<div class="main user-layout-register">
|
||||
<h3><span>注册</span></h3>
|
||||
<a-form ref="formRegister" :autoFormCreate="(form)=>{this.form = form}" id="formRegister">
|
||||
<a-form-item
|
||||
fieldDecoratorId="username"
|
||||
:fieldDecoratorOptions="{rules: [{ required: false}, { validator: this.checkUsername }]}">
|
||||
<a-input size="large" type="text" autocomplete="false" placeholder="请输入用户名"></a-input>
|
||||
</a-form-item>
|
||||
|
||||
<a-popover placement="rightTop" trigger="click" :visible="state.passwordLevelChecked">
|
||||
<template slot="content">
|
||||
<div :style="{ width: '240px' }">
|
||||
<div :class="['user-register', passwordLevelClass]">强度:<span>{{ passwordLevelName }}</span></div>
|
||||
<a-progress :percent="state.percent" :showInfo="false" :strokeColor=" passwordLevelColor "/>
|
||||
<div style="margin-top: 10px;">
|
||||
<span>请至少输入 8 个字符。请不要使用容易被猜到的密码。</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<a-form-item
|
||||
fieldDecoratorId="password"
|
||||
:fieldDecoratorOptions="{rules: [{ required: false}, { validator: this.handlePasswordLevel }]}">
|
||||
<a-input size="large" type="password" @click="handlePasswordInputClick" autocomplete="false" placeholder="至少8位密码,区分大小写"></a-input>
|
||||
</a-form-item>
|
||||
</a-popover>
|
||||
|
||||
<a-form-item
|
||||
fieldDecoratorId="password2"
|
||||
:fieldDecoratorOptions="{rules: [{ required: false}, { validator: this.handlePasswordCheck }]}">
|
||||
|
||||
<a-input size="large" type="password" autocomplete="false" placeholder="确认密码"></a-input>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item-->
|
||||
<!-- fieldDecoratorId="email">-->
|
||||
<!-- <a-input size="large" type="text" placeholder="邮箱"></a-input>-->
|
||||
<!-- </a-form-item>-->
|
||||
<a-form-item
|
||||
fieldDecoratorId="mobile"
|
||||
:fieldDecoratorOptions="{rules: [{ required: false}, { validator: this.handlePhoneCheck }]}">
|
||||
<a-input size="large" placeholder="11 位手机号">
|
||||
<a-select slot="addonBefore" size="large" defaultValue="+86">
|
||||
<a-select-option value="+86">+86</a-select-option>
|
||||
<a-select-option value="+87">+87</a-select-option>
|
||||
</a-select>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<!--<a-input-group size="large" compact>
|
||||
<a-select style="width: 20%" size="large" defaultValue="+86">
|
||||
<a-select-option value="+86">+86</a-select-option>
|
||||
<a-select-option value="+87">+87</a-select-option>
|
||||
</a-select>
|
||||
<a-input style="width: 80%" size="large" placeholder="11 位手机号"></a-input>
|
||||
</a-input-group>-->
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col class="gutter-row" :span="16">
|
||||
<a-form-item
|
||||
fieldDecoratorId="captcha"
|
||||
:fieldDecoratorOptions="{rules: [{ required: false}, { validator: this.handleCaptchaCheck }]}">
|
||||
<a-input size="large" type="text" placeholder="验证码">
|
||||
<a-icon slot="prefix" type="mail" :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col class="gutter-row" :span="8">
|
||||
<a-button
|
||||
class="getCaptcha"
|
||||
size="large"
|
||||
:disabled="state.smsSendBtn"
|
||||
@click.stop.prevent="getCaptcha"
|
||||
v-text="!state.smsSendBtn && '获取验证码'||(state.time+' s')"></a-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-form-item>
|
||||
<a-button
|
||||
size="large"
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
class="register-button"
|
||||
:loading="registerBtn"
|
||||
@click.stop.prevent="handleSubmit"
|
||||
:disabled="registerBtn">注册
|
||||
</a-button>
|
||||
<router-link class="login" :to="{ name: 'login' }">使用已有账户登录</router-link>
|
||||
</a-form-item>
|
||||
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mixinDevice } from '@/utils/mixin.js'
|
||||
import { postAction } from '@/api/manage'
|
||||
import { checkOnlyUser } from '@/api/api'
|
||||
|
||||
const levelNames = {
|
||||
0: '低',
|
||||
1: '低',
|
||||
2: '中',
|
||||
3: '强'
|
||||
}
|
||||
const levelClass = {
|
||||
0: 'error',
|
||||
1: 'error',
|
||||
2: 'warning',
|
||||
3: 'success'
|
||||
}
|
||||
const levelColor = {
|
||||
0: '#ff0000',
|
||||
1: '#ff0000',
|
||||
2: '#ff7e05',
|
||||
3: '#52c41a'
|
||||
}
|
||||
export default {
|
||||
name: 'Register',
|
||||
components: {},
|
||||
mixins: [mixinDevice],
|
||||
data () {
|
||||
return {
|
||||
form: null,
|
||||
|
||||
state: {
|
||||
time: 60,
|
||||
smsSendBtn: false,
|
||||
passwordLevel: 0,
|
||||
passwordLevelChecked: false,
|
||||
percent: 10,
|
||||
progressColor: '#FF0000'
|
||||
},
|
||||
registerBtn: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
passwordLevelClass () {
|
||||
return levelClass[this.state.passwordLevel]
|
||||
},
|
||||
passwordLevelName () {
|
||||
return levelNames[this.state.passwordLevel]
|
||||
},
|
||||
passwordLevelColor () {
|
||||
return levelColor[this.state.passwordLevel]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
checkUsername (rule, value, callback) {
|
||||
if (!value) {
|
||||
callback(new Error('请输入用户名'))
|
||||
} else {
|
||||
const params = {
|
||||
username: value
|
||||
}
|
||||
checkOnlyUser(params).then((res) => {
|
||||
if (res.success) {
|
||||
callback()
|
||||
} else {
|
||||
const err = '用户名已存在!'
|
||||
callback(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
handleEmailCheck (rule, value, callback) {
|
||||
const params = {
|
||||
email: value
|
||||
}
|
||||
checkOnlyUser(params).then((res) => {
|
||||
if (res.success) {
|
||||
callback()
|
||||
} else {
|
||||
const err = '邮箱已存在!'
|
||||
callback(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
handlePasswordLevel (rule, value, callback) {
|
||||
let level = 0
|
||||
const reg = /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/
|
||||
if (!reg.test(value)) {
|
||||
callback(new Error('密码由8位数字、大小写字母和特殊符号组成!'))
|
||||
}
|
||||
// 判断这个字符串中有没有数字
|
||||
if (/[0-9]/.test(value)) {
|
||||
level++
|
||||
}
|
||||
// 判断字符串中有没有字母
|
||||
if (/[a-zA-Z]/.test(value)) {
|
||||
level++
|
||||
}
|
||||
// 判断字符串中有没有特殊符号
|
||||
if (/[^0-9a-zA-Z_]/.test(value)) {
|
||||
level++
|
||||
}
|
||||
this.state.passwordLevel = level
|
||||
this.state.percent = level * 30
|
||||
if (level >= 2) {
|
||||
if (level >= 3) {
|
||||
this.state.percent = 100
|
||||
}
|
||||
callback()
|
||||
} else {
|
||||
if (level === 0) {
|
||||
this.state.percent = 10
|
||||
}
|
||||
callback(new Error('密码强度不够'))
|
||||
}
|
||||
},
|
||||
|
||||
handlePasswordCheck (rule, value, callback) {
|
||||
const password = this.form.getFieldValue('password')
|
||||
// console.log('value', value)
|
||||
if (value === undefined) {
|
||||
callback(new Error('请输入密码'))
|
||||
}
|
||||
if (value && password && value.trim() !== password.trim()) {
|
||||
callback(new Error('两次密码不一致'))
|
||||
}
|
||||
callback()
|
||||
},
|
||||
handleCaptchaCheck (rule, value, callback) {
|
||||
if (!value) {
|
||||
callback(new Error('请输入验证码'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
handlePhoneCheck (rule, value, callback) {
|
||||
const reg = /^1[3456789]\d{9}$/
|
||||
if (!reg.test(value)) {
|
||||
callback(new Error('请输入正确手机号'))
|
||||
} else {
|
||||
const params = {
|
||||
phone: value
|
||||
}
|
||||
checkOnlyUser(params).then((res) => {
|
||||
if (res.success) {
|
||||
callback()
|
||||
} else {
|
||||
callback(new Error('手机号已存在!'))
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
handlePasswordInputClick () {
|
||||
if (!this.isMobile()) {
|
||||
this.state.passwordLevelChecked = true
|
||||
return
|
||||
}
|
||||
this.state.passwordLevelChecked = false
|
||||
},
|
||||
|
||||
handleSubmit () {
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
const register = {
|
||||
username: values.username,
|
||||
password: values.password,
|
||||
phone: values.mobile,
|
||||
smscode: values.captcha
|
||||
}
|
||||
postAction('/sys/user/register', register).then((res) => {
|
||||
if (!res.success) {
|
||||
this.registerFailed(res.message)
|
||||
} else {
|
||||
this.$router.push({ name: 'registerResult', params: { ...values } })
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getCaptcha (e) {
|
||||
e.preventDefault()
|
||||
const that = this
|
||||
this.form.validateFields(['mobile'], { force: true }, (err, values) => {
|
||||
if (!err) {
|
||||
this.state.smsSendBtn = true
|
||||
const interval = window.setInterval(() => {
|
||||
if (that.state.time-- <= 0) {
|
||||
that.state.time = 60
|
||||
that.state.smsSendBtn = false
|
||||
window.clearInterval(interval)
|
||||
}
|
||||
}, 1000)
|
||||
const hide = this.$message.loading('验证码发送中..', 0)
|
||||
const params = {
|
||||
mobile: values.mobile,
|
||||
smsmode: '1'
|
||||
}
|
||||
postAction('/sys/sms', params).then((res) => {
|
||||
if (!res.success) {
|
||||
this.registerFailed(res.message)
|
||||
setTimeout(hide, 0)
|
||||
}
|
||||
setTimeout(hide, 500)
|
||||
}).catch(err => {
|
||||
setTimeout(hide, 1)
|
||||
clearInterval(interval)
|
||||
that.state.time = 60
|
||||
that.state.smsSendBtn = false
|
||||
this.requestFailed(err)
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
registerFailed (message) {
|
||||
this.$notification.error({
|
||||
message: '注册失败',
|
||||
description: message,
|
||||
duration: 2
|
||||
})
|
||||
},
|
||||
requestFailed (err) {
|
||||
this.$notification.error({
|
||||
message: '错误',
|
||||
description: ((err.response || {}).data || {}).message || '请求出现错误,请稍后再试',
|
||||
duration: 4
|
||||
})
|
||||
this.registerBtn = false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'state.passwordLevel' (val) {
|
||||
console.log(val)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.user-register {
|
||||
|
||||
&.error {
|
||||
color: #ff0000;
|
||||
}
|
||||
|
||||
&.warning {
|
||||
color: #ff7e05;
|
||||
}
|
||||
|
||||
&.success {
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.user-layout-register {
|
||||
.ant-input-group-addon:first-child {
|
||||
background-color: #fff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style lang="less" scoped>
|
||||
.user-layout-register {
|
||||
|
||||
& > h3 {
|
||||
font-size: 16px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.getCaptcha {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.register-button {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.login {
|
||||
float: right;
|
||||
line-height: 40px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<result
|
||||
:isSuccess="true"
|
||||
:content="false"
|
||||
:title="email">
|
||||
|
||||
<template slot="action">
|
||||
<a-button size="large" style="margin-left: 8px" @click="goHomeHandle">返回首页</a-button>
|
||||
</template>
|
||||
|
||||
</result>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Result from '@/views/result/Result'
|
||||
|
||||
export default {
|
||||
name: 'RegisterResult',
|
||||
components: {
|
||||
Result
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
form: {}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
email () {
|
||||
const v = this.form ? this.form.username || this.form.mobile : ' XXX '
|
||||
const title = `你的账户:${v} 注册成功`
|
||||
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
||||
this.username = v
|
||||
return title
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.form = this.$route.params
|
||||
},
|
||||
methods: {
|
||||
goHomeHandle () {
|
||||
const params = {}
|
||||
params.username = this.form.username
|
||||
params.password = this.form.password
|
||||
console.log(params)
|
||||
this.$router.push({ name: 'login', params })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,211 @@
|
||||
/**
|
||||
*第三方登录
|
||||
*/
|
||||
import { mapActions } from 'vuex'
|
||||
import { postAction } from '@api/manage'
|
||||
import { timeFix } from '@/utils/util'
|
||||
|
||||
export const JeroThirdLoginMixin = {
|
||||
data () {
|
||||
return {
|
||||
// 第三方登录相关信息
|
||||
thirdLoginInfo: '',
|
||||
thirdPasswordShow: false,
|
||||
thirdLoginPassword: '',
|
||||
thirdLoginUser: '',
|
||||
thirdConfirmShow: false,
|
||||
thirdCreateUserLoding: false,
|
||||
thirdLoginState: false,
|
||||
// 绑定手机号弹窗
|
||||
bindingPhoneModal: false,
|
||||
thirdPhone: '',
|
||||
thirdCaptcha: '',
|
||||
// 获取验证码按钮30s之内是否可点击
|
||||
thirdState: {
|
||||
time: 30,
|
||||
smsSendBtn: false
|
||||
},
|
||||
// 第三方用户UUID
|
||||
thirdUserUuid: '',
|
||||
thirdType: '',
|
||||
url: {
|
||||
bindingThirdPhone: '/sys/thirdLogin/bindingThirdPhone'
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['ThirdLogin']),
|
||||
// 第三方登录
|
||||
onThirdLogin (source) {
|
||||
const url = window._CONFIG.domianURL + `/sys/thirdLogin/render/${source}`
|
||||
window.open(url, `login ${source}`, 'height=500, width=500, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no')
|
||||
const that = this
|
||||
that.thirdType = source
|
||||
that.thirdLoginInfo = ''
|
||||
that.thirdLoginState = false
|
||||
const receiveMessage = function (event) {
|
||||
const token = event.data
|
||||
if (typeof token === 'string') {
|
||||
// 如果是字符串类型 说明是token信息
|
||||
if (token === '登录失败') {
|
||||
that.$message.warning(token)
|
||||
} else if (token.includes('绑定手机号')) {
|
||||
that.bindingPhoneModal = true
|
||||
const strings = token.split(',')
|
||||
that.thirdUserUuid = strings[1]
|
||||
} else {
|
||||
that.doThirdLogin(token)
|
||||
}
|
||||
} else if (typeof token === 'object') {
|
||||
// 对象类型 说明需要提示是否绑定现有账号
|
||||
if (token.isObj === true) {
|
||||
that.thirdConfirmShow = true
|
||||
that.thirdLoginInfo = { ...token }
|
||||
}
|
||||
} else {
|
||||
that.$message.warning('不识别的信息传递')
|
||||
}
|
||||
}
|
||||
window.addEventListener('message', receiveMessage, false)
|
||||
},
|
||||
// 根据token执行登录
|
||||
doThirdLogin (token) {
|
||||
if (this.thirdLoginState === false) {
|
||||
this.thirdLoginState = true
|
||||
const param = {}
|
||||
param.thirdType = this.thirdType
|
||||
param.token = token
|
||||
this.ThirdLogin(param).then(res => {
|
||||
if (res.success) {
|
||||
this.loginSuccess()
|
||||
} else {
|
||||
this.requestFailed(res)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
// 绑定已有账号 需要输入密码
|
||||
thirdLoginUserBind () {
|
||||
this.thirdLoginPassword = ''
|
||||
this.thirdLoginUser = this.thirdLoginInfo.uuid
|
||||
this.thirdConfirmShow = false
|
||||
this.thirdPasswordShow = true
|
||||
},
|
||||
// 创建新账号
|
||||
thirdLoginUserCreate () {
|
||||
this.thirdCreateUserLoding = true
|
||||
// 账号名后面添加两位随机数
|
||||
this.thirdLoginInfo.suffix = parseInt((Math.random() * 98 + 1) + '')
|
||||
// this.thirdLoginInfo.operateCode = 123 //测试校验失败
|
||||
postAction('/sys/third/user/create', this.thirdLoginInfo).then(res => {
|
||||
if (res.success) {
|
||||
const token = res.result
|
||||
console.log('thirdCreateNewAccount', token)
|
||||
this.doThirdLogin(token)
|
||||
this.thirdConfirmShow = false
|
||||
} else {
|
||||
this.$message.warning(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
this.thirdCreateUserLoding = false
|
||||
})
|
||||
},
|
||||
// 核实密码
|
||||
thirdLoginCheckPassword () {
|
||||
// this.thirdLoginInfo.operateCode = 123 //测试校验失败
|
||||
const param = Object.assign({}, this.thirdLoginInfo, { password: this.thirdLoginPassword })
|
||||
postAction('/sys/third/user/checkPassword', param).then(res => {
|
||||
if (res.success) {
|
||||
this.thirdLoginNoPassword()
|
||||
this.doThirdLogin(res.result)
|
||||
} else {
|
||||
this.$message.warning(res.message)
|
||||
}
|
||||
})
|
||||
},
|
||||
// 没有密码 取消操作
|
||||
thirdLoginNoPassword () {
|
||||
this.thirdPasswordShow = false
|
||||
this.thirdLoginPassword = ''
|
||||
this.thirdLoginUser = ''
|
||||
},
|
||||
// 获取第三方验证码
|
||||
getThirdCaptcha () {
|
||||
const that = this
|
||||
if (!this.thirdPhone) {
|
||||
that.cmsFailed('请输入手机号')
|
||||
} else {
|
||||
this.thirdState.smsSendBtn = true
|
||||
const interval = window.setInterval(() => {
|
||||
if (that.thirdState.time-- <= 0) {
|
||||
that.thirdState.time = 30
|
||||
that.thirdState.smsSendBtn = false
|
||||
window.clearInterval(interval)
|
||||
}
|
||||
}, 1000)
|
||||
const hide = this.$message.loading('验证码发送中..', 0)
|
||||
const smsParams = {}
|
||||
smsParams.mobile = this.thirdPhone
|
||||
smsParams.smsmode = '0'
|
||||
postAction('/sys/sms', smsParams).then(res => {
|
||||
if (!res.success) {
|
||||
setTimeout(hide, 0)
|
||||
this.cmsFailed(res.message)
|
||||
}
|
||||
setTimeout(hide, 500)
|
||||
}).catch(err => {
|
||||
setTimeout(hide, 1)
|
||||
clearInterval(interval)
|
||||
that.thirdState.time = 30
|
||||
that.thirdState.smsSendBtn = false
|
||||
this.requestFailed(err)
|
||||
})
|
||||
}
|
||||
},
|
||||
// 绑定手机号点击确定按钮
|
||||
thirdHandleOk () {
|
||||
const bingingParams = {}
|
||||
bingingParams.mobile = this.thirdPhone
|
||||
bingingParams.captcha = this.thirdCaptcha
|
||||
bingingParams.thirdUserUuid = this.thirdUserUuid
|
||||
postAction(this.url.bindingThirdPhone, bingingParams).then(res => {
|
||||
if (res.success) {
|
||||
this.bindingPhoneModal = false
|
||||
this.doThirdLogin(res.result)
|
||||
} else {
|
||||
this.$message.warning(res.message)
|
||||
}
|
||||
})
|
||||
},
|
||||
loginSuccess () {
|
||||
// update-begin- author:sunjianlei --- date:20190812 --- for: 登录成功后不解除禁用按钮,防止多次点击
|
||||
// this.loginBtn = false
|
||||
// update-end- author:sunjianlei --- date:20190812 --- for: 登录成功后不解除禁用按钮,防止多次点击
|
||||
this.$router.push({ path: '/dashboard/analysis' }).catch(() => {
|
||||
console.log('登录跳转首页出错,这个错误从哪里来的')
|
||||
})
|
||||
this.$notification.success({
|
||||
message: '欢迎',
|
||||
description: `${timeFix()},欢迎回来`
|
||||
})
|
||||
},
|
||||
cmsFailed (err) {
|
||||
this.$notification.error({
|
||||
message: '登录失败',
|
||||
description: err,
|
||||
duration: 4
|
||||
})
|
||||
},
|
||||
requestFailed (err) {
|
||||
this.$notification.error({
|
||||
message: '登录失败',
|
||||
description: ((err.response || {}).data || {}).message || err.message || '请求出现错误,请稍后再试',
|
||||
duration: 4
|
||||
})
|
||||
this.loginBtn = false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="user-login-other">
|
||||
<span>其他登录方式</span>
|
||||
<a @click="onThirdLogin('github')" title="github"><a-icon class="item-icon" type="github"></a-icon></a>
|
||||
<a @click="onThirdLogin('wechat_enterprise')" title="企业微信"> <icon-font class="item-icon" type="icon-qiyeweixin3" /></a>
|
||||
<a @click="onThirdLogin('dingtalk')" title="钉钉"><a-icon class="item-icon" type="dingding"></a-icon></a>
|
||||
<a @click="onThirdLogin('wechat_open')" title="微信"><a-icon class="item-icon" type="wechat"></a-icon></a>
|
||||
</div>
|
||||
<!-- 第三方登录绑定账号密码输入弹框 -->
|
||||
<j-modal title="请输入密码" :visible="thirdPasswordShow" switchFullscreen @ok="thirdLoginCheckPassword" @cancel="thirdLoginNoPassword">
|
||||
<a-input-password placeholder="请输入密码" v-model="thirdLoginPassword" />
|
||||
</j-modal>
|
||||
|
||||
<!-- 第三方登录提示是否绑定账号弹框 -->
|
||||
<j-modal :footer="null" :closable="false" :visible="thirdConfirmShow" :class="'ant-modal-confirm'" switchFullscreen>
|
||||
<div class="ant-modal-confirm-body-wrapper">
|
||||
<div class="ant-modal-confirm-body">
|
||||
<a-icon type="question-circle" style="color:#faad14"/>
|
||||
<span class="ant-modal-confirm-title">提示</span>
|
||||
<div class="ant-modal-confirm-content">
|
||||
已有同名账号存在,请确认是否绑定该账号?
|
||||
</div>
|
||||
</div>
|
||||
<div class="ant-modal-confirm-btns">
|
||||
<a-button @click="thirdLoginUserCreate" :loading="thirdCreateUserLoding">创建新账号</a-button>
|
||||
<a-button @click="thirdLoginUserBind" type="primary">确认绑定</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</j-modal>
|
||||
|
||||
<!-- 第三方登录绑定手机号 -->
|
||||
<j-modal :visible="bindingPhoneModal" :class="'ant-modal-confirm'" switchFullscreen>
|
||||
<template slot="footer">
|
||||
<a-button key="submit" type="primary" @click="thirdHandleOk">
|
||||
确定
|
||||
</a-button>
|
||||
</template>
|
||||
<div class="ant-modal-confirm-body-wrapper">
|
||||
<a-form-item>
|
||||
<span>绑定手机号</span>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-input
|
||||
size="large"
|
||||
type="text"
|
||||
placeholder="手机号"
|
||||
v-model="thirdPhone">
|
||||
<a-icon slot="prefix" type="mobile" :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col class="gutter-row" :span="16">
|
||||
<a-form-item>
|
||||
<a-input
|
||||
size="large"
|
||||
type="text"
|
||||
placeholder="请输入验证码"
|
||||
v-model="thirdCaptcha">
|
||||
<a-icon slot="prefix" type="mail" :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col class="gutter-row" :span="8">
|
||||
<a-button
|
||||
class="getCaptcha"
|
||||
tabindex="-1"
|
||||
:disabled="thirdState.smsSendBtn"
|
||||
@click.stop.prevent="getThirdCaptcha"
|
||||
v-text="!thirdState.smsSendBtn && '获取验证码' || (thirdState.time+' s')"></a-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</j-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { JeroThirdLoginMixin } from '@views/user/third/JeroThirdLoginMixin'
|
||||
import { Icon } from 'ant-design-vue'
|
||||
|
||||
const IconFont = Icon.createFromIconfontCN({
|
||||
// scriptUrl: '//at.alicdn.com/t/font_2316098_umqusozousr.js',
|
||||
scriptUrl: '/cdn/font-icon/font_2316098_umqusozousr.js'
|
||||
})
|
||||
export default {
|
||||
name: 'thirdLogin',
|
||||
mixins: [JeroThirdLoginMixin],
|
||||
components: {
|
||||
IconFont
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.user-login-other {
|
||||
text-align: left;
|
||||
margin-top: 24px;
|
||||
line-height: 22px;
|
||||
|
||||
.item-icon {
|
||||
font-size: 24px;
|
||||
color: rgba(0, 0, 0, .2);
|
||||
margin-left: 16px;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
transition: color .3s;
|
||||
|
||||
& :hover {
|
||||
color: #1890ff;
|
||||
}
|
||||
}
|
||||
.register {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user