登录调整

master
yujialong 4 months ago
parent 7f18b99801
commit 6036ec0efd
  1. 4
      src/api/index.js
  2. 42
      src/layouts/header/index.vue
  3. 112
      src/pages/account/login/index.vue
  4. 4
      src/setting.js
  5. 13
      src/store/modules/user.js

@ -3,12 +3,13 @@ const host = Setting.apiBaseURL
export default { export default {
// 登录注册 // 登录注册
logins: `users/users/user/login`, logins: `users/users/user/login`,
verification: `${host}users/users/user/captcha`, verification: `${host}users/users/user/captcha`,
sendPhoneVerificationCode: `users/users/user/sendPhoneVerificationCode`, sendPhoneVerificationCode: `users/users/user/sendPhoneVerificationCode`,
getToken: `users/users/user/getToken`, getToken: `users/users/user/getToken`,
getOtherAccountByPhone: `users/users/user/getOtherAccountByPhone`, getOtherAccountByPhone: `users/users/user/getOtherAccountByPhone`,
unbindAccounts: `users/users/user/unbindAccounts`, unbindAccounts: `users/users/user/unbindAccounts`,
logout: `users/users/user/logout`,
// 加密货币 // 加密货币
market: `/topic/market`, market: `/topic/market`,
@ -50,7 +51,6 @@ export default {
unbindMobilePhone: `users/users/userAccount/unbindMobilePhone`, unbindMobilePhone: `users/users/userAccount/unbindMobilePhone`,
bindPhoneOrEmail: `users/users/userAccount/bindPhoneOrEmail`, bindPhoneOrEmail: `users/users/userAccount/bindPhoneOrEmail`,
examinePassword: `users/users/userAccount/examinePassword`, examinePassword: `users/users/userAccount/examinePassword`,
isClient: `${host}users/users/user/isClient`,
deleteProfile: `users/users/userInfo/deleteProfile`, deleteProfile: `users/users/userInfo/deleteProfile`,
checkEmailOrPhone: `occupationlab/occupationlab/architecture/checkEmailOrPhone`, checkEmailOrPhone: `occupationlab/occupationlab/architecture/checkEmailOrPhone`,
accountIsDisabled: `users/users/user/accountIsDisabled`, accountIsDisabled: `users/users/user/accountIsDisabled`,

@ -29,16 +29,19 @@
</div> </div>
</div> </div>
<el-dialog title="修改密码" :visible.sync="passwordVisible" :close-on-click-modal="false" :append-to-body="true" @close="closePassword" width="30%"> <el-dialog title="修改密码" :visible.sync="passwordVisible" :close-on-click-modal="false" :append-to-body="true"
@close="closePassword" width="30%">
<el-form ref="passwordForm" label-width="82px"> <el-form ref="passwordForm" label-width="82px">
<el-form-item label="原密码"> <el-form-item label="原密码">
<el-input type="password" v-model="passwordForm.password" placeholder="请输入原密码"></el-input> <el-input type="password" v-model="passwordForm.password" placeholder="请输入原密码"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="新密码"> <el-form-item label="新密码">
<el-input type="password" v-model="passwordForm.newPassword" placeholder="请输入新密码" @keyup.enter.native="editPassword"></el-input> <el-input type="password" v-model="passwordForm.newPassword" placeholder="请输入新密码"
@keyup.enter.native="editPassword"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="确认新密码"> <el-form-item label="确认新密码">
<el-input type="password" v-model="passwordForm.reNewPassword" placeholder="请确认新密码" @keyup.enter.native="editPassword"></el-input> <el-input type="password" v-model="passwordForm.reNewPassword" placeholder="请确认新密码"
@keyup.enter.native="editPassword"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
@ -114,10 +117,6 @@ export default {
avatar: userInfo.userAvatars, avatar: userInfo.userAvatars,
userName: userInfo.userName userName: userInfo.userName
}) })
//
userInfo.userName || this.$get(this.api.isClient).then(res => {
res.customerName && this.setInfo({userName: res.customerName})
}).catch(res => {})
}).catch(err => { }) }).catch(err => { })
}, },
hideSetting () { hideSetting () {
@ -195,6 +194,7 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
$height: 64px; $height: 64px;
.header { .header {
z-index: 10; z-index: 10;
position: fixed; position: fixed;
@ -204,6 +204,7 @@ $height: 64px;
height: $height; height: $height;
background-color: #fff; background-color: #fff;
box-shadow: 0px 0px 6px 0px rgba(178, 178, 178, 0.32); box-shadow: 0px 0px 6px 0px rgba(178, 178, 178, 0.32);
.inner { .inner {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -212,6 +213,7 @@ $height: 64px;
padding: 0 80px 0 10px; padding: 0 80px 0 10px;
margin: 0 auto; margin: 0 auto;
} }
.logo { .logo {
position: absolute; position: absolute;
top: 0; top: 0;
@ -236,6 +238,7 @@ $height: 64px;
padding: 7px 20px; padding: 7px 20px;
margin: 0 auto; margin: 0 auto;
background-color: #fff; background-color: #fff;
input { input {
width: 195px; width: 195px;
margin-left: 10px; margin-left: 10px;
@ -243,26 +246,41 @@ $height: 64px;
color: #333; color: #333;
background-color: transparent; background-color: transparent;
border: 0; border: 0;
&::-webkit-input-placeholder{color: #999}
&::-moz-placeholder{color: #999} &::-webkit-input-placeholder {
&:-moz-placeholder{color: #999} color: #999
}
&::-moz-placeholder {
color: #999
}
&:-moz-placeholder {
color: #999
}
&:focus { &:focus {
outline: none; outline: none;
} }
} }
.remove { .remove {
cursor: pointer; cursor: pointer;
} }
.search-icon { .search-icon {
width: 18px; width: 18px;
} }
} }
.action { .action {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
.icon { .icon {
cursor: pointer; cursor: pointer;
} }
.user-wrap { .user-wrap {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@ -271,6 +289,7 @@ $height: 64px;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
.username { .username {
margin-left: 10px; margin-left: 10px;
color: #000; color: #000;
@ -279,13 +298,16 @@ $height: 64px;
} }
} }
} }
.login { .login {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
&:hover { &:hover {
opacity: .9; opacity: .9;
} }
span { span {
margin-left: 5px; margin-left: 5px;
color: #666; color: #666;

@ -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%;
} }

@ -11,8 +11,8 @@ const url = location.host
const dev = process.env.NODE_ENV === 'development' // 本地 const dev = process.env.NODE_ENV === 'development' // 本地
let host = `${location.origin}/` let host = `${location.origin}/`
if (dev) { if (dev) {
host = 'https://www.dataforward.cn/' // host = 'https://www.dataforward.cn/'
// host = 'http://192.168.31.217:9000/' host = 'http://192.168.31.51:9000/'
} }
const Setting = { const Setting = {

@ -9,7 +9,7 @@
import Setting from '@/setting' import Setting from '@/setting'
import util from '@/libs/util' import util from '@/libs/util'
import {post,get,del,put} from '@/plugins/requests/index.js' import { post, get } from '@/plugins/requests/index.js'
import api from '@/api' import api from '@/api'
/** /**
@ -60,13 +60,6 @@ export default {
if (res.status == 200) { if (res.status == 200) {
util.local.set(Setting.tokenKey, res.data.token, 43200000) util.local.set(Setting.tokenKey, res.data.token, 43200000)
util.successMsg('登录成功') util.successMsg('登录成功')
get(api.isClient).then(res => {
commit('SET_CUSTOMER',res.customer)
const userName = res.customerName
userName && commit('SET_INFO', {
userName
})
}).catch(res => {})
post(api.getSchoolIdByToken).then(res => { post(api.getSchoolIdByToken).then(res => {
commit('SET_INFO', res) commit('SET_INFO', res)
}).catch(res => { }) }).catch(res => { })
@ -88,10 +81,14 @@ export default {
}, },
logout ({ commit, state, dispatch }) { logout ({ commit, state, dispatch }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
post(api.logout).then(() => {
util.local.remove(Setting.storeKey) util.local.remove(Setting.storeKey)
util.local.remove(Setting.tokenKey) util.local.remove(Setting.tokenKey)
location.reload() location.reload()
resolve() resolve()
}).catch(error => {
reject(error)
})
}) })
}, },
setAvatar ({ state, commit }, avatar) { setAvatar ({ state, commit }, avatar) {

Loading…
Cancel
Save