Browse Source

对接登录

chenrui 4 years ago
parent
commit
c2cf3e0704

+ 0 - 100
src/api/car-wash.js

@@ -1,100 +0,0 @@
-import { axios } from '@/utils/request'
-
-// 门店设备列表
-export const storeQuery = (params) => {
-  const url = `store/query/${params.pageNo}/${params.pageSize}`
-  delete params.pageNo
-  delete params.pageSize
-  return axios({
-    url: url,
-    data: params,
-    method: 'post'
-  })
-}
-// 门店设备保存
-export const storeSave = (params) => {
-  const url = 'store/save'
-  return axios({
-    url: url,
-    data: params,
-    method: 'post'
-  })
-}
-// 查询设备
-export const deviceQuery = (params) => {
-  const url = `device/query/${params.pageNo}/${params.pageSize}`
-  delete params.pageNo
-  delete params.pageSize
-  return axios({
-    url: url,
-    data: params,
-    method: 'post'
-  })
-}
-// 网点详情
-export const storeFind = params => {
-  const url = `store/find/${params.id}`
-  return axios.request({
-    url: url,
-    method: 'get'
-  })
-}
-// 查询门店的服务时段价格
-export const findItem = params => {
-  const url = `item/${params.id}`
-  return axios.request({
-    url: url,
-    method: 'get'
-  })
-}
-// 服务列表
-export const itemQuery = (params) => {
-  const url = `item/query/${params.pageNo}/${params.pageSize}`
-  delete params.pageNo
-  delete params.pageSize
-  return axios({
-    url: url,
-    data: params,
-    method: 'post'
-  })
-}
-// 删除网点
-export const storeDel = params => {
-  const url = `store/del/${params.id}`
-  return axios.request({
-    url: url,
-    method: 'get'
-  })
-}
-// 获取当前设备图片
-export const deviceImage = params => {
-  const url = `device/image/${params.deviceNo}`
-  return axios.request({
-    url: url,
-    method: 'get'
-  })
-}
-// 获取网点小程序码
-export const storeQrCode = params => {
-  const url = `store/qrCode/${params.deviceNo}/${params.id}`
-  return axios.request({
-    url: url,
-    method: 'get'
-  })
-}
-// 更改网点营业状态
-export const storeUpdateStatus = params => {
-  const url = `store/updateStatus/${params.id}/${params.businessStatus}`
-  return axios.request({
-    url: url,
-    method: 'get'
-  })
-}
-// 检测设备状态
-export const deviceValidStatus = params => {
-  const url = `device/validStatus/${params.deviceNo}`
-  return axios.request({
-    url: url,
-    method: 'get'
-  })
-}

+ 0 - 59
src/api/card-voucher-role.js

@@ -1,59 +0,0 @@
-import { axios } from '@/utils/request'
-
-// 获取列表数据
-export const getPowerRoleList = params => {
-  const url = `yyrole/queryLike/${params.pageNo}/${params.pageSize}`
-  delete params.pageNo
-  delete params.pageSize
-  return axios({
-    url: url,
-    data: params,
-    method: 'POST'
-  })
-}
-
-// 改变权限状态接口 flag 0:禁用 1:启用
-export const updateEnableStatus = params => {
-  return axios({
-    url: `yyrole/enable/${params.id}/${params.flag}`,
-    data: {},
-    method: 'get'
-  })
-}
-
-// 删除用户接口
-export const delectRolePower = params => {
-  return axios({
-    url: `yyrole/delete/${params.id}`,
-    data: {},
-    method: 'get'
-  })
-}
-
-// 新增/编辑保存接口
-export const saveRolePower = params => {
-  return axios({
-    url: 'yyrole/save',
-    data: params,
-    method: 'POST'
-  })
-}
-
-// 获取菜单树数据
-export const getMenuList = params => {
-  const url = `yyrole/findAllMenu/${params.id}`
-  return axios({
-    url: url,
-    method: 'get'
-  })
-}
-
-// 保存权限分配
-export const addMenuPower = params => {
-  const url = `yyrole/saveRoleMenu`
-  return axios({
-    url: url,
-    data: params,
-    method: 'post'
-  })
-}

