From 341cbab1b3dc8741b5c535af817a4a9f5a781f11 Mon Sep 17 00:00:00 2001 From: liyanhong <17806274112@163.com> Date: Wed, 13 Nov 2024 17:32:05 +0800 Subject: [PATCH] 1 --- src/api/table.js | 9 - src/api/user.js | 38 +++- src/components/Breadcrumb/index.vue | 10 +- src/layout/components/Navbar.vue | 15 +- src/main.js | 4 +- src/permission.js | 2 +- src/store/modules/user.js | 57 +++-- src/utils/request.js | 19 +- src/views/dashboard/index.vue | 2 +- src/views/form/index.vue | 335 +++++++++++----------------- src/views/login/index.vue | 6 +- src/views/table/index.vue | 152 +++++++------ 12 files changed, 286 insertions(+), 363 deletions(-) delete mode 100644 src/api/table.js diff --git a/src/api/table.js b/src/api/table.js deleted file mode 100644 index 2752f52..0000000 --- a/src/api/table.js +++ /dev/null @@ -1,9 +0,0 @@ -import request from '@/utils/request' - -export function getList(params) { - return request({ - url: '/vue-admin-template/table/list', - method: 'get', - params - }) -} diff --git a/src/api/user.js b/src/api/user.js index 8ff4389..e5865db 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -1,5 +1,5 @@ import request from '@/utils/request' - +// 登录 export function login(data) { return request({ url: '/vue-admin-template/user/login', @@ -7,7 +7,7 @@ export function login(data) { data }) } - +// 用户信息 export function getInfo(token) { return request({ url: '/vue-admin-template/user/info', @@ -15,10 +15,42 @@ export function getInfo(token) { params: { token } }) } - +// 登出 export function logout() { return request({ url: '/vue-admin-template/user/logout', method: 'post' }) } +// 推广人注册 +export function register(data) { + return request({ + url: '/api/promoter/register', + method: 'post', + data + }) +} +// 图片上传 +export function upload(data) { + return request({ + url: '/api/public/upload', + method: 'post', + data + }) +} +// 所在地区 +export function getArea(data) { + return request({ + url: '/api/public/areas', + method: 'post', + data + }) +} +// 进件列表 +export function getApplyList(data) { + return request({ + url: '/api/promoter/account_list', + method: 'post', + data + }) +} diff --git a/src/components/Breadcrumb/index.vue b/src/components/Breadcrumb/index.vue index 29f9a04..44d1613 100644 --- a/src/components/Breadcrumb/index.vue +++ b/src/components/Breadcrumb/index.vue @@ -29,12 +29,12 @@ export default { methods: { getBreadcrumb() { // only show routes with meta.title - let matched = this.$route.matched.filter(item => item.meta && item.meta.title) - const first = matched[0] + const matched = this.$route.matched.filter(item => item.meta && item.meta.title) + // const first = matched[0] - if (!this.isDashboard(first)) { - matched = [{ path: '/dashboard', meta: { title: 'Dashboard' }}].concat(matched) - } + // if (!this.isDashboard(first)) { + // matched = [{ path: '/dashboard', meta: { title: '推广人' }}].concat(matched) + // } this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false) }, diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 0ca5cf6..2e06b7b 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -7,21 +7,10 @@
- +
- - - Home - - - - Github - - - Docs - Log Out @@ -53,7 +42,7 @@ export default { }, async logout() { await this.$store.dispatch('user/logout') - this.$router.push(`/login?redirect=${this.$route.fullPath}`) + this.$router.push({ name: 'login' }) } } } diff --git a/src/main.js b/src/main.js index 01cba2f..676a431 100644 --- a/src/main.js +++ b/src/main.js @@ -29,9 +29,9 @@ if (process.env.NODE_ENV === 'production') { } // set ElementUI lang to EN -Vue.use(ElementUI, { locale }) +// Vue.use(ElementUI, { locale }) // 如果想要中文版 element-ui,按如下方式声明 -// Vue.use(ElementUI) +Vue.use(ElementUI) Vue.config.productionTip = false diff --git a/src/permission.js b/src/permission.js index fa1ea19..ee26a4c 100644 --- a/src/permission.js +++ b/src/permission.js @@ -32,7 +32,7 @@ router.beforeEach(async(to, from, next) => { } else { try { // get user info - await store.dispatch('user/getInfo') + // await store.dispatch('user/getInfo') next() } catch (error) { diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 2f6423f..558f043 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -30,51 +30,50 @@ const mutations = { const actions = { // user login login({ commit }, userInfo) { - const { username, password } = userInfo + // const { username, password } = userInfo return new Promise((resolve, reject) => { - login({ username: username.trim(), password: password }).then(response => { - const { data } = response - commit('SET_TOKEN', data.token) - setToken(data.token) - resolve() - }).catch(error => { - reject(error) - }) + // login({ username: username.trim(), password: password }).then(response => { + commit('SET_TOKEN', 'admin-token') + setToken('admin-token') + resolve() + // }).catch(error => { + // reject(error) + // }) }) }, // get user info getInfo({ commit, state }) { return new Promise((resolve, reject) => { - getInfo(state.token).then(response => { - const { data } = response + // getInfo(state.token).then(response => { + // const { data } = response - if (!data) { - return reject('Verification failed, please Login again.') - } + // if (!data) { + // return reject('Verification failed, please Login again.') + // } - const { name, avatar } = data + // const { name, avatar } = data - commit('SET_NAME', name) - commit('SET_AVATAR', avatar) - resolve(data) - }).catch(error => { - reject(error) - }) + // commit('SET_NAME', name) + // commit('SET_AVATAR', avatar) + // resolve(data) + // }).catch(error => { + // reject(error) + // }) }) }, // user logout logout({ commit, state }) { return new Promise((resolve, reject) => { - logout(state.token).then(() => { - removeToken() // must remove token first - resetRouter() - commit('RESET_STATE') - resolve() - }).catch(error => { - reject(error) - }) + // logout(state.token).then(() => { + removeToken() // must remove token first + resetRouter() + commit('RESET_STATE') + resolve() + // }).catch(error => { + // reject(error) + // }) }) }, diff --git a/src/utils/request.js b/src/utils/request.js index 2fb95ac..8963bea 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -5,8 +5,9 @@ import { getToken } from '@/utils/auth' // create an axios instance const service = axios.create({ - baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url + // baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url // withCredentials: true, // send cookies when cross-domain requests + baseURL: 'http://192.168.0.155:7301', timeout: 5000 // request timeout }) @@ -46,26 +47,12 @@ service.interceptors.response.use( const res = response.data // if the custom code is not 20000, it is judged as an error. - if (res.code !== 20000) { + if (res.code !== 200) { Message({ message: res.message || 'Error', type: 'error', duration: 5 * 1000 }) - - // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired; - if (res.code === 50008 || res.code === 50012 || res.code === 50014) { - // to re-login - MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', { - confirmButtonText: 'Re-Login', - cancelButtonText: 'Cancel', - type: 'warning' - }).then(() => { - store.dispatch('user/resetToken').then(() => { - location.reload() - }) - }) - } return Promise.reject(new Error(res.message || 'Error')) } else { return res diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index e3d080c..f3e8ed4 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -3,7 +3,7 @@
diff --git a/src/views/form/index.vue b/src/views/form/index.vue index bbdeb93..3de24a6 100644 --- a/src/views/form/index.vue +++ b/src/views/form/index.vue @@ -1,239 +1,160 @@ +