|
|
|
@ -53,11 +53,12 @@ |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import { mapActions } from 'vuex' |
|
|
|
|
import { mapMutations, mapActions } from 'vuex' |
|
|
|
|
import vHead from '@/layouts/header' |
|
|
|
|
import util from '@/libs/util' |
|
|
|
|
import Setting from '@/setting' |
|
|
|
|
import vFooter from '@/layouts/footer' |
|
|
|
|
import axios from 'axios' |
|
|
|
|
export default { |
|
|
|
|
data: function() { |
|
|
|
|
return { |
|
|
|
@ -76,13 +77,16 @@ export default { |
|
|
|
|
account: '', |
|
|
|
|
password: '', |
|
|
|
|
random: '', |
|
|
|
|
code: '' |
|
|
|
|
code: '', |
|
|
|
|
type: 2, // 平台端区分:0->教师端 1->学生端 2->无端 |
|
|
|
|
platform: Setting.platformId, // 所属平台id(1.职站 2.数据平台 3.中台) |
|
|
|
|
}, |
|
|
|
|
rules: { |
|
|
|
|
account: [{ required: true, message: '请输入账号', trigger: 'blur' }], |
|
|
|
|
password: [{ required: true, message: '请输入密码', trigger: 'blur' }], |
|
|
|
|
code: [{ required: true, message: '请输入验证码', trigger: 'blur' }], |
|
|
|
|
}, |
|
|
|
|
token: '', |
|
|
|
|
phoneVisible: false, |
|
|
|
|
phone: '', |
|
|
|
|
phoneCode: '', |
|
|
|
@ -96,6 +100,9 @@ export default { |
|
|
|
|
this.getVerImg() |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
...mapMutations("user", [ |
|
|
|
|
'SET_CUSTOMERNAME', 'SET_CUSTOMER', 'SET_INFO' |
|
|
|
|
]), |
|
|
|
|
...mapActions('user', [ |
|
|
|
|
'login','setCustomer' |
|
|
|
|
]), |
|
|
|
@ -105,18 +112,48 @@ export default { |
|
|
|
|
this.$refs.login.clearValidate() |
|
|
|
|
this.rules.account[0].message = item.id == 1 ? '请输入账号' : '请输入手机号/邮箱' |
|
|
|
|
}, |
|
|
|
|
// 处理登录成功 |
|
|
|
|
setLogin() { |
|
|
|
|
window.opener && window.opener.location.reload() // 刷新官网 |
|
|
|
|
util.local.set(Setting.tokenKey, this.token, Setting.tokenExpires) |
|
|
|
|
// 查询是否是客户,如果是客户,则弹出选择端的页面去选择跳转到哪个端 |
|
|
|
|
this.$get(this.api.isClient).then(res => { |
|
|
|
|
// 如果是客户 |
|
|
|
|
this.SET_CUSTOMER(res.customer) |
|
|
|
|
const userName = res.customerName |
|
|
|
|
userName && this.SET_INFO({ |
|
|
|
|
userName |
|
|
|
|
}) |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
// 查询schoolId |
|
|
|
|
this.$post(this.api.getSchoolIdByToken).then(res => { |
|
|
|
|
this.SET_INFO(res) |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
// 登录次数+1 |
|
|
|
|
this.$post(this.api.saveRecord,{ |
|
|
|
|
type: 3, |
|
|
|
|
}).then(res => {}).catch(res => {}) |
|
|
|
|
// 查询是否有更新日志,如果返回了true,则直接跳转到日志页 |
|
|
|
|
this.$get(this.api.logNotification).then(res => { |
|
|
|
|
const history = this.$route.query.redirect |
|
|
|
|
const redirect = res.notification ? |
|
|
|
|
'/log' : |
|
|
|
|
history ? |
|
|
|
|
decodeURIComponent(history) : |
|
|
|
|
'/index' |
|
|
|
|
util.successMsg('登录成功') |
|
|
|
|
this.$router.replace(redirect) |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}, |
|
|
|
|
submitForm() { |
|
|
|
|
this.$refs.login.validate(valid => { |
|
|
|
|
if (valid) { |
|
|
|
|
this.login(this.form).then(() => { |
|
|
|
|
window.opener && window.opener.location.reload() // 刷新官网 |
|
|
|
|
let redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : '/index' |
|
|
|
|
this.$router.replace(redirect) |
|
|
|
|
this.$post(this.api.logins, this.form).then(res => { |
|
|
|
|
this.token = res.data.token |
|
|
|
|
this.setLogin() |
|
|
|
|
}).catch(res => { |
|
|
|
|
// 如果没有绑定手机号 |
|
|
|
|
if(res && res.status == 30001){ |
|
|
|
|
this.phoneVisible = true |
|
|
|
|
} |
|
|
|
|
if (res && res.status == 30001) this.phoneVisible = true |
|
|
|
|
this.getVerImg() |
|
|
|
|
this.form.code = '' |
|
|
|
|
}) |
|
|
|
@ -178,18 +215,7 @@ export default { |
|
|
|
|
util.successMsg('绑定成功') |
|
|
|
|
this.form.phone = this.phone |
|
|
|
|
this.phoneVisible = false |
|
|
|
|
// 是否是客户 |
|
|
|
|
this.$get(this.api.isClient).then(res => { |
|
|
|
|
this.setCustomer(res.customer) |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
util.local.set(Setting.tokenKey,res.token,43200000) |
|
|
|
|
util.successMsg('登录成功') |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.$post(this.api.saveRecord,{ |
|
|
|
|
type: 3, |
|
|
|
|
}).then(res => {}).catch(res => {}) |
|
|
|
|
},3000) |
|
|
|
|
this.$router.push('/index/list') |
|
|
|
|
this.setLogin() |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|