+ 0 - 58
src/api/card-voucher-user.js

@@ -1,58 +0,0 @@
-import { axios } from '@/utils/request'
-
-// 重置密码
-export const resetPSD = params => {
-  return axios({
-    url: 'yyuser/resetPwd',
-    data: params,
-    method: 'POST'
-  })
-}
-
-// 获取列表数据
-export const getPowerUserList = params => {
-  const url = `yyuser/queryLike/${params.pageNo}/${params.pageSize}`
-  delete params.pageNo
-  delete params.pageSize
-  return axios({
-    url: url,
-    data: params,
-    method: 'POST'
-  })
-}
-
-// 改变权限状态接口
-export const updateEnableStatus = params => {
-  return axios({
-    url: `yyuser/enable/${params.id}/${params.flag}`,
-    data: {},
-    method: 'get'
-  })
-}
-
-// 删除用户接口
-export const delectUserPower = params => {
-  return axios({
-    url: `yyuser/delete/${params.id}`,
-    data: {},
-    method: 'get'
-  })
-}
-
-// 新增/编辑保存接口
-export const saveUserPower = params => {
-  return axios({
-    url: 'yyuser/save',
-    data: params,
-    method: 'POST'
-  })
-}
-
-// 获取角色列表接口
-export const getRoleList = params => {
-  return axios({
-    url: 'yyrole/findAll',
-    data: params,
-    method: 'POST'
-  })
-}

+ 3 - 3
src/api/data.js

