Compare commits

...

2 Commits

Author SHA1 Message Date
yujialong 7f18b99801 fix 4 months ago
yujialong 3bf5c1b98a fix 9 months ago
  1. 83
      src/layouts/footer/index.vue
  2. 593
      src/pages/account/login/index.vue
  3. 2254
      src/pages/screen/list/index.vue
  4. 306
      src/plugins/requests/index.js
  5. 4
      src/setting.js
  6. 3
      vue.config.js

@ -6,58 +6,59 @@
* @Description: In User Settings Edit * @Description: In User Settings Edit
--> -->
<template> <template>
<div class="footer"> <div class="footer">
<div class="info"> <div class="info">
<!-- <span class="m-r-20">客服邮箱service@huorantech.cn</span> --> <!-- <span class="m-r-20">客服邮箱service@huorantech.cn</span> -->
<span>联系人郭经理 17671782660</span> <span>联系人金经理 15218726836</span>
</div>
<div class="copyright">
<span>© Copyright 2021 Dataforward 数据前瞻</span>
<a href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank">粤ICP备20072679号</a>
</div>
</div> </div>
<div class="copyright">
<span>© Copyright 2021 Dataforward 数据前瞻</span>
<a href="https://beian.miit.gov.cn/#/Integrated/index"
target="_blank">粤ICP备20072679号</a>
</div>
</div>
</template> </template>
<script> <script>
export default { export default {
data() { data () {
return { return {
}; };
}, },
mounted(){ mounted () {
}, },
methods: { methods: {
}, },
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.footer{ .footer {
padding: 17px 0 9px; padding: 17px 0 9px;
text-align: center;
background-color: #0f1d2e;
.info {
margin-bottom: 7px;
font-size: 14px;
line-height: 20px;
color: #d7dfe7;
}
.copyright {
font-size: 12px;
text-align: center; text-align: center;
background-color: #0F1D2E; line-height: 17px;
.info{ span {
margin-bottom: 7px; margin-right: 20px;
font-size: 14px; color: #757f8a;
line-height: 20px;
color: #D7DFE7;
} }
.copyright{ a {
color: #757f8a;
font-size: 12px; font-size: 12px;
text-align: center; &:hover {
line-height: 17px; color: #c7c7c7;
span{
margin-right: 20px;
color: #757F8A;
}
a{
color:#757F8A;
font-size: 12px;
&:hover{
color: #c7c7c7;
}
} }
} }
} }
}
</style> </style>

@ -4,63 +4,42 @@
<div class="form"> <div class="form">
<h6 class="title">欢迎使用请登录</h6> <h6 class="title">欢迎使用请登录</h6>
<ul class="tab"> <ul class="tab">
<li v-for="(item,index) in tabList" <li v-for="(item, index) in tabList" :key="index" :class="{ active: form.distinguish == item.id }"
:key="index" @click="typeClick(item)">{{ item.label }}</li>
:class="{active: form.distinguish == item.id}"
@click="typeClick(item)">{{item.label}}</li>
</ul> </ul>
<el-form :model="form" <el-form :model="form" :rules="rules" ref="form" style="margin-top: 20px">
:rules="rules"
ref="form"
style="margin-top: 20px">
<!-- 学号工号 --> <!-- 学号工号 -->
<div v-show="!form.distinguish"> <div v-show="!form.distinguish">
<el-form-item class="school-select" <el-form-item class="school-select" prop="schoolId">
prop="schoolId">
<label class="label school"></label> <label class="label school"></label>
<el-select v-model="form.schoolId" <el-select v-model="form.schoolId" clearable filterable placeholder="请选择学校">
clearable <el-option v-for="(item, i) in schoolList" :key="i" :label="item.schoolName"
filterable :value="item.schoolId"></el-option>
placeholder="请选择学校">
<el-option v-for="(item, i) in schoolList"
:key="i"
:label="item.schoolName"
:value="item.schoolId"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item class="flex-1" <el-form-item class="flex-1" prop="workNumber">
prop="workNumber">
<label class="label account"></label> <label class="label account"></label>
<el-input v-model.trim="form.workNumber" <el-input v-model.trim="form.workNumber" :placeholder="'请输入学号/工号'"
:placeholder="'请输入学号/工号'" @keyup.enter.native="submit"></el-input>
@keyup.enter.native="submit"></el-input>
</el-form-item> </el-form-item>
</div> </div>
<!-- 手机号登录 --> <!-- 手机号登录 -->
<el-form-item v-show="form.distinguish === 1" <el-form-item v-show="form.distinguish === 1" prop="account">
prop="account">
<label class="label account"></label> <label class="label account"></label>
<el-input v-model.trim="form.account" <el-input v-model.trim="form.account" placeholder="请输入账号" @keyup.enter.native="submit"></el-input>
placeholder="请输入账号"
@keyup.enter.native="submit"></el-input>
</el-form-item> </el-form-item>
<template v-if="form.distinguish === 2"> <template v-if="form.distinguish === 2">
<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" <el-input v-model.trim="form.account" placeholder="请输入手机号/邮箱" @keyup.enter.native="submit"></el-input>
placeholder="请输入手机号/邮箱"
@keyup.enter.native="submit"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="code"> <el-form-item prop="code">
<label class="label code"></label> <label class="label code"></label>
<div class="ver-code"> <div class="ver-code">
<el-input v-model="form.code" <el-input v-model="form.code" placeholder="请输入验证码" maxlength="6"
placeholder="请输入验证码" @keyup.enter.native="submit"></el-input>
maxlength="6" <el-button type="text" @click="sendPhoneCodeLogin" :disabled="phoneDisabledLogin">{{ phoneBtnTextLogin
@keyup.enter.native="submit"></el-input> }}
<el-button type="text"
@click="sendPhoneCodeLogin"
:disabled="phoneDisabledLogin">{{ phoneBtnTextLogin }}
</el-button> </el-button>
</div> </div>
</el-form-item> </el-form-item>
@ -68,89 +47,55 @@
<template v-if="form.distinguish !== 2"> <template v-if="form.distinguish !== 2">
<el-form-item prop="password"> <el-form-item prop="password">
<label class="password label"></label> <label class="password label"></label>
<el-input type="password" <el-input type="password" placeholder="请输入密码" v-model.trim="form.password" @keyup.enter.native="submit">
placeholder="请输入密码"
v-model.trim="form.password"
@keyup.enter.native="submit">
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item prop="code"> <el-form-item prop="code">
<label class="label code"></label> <label class="label code"></label>
<el-input placeholder="请输入验证码" <el-input placeholder="请输入验证码" v-model.trim="form.code" @keyup.enter.native="submit">
v-model.trim="form.code"
@keyup.enter.native="submit">
</el-input> </el-input>
<img @click="getVerImg" <img @click="getVerImg" :src="verificationIMG" class="ver-img" alt="">
:src="verificationIMG"
class="ver-img"
alt="">
</el-form-item> </el-form-item>
</template> </template>
<div v-show="!form.distinguish" <div v-show="!form.distinguish" class="default-check">
class="default-check">
<el-checkbox v-model="setDefault">设置为默认学校</el-checkbox> <el-checkbox v-model="setDefault">设置为默认学校</el-checkbox>
</div> </div>
<el-button class="submit" <el-button class="submit" type="primary" @click="submit">登录</el-button>
type="primary"
@click="submit">登录</el-button>
</el-form> </el-form>
</div> </div>
</div> </div>
<el-dialog title="绑定手机号" <el-dialog title="绑定手机号" :visible.sync="phoneVisible" :close-on-click-modal="false" width="576px">
:visible.sync="phoneVisible"
:close-on-click-modal="false"
width="576px">
<p class="tips">依据国家政策法规需绑定手机号进行网络实名才可登录使用本平台</p> <p class="tips">依据国家政策法规需绑定手机号进行网络实名才可登录使用本平台</p>
<el-form label-width="60px"> <el-form label-width="60px">
<el-form-item label="手机号"> <el-form-item label="手机号">
<el-input placeholder="请输入手机号" <el-input placeholder="请输入手机号" v-model="phone" maxlength="11" @change="phoneChange"></el-input>
v-model="phone"
maxlength="11"
@change="phoneChange"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="验证码"> <el-form-item label="验证码">
<div class="ver-code"> <div class="ver-code">
<el-input v-model="phoneCode" <el-input v-model="phoneCode" placeholder="请输入验证码" maxlength="6"></el-input>
placeholder="请输入验证码" <el-button style="top: 1px" type="text" @click="sendPhoneCode(1)"
maxlength="6"></el-input> :disabled="binding === '' || phoneDisabled">{{ phoneBtnText }}</el-button>
<el-button style="top: 1px"
type="text"
@click="sendPhoneCode(1)"
:disabled="binding === '' || phoneDisabled">{{phoneBtnText}}</el-button>
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" <span slot="footer" class="dialog-footer">
class="dialog-footer"> <el-button size="small" @click="phoneVisible = false"> </el-button>
<el-button size="small" <el-button size="small" type="primary" @click="phoneSubmit"> </el-button>
@click="phoneVisible = false"> </el-button>
<el-button size="small"
type="primary"
@click="phoneSubmit"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
<el-dialog title="请选择您要登录的用户" <el-dialog title="请选择您要登录的用户" :visible.sync="userVisible" :close-on-click-modal="false" custom-class="user-dia"
:visible.sync="userVisible" width="500px">
:close-on-click-modal="false"
custom-class="user-dia"
width="500px">
<p class="tips">该手机号已绑定以下用户信息</p> <p class="tips">该手机号已绑定以下用户信息</p>
<ul class="users"> <ul class="users">
<li :class="{isEnable: !user.isEnable}" <li :class="{ isEnable: !user.isEnable }" v-for="(user, i) in users" :key="i" @click="chooseUser(user)">
v-for="(user, i) in users" <span>{{ user.schoolName }}{{ user.userName }}{{ user.workNumber }}{{ user.isEnable ? '' : '(已禁用)' }}</span>
:key="i"
@click="chooseUser(user)">
<span>{{ user.schoolName }}{{ user.userName }}{{ user.workNumber }}{{ user.isEnable ? '' : '(已禁用)'}}</span>
<i class="el-icon-right"></i> <i class="el-icon-right"></i>
</li> </li>
</ul> </ul>
</el-dialog> </el-dialog>
<el-dialog :visible.sync="infoVisible" <el-dialog :visible.sync="infoVisible" :close-on-click-modal="false" :show-close="false" custom-class="info-dia"
:close-on-click-modal="false" width="400px">
:show-close="false"
custom-class="info-dia"
width="400px">
<div class="info-header"> <div class="info-header">
<i class="el-icon-warning"></i> <i class="el-icon-warning"></i>
提示 提示
@ -158,26 +103,20 @@
<div class="info-wrap"> <div class="info-wrap">
<p class="tips">该手机号已与以下用户绑定</p> <p class="tips">该手机号已与以下用户绑定</p>
<ul class="users"> <ul class="users">
<li v-for="(user, i) in infos" <li v-for="(user, i) in infos" :key="i">
:key="i">
<span>{{ user.userName }}{{ user.schoolName }}</span> <span>{{ user.userName }}{{ user.schoolName }}</span>
</li> </li>
</ul> </ul>
<div class="info-footer"> <div class="info-footer">
<el-button size="small" <el-button size="small" type="primary" @click="bindPhone">是本人继续绑定</el-button>
type="primary" <el-button class="unbind" size="small" @click="unbindPhone">不是本人解绑以上用户并绑定新用户</el-button>
@click="bindPhone">是本人继续绑定</el-button>
<el-button class="unbind"
size="small"
@click="unbindPhone">不是本人解绑以上用户并绑定新用户</el-button>
</div> </div>
</div> </div>
</el-dialog> </el-dialog>
<div class="footer"> <div class="footer">
<div class="copyright"> <div class="copyright">
<a href="https://beian.miit.gov.cn/#/Integrated/index" <a href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank">粤ICP备20072679号</a>
target="_blank">粤ICP备20072679号</a>
</div> </div>
</div> </div>
</div> </div>
@ -537,230 +476,272 @@ export default {
<style scoped lang="scss"> <style scoped lang="scss">
.wrap { .wrap {
min-height: 100%; min-height: 100%;
background-color: #f3f6fa; background-color: #f3f6fa;
} }
.ver-code { .ver-code {
position: relative; position: relative;
.el-button {
position: absolute; .el-button {
top: 10px; position: absolute;
right: 10px; top: 10px;
} right: 10px;
}
} }
.login { .login {
min-height: calc(100vh - 70px); min-height: calc(100vh - 70px);
padding-top: calc((100vh - 611px) / 2); padding-top: calc((100vh - 611px) / 2);
background: url(../../../assets/img/shapes/shape1.png) (0 123px) / auto no-repeat, background: url(../../../assets/img/shapes/shape1.png) (0 123px) / auto no-repeat,
url(../../../assets/img/shapes/shape2.png) (35px 238px) / auto no-repeat, url(../../../assets/img/shapes/shape2.png) (35px 238px) / auto no-repeat,
url(../../../assets/img/shapes/shape3.png) (0 485px) / auto no-repeat, url(../../../assets/img/shapes/shape3.png) (0 485px) / auto no-repeat,
url(../../../assets/img/shapes/shape4.png) (right 50%) / auto no-repeat, url(../../../assets/img/shapes/shape4.png) (right 50%) / auto no-repeat,
url(../../../assets/img/shapes/shape5.png) (right 80%) / auto no-repeat, url(../../../assets/img/shapes/shape5.png) (right 80%) / auto no-repeat,
url(../../../assets/img/shapes/shape6.png) (right bottom) / auto no-repeat; url(../../../assets/img/shapes/shape6.png) (right bottom) / auto no-repeat;
.tab {
display: flex; .tab {
justify-content: space-between; display: flex;
align-items: center; justify-content: space-between;
margin-bottom: 24px; align-items: center;
border-bottom: 2px solid #e1e6f2; margin-bottom: 24px;
li { border-bottom: 2px solid #e1e6f2;
padding: 18px 0;
margin-bottom: -1px; li {
font-size: 16px; padding: 18px 0;
color: #555; margin-bottom: -1px;
cursor: pointer; font-size: 16px;
border-bottom: 4px solid transparent; color: #555;
&:last-child { cursor: pointer;
margin-right: 0; border-bottom: 4px solid transparent;
}
&.active { &:last-child {
color: $main-color; margin-right: 0;
border-bottom-color: $main-color; }
}
} &.active {
} color: $main-color;
.items { border-bottom-color: $main-color;
display: flex; }
align-items: center;
}
.form {
width: 436px;
padding: 38px 38px 60px;
margin: 0 auto 0;
border-radius: 6px;
background-color: #fff;
.title {
margin-bottom: 25px;
font-size: 26px;
color: #0b1d30;
letter-spacing: 4px;
}
}
/deep/.el-form-item {
margin-bottom: 20px;
}
/deep/.el-input__inner {
position: relative;
height: 52px;
padding: 0 20px 0 34px;
line-height: 50px;
background-color: #fbfbfb;
border: 1px solid #e1e6f2;
border-radius: 4px !important;
}
.default-check {
text-align: right;
}
.el-select {
width: 100%;
}
.label {
z-index: 1;
position: absolute;
top: 17px;
left: 11px;
width: 18px;
height: 18px;
background: url(../../../assets/img/login/account.png) 0 0/100% 100% no-repeat;
}
.school {
background-image: url(../../../assets/img/login/school.png);
}
.workNumber {
width: 17px;
background-image: url(../../../assets/img/login/workNumber.png);
}
.password {
top: 18px;
background-image: url(../../../assets/img/login/password.png);
}
.code {
top: 18px;
background-image: url(../../../assets/img/login/code.png);
}
.ver-img {
position: absolute;
top: 1px;
right: 1px;
}
/deep/.el-form-item__error {
top: 105%;
left: auto;
right: 0;
color: #ffa94e;
} }
.submit { }
width: 100%;
height: 48px; .items {
margin-top: 30px; display: flex;
line-height: 48px; align-items: center;
padding: 0; }
font-size: 20px;
background-color: $main-color; .form {
border-radius: 4px; width: 436px;
border: 0; padding: 38px 38px 60px;
margin: 0 auto 0;
border-radius: 6px;
background-color: #fff;
.title {
margin-bottom: 25px;
font-size: 26px;
color: #0b1d30;
letter-spacing: 4px;
} }
}
/deep/.el-form-item {
margin-bottom: 20px;
}
/deep/.el-input__inner {
position: relative;
height: 52px;
padding: 0 20px 0 34px;
line-height: 50px;
background-color: #fbfbfb;
border: 1px solid #e1e6f2;
border-radius: 4px !important;
}
.default-check {
text-align: right;
}
.el-select {
width: 100%;
}
.label {
z-index: 1;
position: absolute;
top: 17px;
left: 11px;
width: 18px;
height: 18px;
background: url(../../../assets/img/login/account.png) 0 0/100% 100% no-repeat;
}
.school {
background-image: url(../../../assets/img/login/school.png);
}
.workNumber {
width: 17px;
background-image: url(../../../assets/img/login/workNumber.png);
}
.password {
top: 18px;
background-image: url(../../../assets/img/login/password.png);
}
.code {
top: 18px;
background-image: url(../../../assets/img/login/code.png);
}
.ver-img {
position: absolute;
top: 1px;
right: 1px;
}
/deep/.el-form-item__error {
top: 105%;
left: auto;
right: 0;
color: #ffa94e;
}
.submit {
width: 100%;
height: 48px;
margin-top: 30px;
line-height: 48px;
padding: 0;
font-size: 20px;
background-color: $main-color;
border-radius: 4px;
border: 0;
}
} }
.copyright { .copyright {
padding: 18px 0; padding: 18px 0;
font-size: 12px;
text-align: center;
background-color: #f3f6fa;
a {
color: #b1b4b8;
font-size: 12px; font-size: 12px;
text-align: center;
background-color: #f3f6fa; &:hover {
a { opacity: 0.8;
color: #b1b4b8;
font-size: 12px;
&:hover {
opacity: 0.8;
}
} }
}
} }
.tips { .tips {
margin: 0 0 10px 5px; margin: 0 0 10px 5px;
font-size: 14px; font-size: 14px;
text-align: center; text-align: center;
color: #666; color: #666;
} }
/deep/.user-dia { /deep/.user-dia {
.tips { .tips {
margin-bottom: 20px; margin-bottom: 20px;
text-align: center; text-align: center;
color: #666; color: #666;
} }
.users {
li { .users {
display: flex; li {
justify-content: space-between; display: flex;
align-items: center; justify-content: space-between;
padding: 0 15px; align-items: center;
margin-bottom: 10px; padding: 0 15px;
line-height: 40px; margin-bottom: 10px;
font-size: 14px; line-height: 40px;
background-color: #ebeef5; font-size: 14px;
cursor: pointer; background-color: #ebeef5;
&.isEnable { cursor: pointer;
color: #c0c4cc;
background-color: #f5f7fa; &.isEnable {
cursor: not-allowed; color: #c0c4cc;
} background-color: #f5f7fa;
&:last-child { cursor: not-allowed;
margin-bottom: 0; }
}
&:hover { &:last-child {
background-color: #d3e0ff; margin-bottom: 0;
} }
i {
font-size: 16px; &:hover {
} background-color: #d3e0ff;
} }
i {
font-size: 16px;
}
} }
}
} }
/deep/.info-dia { /deep/.info-dia {
.el-dialog__header { .el-dialog__header {
border-bottom: 0; border-bottom: 0;
} }
.info-header {
position: absolute; .info-header {
top: 20px; position: absolute;
display: flex; top: 20px;
align-items: center; display: flex;
font-size: 16px; align-items: center;
color: #333; font-size: 16px;
} color: #333;
.el-icon-warning { }
margin-right: 10px;
color: #e6a23c; .el-icon-warning {
font-size: 24px; margin-right: 10px;
} color: #e6a23c;
.info-wrap { font-size: 24px;
padding: 10px 33px; }
}
.users { .info-wrap {
max-height: 125px; padding: 10px 33px;
margin-top: 20px; }
overflow: auto;
li { .users {
margin: 5px; max-height: 125px;
font-size: 14px; margin-top: 20px;
color: #333; overflow: auto;
}
} li {
.info-footer { margin: 5px;
display: flex; font-size: 14px;
justify-content: space-between; color: #333;
// align-items: center;
margin-top: 20px;
}
.el-button {
width: 142px;
}
.unbind {
white-space: normal;
line-height: 1.6;
} }
}
.info-footer {
display: flex;
justify-content: space-between;
// align-items: center;
margin-top: 20px;
}
.el-button {
width: 142px;
}
.unbind {
white-space: normal;
line-height: 1.6;
}
} }
@media (max-height: 680px) { @media (max-height: 680px) {
.wrap .login { .wrap .login {
padding: 40px 0; padding: 40px 0;
} }
} }
</style> </style>

