From 4a172c489083ced0bbfa9d433bcc79278e2a40ba Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Fri, 4 Jun 2021 16:23:02 +0800 Subject: [PATCH] fix --- src/App.vue | 10 +- src/api/index.js | 5 +- src/assets/img/remove-gray.png | Bin 0 -> 521 bytes src/assets/img/search-gray.png | Bin 0 -> 629 bytes src/layouts/header/index.vue | 17 +- src/libs/util.db.js | 3 +- src/pages/account/login/index.vue | 8 +- src/pages/index/list/index.vue | 165 ++++++++++---- src/pages/setting/person/download.vue | 7 +- src/pages/setting/person/info.vue | 204 +++++++++++++++--- src/plugins/auth/index.js | 2 +- src/plugins/requests/index.js | 2 +- src/router/modules/wrongBook.js | 28 --- src/router/permission.js | 2 +- src/setting.js | 9 +- src/store/modules/{achievement.js => data.js} | 0 src/store/modules/exam.js | 97 --------- src/store/modules/{client.js => role.js} | 0 src/store/modules/{practice.js => stat.js} | 0 src/store/modules/user.js | 35 +-- src/store/modules/wrongBook.js | 24 --- src/styles/layout/index.scss | 2 +- 22 files changed, 359 insertions(+), 261 deletions(-) create mode 100644 src/assets/img/remove-gray.png create mode 100644 src/assets/img/search-gray.png delete mode 100644 src/router/modules/wrongBook.js rename src/store/modules/{achievement.js => data.js} (100%) delete mode 100644 src/store/modules/exam.js rename src/store/modules/{client.js => role.js} (100%) rename src/store/modules/{practice.js => stat.js} (100%) delete mode 100644 src/store/modules/wrongBook.js diff --git a/src/App.vue b/src/App.vue index ebbd6b0..7295af1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,14 +10,14 @@ export default { name: 'App', created () { - //在页面加载时读取sessionStorage里的状态信息 - if (util.session.get(Setting.storeKey) ) { - this.$store.replaceState(Object.assign({}, this.$store.state,JSON.parse(util.session.get(Setting.storeKey)))) + //在页面加载时读取localStorage里的状态信息 + if (util.local.get(Setting.storeKey) ) { + this.$store.replaceState(Object.assign({}, this.$store.state,util.local.get(Setting.storeKey))) } - //在页面刷新时将vuex里的信息保存到sessionStorage里 + //在页面刷新时将vuex里的信息保存到localStorage里 window.addEventListener("beforeunload",()=>{ - util.session.get(Setting.usernameKey) && util.session.set(Setting.storeKey,JSON.stringify(this.$store.state)) + util.local.get(Setting.usernameKey) && util.local.set(Setting.storeKey,this.$store.state) }) } } diff --git a/src/api/index.js b/src/api/index.js index 1776a22..f69c827 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -2,9 +2,8 @@ import Setting from '@/setting' let uploadURL = Setting.upload.apiURL export default { - // 登录注册 - logins: `management/userInfo/login`, - save: `management/userInfo/add`, + // 登录注册 + logins: `liuwanr/userInfo/adminLogins`, uploadUserAvatars: `liuwanr/userInfo/uploadUserAvatars`, queryProvince: `liuwanr/province/queryProvince`, diff --git a/src/assets/img/remove-gray.png b/src/assets/img/remove-gray.png new file mode 100644 index 0000000000000000000000000000000000000000..f8bf9f4f2f954dc2110281876615d85f8a141a32 GIT binary patch literal 521 zcmV+k0`~ohP)Az>F)=?h*zj z`~bqtCvc>uf{BR~6DJ#rU2HIKb4Sj4ErxJQ)4TV6_x^eAy#%617C;g}hJDG>1F!(_ z1;CMQO-LpQasVI|a~LfV^pzd5HVp&!0PJr7g_q|5-ua{m+y=%uZvZ~%hXX0h5>1T9 z<65y;JTnZV-fT9XW#0CBy_0ISdShAEeYsrjFdLJ?=fESLGXj=MrJC>i3mLTCZWkJj z#+{-l8Pha70+4e0L_n(Mq3FqMHf!Z_xzjLIgxR(|&@`Y+$X{oAu5f}2NqPT`()L2nE zilV5tZ9iz5b}fMhMTwJ50OJB@vWbHRvY{ap_AeOsMubKQJ4jFH>Ya<8g+pUk@7A)c ze$>^YJv(g<+=*?V>rNwf8!@V#HdqlXJ^{RYQ%9jEfS!U+nHGNlN@VI1byp;k00000 LNkvXXu0mjfcvak< literal 0 HcmV?d00001 diff --git a/src/assets/img/search-gray.png b/src/assets/img/search-gray.png new file mode 100644 index 0000000000000000000000000000000000000000..2f327fa8211b966f2adf1b6e0be2fe94a099dea4 GIT binary patch literal 629 zcmV-*0*d{KP)c#H5ZpZhRO#demR}J11(sfrq)Hj9(H*PUZ5rEEkWQ({ zQ$s&NenI3Hm`~6TB6p&S+h7DzI8#STHcUW(q`RHnot+&r1)e<5KWsLe&qNf9NX*Pb z5m_>GK|}>JKTIYQeD8d?d77r_kePF49vq0BMp1M(9*wjfjkK9!jtS&$4XF%s+_enTT$+*3-6%szmohbU{Qb=iGUc zB+KUgEjXx9O8o^e_&tVC#93>R;Jb({j4`7_KWC5YS5@tUSZkq}lPHQl`s!h8Ehc^8oEx=G{ZKb; z7yuUpYpwS*e+aZb_qxB+THn_H0~``Mb
- +
- +
@@ -48,8 +50,13 @@ export default { ...mapActions('user', [ 'logout' ]), + toIndex(){ + this.$refs.nav.jump({ + index: '/index/list', + title: '首页' + }) + }, userCommand(command){ - console.log(command) if(command == 'person'){ this.$router.push('/setting/person') }else{ @@ -73,6 +80,10 @@ export default { } .logo{ width: 180px; + cursor: pointer; + img{ + width: 100%; + } } .action{ diff --git a/src/libs/util.db.js b/src/libs/util.db.js index 06f0fb3..944ea81 100644 --- a/src/libs/util.db.js +++ b/src/libs/util.db.js @@ -35,9 +35,10 @@ var _local = { // 如果有startTime的值,说明设置了失效时间 if (item && item.startTime) { let date = new Date().getTime(); + // 如果大于就是过期了,如果小于或等于就还没过期 if (date - item.startTime > item.expires) { - localStorage.removeItem(name); + localStorage.removeItem(key); return false; } else { return item.value; diff --git a/src/pages/account/login/index.vue b/src/pages/account/login/index.vue index 4006662..c19909e 100644 --- a/src/pages/account/login/index.vue +++ b/src/pages/account/login/index.vue @@ -30,12 +30,13 @@ - + \ No newline at end of file diff --git a/src/pages/setting/person/download.vue b/src/pages/setting/person/download.vue index b2ad793..3918f2b 100644 --- a/src/pages/setting/person/download.vue +++ b/src/pages/setting/person/download.vue @@ -23,7 +23,7 @@
@@ -86,6 +86,11 @@ export default { handleSelectionChange(val) { this.multipleSelection = val }, + handleCurrentChange(val) { + this.page = val + this.$refs.table.clearSelection() + this.getData() + }, } }; diff --git a/src/pages/setting/person/info.vue b/src/pages/setting/person/info.vue index 6db6b46..b67a189 100644 --- a/src/pages/setting/person/info.vue +++ b/src/pages/setting/person/info.vue @@ -35,12 +35,7 @@ 国家
- +
@@ -48,12 +43,7 @@ 省份
- +
@@ -61,12 +51,7 @@ 城市
- +
@@ -82,12 +67,7 @@
- +
@@ -174,13 +154,15 @@
  • - + {{personalInformation.phone}} + 更换
  • - + {{personalInformation.email}} + 更换
  • @@ -195,6 +177,41 @@ + + + + + + +
    + + {{emailBtnText}} +
    +
    +
    + + 取 消 + 确 定 + +
    + + + + + + + +
    + + {{phoneBtnText}} +
    +
    +
    + + 取 消 + 确 定 + +
    @@ -442,11 +459,11 @@ export default { } }, addArch() { - let isEmpty = false - this.archivesList.forEach((n,k) => { - if(!n.personalCareerId) isEmpty = true - }) - if(isEmpty) return this.$message.warning('请选择职业') + // let isEmpty = false + // this.archivesList.forEach((n,k) => { + // if(!n.personalCareerId) isEmpty = true + // }) + // if(isEmpty) return this.$message.warning('请选择职业') this.showArch = true this.concatArch() }, @@ -496,6 +513,120 @@ export default { document.documentElement.scrollTop = document.querySelector('.content-box').scrollHeight }) }, + emailCountdown(){ + let count = 60 + if(!this.emailTimer){ + this.emailDisabled = true + this.emailTimer = setInterval(() => { + console.log('倒计时中') + if(count > 0){ + count-- + this.emailBtnText = `${count}秒后重试` + }else{ + this.emailDisabled = false + clearInterval(this.emailTimer) + this.emailTimer = null + this.emailBtnText = `发送验证码` + } + },1000) + } + }, + 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) + } + }, + closeEmail(){ + if(!this.emailDisabled){ + this.emailCode = '' + } + }, + sendEmailCode(){ + if(!this.email) return this.$message.warning('请输入邮箱') + if(!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return this.$message.warning('请输入正确的邮箱') + let data = { + userId: this.userId, + email: this.email, + types: 1 + } + this.$post(this.api.sendEmailCode,data).then(res => { + if(res.errmessage == 'success'){ + this.emailCountdown() + this.emailOpener = res.data + } + }).catch(res => {}); + }, + emailSubmit(){ + if(!this.email) return this.$message.warning('请输入邮箱') + if(!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return this.$message.warning('请输入正确的邮箱') + if(!this.emailCode) return this.$message.warning('请输入验证码') + let data = { + userId: this.userId, + email: this.email, + types: 1, + code: this.emailCode, + opener: this.emailOpener + } + this.$put(this.api.bingEmail,data).then(res => { + if(res.errmessage == 'success'){ + this.$message.success('绑定成功') + this.personalInformation.email = this.email + this.emailVisible = false + } + }).catch(res => {}); + }, + closePhone(){ + if(!this.emailDisabled){ + this.emailCode = '' + } + }, + sendPhoneCode(){ + if(!this.phone) return this.$message.warning('请输入手机号') + if(!/^1[3456789]\d{9}$/.test(this.phone)) return this.$message.warning('请输入正确的手机号') + let data = { + userId: this.userId, + phone: this.phone, + types: 2 + } + this.$post(this.api.sendPhoneCode,data).then(res => { + if(res.errmessage == 'success'){ + this.phoneCountdown() + this.phoneOpener = res.data + } + }).catch(res => {}); + }, + phoneSubmit(){ + if(!this.phone) return this.$message.warning('请输入手机号') + if(!/^1[3456789]\d{9}$/.test(this.phone)) return this.$message.warning('请输入正确的手机号') + if(!this.phoneCode) return this.$message.warning('请输入验证码') + let data = { + userId: this.userId, + phone: this.phone, + types: 2, + code: this.phoneCode, + opener: this.phoneOpener + } + this.$put(this.api.bindPhone,data).then(res => { + if(res.errmessage == 'success'){ + this.$message.success('绑定成功') + this.personalInformation.phone = this.phone + this.phoneVisible = false + } + }).catch(res => {}); + }, } }; @@ -530,6 +661,11 @@ export default { border-color: #999; } } + .val{ + margin-right: 15px; + color: #606266; + font-size: 14px; + } .mul{ display: inline-flex; margin-top: 10px; @@ -547,5 +683,11 @@ export default { } } + .archives{ + padding: 30px; + margin-bottom: 30px; + border-radius: 8px; + border: 1px dashed #C0C4CC; + } } \ No newline at end of file diff --git a/src/plugins/auth/index.js b/src/plugins/auth/index.js index 62f20f2..81ab8bb 100644 --- a/src/plugins/auth/index.js +++ b/src/plugins/auth/index.js @@ -1,7 +1,7 @@ /** * @description 鉴权指令 * 当传入的权限当前用户没有时,会移除该组件 - * 用例:text 或者:text + * 用例:text 或者:text * */ import store from '@/store'; diff --git a/src/plugins/requests/index.js b/src/plugins/requests/index.js index 7eb28fa..6649b87 100644 --- a/src/plugins/requests/index.js +++ b/src/plugins/requests/index.js @@ -32,7 +32,7 @@ service.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8' service.interceptors.response.use( response => { const res = response.data - if (res.success) { + if (res.status == 200) { return Promise.resolve(res).catch(e => {}) } else { switch (res.code) { diff --git a/src/router/modules/wrongBook.js b/src/router/modules/wrongBook.js deleted file mode 100644 index 2ea048a..0000000 --- a/src/router/modules/wrongBook.js +++ /dev/null @@ -1,28 +0,0 @@ -import BasicLayout from '@/layouts/home'; - -const meta = {}; - -const pre = 'wrongBook-'; - -export default { - path: '/wrongBook', - name: 'wrongBook', - redirect: { - name: `${pre}list` - }, - meta, - component: BasicLayout, - children: [ - { - name: `${pre}list`, - path: `list`, - component: () => import('@/pages/wrongBook/list'), - meta: { title: '我的错题本' } - },{ - name: `${pre}do`, - path: `do`, - component: () => import('@/pages/wrongBook/do'), - meta: { title: '错题练习' } - }, - ] -}; diff --git a/src/router/permission.js b/src/router/permission.js index 10915b2..c1fe03b 100644 --- a/src/router/permission.js +++ b/src/router/permission.js @@ -4,7 +4,7 @@ import util from '@/libs/util' router.beforeEach((to, from, next) => { document.title = Setting.titleSuffix; - const role = util.session.get(Setting.usernameKey); + const role = util.local.get(Setting.usernameKey); if (!role && to.path !== '/login') { next('/login') } else if(role && to.path == '/login') { diff --git a/src/setting.js b/src/setting.js index 3748d3c..f3b6eea 100644 --- a/src/setting.js +++ b/src/setting.js @@ -16,13 +16,17 @@ const Setting = { showProgressBar: true, // 接口请求地址 // apiBaseURL: env === 'development' ? 'http://192.168.31.151:8001' : 'http://39.108.250.202:8000', - apiBaseURL: env === 'development' ? 'http://39.108.250.202:9000' : 'http://39.108.250.202:9000', + apiBaseURL: env === 'development' ? 'http://www.occupationlab.com' : 'http://www.liuwanr.cn', // 接口请求返回错误时,弹窗的持续时间,单位:秒 modalDuration: 3, // 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice errorModalType: 'Message', // Cookies 默认保存时间,单位:天 cookiesExpires: 1, + /** + * 免登录保存的token的key + */ + tokenKey: 'data_token', /** * sessionStorage里state的key */ @@ -48,8 +52,7 @@ const Setting = { * 布局配置 * */ layout: { - // 需要隐藏顶栏的页面路径 - hideNavList: ['practice-do','practice-randomDo','setting-person','achievement-assessment','achievement-practice','exam-do','exam-detail','wrongBook-do'], + }, /** * 功能配置 diff --git a/src/store/modules/achievement.js b/src/store/modules/data.js similarity index 100% rename from src/store/modules/achievement.js rename to src/store/modules/data.js diff --git a/src/store/modules/exam.js b/src/store/modules/exam.js deleted file mode 100644 index 321b6f1..0000000 --- a/src/store/modules/exam.js +++ /dev/null @@ -1,97 +0,0 @@ -/** - * 试卷管理 - * */ -export default { - namespaced: true, - state: { - typeList: [ - { - id: 1, - name: '期中考试' - },{ - id: 2, - name: '期末考试' - },{ - id: 3, - name: '模拟考' - } - ], - stateList: [ - { - id: 0, - name: '待开始' - },{ - id: 1, - name: '进行中' - },{ - id: 2, - name: '已提交' - } - ], - assessmentStateList: [ - { - id: 1, - name: '待开始' - },{ - id: 2, - name: '进行中' - },{ - id: 3, - name: '已结束' - } - ], - degreeList: [ - { - id: 0, - label: '简单' - },{ - id: 1, - label: '一般' - },{ - id: 2, - label: '较难' - },{ - id: 3, - label: '很难' - }, - ], - assessmentName: '', - testPaperId: '', - assessmentId: '', - teacherId: '', - classId: '', - paperName: '', - countdown: '', - assessmentName: '' - }, - getters: { - getDegreeName: state => id => { - return id != null ? state.degreeList.find(n => n.id == id).label : '' - }, - getTypeName: state => id => { - return id != null ? state.typeList.find(n => n.id == id).name : '' - }, - getStateName: state => id => { - return id != null ? state.stateList.find(n => n.id == id).name : '' - }, - getAssessmentStateName: state => id => { - return id != null ? state.assessmentStateList.find(n => n.id == id).name : '' - }, - }, - mutations: { - SET_INFO: (state, info) => { - state.assessmentName = info.assessmentName - state.assessmentId = info.assessmentId - state.teacherId = info.teacherId - state.classId = info.classId - state.testPaperId = info.testPaperId - state.countdown = info.countdown - state.assessmentName = info.assessmentName - }, - }, - actions: { - setInfo({ commit },info) { - commit('SET_INFO',info) - }, - } -} \ No newline at end of file diff --git a/src/store/modules/client.js b/src/store/modules/role.js similarity index 100% rename from src/store/modules/client.js rename to src/store/modules/role.js diff --git a/src/store/modules/practice.js b/src/store/modules/stat.js similarity index 100% rename from src/store/modules/practice.js rename to src/store/modules/stat.js diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 900bcb6..e4f6835 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,9 +1,9 @@ -import addRoutes from '@/libs/route/addRoutes'; -import Setting from '@/setting'; -import util from '@/libs/util'; -import { Message } from 'element-ui'; +import addRoutes from '@/libs/route/addRoutes' +import Setting from '@/setting' +import util from '@/libs/util' +import { Message } from 'element-ui' import {post,get,del,put} from '@/plugins/requests/index.js' -import api from '@/api'; +import api from '@/api' /** * 用户信息 @@ -53,13 +53,16 @@ export default { }, actions: { login({ state,commit }, userInfo) { + // util.local.set('data-token','testfffff',1296000000) const { username, password } = userInfo return new Promise((resolve, reject) => { - get(api.logins,{ account: username.trim(), password: password }).then(res => { - if(res.success){ - let user = res.data.userInfo - if(user.roleId == 4){ - let routes = res.data.permissions[0].children + get(api.logins,{ account: username.trim(), password: password, source: 0 }).then(res => { + console.log(333,res) + if(res.status == 200){ + let user = res.message.retvalue + console.log(user) + if(user.roleId == 1){ + let routes = res.message.listValue commit('SET_INFO',{ avatar: user.userAvatars, userId: user.userId, @@ -70,9 +73,12 @@ export default { clientId: user.clientId, clientName: user.clientName, }) + + if(userInfo.remember) util.local.set(Setting.tokenKey,user.token,1296000000) + Setting.dynamicRoute && addRoutes(routes) - util.session.set(Setting.usernameKey, user.userName) - util.successMsg('登录成功'); + util.local.set(Setting.usernameKey, user.userName) + util.successMsg('登录成功') resolve() }else{ util.errorMsg('该用户没有权限') @@ -87,8 +93,9 @@ export default { }, logout({ commit, state, dispatch }) { return new Promise((resolve, reject) => { - util.session.remove(Setting.usernameKey); - util.session.remove(Setting.storeKey); + util.local.remove(Setting.usernameKey) + util.local.remove(Setting.storeKey) + util.local.remove(Setting.tokenKey) location.reload() resolve() }) diff --git a/src/store/modules/wrongBook.js b/src/store/modules/wrongBook.js deleted file mode 100644 index 150d6f6..0000000 --- a/src/store/modules/wrongBook.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * 我的错题本 - * */ -export default { - namespaced: true, - state: { - qid: '', - type: 1 - }, - getters: { - - }, - mutations: { - SET_INFO: (state, info) => { - state.qid = info.qid - state.type = info.type - }, - }, - actions: { - setInfo({ commit },info) { - commit('SET_INFO',info) - }, - } -} \ No newline at end of file diff --git a/src/styles/layout/index.scss b/src/styles/layout/index.scss index 30aabc5..160ad90 100644 --- a/src/styles/layout/index.scss +++ b/src/styles/layout/index.scss @@ -9,7 +9,7 @@ body, } body { - min-width: $inner-width; + min-width: 1500px; font-family: 'PingFang SC', "Helvetica Neue", Helvetica, "microsoft yahei", arial, STHeiTi, sans-serif; font-size: 14px; background: rgba(0, 0, 0, 0.02);