@@ -2,14 +2,14 @@ import { axios } from '@/utils/request'
 
 
 export function login (parameter) {
 export function login (parameter) {
   return axios({
   return axios({
-    url: '/login',
+    url: '/auth/login',
     method: 'post',
     method: 'post',
     data: parameter
     data: parameter
   })
   })
 }
 }
 
 
 export const listLookUp = params => {
 export const listLookUp = params => {
-  let url = `/lookup/queryLike`
+  const url = `/lookup/queryLike`
   return axios({
   return axios({
     url: url,
     url: url,
     data: params,
     data: params,
@@ -18,7 +18,7 @@ export const listLookUp = params => {
 }
 }
 
 
 export const getLookUpData = (params) => {
 export const getLookUpData = (params) => {
-  let url = `/lookupItem/query/${params.pageNo}/${params.pageSize}`
+  const url = `/lookupItem/query/${params.pageNo}/${params.pageSize}`
   delete params.pageNo
   delete params.pageNo
   delete params.pageSize
   delete params.pageSize
   return axios({
   return axios({

+ 3 - 3
src/api/index.js

@@ -1,6 +1,6 @@
 const api = {
 const api = {
-  Login: '/login',
-  Logout: '/logout',
+  Login: '/auth/login',
+  Logout: '/auth/logout',
   ForgePassword: '/auth/forge-password',
   ForgePassword: '/auth/forge-password',
   Register: '/auth/register',
   Register: '/auth/register',
   twoStepCode: '/auth/2step-code',
   twoStepCode: '/auth/2step-code',
@@ -9,4 +9,4 @@ const api = {
   // get my info
   // get my info
   UserInfo: '/user/info'
   UserInfo: '/user/info'
 }
 }
-export default api
+export default api

+ 5 - 6
src/api/login.js

@@ -3,16 +3,15 @@ import { axios } from '@/utils/request'
 
 
 export function login ({ username, password }) {
 export function login ({ username, password }) {
   return axios({
   return axios({
-    url: 'login',
-    headers: { 'content-type': 'application/x-www-form-urlencoded', 'App-Type': 9 },
-    data: `username=${username}&password=${password}`,
+    url: 'auth/login',
+    data: { username, password },
     method: 'post'
     method: 'post'
-  }).then(res => res.data)
+  })
 }
 }
 
 
 export function logout () {
 export function logout () {
   return axios({
   return axios({
-    url: 'logout',
+    url: 'auth/logout',
     method: 'get'
     method: 'get'
   })
   })
 }
 }
@@ -57,7 +56,7 @@ export function get2step (parameter) {
 // 修改密码
 // 修改密码
 export function changePwd (parameter) {
 export function changePwd (parameter) {
   return axios({
   return axios({
-    url: 'user/changePWD',
+    url: '/user/changePWD',
     method: 'post',
     method: 'post',
     data: parameter
     data: parameter
   })
   })

+ 12 - 12
src/config/router.config.js

@@ -51,8 +51,8 @@ export const asyncRouterMap = [{
     component: PageView,
     component: PageView,
     meta: {
     meta: {
       title: '套餐销售',
       title: '套餐销售',
-      icon: 'snippets',
-      permission: 'M_order_0'
+      icon: 'snippets'
+      // permission: 'M_order_0'
     },
     },
     children: [{
     children: [{
       path: '/SetmealSales/VerificationRecords',
       path: '/SetmealSales/VerificationRecords',
@@ -106,8 +106,8 @@ export const asyncRouterMap = [{
     component: PageView,
     component: PageView,
     meta: {
     meta: {
       title: '运营平台权限管理',
       title: '运营平台权限管理',
-      icon: 'apartment',
-      permission: 'M_yyAuth_0'
+      icon: 'apartment'
+      // permission: 'M_yyAuth_0'
     },
     },
     children: [
     children: [
       {
       {
@@ -116,8 +116,8 @@ export const asyncRouterMap = [{
         component: () => import(/* webpackChunkName: "auth" */ '@/views/power/user/userList.vue'),
         component: () => import(/* webpackChunkName: "auth" */ '@/views/power/user/userList.vue'),
         meta: {
         meta: {
           title: '用户管理',
           title: '用户管理',
-          icon: 'user',
-          permission: 'M_auth_yyUser'
+          icon: 'user'
+          // permission: 'M_auth_yyUser'
         }
         }
       },
       },
       {
       {
@@ -126,8 +126,8 @@ export const asyncRouterMap = [{
         component: () => import(/* webpackChunkName: "auth" */ '@/views/power/role/roleList.vue'),
         component: () => import(/* webpackChunkName: "auth" */ '@/views/power/role/roleList.vue'),
         meta: {
         meta: {
           title: '角色管理',
           title: '角色管理',
-          icon: 'solution',
-          permission: 'M_auth_yyRole'
+          icon: 'solution'
+          // permission: 'M_auth_yyRole'
         }
         }
       }
       }
     ]
     ]
@@ -138,8 +138,8 @@ export const asyncRouterMap = [{
     component: PageView,
     component: PageView,
     meta: {
     meta: {
       title: '系统设置',
       title: '系统设置',
-      icon: 'setting',
-      permission: 'M_setting_0'
+      icon: 'setting'
+      // permission: 'M_setting_0'
     },
     },
     children: [{
     children: [{
       path: '/setting/dataDictionary',
       path: '/setting/dataDictionary',
@@ -148,8 +148,8 @@ export const asyncRouterMap = [{
         '@/views/power/dataDictionary/dataDictionary.vue'),
         '@/views/power/dataDictionary/dataDictionary.vue'),
       meta: {
       meta: {
         title: '数据字典管理',
         title: '数据字典管理',
-        icon: 'database',
-        permission: 'M_sys_dataDictionary'
+        icon: 'database'
+        // permission: 'M_sys_dataDictionary'
       }
       }
     }
     }
       // 暂时屏蔽,后期可能需要
       // 暂时屏蔽,后期可能需要

+ 44 - 14
src/store/modules/user.js

@@ -36,25 +36,55 @@ const user = {
 
 
   actions: {
   actions: {
     // 登录
     // 登录
+    // Login ({ commit }, userInfo) {
+    //   console.log(userInfo, 'userInfo----')
+    //   return new Promise((resolve, reject) => {
+    //     login(userInfo).then(res => {
+    //       console.log(res, 'login success')
+    //       if (res && res.userid) {
+    //         Vue.ls.set('hasError', 0)
+    //         commit('SET_TOKEN', res.userid)
+    //         commit('SET_NAME', { name: res.userNameCN, welcome: welcome() })
+    //         commit('SET_AVATAR', res.avatar ? res.avatar : '')
+    //         Vue.ls.set('rolesAccess', { permissionList: res.permCodes }, 7 * 24 * 60 * 60 * 1000)
+    //         // 记住密码
+    //         if (userInfo.rememberMe) {
+    //           VueCookies.set('REMEMBER_ME', JSON.stringify(userInfo))
+    //         } else {
+    //           VueCookies.remove('REMEMBER_ME')
+    //         }
+    //       }
+    //       resolve()
+    //     }).catch(error => {
+    //       reject(error)
+    //     })
+    //   })
+    // },
     Login ({ commit }, userInfo) {
     Login ({ commit }, userInfo) {
       console.log(userInfo, 'userInfo----')
       console.log(userInfo, 'userInfo----')
       return new Promise((resolve, reject) => {
       return new Promise((resolve, reject) => {
-        login(userInfo).then(res => {
-          console.log(res, 'login success')
-          if (res && res.userid) {
-            Vue.ls.set('hasError', 0)
-            commit('SET_TOKEN', res.userid)
-            commit('SET_NAME', { name: res.userNameCN, welcome: welcome() })
-            commit('SET_AVATAR', res.avatar ? res.avatar : '')
-            Vue.ls.set('rolesAccess', { permissionList: res.permCodes }, 7 * 24 * 60 * 60 * 1000)
-            // 记住密码
-            if (userInfo.rememberMe) {
-              VueCookies.set('REMEMBER_ME', JSON.stringify(userInfo))
-            } else {
-              VueCookies.remove('REMEMBER_ME')
+        login(userInfo).then(ret => {
+          console.log(ret, 'login success')
+          if (ret.status == 200) {
+            const res = ret.data
+            if (res.access_token && res.auth_user) {
+              const users = res.auth_user
+              Vue.ls.set('hasError', 0)
+              commit('SET_TOKEN', res.access_token)
+              commit('SET_NAME', { name: users.userNameCN, welcome: welcome() })
+              Vue.ls.set('rolesAccess', { permissionList: users.permCodes }, 7 * 24 * 60 * 60 * 1000)
+              commit('SET_AVATAR', res.avatar ? res.avatar : '')
+              // 记住密码
+              if (userInfo.rememberMe) {
+                VueCookies.set('REMEMBER_ME', JSON.stringify(userInfo))
+              } else {
+                VueCookies.remove('REMEMBER_ME')
+              }
             }
             }
+            resolve(res)
+          } else {
+            reject(ret)
           }
           }
-          resolve()
         }).catch(error => {
         }).catch(error => {
           reject(error)
           reject(error)
         })
         })

+ 29 - 28
src/utils/request.js

@@ -1,10 +1,11 @@
-import Vue from 'vue'
+// import Vue from 'vue'
 import axios from 'axios'
 import axios from 'axios'
 import store from '@/store'
 import store from '@/store'
 import notification from 'ant-design-vue/es/notification'
 import notification from 'ant-design-vue/es/notification'
+import modal from 'ant-design-vue/es/modal'
 import { VueAxios } from './axios'
 import { VueAxios } from './axios'
-import { ACCESS_TOKEN } from '@/store/mutation-types'
-console.log(process.env.VUE_APP_PRO_NAME)
+// import { ACCESS_TOKEN } from '@/store/mutation-types'
+// console.log(process.env.VUE_APP_PRO_NAME)
 // 创建 axios 实例
 // 创建 axios 实例
 const service = axios.create({
 const service = axios.create({
   baseURL: process.env.VUE_APP_API_BASE_URL, // api base_url
   baseURL: process.env.VUE_APP_API_BASE_URL, // api base_url
@@ -12,19 +13,15 @@ const service = axios.create({
 })
 })
 
 
 const err = (error) => {
 const err = (error) => {
+  console.log(error.response.data.message, 'error')
   if (error.response) {
   if (error.response) {
-    const data = error.response.data
-    if ((error.response.status == 403 || error.response.status == 401) && window.location.pathname != '/user/login') {
+    const status = error.response.status
+    if ((status == 503 || status == 500) && window.location.pathname != '/user/login') {
       notification.destroy()
       notification.destroy()
       notification.error({
       notification.error({
         message: '提示',
         message: '提示',
-        description: data.message
+        description: error.response.data.message
       })
       })
-      setTimeout(function () {
-        store.dispatch('Logout').then(() => {
-          window.location.reload()
-        })
-      }, 2000)
     }
     }
   }
   }
   // 超时无法访问服务
   // 超时无法访问服务
@@ -32,47 +29,51 @@ const err = (error) => {
     notification.destroy()
     notification.destroy()
     notification.error({
     notification.error({
       message: '提示',
       message: '提示',
-      description: error.message
+      description: '请求超时'
     })
     })
-    setTimeout(function () {
-      store.dispatch('Logout').then(() => {
-        window.location.reload()
-      })
-    }, 2000)
   }
   }
   return Promise.reject(error)
   return Promise.reject(error)
 }
 }
 
 
 // request interceptor
 // request interceptor
 service.interceptors.request.use(config => {
 service.interceptors.request.use(config => {
-  const token = Vue.ls.get(ACCESS_TOKEN)
+  const token = store.getters.token
+  config.headers['App-Type'] = 8 // 平台类型
   if (token) {
   if (token) {
-    // config.headers['Access-Token'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
+    config.headers['access-token'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
   }
   }
   return config
   return config
 }, err)
 }, err)
 
 
 // response interceptor
 // response interceptor
 service.interceptors.response.use((response) => {
 service.interceptors.response.use((response) => {
-  console.log(response, response.data.status, 'responseresponseresponse')
+  console.log(response, 'response.data.status')
   if (window.location.pathname != '/user/login') {
   if (window.location.pathname != '/user/login') {
-    if (response.data.status == '900') {
+    if (response.data.status == '500') {
       notification.destroy()
       notification.destroy()
       notification.error({
       notification.error({
         message: '提示',
         message: '提示',
         description: response.data.message
         description: response.data.message
       })
       })
     }
     }
-  } else {
-    if (response.data.status == '500') {
-      notification.destroy()
-      notification.error({
-        message: '提示',
-        description: response.data.message
+    const et = sessionStorage.getItem('errorTips')
+    if (response.data.status.length == 4 && !et) {
+      sessionStorage.setItem('errorTips', 1)
+      modal.destroyAll()
+      modal.error({
+        title: '提示',
+        content: response.data.message,
+        onOk () {
+          sessionStorage.setItem('errorTips', 0)
+          if (['1001', '1002', '1006', '1099', '1100', '9000'].indexOf(response.data.status) >= 0) {
+            store.dispatch('Logout').then(() => {
+              window.location.reload()
+            })
+          }
+        }
       })
       })
     }
     }
   }
   }
-
   return response.data
   return response.data
 }, err)
 }, err)
 
 

+ 1 - 0
src/views/SetmealSales/PurchasedSetmeal.vue

@@ -255,6 +255,7 @@ export default {
         customerMobile: this.searchForm.customerMobile,
         customerMobile: this.searchForm.customerMobile,
         orderStatus: this.searchForm.orderStatus
         orderStatus: this.searchForm.orderStatus
       }
       }
+      // 判断两个时间段是否相差m个月
       if (!completeDate(params.beginDate, params.endDate, 3)) {
       if (!completeDate(params.beginDate, params.endDate, 3)) {
         this.$message.error('单次最多只能导出3个月的数据,请缩小查询区间后再进行导出!')
         this.$message.error('单次最多只能导出3个月的数据,请缩小查询区间后再进行导出!')
         return
         return

+ 1 - 1
vue.config.js

@@ -109,7 +109,7 @@ const vueConfig = {
     proxy: {
     proxy: {
       '/api': {
       '/api': {
         // target: 'http://carwash.test.zyucgj.com/cw-admin/',
         // target: 'http://carwash.test.zyucgj.com/cw-admin/',
-        target: 'http://192.168.16.102:8101/cw-admin/',
+        target: 'http://192.168.16.103:8081/zyyc-channel/',
         // target: 'https://carwash.test.zyucgj.com/cw-admin/',
         // target: 'https://carwash.test.zyucgj.com/cw-admin/',
         ws: false,
         ws: false,
         changeOrigin: true,
         changeOrigin: true,