File diff suppressed because it is too large Load Diff

@ -1,5 +1,5 @@
import axios from 'axios' import axios from 'axios'
import util from '@/libs/util' import Util from '@/libs/util'
import router from '@/router/index' import router from '@/router/index'
import Setting from '@/setting' import Setting from '@/setting'
import store from '@/store' import store from '@/store'
@ -8,8 +8,8 @@ import { Message } from 'element-ui'
const baseURL = Setting.apiBaseURL const baseURL = Setting.apiBaseURL
const service = axios.create({ const service = axios.create({
baseURL, baseURL,
timeout: 10000000 timeout: 10000000
}) })
// post请求头 // post请求头
service.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8' service.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
@ -18,168 +18,182 @@ let check = true
let checkTimer = null let checkTimer = null
// 检测账号是否被禁用,如果禁用则提示并退出登录 // 检测账号是否被禁用,如果禁用则提示并退出登录
function checkDisabled () { function checkDisabled () {
const token = util.local.get(Setting.tokenKey) const token = Util.local.get(Setting.tokenKey)
if (!token) return false if (!token) return false
check = false check = false
axios.get(baseURL + api.accountIsDisabled + '?token=' + token, { axios.get(baseURL + api.accountIsDisabled + '?token=' + token, {
token: util.local.get(Setting.tokenKey), token: Util.local.get(Setting.tokenKey),
headers: { headers: {
token token
} }
}).then(res => { }).then(res => {
if (res.data) { if (res.data) {
util.errorMsg('账号被禁用,已强制退出,有疑问请联系管理员') Util.errorMsg('账号被禁用,已强制退出,有疑问请联系管理员')
setTimeout(() => { setTimeout(() => {
store.dispatch('user/logout') store.dispatch('user/logout')
}, 1500) }, 1500)
} }
}).catch(res => {}) }).catch(res => { })
} }
// 请求拦截器 // 请求拦截器
service.interceptors.request.use(config => { service.interceptors.request.use(config => {
let token = util.local.get(Setting.tokenKey) let token = Util.local.get(Setting.tokenKey)
if(token) config.headers.token = token if (token) config.headers.token = token
let storeSchoolId = store.state.user.schoolId let storeSchoolId = store.state.user.schoolId
let routeSchoolId = router.app._route.query.schoolId let routeSchoolId = router.app._route.query.schoolId
if(routeSchoolId) routeSchoolId = atob(decodeURI(routeSchoolId)) if (routeSchoolId) routeSchoolId = atob(decodeURI(routeSchoolId))
// 如果store里没有schoolId,则取url里的schoolId,从用户跳转到后台的时候因为加载顺序的问题会出现这个情况,所以要做这个处理 // 如果store里没有schoolId,则取url里的schoolId,从用户跳转到后台的时候因为加载顺序的问题会出现这个情况,所以要做这个处理
if(storeSchoolId || routeSchoolId) config.headers.schoolId = storeSchoolId ? storeSchoolId : routeSchoolId if (storeSchoolId || routeSchoolId) config.headers.schoolId = storeSchoolId ? storeSchoolId : routeSchoolId
clearTimeout(checkTimer) clearTimeout(checkTimer)
check && checkDisabled() check && checkDisabled()
checkTimer = setTimeout(() => { checkTimer = setTimeout(() => {
check = true check = true
}, 2000) }, 2000)
return config return config
},err => { }, err => {
util.errorMsg({ Util.errorMsg({
message: '退出登陆', message: '退出登陆',
onClose: function () { onClose: function () {
router.push({name: '/login'}) router.push({ name: '/login' })
} }
}) })
return Promise.reject(err) return Promise.reject(err)
}) })
// 响应拦截器 // 响应拦截器
service.interceptors.response.use( service.interceptors.response.use(
response => { response => {
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) { } else if (res.code === 401) {
return Promise.resolve(res).catch(e => {}) // 账号互踢
}else if(!res.status){ if (!logouted) {
return Promise.resolve(res).catch(e => {}) Util.local.remove(Setting.storeKey)
} else if (res.status === 10008) { Util.local.remove(Setting.tokenKey)
Message.error({ Util.errorMsg(res.msg.includes('顶') ? '您的账号已在其他设备登录,您已被迫下线!' : '登录过期,请重新登录!')
message: res.message, setTimeout(() => {
showClose: true, router.replace({
duration: 1500 path: '/login'
}) })
return Promise.reject(res) logouted = 0
}else { }, 1500)
util.errorMsg(res.message) logouted = 1
res.message === '该账号无权限!' && setTimeout(() => { }
store.dispatch('user/logout') } else if (res.status == 30001) {
}, 1500) return Promise.resolve(res).catch(e => { })
return Promise.reject(res) } else if (!res.status) {
} return Promise.resolve(res).catch(e => { })
}, } else if (res.status === 10008) {
// 服务器状态码不是200的情况 Message.error({
error => { message: res.message,
if (error.response.status) { showClose: true,
switch (error.response.status) { duration: 1500
// 401: 未登录 })
// 未登录则跳转登录页面,并携带当前页面的路径 return Promise.reject(res)
// 在登录成功后返回当前页面,这一步需要在登录页操作。 } else {
case 401: Util.errorMsg(res.message)
util.local.remove(Setting.storeKey) res.message === '该账号无权限!' && setTimeout(() => {
util.local.remove(Setting.tokenKey) store.dispatch('user/logout')
util.errorMsg('登录过期,请重新登录') }, 1500)
setTimeout(() => { return Promise.reject(res)
router.replace({ }
path: '/login' },
}) // 服务器状态码不是200的情况
}, 1000) error => {
break if (error.response.status) {
case 500: switch (error.response.status) {
util.errorMsg('网络错误') // 401: 未登录
break // 未登录则跳转登录页面,并携带当前页面的路径
// 403 token过期 // 在登录成功后返回当前页面,这一步需要在登录页操作。
// 登录过期对用户进行提示 case 401:
// 清除本地token和清空vuex中token对象 Util.local.remove(Setting.storeKey)
// 跳转登录页面 Util.local.remove(Setting.tokenKey)
case 403: Util.errorMsg('登录过期,请重新登录')
util.local.remove(Setting.storeKey) setTimeout(() => {
util.local.remove(Setting.tokenKey) router.replace({
util.errorMsg('登录过期,请重新登录') path: '/login'
// 清除token })
// store.commit('loginSuccess', null); }, 1000)
// 跳转登录页面,并将要浏览的页面fullPath传过去,登录成功后跳转需要访问的页面 break
setTimeout(() => { case 500:
router.replace({ Util.errorMsg('网络错误')
path: '/login', break
// query: { // 403 token过期
// redirect: router.currentRoute.fullPath // 登录过期对用户进行提示
// } // 清除本地token和清空vuex中token对象
}) // 跳转登录页面
}, 1000) case 403:
break Util.local.remove(Setting.storeKey)
// 404请求不存在 Util.local.remove(Setting.tokenKey)
case 404: Util.errorMsg('登录过期,请重新登录')
util.errorMsg('网络请求不存在!') // 清除token
break // store.commit('loginSuccess', null);
// 其他错误,直接抛出错误提示 // 跳转登录页面,并将要浏览的页面fullPath传过去,登录成功后跳转需要访问的页面
default: setTimeout(() => {
util.errorMsg(error.response.data.message) router.replace({
Promise.reject(res) path: '/login',
} // query: {
return Promise.reject(error.response) // redirect: router.currentRoute.fullPath
} // }
})
}, 1000)
break
// 404请求不存在
case 404:
Util.errorMsg('网络请求不存在!')
break
// 其他错误,直接抛出错误提示
default:
Util.errorMsg(error.response.data.message)
Promise.reject(res)
}
return Promise.reject(error.response)
} }
}
); );
function get(url, params){ function get (url, params) {
return new Promise((resolve, reject) =>{ return new Promise((resolve, reject) => {
service.get(url, {params: params}).then(res => { service.get(url, { params: params }).then(res => {
resolve(res) resolve(res)
}).catch(err => { }).catch(err => {
reject(err) reject(err)
})
}) })
})
} }
function post(url, params){ function post (url, params) {
return new Promise((resolve, reject) =>{ return new Promise((resolve, reject) => {
service.post(url,params).then(res => { service.post(url, params).then(res => {
resolve(res) resolve(res)
}).catch(err => { }).catch(err => {
reject(err.data) reject(err.data)
})
}) })
})
} }
function del(url, params){ function del (url, params) {
return new Promise((resolve, reject) =>{ return new Promise((resolve, reject) => {
service.delete(url, { service.delete(url, {
params params
}).then(res => { }).then(res => {
resolve(res) resolve(res)
}).catch(err => { }).catch(err => {
reject(err.data) reject(err.data)
})
}) })
})
} }
function put(url, params){ function put (url, params) {
return new Promise((resolve, reject) =>{ return new Promise((resolve, reject) => {
service.put(url, { service.put(url, {
params params
}).then(res => { }).then(res => {
resolve(res) resolve(res)
}).catch(err => { }).catch(err => {
reject(err.data) reject(err.data)
})
}) })
})
} }
export { get,post,del,put } export { get, post, del, put }

@ -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 = 'http://121.37.12.51/' host = 'https://www.dataforward.cn/'
// host = 'http://192.168.31.51:9000/' // host = 'http://192.168.31.217:9000/'
} }
const Setting = { const Setting = {

@ -14,5 +14,6 @@ module.exports = {
  assetsDir: Setting.assetsDir,   assetsDir: Setting.assetsDir,
devServer: { devServer: {
port: 8092 port: 8092
} },
productionSourceMap: false,
} }
Loading…
Cancel
Save