diff --git a/smart-admin-h5/.env.development b/smart-admin-h5/.env.development index 38de0149..b698907c 100644 --- a/smart-admin-h5/.env.development +++ b/smart-admin-h5/.env.development @@ -1,4 +1,3 @@ NODE_ENV = development VUE_APP_ENV = dev -VUE_APP_URL = http://127.0.0.1:10086/smart-admin-api/ - +VUE_APP_URL = http://127.0.0.1:10086/smart-admin-api diff --git a/smart-admin-h5/.env.local b/smart-admin-h5/.env.local index e1aa3c0e..6d07d04c 100644 --- a/smart-admin-h5/.env.local +++ b/smart-admin-h5/.env.local @@ -1,3 +1,3 @@ NODE_ENV = development VUE_APP_ENV = local -VUE_APP_URL=http://127.0.0.1:10086/smart-admin-api/ +VUE_APP_URL = http://127.0.0.1:10086/smart-admin-api diff --git a/smart-admin-h5/.env.pre b/smart-admin-h5/.env.pre index b22ff885..80c46b0e 100644 --- a/smart-admin-h5/.env.pre +++ b/smart-admin-h5/.env.pre @@ -1,3 +1,3 @@ NODE_ENV = production VUE_APP_ENV = pre -VUE_APP_URL = http://smartadmin.1024lab.net/api/ +VUE_APP_URL = http://smartadmin.1024lab.net/smart-admin-api diff --git a/smart-admin-h5/.env.prod b/smart-admin-h5/.env.prod index 1f390bca..0e1616d4 100644 --- a/smart-admin-h5/.env.prod +++ b/smart-admin-h5/.env.prod @@ -1,3 +1,3 @@ NODE_ENV = production VUE_APP_ENV = prod -VUE_APP_URL = http://smartadmin.1024lab.net/api/ +VUE_APP_URL = http://smartadmin.1024lab.net/smart-admin-api diff --git a/smart-admin-h5/.env.sit b/smart-admin-h5/.env.sit index f0b82667..411bc968 100644 --- a/smart-admin-h5/.env.sit +++ b/smart-admin-h5/.env.sit @@ -1,3 +1,3 @@ NODE_ENV = production VUE_APP_ENV = sit -VUE_APP_URL=http://127.0.0.1:10086/smart-admin-api/ +VUE_APP_URL = http://smartadmin.1024lab.net/smart-admin-api diff --git a/smart-admin-h5/.postcssrc.js b/smart-admin-h5/.postcssrc.js index 6483e7ba..e2783a57 100644 --- a/smart-admin-h5/.postcssrc.js +++ b/smart-admin-h5/.postcssrc.js @@ -1,4 +1,3 @@ -// 详情请看 https://github.com/michael-ciniawsky/postcss-load-config module.exports = { plugins: { autoprefixer: { diff --git a/smart-admin-h5/.sentryclirc b/smart-admin-h5/.sentryclirc index b676dbde..b6f61dbd 100644 --- a/smart-admin-h5/.sentryclirc +++ b/smart-admin-h5/.sentryclirc @@ -1,7 +1,7 @@ [defaults] url = https://sentry.1024lab.net/ -org = 1024lab +org = 1024lab-sentry project = smart-admin-h5 [auth] -token = 8bab45b9152d44b19d4e0a762a93dd34a1318ee8317f46a0a007c48da0e9888e +token = 8dflijsldjkasdo3u49230948pkjdasoia8023jl3k4jr29o81029i40534p545ke diff --git a/smart-admin-h5/README.en.md b/smart-admin-h5/README.en.md deleted file mode 100644 index 5f55837d..00000000 --- a/smart-admin-h5/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# ren-min-yi-xue-manage-h5 - -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/smart-admin-h5/README.md b/smart-admin-h5/README.md index cdc9d586..c5f8fa10 100644 --- a/smart-admin-h5/README.md +++ b/smart-admin-h5/README.md @@ -1,39 +1,4 @@ -# ren-min-yi-xue-manage-h5 +# SmartAdmin-H5 #### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} - -#### 软件架构 -软件架构说明 - - -#### 安装教程 - -1. xxxx -2. xxxx -3. xxxx - -#### 使用说明 - -1. xxxx -2. xxxx -3. xxxx - -#### 参与贡献 - -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request - - -#### 特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +SmartAdmin-H5 是SmartAdmin 平台的移动端web项目 diff --git a/smart-admin-h5/package.json b/smart-admin-h5/package.json index 9efbc94d..cd09ecb3 100644 --- a/smart-admin-h5/package.json +++ b/smart-admin-h5/package.json @@ -1,7 +1,7 @@ { "name": "smart-admin-h5", "version": "1.0.0", - "description": "基于Smart-H5的SmartAdmin的H5端", + "description": "基于vue和vant的h5模板", "author": "zhuoluodada@qq.com", "private": true, "scripts": { @@ -26,12 +26,12 @@ "moment": "^2.29.0", "nprogress": "^0.2.0", "regenerator-runtime": "^0.13.5", - "vant": "^2.10.2", - "vue": "^2.6.11", + "vant": "^2.11.1", + "vue": "^2.6.12", "vue-enum": "^1.0.5", "vue-loading-overlay": "^3.4.2", - "vue-router": "^3.2.0", - "vuex": "^3.4.0" + "vue-router": "^3.4.0", + "vuex": "^3.6.0" }, "devDependencies": { "@sentry/webpack-plugin": "^1.11.1", @@ -46,15 +46,13 @@ "compression-webpack-plugin": "^3.1.0", "eslint": "^6.7.2", "eslint-plugin-vue": "^6.2.2", - "less": "^3.11.2", - "less-loader": "^6.1.0", "node-sass": "^4.14.1", "postcss-pxtorem": "^5.1.1", - "sass-loader": "^8.0.2", - "script-ext-html-webpack-plugin": "^2.1.4", + "sass": "^1.3.0", + "sass-loader": "^9.0.3", + "script-ext-html-webpack-plugin": "^2.1.5", "uglifyjs-webpack-plugin": "^2.2.0", - "vconsole": "^3.3.4", - "vue-template-compiler": "^2.6.11", - "webpack-bundle-analyzer": "^3.8.0" + "vue-template-compiler": "^2.6.12", + "webpack-bundle-analyzer": "^4.2.0" } } diff --git a/smart-admin-h5/src/App.vue b/smart-admin-h5/src/App.vue index 3f407985..f3b5bda4 100644 --- a/smart-admin-h5/src/App.vue +++ b/smart-admin-h5/src/App.vue @@ -8,7 +8,7 @@ export default { name: 'App' }; - diff --git a/smart-admin-h5/src/components/employee/department-employee-selector.vue b/smart-admin-h5/src/components/employee/department-employee-selector.vue index 3affe14f..7889136a 100644 --- a/smart-admin-h5/src/components/employee/department-employee-selector.vue +++ b/smart-admin-h5/src/components/employee/department-employee-selector.vue @@ -1,6 +1,7 @@ /** * @description:department-employee-selector * @author: zhuoda +* @date: 2020/10/30 13:56 */ diff --git a/smart-admin-h5/src/views/main/main-mixin.js b/smart-admin-h5/src/components/mixin/session-mixin.js similarity index 77% rename from smart-admin-h5/src/views/main/main-mixin.js rename to smart-admin-h5/src/components/mixin/session-mixin.js index ed3bc0e4..94026bb0 100644 --- a/smart-admin-h5/src/views/main/main-mixin.js +++ b/smart-admin-h5/src/components/mixin/session-mixin.js @@ -2,8 +2,8 @@ import cookie from '@/lib/cookie'; import { userApi } from 'api/user'; /** - * 此 mixin为登录以后的页面用的,因为所有的有效路由(排除登录、注册、404,500 这个几个特殊页面)都会走 other-main 或者 tabber-main两个父级组件。 - * 所以对于一些session的信息获取只能放到这个两个main组件上,故此mixin只用于两个main组件,起到全局的作用 + * 此 mixin为登录以后的页面用的,因为所有的有效路由(排除登录、注册、404,500 这个几个特殊页面)都会走 App.vue里的router + * @author zhuoda */ export default { created: function() { diff --git a/smart-admin-h5/src/config/index.js b/smart-admin-h5/src/config/index.js index 472fcc6e..dafb4212 100644 --- a/smart-admin-h5/src/config/index.js +++ b/smart-admin-h5/src/config/index.js @@ -12,12 +12,14 @@ module.exports = { */ baseUrl: { apiUrl: process.env.VUE_APP_URL, + erpApiUrl: process.env.VUE_APP_ERP_URL, + webSocketUrl: process.env.VUE_APP_SOCKET_URL }, /** * 打包后静态资源地址;如果是走cdn的话,可以配置如下: * publicPath: isProd ? 'https://cdn.1024lab.net/static/smart-h5/' : '/' */ - publicPath: isProductionEnv ? '/smart-admin-h5/' : '/', + publicPath: isProductionEnv ? '/manage-h5/' : '/', // ==================== cdn 相关 begin ==================== cdn: { diff --git a/smart-admin-h5/src/constants/erp/contact-company.js b/smart-admin-h5/src/constants/erp/contact-company.js new file mode 100644 index 00000000..b3730d9b --- /dev/null +++ b/smart-admin-h5/src/constants/erp/contact-company.js @@ -0,0 +1,165 @@ +/** + * 往来单位性质 + * @type {{ENTERPRISE: {value: number, desc: string}, PERSONAL: {value: number, desc: string}}} + */ +export const CONTACT_COMPANY_NATURE_ENUM = + { + ENTERPRISE: { + value: 0, + desc: '企业' + }, + PERSONAL: { + value: 1, + desc: '个人' + } + }; +/** + * 往来机构类型 + * @type {{CUSTOMER: {value: number, desc: string}, SUPPLIER: {value: number, desc: string}}} + */ +export const + CONTACT_COMPANY_TYPE_ENUM = + { + CUSTOMER: { + value: 0, + desc: '客户' + }, + SUPPLIER: { + value: 1, + desc: '供应商' + }, + SCHOOL: { + value: 2, + desc: '分校' + }, + COOPERATIVE_ORG: { + value: 3, + desc: '合作机构' + } + }; + +/** + * 付款方式 + * @type {{BANK: {value: number, desc: string}, ZHI_FU_BAO: {value: number, desc: string}, WE_CHAT: {value: number, desc: string}}} + */ +export const + PAYMENT_TYPE_ENUM = + { + BANK: { + value: 0, + desc: '银行卡' + }, + WE_CHAT: { + value: 1, + desc: '微信' + }, + ZHI_FU_BAO: { + value: 2, + desc: '支付宝' + } + }; + +/** + * 往来机构余额类型 + * @type {{RECEIVE_BALANCE: {value: number, desc: string}, PAY_BALANCE: {value: number, desc: string}}} + */ +export const + CONTACT_COMPANY_BALANCE_TYPE = + { + PAY_BALANCE: { + value: 0, + desc: '应付款余额' + }, + RECEIVE_BALANCE: { + value: 1, + desc: '应收款余额' + } + }; + +/** + * 往来单位等级 + * @type {{CORE: {value: number, desc: string}, POTENTIAL: {value: number, desc: string}, BAD: {value: number, desc: string}, GENERAL: {value: number, desc: string}}} + */ +export const CONTACT_COMPANY_GRADE_ENUM = { + CORE: { + value: 1, + desc: '核心', + color: 'green' + }, + POTENTIAL: { + value: 2, + desc: '有潜力', + color: 'cyan' + }, + GENERAL: { + value: 3, + desc: '普通', + color: 'blue' + }, + BAD: { + value: 4, + desc: '较差', + color: 'purple' + } +}; + +/** + * 往来单位等级 + * @type {{OWNER: {value: number, desc: string}, SHARER: {value: number, desc: string}, COMMON: {value: number, desc: string}}} + */ +export const CONTACT_COMPANY_SHARE_TYPE_ENUM = { + OWNER: { + value: 0, + desc: '属于我的' + }, + SHARER: { + value: 1, + desc: '共享的' + }, + COMMON: { + value: 2, + desc: '公共的' + } +}; + +/** + * 往来单位标签 + * @type {{OWNER: {value: number, desc: string}, SHARER: {value: number, desc: string}, COMMON: {value: number, desc: string}}} + */ +export const CONTACT_COMPANY_TAG_ENUM = { + POTENTIAL: { + value: 0, + desc: '潜在', + color: 'green' + }, + INTENTION: { + value: 1, + desc: '意向', + color: 'cyan' + }, + NEGOTIATION: { + value: 2, + desc: '洽谈', + color: 'blue' + }, + DEAL: { + value: 3, + desc: '成交', + color: 'geekblue' + }, + LOSS: { + value: 4, + desc: '流失', + color: 'red' + } +}; + +export default { + CONTACT_COMPANY_NATURE_ENUM, + CONTACT_COMPANY_TYPE_ENUM, + PAYMENT_TYPE_ENUM, + CONTACT_COMPANY_BALANCE_TYPE, + CONTACT_COMPANY_GRADE_ENUM, + CONTACT_COMPANY_SHARE_TYPE_ENUM, + CONTACT_COMPANY_TAG_ENUM +}; diff --git a/smart-admin-h5/src/constants/erp/index.js b/smart-admin-h5/src/constants/erp/index.js new file mode 100644 index 00000000..b14cb861 --- /dev/null +++ b/smart-admin-h5/src/constants/erp/index.js @@ -0,0 +1,6 @@ +import contactCompany from './contact-company'; + +export default { + ...contactCompany +}; + diff --git a/smart-admin-h5/src/constants/index.js b/smart-admin-h5/src/constants/index.js index fe01d2fd..384b7029 100644 --- a/smart-admin-h5/src/constants/index.js +++ b/smart-admin-h5/src/constants/index.js @@ -1,5 +1,7 @@ -import file from './file'; +import school from '@/constants/school'; +import erp from './erp'; export default { - ...file, + ...school, + ...erp }; diff --git a/smart-admin-h5/src/constants/school.js b/smart-admin-h5/src/constants/school.js new file mode 100644 index 00000000..aa69bd01 --- /dev/null +++ b/smart-admin-h5/src/constants/school.js @@ -0,0 +1,71 @@ +/** + * 分校标签 + */ +export const SCHOOL_TAG_ENUM = { + POTENTIAL: { + value: 0, + desc: '潜在' + }, + INTENTION: { + value: 1, + desc: '意向' + }, + NEGOTIATION: { + value: 2, + desc: '洽谈' + }, + DEAL: { + value: 3, + desc: '成交' + }, + LOSS: { + value: 4, + desc: '流失' + } +}; + +/** + * 分校等级 + */ +export const SCHOOL_GRADE_ENUM = { + CORE: { + value: 1, + desc: '核心' + }, + POTENTIAL: { + value: 2, + desc: '有潜力' + }, + GENERAL: { + value: 3, + desc: '普通' + }, + BAD: { + value: 4, + desc: '较差' + } +}; + +/** + * 共享类型 + */ +export const SCHOOL_SHARE_TYPE_ENUM = { + OWNER: { + value: 0, + desc: '属于我的' + }, + SHARER: { + value: 1, + desc: '共享的' + }, + COMMON: { + value: 2, + desc: '公共的' + } +}; + +export default { + SCHOOL_TAG_ENUM, + SCHOOL_GRADE_ENUM, + SCHOOL_SHARE_TYPE_ENUM +}; diff --git a/smart-admin-h5/src/lib/erp-http.js b/smart-admin-h5/src/lib/erp-http.js new file mode 100644 index 00000000..3f4766f8 --- /dev/null +++ b/smart-admin-h5/src/lib/erp-http.js @@ -0,0 +1,65 @@ +import Axios from 'axios'; +import config from '@/config'; +import cookie from '@/lib/cookie'; +import { Toast } from 'vant'; + +export const baseUrl = config.baseUrl.erpApiUrl; + +const axios = Axios.create({ + baseURL: baseUrl, + timeout: 30000, + headers: { + 'Content-Type': 'application/json; charset=utf-8' + } +}); + +// 添加请求拦截器 +axios.interceptors.request.use( + function(config) { + const token = cookie.getToken(); + if (token) { + config.headers['x-access-token'] = token; + } + return config; + }, + function(error) { + return Promise.reject(error); + } +); + +// 添加响应拦截器 +axios.interceptors.response.use( + res => { + const { data } = res; + if (data && data.code && data.code !== 1) { + if (data.code === 121) { + cookie.clearToken(); + localStorage.clear(); + window.location.href = window.location.pathname + '#/login'; + Toast.fail('未登录,或登录失效,请登录'); + return; + } else if (data.code === 502) { + window.location.href = window.location.pathname + '#/500'; + return; + } else { + Toast.fail(data.msg); + return Promise.reject(res); + } + } + return Promise.resolve(data); + }, + error => { + Toast.fail('服务内部错误'); + return Promise.reject(error); + } +); + +export const postAxios = (url, data, config) => { + return axios.post(url, data, config); +}; + +export const getAxios = (url, data) => { + return axios.get(url, { + params: data + }); +}; diff --git a/smart-admin-h5/src/lib/smart-sentry.js b/smart-admin-h5/src/lib/smart-sentry.js index d7bf5bbc..2ccd8f0a 100644 --- a/smart-admin-h5/src/lib/smart-sentry.js +++ b/smart-admin-h5/src/lib/smart-sentry.js @@ -1,6 +1,9 @@ /* * @Description: - * @Author: zhuoda + * @Author: hanyu + * @Date: 2020-05-28 12:46:06 + * @LastEditTime: 2020-07-08 09:16:15 + * @LastEditors: hy */ // smart sentry import * as Sentry from '@sentry/browser'; diff --git a/smart-admin-h5/src/lib/table-action.js b/smart-admin-h5/src/lib/table-action.js deleted file mode 100644 index f9a541fc..00000000 --- a/smart-admin-h5/src/lib/table-action.js +++ /dev/null @@ -1,84 +0,0 @@ -// 处理table操作按钮 -const tableAction = (h, array) => { - let btnArray = []; - let btnMore = []; - array.map((item, index) => { - if (index < 2) { - let btn = h( - 'a', - { - props: { - type: !index ? 'primary' : 'info', - size: 'small', - to: item.to ? item.to : '', - target: item.target ? item.target : '_self', - ghost: true - }, - style: { - marginLeft: '5px' - }, - directives: item.directives, - on: { - click: item.action - } - }, - item.title - ); - btnArray.push(btn); - } else { - btnMore.push( - h( - 'DropdownItem', - { - nativeOn: { - click: item.action - } - }, - item.title - ) - ); - } - }); - let dropdown = h( - 'Dropdown', - { - props: { - transfer: true - } - }, - [ - h( - 'a', - { - props: { - type: 'default', - size: 'small' - }, - style: { - marginLeft: '5px' - } - }, - [ - h('span', '更多'), - h('Icon', { - props: { - type: 'ios-arrow-down' - } - }) - ] - ), - h( - 'DropdownMenu', - { - slot: 'list' - }, - btnMore - ) - ] - ); - if (array.length > 2) { - btnArray.push(dropdown); - } - return btnArray; -}; -export default tableAction; diff --git a/smart-admin-h5/src/main.js b/smart-admin-h5/src/main.js index 8f6fbae9..887c9198 100644 --- a/smart-admin-h5/src/main.js +++ b/smart-admin-h5/src/main.js @@ -12,7 +12,7 @@ import 'vant/lib/index.css'; // 引入首个组件 import App from './App.vue'; // 引入自定义主题样式 -import './themes/index.less'; +import './themes/index.scss'; // 引入过滤器 import './filters'; // 引入配置信息 diff --git a/smart-admin-h5/src/router/dashboard/index.js b/smart-admin-h5/src/router/dashboard/index.js new file mode 100644 index 00000000..69506bbe --- /dev/null +++ b/smart-admin-h5/src/router/dashboard/index.js @@ -0,0 +1,42 @@ +import { ROUTER_PERMISSION_TYPE } from '@/router/router-const'; + +/** + * dashboard首页 + */ +export const dashboardRouter = [ + { + path: '/', + // redirect: '/dashboard/contact-company', + redirect: '/dashboard/user', + meta: { + title: '首页', + keepAlive: true, + permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value + }, + component: () => import('@/views/dashboard/dashboard'), + children: [ + // { + // path: '/dashboard/contact-company', + // name: 'ContactCompany', + // meta: { + // title: '往来单位', + // keepAlive: true, + // showTabbar: true, + // permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value + // }, + // component: () => import('@/views/erp/contact-company/contact-company') + // }, + { + path: '/dashboard/user', + name: 'Mine', + meta: { + title: '我的', + keepAlive: false, + showTabbar: true, + permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value + }, + component: () => import('@/views/user/index') + } + ] + } +]; diff --git a/smart-admin-h5/src/router/develop/develop.js b/smart-admin-h5/src/router/develop/develop.js new file mode 100644 index 00000000..a3220405 --- /dev/null +++ b/smart-admin-h5/src/router/develop/develop.js @@ -0,0 +1,21 @@ +import { ROUTER_PERMISSION_TYPE } from '@/router/router-const'; + +export const developRouter = [ + { + path: '/develop', + component: () => import('@/views/dashboard/dashboard'), + children: [ + { + path: '/develop/config', + name: 'DevelopConfig', + meta: { + title: '开发专用配置', + permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value + }, + component: () => import('views/develop/config') + } + ] + } + +]; + diff --git a/smart-admin-h5/src/router/other/error.js b/smart-admin-h5/src/router/error/error.js similarity index 51% rename from smart-admin-h5/src/router/other/error.js rename to smart-admin-h5/src/router/error/error.js index cf333cf8..982c0f96 100644 --- a/smart-admin-h5/src/router/other/error.js +++ b/smart-admin-h5/src/router/error/error.js @@ -1,7 +1,7 @@ // 错误页 import { ROUTER_PERMISSION_TYPE } from '@/router/router-const'; -export const error = [ +export const errorRouter = [ { path: '/404', name: 'Error404', @@ -10,7 +10,7 @@ export const error = [ access: true, permissionType: ROUTER_PERMISSION_TYPE.NO_VALID.value }, - component: () => import('@/views/error/404.vue') + component: () => import('views/error/404.vue') }, { path: '/500', @@ -21,17 +21,6 @@ export const error = [ noValidatePrivilege: true, permissionType: ROUTER_PERMISSION_TYPE.NO_VALID.value }, - component: () => import('@/views/error/404.vue') - }, - { - path: '*', - name: 'http://localhost:8080/#employee/role-employee-manage', - meta: { - hideInMenu: true, - access: true, - noValidatePrivilege: true, - permissionType: ROUTER_PERMISSION_TYPE.NO_VALID.value - }, - component: () => import('@/views/error/404.vue') + component: () => import('views/error/404.vue') } ]; diff --git a/smart-admin-h5/src/router/index.js b/smart-admin-h5/src/router/index.js index 5494b7c6..c47e1a4a 100644 --- a/smart-admin-h5/src/router/index.js +++ b/smart-admin-h5/src/router/index.js @@ -10,6 +10,10 @@ const projectConfig = require('@/config/index.js'); Vue.use(Router); +/** + * 导入所有的router + * @type {VueRouter} + */ const router = new Router({ routes: routers }); @@ -27,6 +31,8 @@ Router.prototype.push = function(location) { const LOGIN_PAGE_NAME = 'Login'; +// --------------------- router 守卫 begin --------------------- + router.beforeEach((to, from, next) => { // 加载进度条 NProgress.start(); @@ -77,6 +83,19 @@ router.afterEach(to => { } }); +// --------------------- router 守卫 end --------------------- + +/** + * router 检测 + * + * 如果存在相同的 path 或者 name 是一件非常恐怖的事情,所以在develop环境将所有router进行一次遍历 + * 检测内容如下: + * 1、相同的router name + * 2、相同的router name + * 3、path没有以 / 开头 + * + */ + const tempCheckObj = { checkRouterNameMap: new Map(), checkRouterPathMap: new Map() diff --git a/smart-admin-h5/src/router/login/login.js b/smart-admin-h5/src/router/login/login.js new file mode 100644 index 00000000..7c9b6a53 --- /dev/null +++ b/smart-admin-h5/src/router/login/login.js @@ -0,0 +1,15 @@ +import { ROUTER_PERMISSION_TYPE } from '@/router/router-const'; + +export const loginRouter = [ + { + path: '/login', + name: 'Login', + meta: { + title: '登录', + keepAlive: false, + permissionType: ROUTER_PERMISSION_TYPE.NO_VALID.value + }, + component: () => import('@/views/login/login.vue') + } + +]; diff --git a/smart-admin-h5/src/router/other/develop.js b/smart-admin-h5/src/router/other/develop.js deleted file mode 100644 index 5e02ce8f..00000000 --- a/smart-admin-h5/src/router/other/develop.js +++ /dev/null @@ -1,15 +0,0 @@ -import { ROUTER_PERMISSION_TYPE } from '@/router/router-const'; - -export const develop = [ - { - path: '/develop/config', - name: 'DevelopConfig', - meta: { - title: '开发专用配置', - permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value - }, - component: () => - import('@/views/develop/config') - } -]; - diff --git a/smart-admin-h5/src/router/other/index.js b/smart-admin-h5/src/router/other/index.js deleted file mode 100644 index cdf9d3fe..00000000 --- a/smart-admin-h5/src/router/other/index.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * 其他路由 - */ - -import { user } from './user'; -import { ROUTER_PERMISSION_TYPE } from '@/router/router-const'; -import { develop } from '@/router/other/develop'; -import { school } from '@/router/other/school'; -import { contactCompany } from '@/router/other/erp/contact-company'; - -export const otherRouter = [ - { - path: '/other-main', - meta: { - keepAlive: true, - permissionType: ROUTER_PERMISSION_TYPE.NO_VALID.value - }, - component: () => import('views/main/other-main'), - children: [ - ...user, - ...develop, - ...school, - ...contactCompany - ] - }]; diff --git a/smart-admin-h5/src/router/other/school.js b/smart-admin-h5/src/router/other/school.js deleted file mode 100644 index 7ddf5117..00000000 --- a/smart-admin-h5/src/router/other/school.js +++ /dev/null @@ -1,41 +0,0 @@ -import { ROUTER_PERMISSION_TYPE } from '@/router/router-const'; - -export const school = [ - { - path: '/school/detail', - name: 'SchoolDetail', - meta: { - title: '学校详情', - permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value - }, - component: () => import('@/views/crm/school/school-detail') - }, - { - path: '/school/track/add', - name: 'SchoolTrackAdd', - meta: { - title: '学校拜访记录添加', - permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value - }, - component: () => import('@/views/crm/school/add-track') - }, - { - path: '/school/track/detail', - name: 'SchoolTrackDetail', - meta: { - title: '学校拜访记录详情', - permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value - }, - component: () => import('@/views/crm/school/track-detail') - }, - { - path: '/school/update', - name: 'SchoolUpdate', - meta: { - title: '更新学校', - permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value - }, - component: () => import('@/views/crm/school/update-school') - } -]; - diff --git a/smart-admin-h5/src/router/other/user.js b/smart-admin-h5/src/router/other/user.js deleted file mode 100644 index b7ea88ea..00000000 --- a/smart-admin-h5/src/router/other/user.js +++ /dev/null @@ -1,15 +0,0 @@ -import { ROUTER_PERMISSION_TYPE } from '@/router/router-const'; - -export const user = [ - { - path: '/user/change-password', - name: 'UserChangePassword', - meta: { - title: '修改密码', - permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value - }, - component: () => - import('@/views/mine/change-password') - } -]; - diff --git a/smart-admin-h5/src/router/routers.js b/smart-admin-h5/src/router/routers.js index 6dc81893..e1c106e9 100644 --- a/smart-admin-h5/src/router/routers.js +++ b/smart-admin-h5/src/router/routers.js @@ -1,24 +1,32 @@ -import { tabbarRouter } from './tabbar'; -import { otherRouter } from '@/router/other'; -import { error } from './other/error'; -import { ROUTER_PERMISSION_TYPE } from '@/router/router-const'; +// 全局错误页面 +import { errorRouter } from './error/error'; +// 登录注册模块 +import { loginRouter } from './login/login'; +// tabbar dashboard 框架页面 +import { dashboardRouter } from './dashboard'; +// 用户相关 +import { userRouter } from './user/user'; +// 开发相关 +import { developRouter } from './develop/develop'; -// 登录模块 -export const login = { - path: '/login', - name: 'Login', - meta: { - title: '登录', - keepAlive: false, - permissionType: ROUTER_PERMISSION_TYPE.NO_VALID.value - }, - component: () => import('@/views/login/login.vue') -}; - -// 全部路由 +/** + * router meta 说明: + * + * title: 为页面的title,会显示到浏览器的title上 + * permissionType: 具体使用 router-const.js中的 ROUTER_PERMISSION_TYPE 常量;情况有: 1)不验证 2)校验登录 3)登录后校验权限 + * keepAlive: true or false ; 是否进行页面keepalive, 如果想删除keepalive,可以使用vuex中的app module里有mutation + * showTabbar: true or false ; 是否展示 tabbar, 如果是true, 则会展示tabbar + * + */ export const routers = [ - login, - ...tabbarRouter, - ...otherRouter, - ...error + // 登录、注册 + ...loginRouter, + // 404、500、403等 + ...errorRouter, + // tab bar 页面 + ...dashboardRouter, + // 用户 + ...userRouter, + // 开发相关 + ...developRouter ]; diff --git a/smart-admin-h5/src/router/tabbar/index.js b/smart-admin-h5/src/router/tabbar/index.js deleted file mode 100644 index b56b8a8a..00000000 --- a/smart-admin-h5/src/router/tabbar/index.js +++ /dev/null @@ -1,49 +0,0 @@ -import { ROUTER_PERMISSION_TYPE } from '../router-const'; - -/** - * 主要用于 tabbar 的路由 - */ -export const tabbarRouter = [ - { - path: '/', - redirect: '/contact-company', - meta: { - title: '首页', - keepAlive: true, - permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value - }, - component: () => import('views/main/tabbar-main'), - children: [ - { - path: '/home', - name: 'Home', - meta: { - title: '首页', - keepAlive: true, - permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value - }, - component: () => import('@/views/home/index') - }, - { - path: '/business', - name: 'Business', - meta: { - title: '业务中心', - keepAlive: false, - permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value - }, - component: () => import('@/views/business/index') - }, - { - path: '/mine', - name: 'Mine', - meta: { - title: '关于我', - keepAlive: false, - permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value - }, - component: () => import('@/views/mine/index') - } - ] - } -]; diff --git a/smart-admin-h5/src/router/user/user.js b/smart-admin-h5/src/router/user/user.js new file mode 100644 index 00000000..901e5708 --- /dev/null +++ b/smart-admin-h5/src/router/user/user.js @@ -0,0 +1,21 @@ +import { ROUTER_PERMISSION_TYPE } from '@/router/router-const'; + +export const userRouter = [ + { + path: '/user', + component: () => import('@/views/dashboard/dashboard'), + children: [ + { + path: '/user/change-password', + name: 'UserChangePassword', + meta: { + title: '修改密码', + permissionType: ROUTER_PERMISSION_TYPE.NEED_LOGIN.value + }, + component: () => + import('views/user/change-password') + } + ] + } +]; + diff --git a/smart-admin-h5/src/store/index.js b/smart-admin-h5/src/store/index.js index 9e94a45d..11c4962b 100644 --- a/smart-admin-h5/src/store/index.js +++ b/smart-admin-h5/src/store/index.js @@ -2,6 +2,7 @@ import Vue from 'vue'; import Vuex from 'vuex'; import user from './module/user'; +import app from './module/app'; Vue.use(Vuex); @@ -16,6 +17,7 @@ export default new Vuex.Store({ // }, modules: { + app, user } }); diff --git a/smart-admin-h5/src/store/module/app.js b/smart-admin-h5/src/store/module/app.js new file mode 100644 index 00000000..486defe1 --- /dev/null +++ b/smart-admin-h5/src/store/module/app.js @@ -0,0 +1,32 @@ +/** + * 整个应用相关的状态信息 + * + * 比如: keepalive等 + */ +export default { + namespaced: true, + state: { + // 缓存路由 + keepAliveIncludes: [] + }, + + mutations: { + // 加入keep-alive缓存 + pushKeepAliveIncludes(state, val) { + if (state.keepAliveIncludes.length < 30) { + const number = state.keepAliveIncludes.findIndex(e => e === val); + if (number === -1) { + state.keepAliveIncludes.push(val); + } + } + }, + // 删除缓存 + deleteKeepAliveIncludes(state, val) { + const number = state.keepAliveIncludes.findIndex(e => e === val); + if (number !== -1) { + state.keepAliveIncludes.splice(number, 1); + } + } + } + +}; diff --git a/smart-admin-h5/src/themes/index.less b/smart-admin-h5/src/themes/index.less deleted file mode 100644 index 4129c13d..00000000 --- a/smart-admin-h5/src/themes/index.less +++ /dev/null @@ -1,6 +0,0 @@ - -@text-color: #323233; -@border-color: #ebedf0; -@active-color: #f2f3f5; -@background-color: #f7f8fa; -@background-color-light: #fafafa; diff --git a/smart-admin-h5/src/themes/index.scss b/smart-admin-h5/src/themes/index.scss new file mode 100644 index 00000000..b540e422 --- /dev/null +++ b/smart-admin-h5/src/themes/index.scss @@ -0,0 +1,6 @@ + +html, +body { + font-family: Arial, Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, sans-serif; + background-color: $background-color; +} diff --git a/smart-admin-h5/src/utils/index.js b/smart-admin-h5/src/utils/index.js new file mode 100644 index 00000000..37d915fc --- /dev/null +++ b/smart-admin-h5/src/utils/index.js @@ -0,0 +1,110 @@ +/** + * Created by PanJiaChen on 16/11/18. + */ + +/** + * Parse the time to string + * @param {(Object|string|number)} time + * @param {string} cFormat + * @returns {string} + */ +export function parseTime(time, cFormat) { + if (arguments.length === 0) { + return null + } + const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}' + let date + if (typeof time === 'object') { + date = time + } else { + if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { + time = parseInt(time) + } + if ((typeof time === 'number') && (time.toString().length === 10)) { + time = time * 1000 + } + date = new Date(time) + } + const formatObj = { + y: date.getFullYear(), + m: date.getMonth() + 1, + d: date.getDate(), + h: date.getHours(), + i: date.getMinutes(), + s: date.getSeconds(), + a: date.getDay() + } + const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { + let value = formatObj[key] + // Note: getDay() returns 0 on Sunday + if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] } + if (result.length > 0 && value < 10) { + value = '0' + value + } + return value || 0 + }) + return time_str +} + +/** + * @param {number} time + * @param {string} option + * @returns {string} + */ +export function formatTime(time, option) { + if (('' + time).length === 10) { + time = parseInt(time) * 1000 + } else { + time = +time + } + const d = new Date(time) + const now = Date.now() + + const diff = (now - d) / 1000 + + if (diff < 30) { + return '刚刚' + } else if (diff < 3600) { + // less 1 hour + return Math.ceil(diff / 60) + '分钟前' + } else if (diff < 3600 * 24) { + return Math.ceil(diff / 3600) + '小时前' + } else if (diff < 3600 * 24 * 2) { + return '1天前' + } + if (option) { + return parseTime(time, option) + } else { + return ( + d.getMonth() + + 1 + + '月' + + d.getDate() + + '日' + + d.getHours() + + '时' + + d.getMinutes() + + '分' + ) + } +} + +/** + * @param {string} url + * @returns {Object} + */ +export function param2Obj(url) { + const search = url.split('?')[1] + if (!search) { + return {} + } + return JSON.parse( + '{"' + + decodeURIComponent(search) + .replace(/"/g, '\\"') + .replace(/&/g, '","') + .replace(/=/g, '":"') + .replace(/\+/g, ' ') + + '"}' + ) +} diff --git a/smart-admin-h5/src/utils/request.js b/smart-admin-h5/src/utils/request.js new file mode 100644 index 00000000..6788f91b --- /dev/null +++ b/smart-admin-h5/src/utils/request.js @@ -0,0 +1,58 @@ +import axios from 'axios' +import store from '@/store' +import { Toast } from 'vant' +// 根据环境不同引入不同api地址 +import { baseApi } from '@/config' +// create an axios instance +const service = axios.create({ + baseURL: baseApi, // url = base api url + request url + withCredentials: true, // send cookies when cross-domain requests + timeout: 5000 // request timeout +}) + +// request拦截器 request interceptor +service.interceptors.request.use( + config => { + // 不传递默认开启loading + if (!config.hideloading) { + // loading + Toast.loading({ + forbidClick: true + }) + } + if (store.getters.token) { + config.headers['X-Token'] = '' + } + return config + }, + error => { + // do something with request error + console.log(error) // for debug + return Promise.reject(error) + } +) +// respone拦截器 +service.interceptors.response.use( + response => { + Toast.clear() + const res = response.data + if (res.status && res.status !== 200) { + // 登录超时,重新登录 + if (res.status === 401) { + store.dispatch('FedLogOut').then(() => { + location.reload() + }) + } + return Promise.reject(res || 'error') + } else { + return Promise.resolve(res) + } + }, + error => { + Toast.clear() + console.log('err' + error) // for debug + return Promise.reject(error) + } +) + +export default service diff --git a/smart-admin-h5/src/utils/validate.js b/smart-admin-h5/src/utils/validate.js new file mode 100644 index 00000000..e9bd1bab --- /dev/null +++ b/smart-admin-h5/src/utils/validate.js @@ -0,0 +1,20 @@ +/** + * Created by Sunnie on 19/06/04. + */ + +/** + * @param {string} path + * @returns {Boolean} + */ +export function isExternal(path) { + return /^(https?:|mailto:|tel:)/.test(path) +} + +/** + * @param {string} str + * @returns {Boolean} + */ +export function validUsername(str) { + const valid_map = ['admin', 'editor'] + return valid_map.indexOf(str.trim()) >= 0 +} diff --git a/smart-admin-h5/src/views/bpm/index.vue b/smart-admin-h5/src/views/bpm/index.vue deleted file mode 100644 index a2eccc23..00000000 --- a/smart-admin-h5/src/views/bpm/index.vue +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - 内容 2 - 内容 3 - 内容 4 - - - - - - - diff --git a/smart-admin-h5/src/views/business/index.vue b/smart-admin-h5/src/views/business/index.vue deleted file mode 100644 index e6ba62dc..00000000 --- a/smart-admin-h5/src/views/business/index.vue +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - 业务 - - - - - - - diff --git a/smart-admin-h5/src/views/dashboard/dashboard.vue b/smart-admin-h5/src/views/dashboard/dashboard.vue new file mode 100644 index 00000000..47b1ab24 --- /dev/null +++ b/smart-admin-h5/src/views/dashboard/dashboard.vue @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/smart-admin-h5/src/views/develop/config.vue b/smart-admin-h5/src/views/develop/config.vue index 360c1f21..18b2ec08 100644 --- a/smart-admin-h5/src/views/develop/config.vue +++ b/smart-admin-h5/src/views/develop/config.vue @@ -1,7 +1,7 @@ - + @@ -13,6 +13,7 @@ import RouterNavBar from 'components/van-bar/RouterNavBar'; const VCONSOLE_ID = '__vconsole'; export default { + name: 'DevelopConfig', components: { RouterNavBar }, diff --git a/smart-admin-h5/src/views/home/index.vue b/smart-admin-h5/src/views/home/index.vue deleted file mode 100644 index e1a9aff3..00000000 --- a/smart-admin-h5/src/views/home/index.vue +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - 首页 - - - span: 8 - span: 8 - - - - - - - - - diff --git a/smart-admin-h5/src/views/login/login.vue b/smart-admin-h5/src/views/login/login.vue index c9e4a2e3..8fd8806f 100644 --- a/smart-admin-h5/src/views/login/login.vue +++ b/smart-admin-h5/src/views/login/login.vue @@ -38,26 +38,12 @@ export default { loginName: '', loginPwd: '' }, - codeUrl: '' }; }, mounted() { }, methods: { - // 获取验证码 - async getVerificationCode() { - try { - const res = await loginApi.getVerificationCode(); - const data = res.data; - this.formData.codeUuid = data.uuid; - this.codeUrl = data.code; - this.formData.code = ''; - console.log(this.codeUrl); - } catch (e) { - this.$smartSentry.captureException(e); - } - }, - // 提交表单 + // 提交登录表单 async onSubmit() { this.$smart.loading(); try { @@ -66,9 +52,9 @@ export default { this.$store.commit('user/updateSession', loginInfo); cookie.setToken(loginInfo.xaccessToken); this.$toast.success('登录成功'); - this.$router.replace('/bpm'); + this.$router.replace('/dashboard/user'); + // this.$router.replace('/contact-company'); } catch (e) { - console.log(e); this.$smartSentry.captureException(e); await this.getVerificationCode(); } finally { @@ -78,3 +64,5 @@ export default { } }; + diff --git a/smart-admin-h5/src/views/main/other-main.vue b/smart-admin-h5/src/views/main/other-main.vue deleted file mode 100644 index 1ed7f166..00000000 --- a/smart-admin-h5/src/views/main/other-main.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/smart-admin-h5/src/views/main/tabbar-main.vue b/smart-admin-h5/src/views/main/tabbar-main.vue deleted file mode 100644 index 8a97159b..00000000 --- a/smart-admin-h5/src/views/main/tabbar-main.vue +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/smart-admin-h5/src/views/mine/change-password.vue b/smart-admin-h5/src/views/user/change-password.vue similarity index 62% rename from smart-admin-h5/src/views/mine/change-password.vue rename to smart-admin-h5/src/views/user/change-password.vue index ef4b9223..08f4c4e8 100644 --- a/smart-admin-h5/src/views/mine/change-password.vue +++ b/smart-admin-h5/src/views/user/change-password.vue @@ -1,7 +1,7 @@ - +