|
|
@ -9,17 +9,10 @@ |
|
|
|
</ul> |
|
|
|
</ul> |
|
|
|
<el-form :model="form" :rules="rules" ref="form" style="margin-top: 20px"> |
|
|
|
<el-form :model="form" :rules="rules" ref="form" style="margin-top: 20px"> |
|
|
|
<!-- 学号工号 --> |
|
|
|
<!-- 学号工号 --> |
|
|
|
<div v-show="!form.distinguish"> |
|
|
|
<div v-show="!form.distinguish && !verCodeLogin" class="items"> |
|
|
|
<el-form-item class="school-select" prop="schoolId"> |
|
|
|
|
|
|
|
<label class="label school"></label> |
|
|
|
|
|
|
|
<el-select v-model="form.schoolId" clearable filterable placeholder="请选择学校"> |
|
|
|
|
|
|
|
<el-option v-for="(item, i) in schoolList" :key="i" :label="item.schoolName" |
|
|
|
|
|
|
|
:value="item.schoolId"></el-option> |
|
|
|
|
|
|
|
</el-select> |
|
|
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
<el-form-item class="flex-1" prop="workNumber"> |
|
|
|
<el-form-item class="flex-1" prop="workNumber"> |
|
|
|
<label class="label account"></label> |
|
|
|
<label class="label account"></label> |
|
|
|
<el-input v-model.trim="form.workNumber" :placeholder="'请输入学号/工号'" |
|
|
|
<el-input v-model.trim="form.workNumber" placeholder="请输入学号/工号/手机号/邮箱" |
|
|
|
@keyup.enter.native="submit"></el-input> |
|
|
|
@keyup.enter.native="submit"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -28,7 +21,7 @@ |
|
|
|
<label class="label account"></label> |
|
|
|
<label class="label account"></label> |
|
|
|
<el-input v-model.trim="form.account" placeholder="请输入账号" @keyup.enter.native="submit"></el-input> |
|
|
|
<el-input v-model.trim="form.account" placeholder="请输入账号" @keyup.enter.native="submit"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<template v-if="form.distinguish === 2"> |
|
|
|
<template v-if="verCodeLogin"> |
|
|
|
<el-form-item prop="account"> |
|
|
|
<el-form-item prop="account"> |
|
|
|
<label class="label account"></label> |
|
|
|
<label class="label account"></label> |
|
|
|
<el-input v-model.trim="form.account" placeholder="请输入手机号/邮箱" @keyup.enter.native="submit"></el-input> |
|
|
|
<el-input v-model.trim="form.account" placeholder="请输入手机号/邮箱" @keyup.enter.native="submit"></el-input> |
|
|
@ -44,7 +37,7 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<template v-if="form.distinguish !== 2"> |
|
|
|
<template v-else> |
|
|
|
<el-form-item prop="password"> |
|
|
|
<el-form-item prop="password"> |
|
|
|
<label class="password label"></label> |
|
|
|
<label class="password label"></label> |
|
|
|
<el-input type="password" placeholder="请输入密码" v-model.trim="form.password" @keyup.enter.native="submit"> |
|
|
|
<el-input type="password" placeholder="请输入密码" v-model.trim="form.password" @keyup.enter.native="submit"> |
|
|
@ -57,8 +50,9 @@ |
|
|
|
<img @click="getVerImg" :src="verificationIMG" class="ver-img" alt=""> |
|
|
|
<img @click="getVerImg" :src="verificationIMG" class="ver-img" alt=""> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<div v-show="!form.distinguish" class="default-check"> |
|
|
|
<div class="bottom"> |
|
|
|
<el-checkbox v-model="setDefault">设置为默认学校</el-checkbox> |
|
|
|
<el-link :underline="false" type="primary" @click="switchType">{{ verCodeLogin ? '密码' : '验证码' }}登录</el-link> |
|
|
|
|
|
|
|
<el-link :underline="false" type="primary" @click="toAccount">没有账号,点击申请</el-link> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<el-button class="submit" type="primary" @click="submit">登录</el-button> |
|
|
|
<el-button class="submit" type="primary" @click="submit">登录</el-button> |
|
|
|
</el-form> |
|
|
|
</el-form> |
|
|
@ -75,7 +69,8 @@ |
|
|
|
<div class="ver-code"> |
|
|
|
<div class="ver-code"> |
|
|
|
<el-input v-model="phoneCode" placeholder="请输入验证码" maxlength="6"></el-input> |
|
|
|
<el-input v-model="phoneCode" placeholder="请输入验证码" maxlength="6"></el-input> |
|
|
|
<el-button style="top: 1px" type="text" @click="sendPhoneCode(1)" |
|
|
|
<el-button style="top: 1px" type="text" @click="sendPhoneCode(1)" |
|
|
|
:disabled="binding === '' || phoneDisabled">{{ phoneBtnText }}</el-button> |
|
|
|
:disabled="binding === '' || phoneDisabled">{{ |
|
|
|
|
|
|
|
phoneBtnText }}</el-button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
</el-form> |
|
|
@ -135,36 +130,30 @@ export default { |
|
|
|
tabList: [ |
|
|
|
tabList: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
id: 0, |
|
|
|
id: 0, |
|
|
|
label: '学号/工号登录' |
|
|
|
label: '学生/老师登录' |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
id: 1, |
|
|
|
id: 1, |
|
|
|
label: '学校管理员登录' |
|
|
|
label: '学校管理员登录' |
|
|
|
}, { |
|
|
|
|
|
|
|
id: 2, |
|
|
|
|
|
|
|
label: '手机号/邮箱' |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
], |
|
|
|
setDefault: !!util.local.get(schoolIdKey), // 本地缓存里有学校id,则默认勾选 |
|
|
|
|
|
|
|
verificationIMG: '', |
|
|
|
verificationIMG: '', |
|
|
|
schoolList: [], |
|
|
|
schoolList: [], |
|
|
|
form: { |
|
|
|
form: { |
|
|
|
schoolId: '', |
|
|
|
|
|
|
|
workNumber: '', |
|
|
|
workNumber: '', |
|
|
|
account: '', |
|
|
|
account: '', // 手机号验证码模式用这个字段 |
|
|
|
password: '', |
|
|
|
password: '', |
|
|
|
code: '', // 验证码 |
|
|
|
code: '', // 验证码 |
|
|
|
random: '', // 随机数 |
|
|
|
random: '', // 随机数 |
|
|
|
distinguish: 0, // 区分手机号账号登录,1为账号登录,2为手机号或邮箱登录 |
|
|
|
platform: Setting.platformId, |
|
|
|
type: 2, // 平台端区分:0->教师端 1->学生端 2->无端 |
|
|
|
distinguish: 0, |
|
|
|
platform: Setting.platformId |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
rules: { |
|
|
|
rules: { |
|
|
|
schoolId: [{ required: true, message: "请选择学校", trigger: "change" }], |
|
|
|
workNumber: [{ required: true, message: "请输入学号/工号/手机号/邮箱", trigger: "blur" }], |
|
|
|
workNumber: [{ required: true, message: "请输入学生学号", trigger: "blur" }], |
|
|
|
|
|
|
|
account: [{ required: false, message: "请输入账号", trigger: "blur" }], |
|
|
|
account: [{ required: false, message: "请输入账号", trigger: "blur" }], |
|
|
|
password: [{ required: true, message: "请输入密码", trigger: "blur" }], |
|
|
|
password: [{ required: true, message: "请输入密码", trigger: "blur" }], |
|
|
|
code: [{ required: true, message: "请输入验证码", trigger: "blur" }] |
|
|
|
code: [{ required: true, message: "请输入验证码", trigger: "blur" }] |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
verCodeLogin: false, |
|
|
|
phoneDisabledLogin: false, |
|
|
|
phoneDisabledLogin: false, |
|
|
|
phoneTimerLogin: null, |
|
|
|
phoneTimerLogin: null, |
|
|
|
phoneBtnTextLogin: '发送验证码', |
|
|
|
phoneBtnTextLogin: '发送验证码', |
|
|
@ -187,7 +176,6 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
components: { vHead, vFooter }, |
|
|
|
components: { vHead, vFooter }, |
|
|
|
mounted () { |
|
|
|
mounted () { |
|
|
|
this.getSchool() |
|
|
|
|
|
|
|
this.getVerImg() |
|
|
|
this.getVerImg() |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
@ -197,21 +185,17 @@ export default { |
|
|
|
...mapActions('user', [ |
|
|
|
...mapActions('user', [ |
|
|
|
'login', 'setCustomer' |
|
|
|
'login', 'setCustomer' |
|
|
|
]), |
|
|
|
]), |
|
|
|
// 赋值学校列表及id |
|
|
|
// 重置验证规则 |
|
|
|
setSchool (list) { |
|
|
|
handleRule () { |
|
|
|
this.schoolList = list |
|
|
|
const type = this.form.distinguish |
|
|
|
// 取本地缓存里的学校id |
|
|
|
const rules = this.rules |
|
|
|
const schoolId = util.local.get(schoolIdKey) |
|
|
|
rules.workNumber[0].required = !type && !this.verCodeLogin |
|
|
|
if (schoolId) this.form.schoolId = schoolId |
|
|
|
rules.account[0].required = (!type && this.verCodeLogin) || type |
|
|
|
}, |
|
|
|
this.rules.account[0].message = type ? |
|
|
|
// 获取学校列表 |
|
|
|
'请输入账号' : |
|
|
|
getSchool () { |
|
|
|
this.verCodeLogin ? |
|
|
|
this.$get(this.api.querySchool, { |
|
|
|
'请输入手机号/邮箱' : |
|
|
|
provinceId: '', |
|
|
|
'请输入学号/工号/手机号/邮箱' |
|
|
|
cityId: '' |
|
|
|
|
|
|
|
}).then(({ list }) => { |
|
|
|
|
|
|
|
this.setSchool(list) |
|
|
|
|
|
|
|
}).catch(res => { }) |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
// 切换标签 |
|
|
|
// 切换标签 |
|
|
|
typeClick (tab) { |
|
|
|
typeClick (tab) { |
|
|
@ -230,14 +214,7 @@ export default { |
|
|
|
platform: form.platform |
|
|
|
platform: form.platform |
|
|
|
} |
|
|
|
} |
|
|
|
this.$refs.form.clearValidate() |
|
|
|
this.$refs.form.clearValidate() |
|
|
|
// 切换了登录方式后,校验规则要变化 |
|
|
|
this.handleRule() |
|
|
|
const rules = this.rules |
|
|
|
|
|
|
|
rules.schoolId[0].required = id === 0 |
|
|
|
|
|
|
|
rules.workNumber[0].required = id === 0 |
|
|
|
|
|
|
|
rules.account[0].required = !!id |
|
|
|
|
|
|
|
this.rules.account[0].message = id === 1 ? |
|
|
|
|
|
|
|
'请输入账号' : |
|
|
|
|
|
|
|
'请输入手机号/邮箱' |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
// 选择用户回调 |
|
|
|
// 选择用户回调 |
|
|
|
chooseUser (user) { |
|
|
|
chooseUser (user) { |
|
|
@ -275,11 +252,7 @@ export default { |
|
|
|
this.$refs.form.validate(valid => { |
|
|
|
this.$refs.form.validate(valid => { |
|
|
|
if (valid) { |
|
|
|
if (valid) { |
|
|
|
const form = JSON.parse(JSON.stringify(this.form)) |
|
|
|
const form = JSON.parse(JSON.stringify(this.form)) |
|
|
|
const { distinguish } = form |
|
|
|
if (this.verCodeLogin) form.distinguish = 2 |
|
|
|
if (!form.distinguish && this.setDefault) util.local.set(schoolIdKey, form.schoolId) // 选的是学号工号登录,并且勾选了默认,则存入缓存 |
|
|
|
|
|
|
|
if (util.local.get(schoolIdKey) && !this.setDefault) util.local.remove(schoolIdKey) // 本地缓存了学校id,并且没有勾选默认,则删除缓存 |
|
|
|
|
|
|
|
if (distinguish) form.schoolId = '' |
|
|
|
|
|
|
|
if (!distinguish) form.distinguish = 1 |
|
|
|
|
|
|
|
this.$post(this.api.logins, form).then(({ status, data, message }) => { |
|
|
|
this.$post(this.api.logins, form).then(({ status, data, message }) => { |
|
|
|
// 未绑定手机号,则弹框去绑定 |
|
|
|
// 未绑定手机号,则弹框去绑定 |
|
|
|
if (status == 30001) { |
|
|
|
if (status == 30001) { |
|
|
@ -287,15 +260,11 @@ export default { |
|
|
|
this.getVerImg() |
|
|
|
this.getVerImg() |
|
|
|
form.code = '' |
|
|
|
form.code = '' |
|
|
|
} else if (status == 200) { |
|
|
|
} else if (status == 200) { |
|
|
|
|
|
|
|
const accounts = data.userAccounts |
|
|
|
// 如果返回的是数组,则弹框给用户选择登录哪个用户,否则,直接登录 |
|
|
|
// 如果返回的是数组,则弹框给用户选择登录哪个用户,否则,直接登录 |
|
|
|
if (data instanceof Array) { |
|
|
|
if (accounts instanceof Array) { |
|
|
|
// 如果只查询到一个用户,则直接登录,否则,弹框让用户选择 |
|
|
|
this.users = accounts |
|
|
|
if (data.length === 1) { |
|
|
|
|
|
|
|
this.chooseUser(data[0]) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.users = data |
|
|
|
|
|
|
|
this.userVisible = true |
|
|
|
this.userVisible = true |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.token = data.token |
|
|
|
this.token = data.token |
|
|
|
this.setLogin() |
|
|
|
this.setLogin() |
|
|
@ -329,6 +298,17 @@ export default { |
|
|
|
return true |
|
|
|
return true |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 账号申请 |
|
|
|
|
|
|
|
switchType () { |
|
|
|
|
|
|
|
this.verCodeLogin = !this.verCodeLogin |
|
|
|
|
|
|
|
this.$refs.form.clearValidate() |
|
|
|
|
|
|
|
this.handleRule() |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 账号申请 |
|
|
|
|
|
|
|
toAccount () { |
|
|
|
|
|
|
|
this.accountVisible = true |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 验证码倒计时 |
|
|
|
// 验证码倒计时 |
|
|
|
phoneCountdownLogin () { |
|
|
|
phoneCountdownLogin () { |
|
|
|
let count = 60 |
|
|
|
let count = 60 |
|
|
@ -502,7 +482,7 @@ export default { |
|
|
|
|
|
|
|
|
|
|
|
.tab { |
|
|
|
.tab { |
|
|
|
display: flex; |
|
|
|
display: flex; |
|
|
|
justify-content: space-between; |
|
|
|
justify-content: space-around; |
|
|
|
align-items: center; |
|
|
|
align-items: center; |
|
|
|
margin-bottom: 24px; |
|
|
|
margin-bottom: 24px; |
|
|
|
border-bottom: 2px solid #e1e6f2; |
|
|
|
border-bottom: 2px solid #e1e6f2; |
|
|
@ -560,10 +540,12 @@ export default { |
|
|
|
border-radius: 4px !important; |
|
|
|
border-radius: 4px !important; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.default-check { |
|
|
|
.bottom { |
|
|
|
text-align: right; |
|
|
|
display: flex; |
|
|
|
|
|
|
|
justify-content: space-between; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.el-select { |
|
|
|
.el-select { |
|
|
|
width: 100%; |
|
|
|
width: 100%; |
|
|
|
} |
|
|
|
} |
|
|
|