yujialong 3 years ago
parent a91e5f20ad
commit 1269387c83
  1. 61
      src/api/index.js
  2. 21
      src/layouts/header/index.vue
  3. 173
      src/pages/account/login/index.vue
  4. 2
      src/pages/index/list/index.vue
  5. 16
      src/pages/setting/person/download.vue
  6. 24
      src/pages/user/list/index.vue
  7. 2
      src/plugins/requests/index.js
  8. 2
      src/router/permission.js
  9. 2
      src/router/routes.js
  10. 4
      src/setting.js
  11. 26
      src/store/modules/user.js

@ -7,23 +7,23 @@ let host3 = 'http://192.168.31.137:9000'//陈
export default { export default {
// 登录注册 // 登录注册
logins: `${host3}/users/users/user/login`, logins: `/users/users/user/login`,
verification:`${host3}/users/users/user/captcha`, verification:`${Setting.apiBaseURL}/users/users/user/captcha`,
// 公用接口 // 公用接口
queryProvince: `${host3}/nakadai/nakadai/province/queryProvince`, queryProvince: `/nakadai/nakadai/province/queryProvince`,
queryCity: `${host3}/nakadai/nakadai/city/queryCity`, queryCity: `/nakadai/nakadai/city/queryCity`,
queryWorkNumberIsExist:`evaluation/tms/userInfo/queryWorkNumberIsExist`, queryWorkNumberIsExist:`evaluation/tms/userInfo/queryWorkNumberIsExist`,
queryStaffWorkNumberIsExist:`evaluation/tms/system/queryStaffWorkNumberIsExist`, queryStaffWorkNumberIsExist:`evaluation/tms/system/queryStaffWorkNumberIsExist`,
querySchool: `${host3}/nakadai/nakadai/school/querySchool`, querySchool: `/nakadai/nakadai/school/querySchool`,
queryCourseDiscipline: `${host2}/nakadai/nakadai/discipline/queryDiscipline`, queryCourseDiscipline: `/nakadai/nakadai/discipline/queryDiscipline`,
queryCourseProfessionalClass: `${host2}/nakadai/nakadai/professionalClass/queryProfessionalClass`, queryCourseProfessionalClass: `/nakadai/nakadai/professionalClass/queryProfessionalClass`,
queryCourseProfessional: `${host2}/nakadai/nakadai/professional/queryProfessional`, queryCourseProfessional: `/nakadai/nakadai/professional/queryProfessional`,
// 个人中心 // 个人中心
uploadUserAvatars: `${host1}/users/users/userAccount/updateUserAvatars`, uploadUserAvatars: `/users/users/userAccount/updateUserAvatars`,
userInfo:`${host1}/users/users/userInfo/getUserInfo`, userInfo:`/users/users/userInfo/getUserInfo`,
updateUser:`${host1}/users/users/userInfo/updateUser`, updateUser:`/users/users/userInfo/updateUser`,
findPasswordByEmail:`/users/users/userAccount/findPasswordByEmail`, findPasswordByEmail:`/users/users/userAccount/findPasswordByEmail`,
findPasswordByPhone:`/users/users/userAccount/findPasswordByPhone`, findPasswordByPhone:`/users/users/userAccount/findPasswordByPhone`,
bingEmail:`evaluation/tms/user/bingEmail`, bingEmail:`evaluation/tms/user/bingEmail`,
@ -39,17 +39,18 @@ export default {
// 用户管理 // 用户管理
saveUser: `/users/users/data/user/save`, saveUser: `/users/users/data/user/save`,
getUserList: `/users/users/data/user/getUserList`, getUserList: `/users/users/data/user/getUserList`,
getUserTotalBySchoolId: `${host1}/users/users/data/user/getUserTotalBySchoolId`, getUserTotalBySchoolId: `/users/users/data/user/getUserTotalBySchoolId`,
checkAccount:`/users/users/data/user/checkAccount`, checkAccount:`/users/users/data/user/checkAccount`,
getDetail:`/users/users/data/user/getDetail`, getDetail:`/users/users/data/user/getDetail`,
modifyUser:`/users/users/data/user/modify`, modifyUser:`/users/users/data/user/modify`,
export_failure:`${Setting.apiBaseURL}/users/users/data/user/export_failure`, export_failure:`${Setting.apiBaseURL}/users/users/data/user/export_failure`,
uploadFile:`${Setting.apiBaseURL}/users/users/data/user/uploadFile`, uploadFile:`${Setting.apiBaseURL}/users/users/data/user/uploadFile`,
deleteUser:`${Setting.apiBaseURL}/users/users/data/user/delete`, deleteUser:`/users/users/data/user/delete`,
resetPwd: `${host2}/users/users/userAccount/resetPwd`, resetPwd: `/users/users/userAccount/resetPwd`,
sendPhoneOrEmailCode: `${host2}/users/users/userAccount/sendPhoneOrEmailCode`, sendPhoneOrEmailCode: `/users/users/userAccount/sendPhoneOrEmailCode`,
bindPhoneOrEmail: `${host2}/users/users/userAccount/bindPhoneOrEmail`, bindPhoneOrEmail: `/users/users/userAccount/bindPhoneOrEmail`,
examinePassword: `${host1}/users/users/userAccount/examinePassword`, examinePassword: `/users/users/userAccount/examinePassword`,
userTemplate: `http://39.108.250.202/template/%E6%95%B0%E6%8D%AE%E5%B9%B3%E5%8F%B0%E7%94%A8%E6%88%B7%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx`,
// 角色管理 // 角色管理
batchRemove:`/data/data/role/batchRemove`, batchRemove:`/data/data/role/batchRemove`,
@ -71,20 +72,20 @@ export default {
getIdQueryTable:`/data/data/table/getIdQueryTable`, getIdQueryTable:`/data/data/table/getIdQueryTable`,
getTableByClassification:`/data/data/table/getTableByClassification`, getTableByClassification:`/data/data/table/getTableByClassification`,
getTableByCondition:`/data/data/table/getTableByCondition`, getTableByCondition:`/data/data/table/getTableByCondition`,
downloadData:`${host1}/data/data/download`, downloadData:`${Setting.apiBaseURL}/data/data/download`,
previewData:`${host1}/data/data/preview`, previewData:`/data/data/preview`,
downloadRecord:`${host1}/data/data/myDownload/downloadRecord`, downloadRecord:`/data/data/myDownload/downloadRecord`,
getDownloadRecord:`/data/data/myDownload/getDownloadRecord`, getDownloadRecord:`/data/data/myDownload/getDownloadRecord`,
downloadAgain:`${host1}/data/data/downloadAgain`, downloadAgain:`/data/data/downloadAgain`,
isDownload:`${host1}/data/data/product/isDownload`, isDownload:`/data/data/product/isDownload`,
// 数据操作记录 // 数据操作记录
queryAccumulate:`${host1}/data/data/dataRecord/queryAccumulate`, queryAccumulate:`/data/data/dataRecord/queryAccumulate`,
queryDatabaseInfo:`${host1}/data/data/dataRecord/queryDatabaseInfo`, queryDatabaseInfo:`/data/data/dataRecord/queryDatabaseInfo`,
queryDatabaseInfoByMonth:`${host1}/data/data/dataRecord/queryDatabaseInfoByMonth`, queryDatabaseInfoByMonth:`/data/data/dataRecord/queryDatabaseInfoByMonth`,
saveRecord:`${host1}/data/data/dataRecord/saveRecord`, saveRecord:`/data/data/dataRecord/saveRecord`,
databaseInfoExport:`${host1}/data/data/dataRecord/databaseInfoExport`, databaseInfoExport:`/data/data/dataRecord/databaseInfoExport`,
databaseInfoByMonthExport:`${host1}/data/data/dataRecord/databaseInfoByMonthExport`, databaseInfoByMonthExport:`/data/data/dataRecord/databaseInfoByMonthExport`,
onlineNumber:`${host1}/data/data/dataRecord/onlineNumber`, onlineNumber:`/data/data/dataRecord/onlineNumber`,
getProductInfoBySchoolId:`${host1}/data/data/product/getProductInfoBySchoolId`, getProductInfoBySchoolId:`/data/data/product/getProductInfoBySchoolId`,
} }

@ -7,14 +7,14 @@
<div style="height: 80px;"></div> <div style="height: 80px;"></div>
<navbar ref="nav"></navbar> <navbar ref="nav"></navbar>
<div class="action" v-if="token"> <div class="action" v-if="token">
<img v-if="isManager && showSetting" class="icon" src="../../assets/img/setting.png" alt="" @click="toManager"> <img v-if="isManager && showSetting" class="icon" :class="{'m-r-20': !isCustomer}" src="../../assets/img/setting.png" alt="" @click="toManager">
<el-dropdown class="user-wrap" @command="userCommand"> <el-dropdown class="user-wrap" @command="userCommand">
<div class="user"> <div class="user">
<el-avatar :size="40" :src="avatar"></el-avatar> <el-avatar :size="40" :src="avatar" v-if="!isCustomer"></el-avatar>
<span class="username">{{userName}}</span> <span class="username">{{userName}}</span>
</div> </div>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="person">个人资料</el-dropdown-item> <el-dropdown-item command="person" v-if="!isCustomer">个人资料</el-dropdown-item>
<el-dropdown-item command="logout">退出登录</el-dropdown-item> <el-dropdown-item command="logout">退出登录</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -49,7 +49,7 @@ export default {
components: { navbar }, components: { navbar },
computed: { computed: {
...mapState('user', [ ...mapState('user', [
'avatar','isManager','schoolId' 'avatar','isManager','schoolId','isCustomer'
]), ]),
...mapState('auth', [ ...mapState('auth', [
'routes' 'routes'
@ -64,17 +64,19 @@ export default {
]), ]),
getUserInfo(){ getUserInfo(){
this.$get(this.api.userInfo).then(res => { this.$get(this.api.userInfo).then(res => {
let userInfo = res.userInfo let userInfo = res.userInfo ? res.userInfo : {}
let isManager = userInfo.roleId != '0' let userAccount = res.userAccount
let isManager = userAccount.roleId != '0'
this.isUser = isManager this.isUser = isManager
let mg = this.$route.query.mg let mg = this.$route.query.mg
if(mg && atob(decodeURI(mg)) === 'true'){ if(mg && atob(decodeURI(mg)) === 'true'){
this.showSetting = false this.showSetting = false
} }
this.userName = userInfo.userName this.userName = userAccount.account
this.setInfo({ this.setInfo({
avatar: userInfo.userAvatars, avatar: userInfo.userAvatars,
schoolId: res.userAccount.schoolId, schoolId: userAccount.schoolId,
}) })
this.setManager(isManager) this.setManager(isManager)
}).catch(err => {}) }).catch(err => {})
@ -148,6 +150,9 @@ export default {
.action{ .action{
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
.icon{
cursor: pointer;
}
.user-wrap { .user-wrap {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;

@ -4,28 +4,48 @@
<div class="login"> <div class="login">
<div class="names"> <div class="names">
<img class="logo" src="../../../assets/img/three.png" alt=""> <img class="logo" src="../../../assets/img/three.png" alt="">
<p class="text">或然数据</p> <p class="text">或然数据平台</p>
</div> </div>
<div class="form"> <div class="form">
<div class="title"><span>登录</span></div> <ul class="tab">
<el-form :model="loginForm" :rules="loginRules" ref="login" label-width="0px"> <li v-for="(item,index) in tabList" :key="index" :class="{active: form.distinguish == item.id}" @click="typeClick(item)">{{item.label}}</li>
</ul>
<el-form :model="form" :rules="rules" ref="login" label-width="0px">
<el-form-item prop="account"> <el-form-item prop="account">
<label class="account"></label> <label class="account"></label>
<el-input v-model="loginForm.account" placeholder="请输入账号/手机号" @keyup.enter.native="submitForm"></el-input> <el-input v-model="form.account" :placeholder="form.distinguish == 1 ? '请输入账号' : '请输入手机号/邮箱'" @keyup.enter.native="submitForm"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="password"> <el-form-item prop="password">
<label class="password"></label> <label class="password"></label>
<el-input type="password" placeholder="请输入密码" v-model="loginForm.password" @keyup.enter.native="submitForm"></el-input> <el-input type="password" placeholder="请输入密码" v-model="form.password" @keyup.enter.native="submitForm"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="code"> <el-form-item prop="code">
<label class="code"></label> <label class="code"></label>
<el-input placeholder="请输入验证码" v-model="loginForm.code" @keyup.enter.native="submitForm"></el-input> <el-input placeholder="请输入验证码" v-model="form.code" @keyup.enter.native="submitForm"></el-input>
<img @click="getVerImg" :src="verificationIMG" class="ver-img" alt=""> <img @click="getVerImg" :src="verificationIMG" class="ver-img" alt="">
</el-form-item> </el-form-item>
<el-button class="submit" type="primary" @click="submitForm">登录</el-button> <el-button class="submit" type="primary" @click="submitForm">登录</el-button>
</el-form> </el-form>
</div> </div>
</div> </div>
<el-dialog title="绑定手机号" :visible.sync="phoneVisible" :close-on-click-modal="false" @close="closePhone" width="30%">
<el-form ref="form" label-width="60px">
<el-form-item label="手机号">
<el-input placeholder="请输入手机号" v-model="phone" maxlength="11"></el-input>
</el-form-item>
<el-form-item label="验证码">
<div class="flex">
<el-input v-model="phoneCode" placeholder="请输入验证码" maxlength="6"></el-input>
<el-button style="margin-left: 10px" type="text" @click="sendPhoneCode" :disabled="phoneDisabled">{{phoneBtnText}}</el-button>
</div>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="phoneVisible = false"> </el-button>
<el-button size="small" type="primary" @click="phoneSubmit"> </el-button>
</span>
</el-dialog>
</div> </div>
</template> </template>
@ -33,21 +53,38 @@
import { mapActions } from 'vuex' import { mapActions } from 'vuex'
import vHead from '@/layouts/header' import vHead from '@/layouts/header'
import util from '@/libs/util' import util from '@/libs/util'
import Setting from '@/setting'
export default { export default {
data: function() { data: function() {
return { return {
tabList: [
{
id: '1',
label: '账号登录'
},{
id: '2',
label: '手机号/邮箱登录'
}
],
verificationIMG: '', verificationIMG: '',
loginForm: { form: {
distinguish: '1',
account: 'admin', account: 'admin',
password: '111aaa', password: '111aaa',
random: '', random: '',
code: '' code: ''
}, },
loginRules: { rules: {
account: [{ required: true, message: '请输入用户名', trigger: 'blur' }], account: [{ required: true, 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' }],
}, },
phoneVisible: false,
phone: '',
phoneCode: '',
phoneDisabled: false,
phoneTimer: null,
phoneBtnText: '发送验证码'
}; };
}, },
components: {vHead}, components: {vHead},
@ -56,28 +93,105 @@ export default {
}, },
methods: { methods: {
...mapActions('user', [ ...mapActions('user', [
'login' 'login','setToken'
]), ]),
typeClick(item){
this.form.account = ''
this.form.distinguish = item.id
this.$refs.login.clearValidate()
this.rules.account[0].message = item.id == 1 ? '请输入账号' : '请输入手机号/邮箱'
},
submitForm() { submitForm() {
this.$refs.login.validate(valid => { this.$refs.login.validate(valid => {
if (valid) { if (valid) {
this.login(this.loginForm).then(() => { this.login(this.form).then(() => {
let redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : '/index' let redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : '/index'
this.$router.replace(redirect) this.$router.replace(redirect)
}).catch(res => { }).catch(res => {
if(res && res.status == 30001){
this.phoneVisible = true
}
this.getVerImg() this.getVerImg()
this.loginForm.code = '' this.form.code = ''
}) })
} }
}) })
}, },
getVerImg(){ getVerImg(){
if(!this.loginForm.account){ if(!this.form.account){
return this.verificationIMG = '' return this.verificationIMG = ''
} }
this.loginForm.random = Math.floor(Math.random()*999999999) this.form.random = Math.floor(Math.random()*999999999)
this.verificationIMG = this.api.verification+'?random='+`${this.loginForm.random}` this.verificationIMG = this.api.verification+'?random='+`${this.form.random}`
} },
phoneCountdown(){
let count = 60
if(!this.phoneTimer){
this.phoneDisabled = true
this.phoneTimer = setInterval(() => {
console.log('倒计时中')
if(count > 0){
count--
this.phoneBtnText = `${count}秒后重试`
}else{
this.phoneDisabled = false
clearInterval(this.phoneTimer)
this.phoneTimer = null
this.phoneBtnText = `发送验证码`
}
},1000)
}
},
closePhone(){
if(!this.emailDisabled){
this.emailCode = ''
}
},
sendPhoneCode(){
if(!this.phone) return util.warningMsg('请输入手机号')
if(!/^1[3456789]\d{9}$/.test(this.phone)) return util.warningMsg('请输入正确的手机号')
let data = {
phone: this.phone,
types: 2
}
this.$post(this.api.sendPhoneOrEmailCode,data).then(res => {
if(res.message.opener){
this.phoneCountdown()
this.phoneOpener = res.message.opener
}else{
util.errorMsg(res.message)
}
}).catch(res => {})
},
phoneSubmit(){
if(!this.phone) return util.warningMsg('请输入手机号')
if(!/^1[3456789]\d{9}$/.test(this.phone)) return util.warningMsg('请输入正确的手机号')
if(!this.phoneCode) return util.warningMsg('请输入验证码')
let data = {
phone: this.phone,
types: 2,
code: this.phoneCode,
opener: this.phoneOpener,
platform: Setting.platformId,
account: this.form.account
}
this.$post(this.api.bindPhoneOrEmail,data).then(res => {
util.successMsg('绑定成功')
this.form.phone = this.phone
this.phoneVisible = false
this.setToken(res.token)
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')
}).catch(res => {})
},
}, },
}; };
</script> </script>
@ -106,24 +220,21 @@ export default {
margin-top: 30px; margin-top: 30px;
border-radius: 10px; border-radius: 10px;
background-color: #fff; background-color: #fff;
.title{ .tab{
position: relative; display: flex;
justify-content: center;
align-items: center;
margin-bottom: 30px; margin-bottom: 30px;
text-align: center; border-bottom: 2px solid #e0e0e0;
span{ li{
display: inline-block;
padding: 9px 20px; padding: 9px 20px;
margin-bottom: -1px;
color: #555; color: #555;
border-bottom: 2px solid $main-color; cursor: pointer;
} border-bottom: 2px solid transparent;
&:after{ &.active{
content: ''; border-bottom-color: $main-color;
position: absolute; }
left: 0;
bottom: -1px;
width: 100%;
height: 1px;
background-color: #e0e0e0;
} }
} }
.el-form{ .el-form{

@ -1,6 +1,6 @@
<template> <template>
<div class="wrap" :class="{result: keyword}"> <div class="wrap" :class="{result: keyword}">
<div class="title" v-if="!keyword">欢迎来到<br>或然数据</div> <div class="title" v-if="!keyword">欢迎来到<br>或然数据平台</div>
<div class="search"> <div class="search">
<div class="input"> <div class="input">
<img v-if="keyword" src="../../../assets/img/search-gray.png" alt=""> <img v-if="keyword" src="../../../assets/img/search-gray.png" alt="">

@ -93,20 +93,8 @@ export default {
}).then(res => { }).then(res => {
msgObj.close() msgObj.close()
if(res.data.type != 'multipart/form-data') return util.warningMsg('数据总数为零!') if(res.data.type != 'multipart/form-data') return util.warningMsg('数据总数为零!')
const blob = new Blob([res.data]) util.downloadFileDirect(`${row.databaseName}.xls`,new Blob([res.data]))
const fileName = `${row.databaseName}.xls`
if ('download' in document.createElement('a')) { // IE
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'none'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href) // URL
document.body.removeChild(elink)
} else { // IE10+
navigator.msSaveBlob(blob, fileName)
}
this.$post(`${this.api.saveRecord}?platformUserId=4&tableId=${row.id}&type=1&schoolId=1`).then(res => {}).catch(res => {}) this.$post(`${this.api.saveRecord}?platformUserId=4&tableId=${row.id}&type=1&schoolId=1`).then(res => {}).catch(res => {})
}).catch(res => { }).catch(res => {
msgObj.close() msgObj.close()

@ -133,10 +133,11 @@
import Setting from '@/setting' import Setting from '@/setting'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import util from '@/libs/util' import util from '@/libs/util'
import axios from 'axios'
export default { export default {
data() { data() {
return { return {
token: '', token: util.local.get(Setting.tokenKey),
month: '', month: '',
monthList: [ monthList: [
{ {
@ -163,10 +164,10 @@ export default {
id: '', id: '',
label: '不限' label: '不限'
},{ },{
id: 0, id: 1,
label: '启用' label: '启用'
},{ },{
id: 1, id: 0,
label: '禁用' label: '禁用'
} }
], ],
@ -271,7 +272,6 @@ export default {
} }
}, },
mounted(){ mounted(){
this.token = util.local.get(Setting.tokenKey)
this.form.schoolId = this.schoolId this.form.schoolId = this.schoolId
this.getData() this.getData()
this.getRole() this.getRole()
@ -397,6 +397,7 @@ export default {
if(this.accountRepeat) return util.warningMsg('该账号已存在') if(this.accountRepeat) return util.warningMsg('该账号已存在')
if(this.workNumberRepeat) return util.warningMsg('该工号已存在') if(this.workNumberRepeat) return util.warningMsg('该工号已存在')
let data = this.form let data = this.form
data.schoolId = data.schoolId ? data.schoolId : this.schoolId
if(!data.userId) data.uniqueIdentification = new Date().getTime() if(!data.userId) data.uniqueIdentification = new Date().getTime()
if(!data.roleId) data.roleId = '0' if(!data.roleId) data.roleId = '0'
if(this.form.userId){ if(this.form.userId){
@ -440,7 +441,9 @@ export default {
phone: '' phone: ''
}).then((res) => { }).then((res) => {
val == 1 ? util.successMsg('启用成功') : util.successMsg('禁用成功') val == 1 ? util.successMsg('启用成功') : util.successMsg('禁用成功')
}).catch((res) => {}) }).catch((res) => {
row.isEnable = val == 1 ? 0 : 1
})
}, },
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val this.multipleSelection = val
@ -475,11 +478,18 @@ export default {
this.getData() this.getData()
}, },
downLoad(){ downLoad(){
location.href = this.api.downloadStaffTemp location.href = this.api.userTemplate
}, },
showFaild(){ showFaild(){
this.importVisible = false this.importVisible = false
location.href = `${this.api.export_failure}?token=${this.importToken}` axios.get(`${this.api.export_failure}?token=${this.importToken}`,{
headers: {
token: this.token
},
responseType: 'blob'
}).then((res) => {
util.downloadFileDirect(`导入失败原因.xlsx`,new Blob([res.data]))
}).catch(res => {})
}, },
handleExceed(files, fileList) { handleExceed(files, fileList) {
util.warningMsg( util.warningMsg(

@ -36,6 +36,8 @@ service.interceptors.response.use(
const res = response.data const res = response.data
if(res.status == 200) { if(res.status == 200) {
return Promise.resolve(res).catch(e => {}) return Promise.resolve(res).catch(e => {})
}else if(res.status == 30001) {
return Promise.resolve(res).catch(e => {})
}else if(!res.status){ }else if(!res.status){
return Promise.resolve(res).catch(e => {}) return Promise.resolve(res).catch(e => {})
}else { }else {

@ -8,7 +8,7 @@ router.beforeEach((to, from, next) => {
document.title = Setting.titleSuffix document.title = Setting.titleSuffix
const role = util.local.get(Setting.tokenKey) const role = util.local.get(Setting.tokenKey)
if (!role && to.path !== '/login' && to.path !== '/index/list') { if (!role && to.path !== '/login' && to.path !== '/index/list') {
next('/login') next('/index/list')
} else if(role && to.path == '/login') { } else if(role && to.path == '/login') {
next('/index') next('/index')
} else { } else {

@ -10,7 +10,7 @@ import BasicLayout from '@/layouts/home'
const frameIn = [ const frameIn = [
{ {
path: '/', path: '/',
redirect: '/login', redirect: '/index/list',
}, },
{ {
path: '/', path: '/',

@ -15,8 +15,8 @@ const Setting = {
// 页面切换时,是否显示模拟的进度条 // 页面切换时,是否显示模拟的进度条
showProgressBar: true, showProgressBar: true,
// 接口请求地址 // 接口请求地址
// apiBaseURL: env === 'development' ? 'http://192.168.31.125:8888' : 'http://39.108.250.202:8000', // apiBaseURL: env === 'development' ? 'http://192.168.31.216:9000' : 'http://39.108.250.202:9000',
apiBaseURL: env === 'development' ? 'http://192.168.31.216:9000' : 'http://www.liuwanr.cn', apiBaseURL: env === 'development' ? 'http://192.168.31.216:9000' : 'http://39.108.250.202:9000',
// 接口请求返回错误时,弹窗的持续时间,单位:秒 // 接口请求返回错误时,弹窗的持续时间,单位:秒
modalDuration: 3, modalDuration: 3,
// 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice // 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice

@ -12,7 +12,8 @@ export default {
state: { state: {
avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png', avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
schoolId: '', schoolId: '',
isManager: false isManager: false,
isCustomer: false
}, },
mutations: { mutations: {
SET_INFO: (state, info) => { SET_INFO: (state, info) => {
@ -25,10 +26,13 @@ export default {
SET_MANAGER: (state, isManager) => { SET_MANAGER: (state, isManager) => {
state.isManager = isManager state.isManager = isManager
}, },
SET_CUSTOMER: (state, isCustomer) => {
state.isCustomer = isCustomer
},
}, },
actions: { actions: {
login({ state,commit }, userInfo) { login({ state,commit }, userInfo) {
const { account, password, code, random } = userInfo const { account, password, code, random, distinguish } = userInfo
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
post(api.logins,{ post(api.logins,{
account, account,
@ -36,16 +40,17 @@ export default {
code, code,
platform: Setting.platformId, platform: Setting.platformId,
random, random,
distinguish
}).then(res => { }).then(res => {
setTimeout(() => {
post(api.saveRecord,{
type: 3,
}).then(res => {}).catch(res => {})
},3000)
if(res.status == 200){ if(res.status == 200){
util.local.set(Setting.tokenKey,res.data.token,1296000000) commit('SET_CUSTOMER',res.data.customer)
util.local.set(Setting.tokenKey,res.data.token,43200000)
util.successMsg('登录成功') util.successMsg('登录成功')
setTimeout(() => {
post(api.saveRecord,{
type: 3,
}).then(res => {}).catch(res => {})
},3000)
resolve() resolve()
}else{ }else{
util.errorMsg(res.message) util.errorMsg(res.message)
@ -73,5 +78,8 @@ export default {
setManager({ state,commit },isManager) { setManager({ state,commit },isManager) {
commit('SET_MANAGER',isManager) commit('SET_MANAGER',isManager)
}, },
setToken({ state,commit },token) {
commit('SET_CUSTOMER',token)
},
} }
} }
Loading…
Cancel
Save