From 86741def1c1505c026f7ae9e5ba5974142058523 Mon Sep 17 00:00:00 2001 From: Eddie <102564160@qq.com> Date: Wed, 11 Aug 2021 14:47:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=99=BB=E5=BD=95=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/admin.js | 2 +- src/api/user.js | 19 ++++++++++-- src/components/AdminInfoDialog/index.vue | 4 +-- src/permission.js | 2 +- src/router/modules/books-management.js | 2 +- src/router/modules/member-management.js | 2 +- src/router/modules/sort-management.js | 2 +- src/store/modules/user.js | 25 +++++++-------- src/utils/auth.js | 2 +- src/utils/request.js | 13 +++++--- .../books-management/ShuYuan-page/index.vue | 6 ++-- src/views/login/index.vue | 1 + .../components/memberDialog.vue | 31 +++++++++++++------ .../otherSettingsDialog.vue | 23 ++++++++++---- .../components/check-books-dialog.vue | 1 - 15 files changed, 87 insertions(+), 48 deletions(-) diff --git a/src/api/admin.js b/src/api/admin.js index 5696497..b4fa27e 100644 --- a/src/api/admin.js +++ b/src/api/admin.js @@ -6,7 +6,7 @@ import request from '@/utils/request' */ export function getAdminInfo() { return request({ - url: '/admin/Index/userInfo', + url: '/user/info', method: 'get' }) } diff --git a/src/api/user.js b/src/api/user.js index d22c66c..dcbb05f 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -1,13 +1,28 @@ import request from '@/utils/request' -export function login(data) { +export function login(params) { return request({ - url: '/Login/login', + url: 'user/login', + method: 'POST', + params: params + }) +} + + +export function loginRegister(data) { + return request({ + url: '/user/register', method: 'post', data }) } + + + + + + export function sendCode(data) { return request({ url: '/Login/loginSms', diff --git a/src/components/AdminInfoDialog/index.vue b/src/components/AdminInfoDialog/index.vue index 316f925..e88de25 100644 --- a/src/components/AdminInfoDialog/index.vue +++ b/src/components/AdminInfoDialog/index.vue @@ -37,12 +37,12 @@
- { console.log(hasToken) - if (!hasToken) { + if ( hasToken) { if (to.path === '/login') { // if is logged in, redirect to the home page next({ path: '/' }) diff --git a/src/router/modules/books-management.js b/src/router/modules/books-management.js index b4feb88..ecaec51 100644 --- a/src/router/modules/books-management.js +++ b/src/router/modules/books-management.js @@ -3,7 +3,7 @@ import Layout from '@/layout' const booksManagement = { - path: '/', + path: '/books', component: Layout, redirect: '/books', name: 'booksManagement', diff --git a/src/router/modules/member-management.js b/src/router/modules/member-management.js index 3b3eaf4..792ac47 100644 --- a/src/router/modules/member-management.js +++ b/src/router/modules/member-management.js @@ -3,7 +3,7 @@ import Layout from '@/layout' const memberManagement = { - path: '/', + path: '/member', component: Layout, redirect: '/member', name: 'memberManagement', diff --git a/src/router/modules/sort-management.js b/src/router/modules/sort-management.js index 489a277..ff79221 100644 --- a/src/router/modules/sort-management.js +++ b/src/router/modules/sort-management.js @@ -3,7 +3,7 @@ import Layout from '@/layout' const sortManagement = { - path: '/', + path: '/sort', component: Layout, redirect: '/sort', name: 'memberManagement', diff --git a/src/store/modules/user.js b/src/store/modules/user.js index b87034c..4c1bd08 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -46,24 +46,23 @@ const actions = { // user login login({ commit }, userInfo) { - const { phone, password, code, type } = userInfo + const { phone, password } = userInfo return new Promise((resolve, reject) => { - // commit('SET_TOKEN', 'admin-token') - // setToken('admin-token') - // resolve() + login({ - phone: phone, - pwd: password, - loginType: type, - code: code + username: phone, + password: password, }) .then(response => { - const { code } = response - if (code === 0) { - commit('SET_TOKEN', 'admin-token') - setToken('admin-token') + + const { error_code , data} = response + + console.log(error_code) + if (error_code === 0) { + commit('SET_TOKEN', ) + setToken(data) } - resolve(code) + resolve(error_code) }) .catch(error => { reject(error) diff --git a/src/utils/auth.js b/src/utils/auth.js index 08a43d6..d7978a5 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -1,6 +1,6 @@ import Cookies from 'js-cookie' -const TokenKey = 'Admin-Token' +const TokenKey = 'api-token' export function getToken() { return Cookies.get(TokenKey) diff --git a/src/utils/request.js b/src/utils/request.js index 3f6d32f..04cb9d6 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -11,16 +11,20 @@ const service = axios.create({ withCredentials: true }) + // request interceptor service.interceptors.request.use( config => { // do something before request is sent - + config.headers['Content-Type'] = 'application/x-www-form-urlencoded'; + if (store.getters.token) { + + console.log(getToken()) // let each request carry token // ['X-Token'] is a custom headers key // please modify it according to the actual situation - config.headers['X-Token'] = getToken() + config.headers['api-token'] = getToken() } return config }, @@ -45,8 +49,9 @@ service.interceptors.response.use( */ response => { const res = response.data + console.log(res) // if the custom code is not 20000, it is judged as an error. - if (res.code !== 0) { + if (res.error_code !== 0) { Message({ message: res.message || 'Error', type: 'error', @@ -59,7 +64,7 @@ service.interceptors.response.use( }, error => { const errorMsg = error.response.data.msg - console.log(error.response.data) + // 特殊处理401,需要验证手机号 if (error.response.data.code === 401) { return error.response.data diff --git a/src/views/books-management/ShuYuan-page/index.vue b/src/views/books-management/ShuYuan-page/index.vue index b0ce193..e069266 100644 --- a/src/views/books-management/ShuYuan-page/index.vue +++ b/src/views/books-management/ShuYuan-page/index.vue @@ -89,7 +89,7 @@ border fit tooltip-effect="dark" - @selection-change="handleSelectionChange" + > { + console.log( code ,9989) if (code === 401) { this.needSendCode = true; this.$message.warning("为了您的账户安全,请输入手机验证码校验"); diff --git a/src/views/member-management/components/memberDialog.vue b/src/views/member-management/components/memberDialog.vue index b03de12..6e8718b 100644 --- a/src/views/member-management/components/memberDialog.vue +++ b/src/views/member-management/components/memberDialog.vue @@ -79,7 +79,7 @@
邀请码 YT23694 - 自定义邀请码
@@ -87,7 +87,7 @@
支付宝账号 ****** - 更改绑定账号
@@ -95,7 +95,7 @@
会员等级 普通会员 - 设置等级
@@ -104,7 +104,7 @@
余额变动 0.0000 - 调整
@@ -112,7 +112,7 @@
积分变动 0.0000 - 调整
@@ -130,8 +130,10 @@ @@ -174,6 +176,8 @@ export default { rules: {}, // + isOtherSettings: false, + othoerItem: {}, options: [ { @@ -235,12 +239,19 @@ export default { }, // 自定义邀请码 - setInvitationCode(){ - this.setItemData = { - title: '自定义邀请码', + setInvitation(title){ + + this.othoerItem = { + title: title, data: [] } + this.isOtherSettings = true }, + + OtherClose(){ + console.log(123) + this.isOtherSettings = false + } }, }; diff --git a/src/views/member-management/components/otherSettingsDialog/otherSettingsDialog.vue b/src/views/member-management/components/otherSettingsDialog/otherSettingsDialog.vue index db96f5f..885495e 100644 --- a/src/views/member-management/components/otherSettingsDialog/otherSettingsDialog.vue +++ b/src/views/member-management/components/otherSettingsDialog/otherSettingsDialog.vue @@ -16,7 +16,7 @@ 15326713918 - + - + - + + - + + + + + + + - +
@@ -72,7 +79,7 @@ export default { }, // 选中的数据 selectItem: { - type: Object, + type: Array, default: () => {}, }, dialogTitle: { @@ -82,6 +89,9 @@ export default { }, }, }, + mounted(){ + console.log(this.selectItem) + }, data() { return { // dialog样式 @@ -131,6 +141,7 @@ export default { methods: { // 关闭弹窗 handleClose() { + console.log(123) this.$emit("handle-close"); }, // 提交弹窗 diff --git a/src/views/sort-management/components/check-books-dialog.vue b/src/views/sort-management/components/check-books-dialog.vue index e286f4f..d1de267 100644 --- a/src/views/sort-management/components/check-books-dialog.vue +++ b/src/views/sort-management/components/check-books-dialog.vue @@ -80,7 +80,6 @@ border fit tooltip-effect="dark" - @selection-change="handleSelectionChange" >