Commit b3e7af00 by 胡悦

init

0 parents
Showing 95 changed files with 4026 additions and 0 deletions
> 1%
last 2 versions
# http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
NODE_ENV='development'
# must start with VUE_APP_
VUE_APP_ENV = 'development'
NODE_ENV='production'
# must start with VUE_APP_
VUE_APP_ENV = 'production'
\ No newline at end of file
NODE_ENV='production'
# must start with VUE_APP_
VUE_APP_ENV = 'staging'
build/*.js
src/assets
src/config
public
dist
module.exports = {
root: true,
env: {
node: true
},
extends: ['plugin:vue/essential', 'eslint:recommended'],
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'vue/max-attributes-per-line': [
2,
{
singleline: 10,
multiline: {
max: 1,
allowFirstLine: false
}
}
],
'vue/singleline-html-element-content-newline': 'off',
'vue/multiline-html-element-content-newline': 'off',
'vue/name-property-casing': ['error', 'PascalCase'],
'vue/no-v-html': 'off',
'accessor-pairs': 2,
'arrow-spacing': [
2,
{
before: true,
after: true
}
],
'block-spacing': [2, 'always'],
'brace-style': [
2,
'1tbs',
{
allowSingleLine: true
}
],
camelcase: [
0,
{
properties: 'always'
}
],
'comma-dangle': [2, 'never'],
'comma-spacing': [
2,
{
before: false,
after: true
}
],
'comma-style': [2, 'last'],
'constructor-super': 2,
curly: [2, 'multi-line'],
'dot-location': [2, 'property'],
'eol-last': 2,
eqeqeq: ['error', 'always', { null: 'ignore' }],
'generator-star-spacing': [
2,
{
before: true,
after: true
}
],
'handle-callback-err': [2, '^(err|error)$'],
indent: [
2,
2,
{
SwitchCase: 1
}
],
'jsx-quotes': [2, 'prefer-single'],
'key-spacing': [
2,
{
beforeColon: false,
afterColon: true
}
],
'keyword-spacing': [
2,
{
before: true,
after: true
}
],
'new-cap': [
2,
{
newIsCap: true,
capIsNew: false
}
],
'new-parens': 2,
'no-array-constructor': 2,
'no-caller': 2,
'no-console': 'off',
'no-class-assign': 2,
'no-cond-assign': 2,
'no-const-assign': 2,
'no-control-regex': 0,
'no-delete-var': 2,
'no-dupe-args': 2,
'no-dupe-class-members': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty-character-class': 2,
'no-empty-pattern': 2,
'no-eval': 2,
'no-ex-assign': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-extra-boolean-cast': 2,
'no-extra-parens': [2, 'functions'],
'no-fallthrough': 2,
'no-floating-decimal': 2,
'no-func-assign': 2,
'no-implied-eval': 2,
'no-inner-declarations': [2, 'functions'],
'no-invalid-regexp': 2,
'no-irregular-whitespace': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': [
2,
{
allowLoop: false,
allowSwitch: false
}
],
'no-lone-blocks': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-multiple-empty-lines': [
2,
{
max: 1
}
],
'no-native-reassign': 2,
'no-negated-in-lhs': 2,
'no-new-object': 2,
'no-new-require': 2,
'no-new-symbol': 2,
'no-new-wrappers': 2,
'no-obj-calls': 2,
'no-octal': 2,
'no-octal-escape': 2,
'no-path-concat': 2,
'no-proto': 2,
'no-redeclare': 2,
'no-regex-spaces': 2,
'no-return-assign': [2, 'except-parens'],
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-sparse-arrays': 2,
'no-this-before-super': 2,
'no-throw-literal': 2,
'no-trailing-spaces': 2,
'no-undef': 2,
'no-undef-init': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2,
'no-unneeded-ternary': [
2,
{
defaultAssignment: false
}
],
'no-unreachable': 2,
'no-unsafe-finally': 2,
'no-unused-vars': [
2,
{
vars: 'all',
args: 'none'
}
],
'no-useless-call': 2,
'no-useless-computed-key': 2,
'no-useless-constructor': 2,
'no-useless-escape': 0,
'no-whitespace-before-property': 2,
'no-with': 2,
'one-var': [
2,
{
initialized: 'never'
}
],
'operator-linebreak': [
2,
'after',
{
overrides: {
'?': 'before',
':': 'before'
}
}
],
'padded-blocks': [2, 'never'],
quotes: [
2,
'single',
{
avoidEscape: true,
allowTemplateLiterals: true
}
],
semi: [2, 'never'],
'semi-spacing': [
2,
{
before: false,
after: true
}
],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [
2,
{
words: true,
nonwords: false
}
],
'spaced-comment': [
2,
'always',
{
markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
}
],
'template-curly-spacing': [2, 'never'],
'use-isnan': 2,
'valid-typeof': 2,
'wrap-iife': [2, 'any'],
'yield-star-spacing': [2, 'both'],
yoda: [2, 'never'],
'prefer-const': 2,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'object-curly-spacing': [
2,
'always',
{
objectsInObjects: false
}
],
'array-bracket-spacing': [2, 'never']
}
}
.DS_Store
node_modules
/dist
/docs
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
package-lock.json
yarn.lock
\ No newline at end of file
// https://github.com/michael-ciniawsky/postcss-load-config
module.exports = {
plugins: {
autoprefixer: {
overrideBrowserslist: ['Android 4.1', 'iOS 7.1', 'Chrome > 31', 'ff > 31', 'ie >= 8']
},
// 'postcss-pxtorem': {
// rootValue: 37.5,
// propList: ['*'],
// selectorBlackList: ['van-','ignore','ign-','.hairlines']
// },
'postcss-px-to-viewport': {
viewportWidth: 375, // 视窗的宽度,对应的是我们设计稿的宽度,一般是750
unitPrecision: 3, // 指定`px`转换为视窗单位值的小数位数(很多时候无法整除)
viewportUnit: 'vw', // 指定需要转换成的视窗单位,建议使用vw
selectorBlackList: ['.ignore', '.hairlines', 'ign-'], // 指定不转换为视窗单位的类,可以自定义,可以无限添加,建议定义一至两个通用的类名
minPixelValue: 1, // 小于或等于`1px`不转换为视窗单位,你也可以设置为你想要的值
mediaQuery: false // 允许在媒体查询中转换`px`
}
}
}
{
"printWidth": 200,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "none",
"semi": false,
"wrap_line_length": 120,
"wrap_attributes": "auto",
"proseWrap": "always",
"arrowParens": "avoid",
"bracketSpacing": true,
"htmlWhitespaceSensitivity": "ignore",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"jsxBracketSameLine": true,
"files.insertFinalNewline": true,
"useTabs": false,
"eslintIntegration": true,
"overrides": [
{
"files": ".prettierrc",
"options": {
"parser": "json"
}
}
],
"endOfLine": "auto"
}
File mode changed
This diff is collapsed. Click to expand it.
// 获取 VUE_APP_ENV 非 NODE_ENV,测试环境依然 console
const IS_PROD = ['production', 'prod'].includes(process.env.VUE_APP_ENV)
const plugins = [
[
'import',
{
libraryName: 'vant',
libraryDirectory: 'es',
style: true
},
'vant'
]
]
// 去除 console.log
if (IS_PROD) {
plugins.push('transform-remove-console')
}
module.exports = {
presets: [['@vue/cli-plugin-babel/preset', { useBuiltIns: 'usage', corejs: 3 }]],
plugins
}
{
"name": "gh-hall",
"version": "1.0.0",
"description": "GH Hall By Work WeChat",
"author": "limin <limin.mail@qq.com>",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --open",
"build": "vue-cli-service build",
"stage": "vue-cli-service build --mode staging",
"lint": "vue-cli-service lint --fix"
},
"dependencies": {
"@antv/f2": "^3.8.9",
"axios": "^0.19.2",
"core-js": "^3.6.4",
"dayjs": "^1.10.5",
"lib-flexible": "^0.3.2",
"regenerator-runtime": "^0.13.5",
"storejs": "^1.1.0",
"vant": "^2.12.21",
"vconsole": "^3.7.0",
"vee-validate": "^3.4.9",
"vue": "^2.6.11",
"vue-easytable": "^2.5.3",
"vue-photo-preview": "^1.1.3",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"babel-plugin-import": "^1.13.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"node-sass": "^4.14.1",
"postcss-px-to-viewport": "^1.1.1",
"postcss-pxtorem": "^5.1.1",
"sass-loader": "^8.0.2",
"script-ext-html-webpack-plugin": "^2.1.4",
"vue-template-compiler": "^2.6.11",
"webpack-bundle-analyzer": "^3.8.0"
}
}
No preview for this file type
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %>
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="preload" as="style" />
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
<% } %>
<title>
<%= webpackConfig.name %>
</title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled. Please enable it
to continue.</strong>
</noscript>
<div id="app"></div>
<script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script>
<!-- 使用CDN加速的JS文件,配置在vue.config.js下 -->
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %>
<script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
<% } %>
<!-- built files will be auto injected -->
</body>
</html>
<template>
<div id="app">
<router-view />
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
<style lang="scss"></style>
/*
* @Descripttion:公共 API
* @version:1.0.0
* @Author: limin
* @Date: 2021-06-08 10:59:15
* @LastEditors: limin
* @LastEditTime: 2021-06-28 13:08:50
*/
import request from '@/plugins/axios'
const common = {
/**
* 根据code登录获取用户信息
* @param {*} data 参数
* @returns
*/
login: function(code, type) {
return request({
url: `/user/login`,
method: 'get',
params: { code, employeeType: type }
})
},
/**
* 获取门店下的车品牌
* @returns
*/
getCarBrands: function() {
return request({
url: `/car/getCarBrands`,
method: 'get'
})
},
/**
* 获取车品牌下的车系
* @returns
*/
getCarLines: function(carBrandId) {
return request({
url: `/car/getCarLines`,
method: 'get',
params: { carBrandId }
})
},
/**
* 获取车系下的车型
* @returns
*/
getCarModels: function(carLineId) {
return request({
url: `/car/getCarModels`,
method: 'get',
params: { carLineId }
})
},
/**
* 获取员工列表
* @returns
*/
getEmployees: function() {
return request({
url: `/user/getWeComEmployees`,
method: 'get',
loading: true
})
},
upload: function(file) {
let formData = new FormData()
formData.append('file', file)
return request.post('/file/uploadFile', formData, {
'Content-Type': 'multipart/form-data'
})
},
getjsconfig(requestUrl) {
return request({
url: `/ww/access/jsconfig`,
method: 'get',
params: { requestUrl }
})
},
getagentconfig(requestUrl) {
return request({
url: `/ww/access/agentconfig`,
method: 'get',
params: { requestUrl }
})
},
/**
* 获取订单状态列表
*/
getOrderStatus: function() {
return request({
loading: true,
url: '/public/getOrderStatusEnum',
method: 'get'
})
},
/**
* 获取客户信息配置数据列表
*/
getConfigList: function(params = {}) {
return request({
url: '/config/getCustomerConfigList',
method: 'get',
params
})
},
/**
* 通过配置组值获取配置数据列表
*/
getListByGroup: function(params = {}) {
return request({
url: '/config/getListByGroup',
method: 'get',
params
})
},
/**
* 获取跟进状态列表
*/
getFollowStatus: function(params = {}) {
return request({
url: '/public/getFollowStatusEnum',
method: 'get'
})
}
}
export default common
/*
* @Descripttion:API 统一外部调用入口
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-17 18:23:27
*/
import user from './user'
import common from './common'
import wechat from './wechat'
export default {
user,
common,
wechat
}
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-26 16:37:47
*/
// axios
import request from '@/plugins/axios'
const user = {
login(data) {
return request({
url: '/user/login',
method: 'post',
data})
},
getUserInfo(data) {
return request({
url: '/user/userinfo',
method: 'post',
data,
hideloading: true
})
},
getUserName(params) {
return request({
url: '/user/name',
method: 'get',
params,
hideloading: true
})
},
customerDetailPermission() {
return request({
url: '/user/customerDetailPermission',
method: 'get'
})
}
}
export default user
/*
* @Descripttion: 企业微信原生API
* @version:1.0.0
* @Author: limin
* @Date: 2021-06-08 11:41:40
* @LastEditors: limin
* @LastEditTime: 2021-06-20 19:35:46
*/
import api from '@/api'
const wechat = {
init(url = window.location.href) {
return new Promise((resolve, reject) => {
api.common.getagentconfig(url).then(res => {
const { corpId: corpid, agentId: agentid, ...cfg } = res.data
wx.agentConfig({
corpid,
agentid,
...cfg,
jsApiList: ['getCurExternalContact', 'openEnterpriseChat'], // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
success: function (res) {
resolve()
},
fail: function (res) {
if (res.errMsg.indexOf('function not exist') > -1) {
alert('版本过低请升级')
}
reject()
}
})
})
})
},
sign(opts) {
const str = Object.keys(opts)
.map(key => `${key}=${opts[key]}`)
.join('&')
return sha1(str)
},
/**
* 获取当前外部联系人userid
*/
getCurExternalContact() {
return new Promise((resolve, reject) => {
wx.invoke('getCurExternalContact', {}, function (res) {
if (res.err_msg == 'getCurExternalContact:ok') {
resolve(res.userId)
} else {
reject(res)
}
})
})
},
/**
* 打开会话
* @param {*} userIds
* @param {*} externalUserIds
* @param {*} groupName
* @param {*} chatId
* @returns
*/
openEnterpriseChat(externalUserIds = '', userIds = '', groupName = '', chatId = '') {
return new Promise((resolve, reject) => {
wx.openEnterpriseChat({
// 注意:userIds和externalUserIds至少选填一个。内部群最多2000人;外部群最多500人;如果有微信联系人,最多40人
userIds, //参与会话的企业成员列表,格式为userid1;userid2;...,用分号隔开。
externalUserIds, //'wmEAlECwAAHrbWYDOK5u3Bf13xlYDAAA;wmEAlECwAAHibWYDOK5u3Af13xlYDAAA', // 参与会话的外部联系人列表,格式为userId1;userId2;…,用分号隔开。
groupName, // 会话名称。单聊时该参数传入空字符串""即可。
chatId, // 若要打开已有会话,需指定此参数。如果是新建会话,chatId必须为空串
success: function (res) {
var chatId = res.chatId //返回当前群聊ID,仅当使用agentConfig注入该接口权限时才返回chatId
resolve(chatId)
},
fail: function (res) {
if (res.errMsg.indexOf('function not exist') > -1) {
alert('版本过低请升级')
}
}
})
})
}
}
export default wechat
/** -------slide-left begin**/
.slide-left-enter {
opacity: 0;
-webkit-transform: translate($translateLength, 0);
transform: translate($translateLength, 0);
}
.slide-left-leave-to {
opacity: 0;
-webkit-transform: translate(-$translateLength, 0);
transform: translate(-$translateLength, 0);
}
.slide-left-enter-active {
transition: all $animateDuration ease;
}
.slide-left-leave-active {
transition: all $animateDuration ease;
}
/** -------slide-left end**/
/** -------slide-right begin**/
.slide-right-enter {
opacity: 0;
-webkit-transform: translate(-$translateLength, 0);
transform: translate(-$translateLength, 0);
}
.slide-right-leave-to {
opacity: 0;
-webkit-transform: translate($translateLength, 0);
transform: translate($translateLength, 0);
}
.slide-right-enter-active {
transition: all $animateDuration ease;
}
.slide-right-leave-active {
transition: all 0.1s ease;
}
/** -------slide-right end**/
.flip-list-move {
transition: transform $animateDuration;
}
@font-face {
font-family: "iconfont"; /* Project id 2609988 */
src: url('//at.alicdn.com/t/font_2609988_3co86ufyx32.woff2?t=1623641587741') format('woff2'),
url('//at.alicdn.com/t/font_2609988_3co86ufyx32.woff?t=1623641587741') format('woff'),
url('//at.alicdn.com/t/font_2609988_3co86ufyx32.ttf?t=1623641587741') format('truetype');
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-refresh:before {
content: "\e620";
}
.icon-people:before {
content: "\e6b4";
}
.icon-arrowdown:before {
content: "\e62b";
}
.icon-radio:before {
content: "\e600";
}
.icon-people1:before {
content: "\e82d";
}
.icon-dian:before {
content: "\ec1e";
}
@import './normalize.scss';
@import './variables.scss';
@import './mixin.scss';
@import './animate.scss';
@import './iconfont.scss';
@import './vant.scss';
html,
body .app {
color: #333333;
font-family: Arial, Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, sans-serif;
background-color: $background-color;
-webkit-overflow-scrolling: touch;
height: 100%;
// overflow: hidden;
}
.line,
.van-divider {
margin: 0;
}
.title {
@include tit;
padding-left: 16px;
background-color: #fff;
}
.app-container {
// padding-bottom: 50px;
}
.app-footer {
// position: fixed;
// z-index:999;
height: 50px;
width: 100%;
// bottom: 0;
background-color: #fff;
display: flex;
align-items: center;
justify-content: center;
padding: 5px 16px;
box-sizing: border-box;
.van-button {
@include btnMain()
}
}
.no-data {
text-align: center;
margin-top: 50px;
}
.search {
position: relative;
.search-list {
position: absolute;
top: 44px;
width: calc(100% - 57px);
font-size: 14px;
background-color: rgb(255, 255, 255);
z-index: 1;
color: #999;
border-radius: 0 0 10px 10px;
// border: 1px solid #3975c6;
// border-top: none;
box-shadow: 1px 1px 2px #eee;
margin-left: 12px;
p {
margin: 10px;
padding-left: 20px;
}
}
}
// mixin
// 清除浮动
@mixin clearfix {
&:after {
content: '';
display: table;
clear: both;
}
}
// 多行隐藏
@mixin textoverflow($clamp: 1) {
display: block;
overflow: hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: $clamp;
/*! autoprefixer: ignore next */
-webkit-box-orient: vertical;
}
//flex box
@mixin flexbox($jc: space-between, $ai: center, $fd: row, $fw: nowrap) {
display: flex;
display: -webkit-flex;
flex: 1;
justify-content: $jc;
-webkit-justify-content: $jc;
align-items: $ai;
-webkit-align-items: $ai;
flex-direction: $fd;
-webkit-flex-direction: $fd;
flex-wrap: $fw;
-webkit-flex-wrap: $fw;
}
@mixin cell($fs: 14px, $fw: 400, $margin: 8px 0, $bgc: #fff) {
background-color: $bgc;
margin: $margin;
font-size: $fs;
font-weight: $fw;
color: #323233;
padding: 0 16px;
}
@mixin font($fs: 14px, $fw: 400, $c:#3975c6){
font-size: $fs;
font-weight: $fw;
color: $c;
}
@mixin mainfont($fs: 14px, $fw: 400) {
@include font($fs,$fw,#3975c6)
}
@mixin darkfont($fs: 14px, $fw: 400, $c: #323233) {
@include font($fs,$fw,$c)
}
@mixin tit {
font-size: 18px;
font-weight: 600;
padding: 14px 0;
display: block;
color: #414143;
}
@mixin textarea{
.content {
display: flex;
flex-direction: column;
.van-cell {
&__title {
flex: 1;
}
&__value {
flex: 0 0 84px;
margin-top: 12px;
background: #f7f8fa;
border-radius: 8px;
}
}
}
}
@mixin recell($mt:8px){
/deep/.van-cell {
margin-top: $mt;
&__title {
margin-right: 8px;
flex: 0 0 70px;
}
&.l{
.van-cell__title {
flex: 0 0 92px;
}
}
&.m{
.van-cell__title {
margin-right: 0;
flex: 0 0 63px;
}
}
}
}
@mixin cellradio {
@include recell();
.radio {
/deep/.van-radio,.van-checkbox {
flex: 1 1 50%;
margin: 14px 0 0;
&:nth-child(1),
&:nth-child(2) {
margin-top: 0;
}
}
}
@include textarea()
}
@mixin btnMain{
flex: 1;
height: 40px;
background-color: $main-color;
border-radius: 100px;
@include font(14px,400,#fff);
}
@mixin card{
display: flex;
height: 142px;
background: #fff;
box-shadow: 0px 2px 12px 0px rgba(100, 101, 102, 0.12);
border-radius: 4px;
padding: 16px;
margin-bottom: 8px;
}
@mixin mt($t:5px){
margin-top: $t;
}
@mixin flexcenter{
display: flex;
justify-content: center;
align-items: center;
}
.van-radio,
.van-checkbox {
&__icon {
&--checked {
.van-icon {
background-color: $main-color !important;
border-color: $main-color !important;
}
}
}
}
// variables
$background-color: #f8f8f8;
//animate.scss
$animateDuration: 0.2s;
$translateLength: 30px;
$main-color:#3975C6;
<!-- components navbar-->
<template>
<div class="com-car-type-container">
<van-field
:value="comValue"
readonly
:label="label"
:placeholder="title"
class="van-ellipsis"
clearable
:right-icon="clearable ? 'replay' : 'arrow'"
input-align="right"
@click-input="show = true"
@click-right-icon="clear"
:required="isRequire"
/>
<van-popup v-model="show" round position="bottom" :style="{ height: '90%' }">
<van-search v-model="txtSearch" placeholder="搜索" input-align="center" @input="onSearch" />
<van-tabs v-model="active" @change="onTabChange" color="#3975C6" :key="active" :animated="true" duration="0.1">
<van-tab :title="select.brand.label" :disabled="!brands.length">
<van-cell-group v-for="o in brands" :key="o.value">
<van-cell :value="o.label" @click="brandClickHandle(o)" class="cell-item">
<template #right-icon v-if="select.brand.value === o.value">
<van-icon name="success" />
</template>
</van-cell>
</van-cell-group>
</van-tab>
<van-tab :title="select.series.lineName" :disabled="!series.length">
<van-cell-group v-for="o in series" :key="o.lineCode">
<van-cell :value="o.lineName" @click="seriesClickHandle(o)" class="cell-item">
<template #right-icon v-if="select.series.lineCode == o.lineCode">
<van-icon name="success" />
</template>
</van-cell>
</van-cell-group>
</van-tab>
<van-tab :title="select.model.modelName" :disabled="!models.length">
<van-cell-group v-for="o in models" :key="o.modelCode">
<van-cell @click="modelsClickHandle(o)" class="cell-item">
<template>
<div>{{ o.modelName }}</div>
<div class="model-code">{{ o.modelCode }}</div>
</template>
<template #right-icon v-if="select.model.modelCode == o.modelCode">
<van-icon name="success" />
</template>
</van-cell>
</van-cell-group>
</van-tab>
</van-tabs>
</van-popup>
</div>
</template>
<script>
import { debounce, tools } from 'utils'
let initData = function() {
return tools.deepClone({
brand: {
label: '品牌',
value: ''
},
series: {
lineName: '车系',
lineCode: ''
},
model: {
modelName: '车型',
modelCode: ''
}
})
}
export default {
name: 'CarType',
props: ['label', 'title', 'value', 'info', 'onChange', 'isRequire', 'clearable'],
data() {
return {
active: 0,
txtSearch: '',
show: false,
bak: [],
curDataName: 'brands',
brands: [],
series: [],
models: [],
select: initData()
}
},
computed: {
comValue() {
return this.value
}
},
mounted() {
this.getCarBrands()
},
watch: {
active() {
this.txtSearch = ''
}
},
methods: {
onTabChange(i) {},
getCarBrands() {
return new Promise(resolve => {
this.api.common.getCarBrands().then(({ data: brands }) => {
this.brands = brands
this.bak[0] = _copy(brands)
resolve()
})
})
},
getCarLines(brandid) {
return new Promise(resolve => {
this.api.common.getCarLines(brandid).then(({ data: series }) => {
this.series = series
this.bak[1] = _copy(series)
resolve()
})
})
},
getCarModels(seriesid) {
return new Promise((resolve, reject) => {
this.api.common.getCarModels(seriesid).then(({ data: models = [] }) => {
if (models.length) {
this.models = models
this.bak[2] = _copy(models)
resolve()
} else {
reject('暂无对应车型')
}
})
})
},
brandClickHandle(brand) {
if (brand.value === this.select.brand.value) {
return
}
this.select = Object.assign(initData(), { brand })
this.series = []
this.models = []
this.getCarLines(brand.value).then(() => {
this.active = 1
})
},
seriesClickHandle(series) {
if (series.lineCode === this.select.series.lineCode) {
return
}
this.model = ''
this.models = []
Object.assign(this.select, { series, model: { modelName: '车型', modelCode: '' } })
this.getCarModels(series.lineCode)
.then(() => {
this.active = 2
})
.catch(err => {
this.$notify(err)
})
},
modelsClickHandle(model) {
this.show = false
Object.assign(this.select, { model })
const { brand, series, model: o } = this.select
const info = {
brandName: brand.label,
brandCode: brand.value,
lineName: series.lineName,
lineCode: series.lineCode,
modelName: o.modelName,
modelCode: o.modelCode
}
this.$emit('update:info', info)
this.$emit('update:value', o.modelName)
this.onChange && this.onChange(info)
},
onSearch: debounce(function(v) {
this[['brands', 'series', 'models'][this.active]] = this.bak[this.active].filter(item => item[['label', 'lineName', 'modelName'][this.active]].toUpperCase().includes(v.toUpperCase()))
}),
reset() {},
clear() {
if (!this.clearable) {
this.show = true
return
}
this.$emit('update:info', {})
this.$emit('update:value', '')
this.active = 0
this.txtSearch = ''
this.show = false
this.curDataName = 'brands'
this.select = initData()
}
}
}
function _copy(obj) {
return JSON.parse(JSON.stringify(obj))
}
</script>
<style lang="scss" scoped>
.com-car-type-container {
/deep/.van-popup {
display: flex;
flex-direction: column;
.van-tabs {
flex: 1;
overflow: auto;
display: flex;
flex-direction: column;
background-color: $background-color;
&__wrap {
box-shadow: 0px 1px 2px 0px #ccc;
}
&__content {
flex: 1;
margin-top: 5px;
overflow: auto;
}
}
}
.cell-item {
align-items: center;
.van-icon-success {
color: $main-color;
}
.model-code {
@include font(12px, 400, #999);
}
}
/deep/.van-cascader {
&__header {
margin-top: 10px;
display: flex;
}
&__title {
flex: 1;
@include flexcenter();
.van-search {
flex: 1;
padding: 0;
}
.reset {
// flex: 0 0 50px;
// text-align: right;
position: absolute;
right: 14px;
top: 72px;
z-index: 111;
// transform: translateX(20px);
@include font(15px, 800, $main-color);
}
}
&__close-icon {
flex: 0 0 30px;
top: -50px;
}
}
}
</style>
<!-- components navbar-->
<template>
<div class="com-car-type-container">
<van-cell :value="comValue" is-link readonly :title="label" @click="show = true" />
<van-popup v-model="show" round position="bottom">
<van-cascader
v-model="cascaderValue"
:options="options"
:closeable="false"
@close="show = false"
@change="onChange"
@finish="onFinish"
active-color="#3975C6"
style="height:90%"
@click.native="onTabChange"
>
<template #title>
<van-search v-model="txtSearch" placeholder="搜索" input-align="center" @input="onSearch" />
<span class="reset" @click="reset">
<van-icon name="revoke" />
&nbsp;重置
</span>
</template>
</van-cascader>
</van-popup>
</div>
</template>
<script>
import { debounce } from 'utils'
export default {
name: 'CarType2',
props: {
label: {
type: String,
default: '意向车型'
},
title: {
type: String,
default: '请选择车型'
},
value: {
type: String
}
},
data() {
return {
txtSearch: '',
show: false,
fieldValue: '',
cascaderValue: '',
options: [],
curOptions: [],
tabIndex: -1,
bak: null,
tagIndex: 0,
datas: []
}
},
computed: {
comValue() {
return this.value || this.title
}
},
mounted() {
// let pop = document.getElementsByClassName("com-car-type-container")[0];
// pop.addEventListener('click', function(e) {
// let _this = e.target;
// if(_this.className.includes('van-tab')){
// console.log(e);
// }
// })
this.getCarBrands()
setTimeout(() => {
this.options = [
{
text: '宝马',
value: '330000',
children: []
},
{
text: '奔驰',
value: '330001',
children: []
}
]
// this.bak = this.tools.deepClone(this.options)
this.datas[0] = this.options
}, 1000)
},
methods: {
onTabChange(e) {
const _this = e.target
if (_this.className.includes('van-tab--active') || _this.parentNode.className.includes('van-tab--active')) {
Array.from(document.getElementsByClassName('van-tab')).forEach((item, index) => {
if (item.getAttribute('aria-selected')) {
this.tagIndex = index
this.s = []
console.log(this.s[0])
// this.s[index]=this.datas[index];
// this.curOptions=this.datas[index]
}
})
}
},
getCarBrands() {
this.api.common.getCarBrands().then(res => {
console.log(res)
})
},
getCarLines() {},
getCarModels() {},
onChange({ value, selectedOptions, tabIndex }) {
console.log(value, selectedOptions)
this.txtSearch = ''
if (tabIndex > 1) return
this.tagIndex = tabIndex + 1
// if (value === this.options[0].value) {
setTimeout(() => {
this.curOptions = selectedOptions[tabIndex]
this.s = selectedOptions
this.tabIndex = tabIndex
const value = [
{ text: 'X5', value: '330100' },
{ text: 'X6', value: '330200' }
]
this.curOptions.children = this.datas[this.tagIndex] = value.map(item => {
if (tabIndex == 0) {
item.children = []
}
return item
})
console.log(this.datas)
// this.bak = this.tools.deepClone(this.curOptions.children)
}, 500)
// }
},
onFinish({ selectedOptions }) {
this.show = false
this.fieldValue = selectedOptions.map(option => option.text).join('/')
this.$emit('update:value', this.fieldValue)
},
onSearch: debounce(function(v) {
// let items = this.tabIndex == -1 ? this.options : this.curOptions.children
// items = this.bak.filter(item=>item.text.includes(v))
console.log(this.tagIndex)
if (this.tagIndex == 0) {
this.options = this.datas[this.tagIndex].filter(item => item.text.toUpperCase().includes(v.toUpperCase()))
} else {
this.curOptions.children = this.datas[this.tagIndex].filter(item => item.text.toUpperCase().includes(v.toUpperCase()))
}
}),
reset() {
setTimeout(() => {
this.options = [
{
text: '宝马',
value: '330000',
children: []
},
{
text: '奔驰',
value: '330001',
children: []
}
]
this.bak = this.tools.deepClone(this.options)
this.tabIndex = -1
}, 1000)
}
}
}
</script>
<style lang="scss" scoped>
.com-car-type-container {
/deep/.van-cascader {
&__header {
margin-top: 10px;
display: flex;
}
&__title {
flex: 1;
@include flexcenter();
.van-search {
flex: 1;
padding: 0;
}
.reset {
// flex: 0 0 50px;
// text-align: right;
position: absolute;
right: 14px;
top: 72px;
z-index: 111;
// transform: translateX(20px);
@include font(15px, 800, $main-color);
}
}
&__close-icon {
flex: 0 0 30px;
top: -50px;
}
}
}
</style>
<!-- components navbar-->
<template>
<van-cell :title="title || data.name" class="radio" :class="clazz">
<template>
<van-checkbox-group v-model="comValue" direction="horizontal">
<van-checkbox :name="item.value" v-for="item in data.value" :key="item.name">{{ item.name }}</van-checkbox>
</van-checkbox-group>
</template>
</van-cell>
</template>
<script>
export default {
name: 'CheckBoxCell',
props: ['title', 'data', 'value', 'clazz'],
computed: {
comValue: {
get() {
return this.value
},
set(val) {
this.$emit('update:value', val)
}
}
},
data() {
return {}
}
}
</script>
<style lang="scss" scoped>
@include cellradio();
@include recell(0);
</style>
<!-- components navbar-->
<template>
<i class="iconfont" :class="iconname"></i>
</template>
<script>
export default {
name: 'Icon',
props: {
name: String
},
computed: {
iconname() {
return 'icon-' + this.name
}
}
}
</script>
<!-- components navbar-->
<template>
<van-list v-model="loading" :finished="finished" offset="100" @load="load" finished-text="">
<slot></slot>
</van-list>
</template>
<script>
import { pager } from '@/mixins'
export default {
name: 'List',
mixins: [pager],
props: ['onLoad'],
data() {
return {
finished: false,
loading: false
}
},
methods: {
load() {
this.pager.pageIndex++
this.loading = true
this.finished = false
this.onLoad(this.pager).then(fin => {
this.loading = false
fin && (this.finished = fin)
})
},
reload() {
this.pager.pageIndex = 0
this.load()
}
},
computed: {}
}
</script>
<!-- components navbar-->
<template>
<div class="com-navbar-container">
<van-nav-bar :title="meta.title" :left-text="leftText" :right-text="rightText" :left-arrow="!meta.isNoBack" @click-left="onClickLeft" @click-right="onClickRight" v-show="meta.title != 'login'" />
<slot></slot>
</div>
</template>
<script>
export default {
name: 'NavBar',
props: {
meta: Object,
leftText: {
type: String,
default: ''
},
rightText: {
type: String,
default: ''
}
},
data() {
return {}
},
computed: {},
mounted() {},
methods: {
onClickLeft() {
// if (this.meta.auth) {
// window.location.href = document.referrer
// window.history.back(-1)
// } else {
this.$router.go(-1)
// }
},
onClickRight() {}
}
}
</script>
<style lang="scss" scoped>
.com-navbar-container {
/deep/.van-nav-bar {
&__arrow {
@include font(20px, 500, #323233);
margin-right: 4px;
}
}
}
</style>
<!-- components navbar-->
<template>
<van-cell :title="title || data.name" class="radio" :class="clazz" :required="isRequire">
<template>
<van-radio-group v-model="comValue" @change="handleChange" direction="horizontal">
<van-radio :name="item.value" v-for="item in data.value" :key="item.name">{{ item.name }}</van-radio>
</van-radio-group>
</template>
</van-cell>
</template>
<script>
export default {
name: 'RadioCell',
props: ['title', 'data', 'value', 'clazz', 'isRequire'],
computed: {
comValue: {
get() {
if (this.value === null && this.isRequire) {
this.$emit('update:value', this.data.value[0].value)
return this.data.value[0].value
}
return this.value
},
set(val) {
this.$emit('update:value', val)
}
}
},
data() {
return {}
},
methods: {
handleChange(value) {
this.$emit('change', value)
}
}
}
</script>
<style lang="scss" scoped>
@include cellradio();
@include recell(0);
</style>
<template>
<div>
<van-tabbar fixed route v-model="active" @change="handleChange">
<van-tabbar-item v-for="(item, index) in data" :to="item.to" :icon="item.icon" :key="index">
{{ item.title }}
</van-tabbar-item>
</van-tabbar>
</div>
</template>
<script>
export default {
name: 'TabBar',
props: {
defaultActive: {
type: Number,
default: 0
},
data: {
type: Array,
default: () => {
return []
}
}
},
data() {
return {
active: this.defaultActive
}
},
methods: {
handleChange(value) {
this.$emit('change', value)
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
<!-- com-timer-tabs-->
<template>
<div class="com-timer-tabs-container">
<van-tabs v-model="active" color="#3975C6" sticky @click="tabClickHandle">
<van-tab :title="date.title" v-for="date in dates" :key="date.value"></van-tab>
</van-tabs>
<van-calendar v-model="isShowCalendar" @confirm="onConfirm" :show-title="false" :color="color" type="range" :allow-same-day="true" :min-date="min" :max-date="max" :style="{ height: popHeight }" />
</div>
</template>
<script>
import { calendar } from '@/mixins'
import * as dayjs from 'dayjs'
function format(s, e) {
return {
startTime: s.format('YYYY-MM-DD 00:00:00'),
endTime: e.format('YYYY-MM-DD 23:59:59')
}
}
const aDates = Object.freeze([
{
title: '今天',
value: 0,
getDate() {
return format(dayjs().startOf('date'), dayjs().startOf('date'))
}
},
{
title: '本月',
value: 1,
getDate() {
return format(dayjs().startOf('month'), dayjs().endOf('month'))
}
},
{
title: '本周',
value: 2,
getDate() {
if (dayjs().day() == 0) {
return format(dayjs().add(-6, 'day'), dayjs())
} else {
return format(
dayjs()
.startOf('week')
.add(1, 'day'),
dayjs()
.endOf('week')
.add(1, 'day')
)
}
}
},
{
title: '自定义',
value: 3
}
])
export default {
name: 'TimerTabs',
mixins: [calendar],
props: ['value', 'onChange', 'minDate', 'maxDate'],
data() {
return {
dates: aDates,
active: 0,
tabIndex: 0
}
},
computed: {
min() {
return this.minDate || new Date(2020, 0, 1)
},
max() {
return this.maxDate || new Date()
}
},
mounted() {
this.$emit('update:value', aDates[this.tabIndex].getDate())
},
methods: {
onClickLeft() {},
onClickRight() {},
tabClickHandle(index) {
if (index === 3) {
this.isShowCalendar = true
return
}
this.broadcast(aDates[index].getDate())
},
dateChangeHandle(date) {
this.broadcast(date)
},
broadcast(value) {
this.$emit('update:value', value)
this.onChange && this.onChange(value)
},
onConfirm([start, end]) {
this.broadcast(format(dayjs(start), dayjs(end)))
document.getElementsByClassName('van-overlay')[0].click() //hack
}
}
}
</script>
<style lang="scss" scoped>
.com-timer-tabs-container {
// /deep/.self{
// .van-tabs{
// height: calc(100vh - 46px);
// display: flex;
// flex-direction: column;
// &__content{
// flex:1;
// overflow: auto;
// .van-tab__pane{
// height: 100%;
// }
// }
// }
// }
}
</style>
<!-- components navbar-->
<template>
<ValidationProvider rules="required" :name="name" v-slot="{ errors }">
<van-field
v-model="comValue"
type="number"
:label="label"
:class="clazz"
:placeholder="placeholder"
clearable
:error-message="errors[0]"
/>
<i></i>
</ValidationProvider>
</template>
<script>
export default {
name: 'ValidateField',
props: {
value: String | Number,
name: String,
label: String,
placeholder: String,
clazz: String
},
computed: {
comValue: {
get() {
return this.value
},
set(val) {
this.$emit('update:value', val)
}
}
}
}
</script>
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-08 19:20:13
* @LastEditors: limin
* @LastEditTime: 2021-06-25 18:09:28
*/
import Vue from 'vue'
const componentsFiles = require.context(`./`, true, /.vue$/)
componentsFiles.keys().forEach(path => {
const component = componentsFiles(path).default
Vue.component(component.name, component)
})
// export default [Icon, NavBar, TabBar, Organization, CustomerList, CustomerDetail, OrderList, OrderDetail, TimerTabs, CarType, RadioCell, CheckBoxCell, ValidateField]
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-08 16:55:43
*/
// 根据环境引入不同配置 process.env.VUE_APP_ENV
const environment = process.env.VUE_APP_ENV || 'production'
let config = require('./env.' + environment)
module.exports = config
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-28 10:13:38
*/
// 本地环境配置
module.exports = {
title: 'gh-hall',
request: {
// baseURL: 'http://scrm.test.glsx.com.cn/scrm-wechat' // 测试项目地址
baseURL: 'http://192.168.2.106:8083/scrm-wechat' // 测试项目地址
},
APPID: 'xxx',
APPSECRET: 'xxx',
cdn: 'https://www.xxx.cn/static'
}
module.exports = {
title: 'gh-hall',
request: {
// baseURL: 'http://ghwx.cgacar.com/scrm-wechat' // 生产
baseURL: 'http://cim.chinagrandauto.com/scrm-wechat' // 生产
// baseURL: 'http://cim.chinagrandauto.com' // 生产
},
APPID: 'xxx',
APPSECRET: 'xxx',
cdn: 'https://www.xxx.cn/static'
}
module.exports = {
title: 'gh-hall',
request: {
baseURL: 'http://xxxxx' // 项目地址
},
APPID: 'xxx',
APPSECRET: 'xxx',
cdn: 'https://www.xxx.cn/static'
}
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-30 11:23:25
*/
// 根据环境引入不同配置 process.env.VUE_APP_ENV
let config = require('./conf.js')
let timeout = 30000 //超时时间
export const fetchConfig = function(isEnv = true) {
if (isEnv) {
let { request } = config
Object.assign(request, { timeout })
return Promise.resolve(config)
}
return window.fetch('https://', {}).then(res => res.json())
}
export const cfg = {
install(vue, config) {
vue.prototype.$config = config
}
}
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-22 13:32:08
* @FilePath: \gh-hall\src\filters\filter.js
*/
/**
*格式化时间
*yyyy-MM-dd hh:mm:ss
*/
export function formatDate(time, fmt) {
if (time === undefined || '') {
return
}
const date = new Date(time)
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
}
const o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds()
}
for (const k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
const str = o[k] + ''
fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str))
}
}
return fmt
}
function padLeftZero(str) {
return ('00' + str).substr(str.length)
}
/*
* 隐藏用户手机号中间四位
*/
export function hidePhone(phone) {
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
}
export function configValue(value, config) {
const obj = config.find(item => item.id == value)
return obj ? obj.confValue : ''
}
export function mapValue(value, config, key = 'key', val = 'value') {
const obj = config.find(item => item[key] == value)
return obj ? obj[val] : ''
}
export function sex(value) {
return { 0: '未知', 1: '男', 2: '女' }[value]
}
export function YoN(value) {
return { Y: '是', N: '否' }[value]
}
export function dateTime(value, T) {
if (!value) return ''
const [date, time] = value.split(' ')
return { date, time }[T]
}
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:50:51
* @FilePath: \gh-hall\src\filters\index.js
*/
import Vue from 'vue'
import * as filter from './filter'
Object.keys(filter).forEach(k => Vue.filter(k, filter[k]))
Vue.prototype.$formatDate = Vue.filter('formatDate')
Vue.prototype.$hidePhone = Vue.filter('hidePhone')
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-29 15:35:47
*/
// 兼容 IE
// https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#babelpolyfill
// import 'core-js/stable'
// import 'regenerator-runtime/runtime'
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import api from './api'
import { fetchConfig, cfg } from '@/config'
import { axsinit } from './plugins/axios'
import 'components'
import './filters'
import '@/assets/css/index.scss'
import { bus, tools, store as local } from './utils'
import { global } from '@/mixins'
// Vue.mixin(global)
// 全局引入按需引入UI库 vant
import { components } from '@/plugins/vant'
components.forEach(component => Vue.use(component))
Vue.prototype.api = api
Vue.prototype.bus = bus
Vue.prototype.tools = tools
Vue.prototype.local = local
Vue.prototype.to = function (name, params) {
if (name === -1) {
router.go(-1)
return
}
router.push({ name, params})
}
// 移动端适配 rem
// import 'lib-flexible/flexible.js'
import 'vue-easytable/libs/theme-default/index.css'
import VueEasytable from 'vue-easytable'
Vue.use(VueEasytable)
Vue.config.productionTip = false
// import VConsole from 'vconsole'
// const vConsole = new VConsole()
import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
Vue.use(preview, {
maxSpreadZoom: 1, // 预览图最大的倍数,默认是2倍
fullscreenEl: false, // 是否显示右上角全屏按钮
tapToClose: true, // 点击滑动区域应关闭图库
shareEl: false, // 是否显示分享按钮
zoomEl: false, // 是否显示放大缩小按钮
counterEl: false, // 是否显示左上角图片数量按钮
arrowEl: true, // 如图的左右箭头(pc浏览器模拟手机时)
tapToToggleControls: true, // 点击应切换控件的可见性
clickToCloseNonZoomable: true // 点击图片应关闭图库,仅当图像小于视口的大小时
})
fetchConfig().then(({ request, cdn }) => {
// 从配置服务器获取动态配置
// 设置 js中可以访问 $cdn
Vue.prototype.$cdn = cdn
Vue.use(cfg)
axsinit(request)
new Vue({
el: '#app',
router,
store,
render: h => h(App)
})
})
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-14 14:25:13
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:50:32
* @FilePath: \gh-hall\src\mixins\calendar.js
*/
export default {
data() {
return {
isShowCalendar: false,
popHeight: '90%',
date: '',
color: '#3975C6'
}
},
mounted() {},
methods: {
onConfirm(date) {
this.isShowCalendar = false
this.date = this.tools.parseTime(date, `{y}-{m}-{d}`)
this.dateChangeHandle(this.date)
document.getElementsByClassName('van-overlay')[0].click() //hack
}
}
}
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-22 20:10:29
* @LastEditors: limin
* @LastEditTime: 2021-07-06 12:39:29
* @FilePath: \gh-hall\src\mixins\global.js
*/
import store from '@/store'
import api from '@/api'
export default {
data() {
return {}
},
computed: {
isSubmit() {
return store.state.app.isSubmit
}
},
beforeRouteEnter(to, from, next) {
console.log('=============')
const {
meta: { auth, employeeType }
} = to
setKeepAlives(to, from)
if (store.state.app.user) {
if (to.name == 'SalesCustomerDetail' && store.state.app.isDennied) {
return next({ name: 'PermissionDennied' })
}
return next()
}
if (auth) {
const code = qs('code')
if (code) {
store
.dispatch('login', { code, type: employeeType })
.then(res => {
if (to.name == 'SalesCustomerDetail') {
api.user
.customerDetailPermission()
.then(({ code, data }) => {
if (code == 200 && data == true) {
next()
} else {
throw new Error('PermissionDennied')
}
})
.catch(err => {
store.dispatch('setIsDennied', true)
next({ name: 'PermissionDennied' })
})
// .catch(err => next())
} else {
next()
}
})
.catch(res => next(false))
} else {
next(false)
}
} else {
next()
}
}
}
function setKeepAlives(to, from) {
const isBack = to.meta.deepth < from.meta.deepth
const tranName = `slide-${{ true: 'right', false: 'left' }[isBack]}`
store.dispatch('setTransitionName', tranName)
// 如果要to(进入)的页面是需要keepAlive缓存的,把name push进keepAlives中
if (to.meta.keepAlive) {
store.dispatch('pushKeep', to.name)
}
// 如果 要 form(离开) 的页面是 keepAlive缓存的,
// 再根据 deepth 来判断是前进还是返回
// 如果是返回删除之前的keepAlive缓存:
if (from.meta.keepAlive && isBack) {
store.dispatch('removeKeep', [from.name])
}
}
function qs(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
var r = window.location.search.substr(1).match(reg)
if (r != null) return unescape(r[2])
return null
}
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-14 14:32:06
* @LastEditors: limin
* @LastEditTime: 2021-06-29 10:51:08
* @FilePath: \gh-hall\src\mixins\index.js
*/
import calendar from './calendar'
import pager from './pager'
import global from './global'
// const mixins = require.context(`./`, true, /^(?!.*index).*\.js$/)
// let modules = mixins.keys().reduce((modules, path) => {
// const name = path.replace(/.\/|.js/g, '')
// modules[name] = mixins(path).default
// return modules
// }, {})
export { calendar, pager, global }
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-17 15:51:57
* @LastEditors: limin
* @LastEditTime: 2021-06-17 15:52:37
*/
export default {
data() {
return {
pager: {
pageIndex: 0,
pageSize: 10
}
}
}
}
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-07 17:24:19
* @LastEditors: limin
* @LastEditTime: 2021-06-29 16:08:08
* @FilePath: \gh-hall\src\plugins\axios\index.js
*/
import axios from 'axios'
import store from '@/store'
import { Notify, Dialog, Toast } from 'vant'
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.loading) {
Toast.loading({
overlay: true,
duration: 0,
forbidClick: true
})
}
if (config.submit) {
store.dispatch('setSubmit', true)
}
if (store.getters.app.user) {
config.headers['Authorization'] = store.getters.app.user.token
}
return config
},
error => {
Toast.clear()
// do something with request error
console.log(error) // for debug
return Promise.reject(error)
}
)
// respone拦截器
service.interceptors.response.use(
response => {
Toast.clear()
// const { config:{params,data} } = response
let {
data: { code, data, message = 'error' }
} = response
store.dispatch('setSubmit', false)
if (code != 200) {
// 登录超时
if (code == 401) {
}
Notify({ message })
return Promise.reject({ code, message })
} else {
return Promise.resolve(response.data)
}
},
error => {
store.dispatch('setSubmit', false)
Toast.clear()
Notify({ message: 'err:' + JSON.stringify(error) })
return Promise.reject(error)
}
)
export const axsinit = function(options = {}) {
Object.assign(service.defaults, options)
}
export default service
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-23 11:44:59
*/
// 按需全局引入 vant组件
import {
Button,
List,
Cell,
Tabbar,
TabbarItem,
NavBar,
Lazyload,
Toast,
Search,
ActionSheet,
CellGroup,
Image as VanImage,
Tag,
Field,
Stepper,
Divider,
Step,
Steps,
NoticeBar,
RadioGroup,
Radio,
Uploader,
Tab,
Tabs,
DropdownMenu,
DropdownItem,
Grid,
GridItem,
Popup,
Calendar,
Cascader,
Checkbox,
CheckboxGroup,
Notify,
Icon,
Empty,
PullRefresh,
Picker,
Dialog
} from 'vant'
export const components = [
Button,
List,
Cell,
Tabbar,
TabbarItem,
NavBar,
Search,
ActionSheet,
CellGroup,
VanImage,
Tag,
Field,
Stepper,
Divider,
Step,
Steps,
NoticeBar,
RadioGroup,
Radio,
Uploader,
Tab,
Tabs,
DropdownMenu,
DropdownItem,
Grid,
GridItem,
Popup,
Calendar,
Cascader,
Checkbox,
CheckboxGroup,
Notify,
Icon,
Empty,
PullRefresh,
Picker,
Dialog
]
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-09 17:11:43
*/
import router from './router'
import { keeps } from './routes'
export const keepAlives = keeps
export default router
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-09 10:59:50
* @LastEditors: limin
* @LastEditTime: 2021-06-29 14:51:39
*/
import Vue from 'vue'
import Router from 'vue-router'
import routes from './routes'
import store from '@/store'
import { store as local } from 'utils'
// hack router push callback
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}
Vue.use(Router)
const router = createRouter()
function createRouter() {
return new Router({
mode: 'history', // 如果是 history模式 需要配置vue.config.js publicPath
base: process.env.BASE_URL,
scrollBehavior: function(to, from, savedPosition) {
return savedPosition || { x: 0, y: 0 }
},
routes
})
}
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
if (to.meta.title) {
store.dispatch('setPageMeta', to.meta)
}
next()
})
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
const newRouter = createRouter()
router.matcher = newRouter.matcher // reset router
}
export default router
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-09 10:59:31
* @LastEditors: limin
* @LastEditTime: 2021-07-06 12:27:30
*/
const routesKeys = Object.freeze([
{
name: 'PermissionDennied',
path: 'home/dennied',
meta: {
title: '无访问权限',
isNoBack: true
}
},
{
name: 'Home',
path: 'home/index',
meta: {
title: '首页',
deepth: 1, // 标识路由的深度 数字越大深度越深 (用于判断路由的前进与返回)
keepAlive: false
}
},
{
name: 'Work',
path: 'work/index',
meta: {
title: '测试',
deepth: 1, // 标识路由的深度 数字越大深度越深 (用于判断路由的前进与返回)
keepAlive: false
}
},
{
name: 'Test',
path: 'work/sub/index',
meta: {
title: 'test',
deepth: 1, // 标识路由的深度 数字越大深度越深 (用于判断路由的前进与返回)
keepAlive: false
}
}
])
const keepAlives = []
const children = routesKeys.map(key => {
const { name, params, meta, path, redirect } = key
if (meta && meta.keepAlive) {
keepAlives.push(name)
}
let _path = `/${path.replace(/sub\/|\/index/g, '')}`
if (params) {
_path = `${_path}/:${params}`
}
console.log(_path)
return {
path: _path,
redirect,
name,
component: resolve => require([`views/${path}.vue`], resolve),
meta
}
})
const routes = [
{
path: '/',
component: resolve => require([`views/layouts/index`], resolve),
redirect: '/home',
meta: {
title: '首页',
keepAlive: false
},
children
}
]
routes.push({ path: '*', redirect: '/home' })
export const keeps = keepAlives
export default routes
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:49:54
* @FilePath: \gh-hall\src\store\getters.js
*/
const getters = {
app: state => state.app
}
export default getters
import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import app from './modules/app'
// import createPersistedState from "vuex-persistedstate"
Vue.use(Vuex)
const store = new Vuex.Store({
modules: {
app
},
getters
// plugins: [createPersistedState({
// //指定存储模式
// storage: window.sessionStorage
// })]
})
export default store
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-07-06 12:02:21
*/
import api from '@/api'
import { store } from 'utils'
const state = {
userName: '',
pageMeta: '',
user: '',
wxUserId: '',
customerId: 0,
keepAlives: [],
transitionName: '',
isSubmit: false,
isDennied: false
}
const mutations = {
SET_USER_NAME(state, name) {
state.userName = name
},
SET_PAGE_META(state, meta) {
state.pageMeta = meta
},
SET_USER(state, user) {
state.user = user
},
SET_WXUSERID(state, userid) {
state.wxUserId = userid
},
SET_CUSTOMER_ID(state, id) {
state.customerId = id
},
PUSH_KEEP(state, name) {
if (!state.keepAlives.includes(name)) {
state.keepAlives.push(name)
}
},
REMOVE_KEEP(state, names) {
state.keepAlives = state.keepAlives.reduce((arr, name) => {
if (!names.includes(name)) {
return arr.push(name)
}
return arr
}, [])
},
SET_TRANSITION_NAME(state, name) {
state.transitionName = name
},
SET_ISSUBMIT(state, value) {
state.isSubmit = value
},
SET_ISDENNIED(state, isDennied) {
state.isDennied = isDennied
}
}
const actions = {
// 设置name
setUser({ commit }, user) {
commit('SET_USER', user)
store.set(store.consts.USER_KEY, user)
},
setPageMeta({ commit }, meta) {
document.title = meta.title
commit('SET_PAGE_META', meta)
},
login({ dispatch }, { code, type }) {
return new Promise((resolve, reject) => {
api.common
.login(code, type)
.then(({ data, code, message }) => {
if (code == 200) {
dispatch('setUser', { token: data })
resolve()
} else {
reject(message)
}
})
.catch(reject)
})
},
logout({ dispatch }) {
return new Promise((resolve, reject) => {
dispatch('setUser', '')
resolve()
})
},
setWxUserId({ commit }, id) {
return new Promise((resolve, reject) => {
commit('SET_WXUSERID', id)
store.set(store.consts.WX_USERID_KEY, id)
resolve()
})
},
setCustomerId({ commit }, id) {
commit('SET_CUSTOMER_ID', id)
},
pushKeep({ commit }, name) {
commit('PUSH_KEEP', name)
},
removeKeep({ commit }, names) {
commit('REMOVE_KEEP', names)
},
setTransitionName({ commit }, name) {
commit('SET_TRANSITION_NAME', name)
},
setSubmit({ commit }, value) {
commit('SET_ISSUBMIT', value)
},
setIsDennied({ commit }, isDennied) {
commit('SET_ISDENNIED', isDennied)
}
}
export default {
state,
mutations,
actions
}
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-15 14:41:02
* @LastEditors: limin
* @LastEditTime: 2021-06-15 14:45:39
*/
export const STORE_USER_KEY = 'STORE_USER_KEY'
const Customer = {
type: {
name: '客户类型',
value: [
{ name: '个人', value: 13 },
{ name: '企业', value: 14 }
]
},
sex: {
name: '性别',
value: [
// { name: '未知', value: 0 },
{ name: '男', value: 1 },
{ name: '女', value: 2 }
]
},
// 证件类型
cert: {
name: '证件类型',
value: [
{ name: '无证件类型', value: '' },
{ name: '身份证', value: 7 },
{ name: '军官证', value: 8 },
{ name: '出生证', value: 9 },
{ name: '港澳台通行证', value: 10 },
{ name: '护照', value: 11 },
{ name: '其他证件', value: 12 }
]
},
// 进店类型
from: {
name: '进店类型',
value: [
{ name: '展厅客户', value: 15 },
{ name: '网电客户', value: 16 },
{ name: '其他客户', value: 17 }
]
},
// 进店渠道
channel: {
name: '进店渠道',
value: [
{ name: '自然到店', value: 18 },
{ name: '朋友介绍', value: 19 },
{ name: '车展', value: 20 },
{ name: '网络', value: 21 },
{ name: '报纸', value: 22 },
{ name: '电台', value: 23 },
{ name: '广告牌', value: 24 },
{ name: '其他', value: 25 }
]
},
// 信息来源
msgfrom: {
name: '信息来源',
value: [
{ name: '报纸', value: 26 },
{ name: '电台', value: 27 },
{ name: '网络', value: 28 },
{ name: '电视', value: 29 },
{ name: '短信', value: 30 },
{ name: '转介绍', value: 31 },
{ name: '广告', value: 32 },
{ name: '电梯', value: 33 },
{ name: '微信', value: 34 },
{ name: '车展', value: 35 },
{ name: '其他', value: 36 }
]
},
// 意向级别
level: {
name: '客户级别',
value: [
{ name: 'H.一周内', value: 37 },
{ name: 'A.半个月内', value: 38 },
{ name: 'B.1个月内', value: 39 },
{ name: 'C.3个月内', value: 40 },
{ name: 'N.3个月后', value: 41 },
{ name: 'F.战败', value: 42 },
{ name: 'O.订车', value: 43 }
]
}
}
const Order = {
type: {
name: '订单类型',
value: [
{ name: '350X:整车:展厅销售订单', value: 44 },
{ name: 'Q004:整车:二网销售订单', value: 45 },
{ name: 'Q005:整车:大客户销售订单', value: 46 },
{ name: 'Q006:整车:网电销售订单', value: 47 },
{ name: 'JK001:新车销售:平行进口车业务', value: 48 }
]
}
}
const YoN = [
{ name: '是', value: 'Y' },
{ name: '否', value: 'N' }
]
const demand = {
isAssess: {
name: '是否评估',
value: [
{ name: '是', value: 'Y' },
{ name: '否', value: 'N' }
]
},
hasDecorate: {
name: '是否有装潢需求',
value: [
{ name: '是', value: 'Y' },
{ name: '否', value: 'N' }
]
},
hasFinance: {
name: '是否有金融需求',
value: [
{ name: '是', value: 'Y' },
{ name: '否', value: 'N' }
]
},
hasInsurance: {
name: '是否有保险需求',
value: [
{ name: '是', value: 'Y' },
{ name: '否', value: 'N' }
]
},
hasReinsurance: {
name: '是否有延保需求',
value: [
{ name: '是', value: 'Y' },
{ name: '否', value: 'N' }
]
},
hasLicensePlate: {
name: '是否有上牌需求',
value: [
{ name: '是', value: 'Y' },
{ name: '否', value: 'N' }
]
},
hasDisplace: {
name: '是否有置换需求',
value: [
{ name: '是', value: 'Y' },
{ name: '否', value: 'N' }
]
},
buyType: {
name: '购买类型',
value: [
{ name: '首次购车', value: 2 },
{ name: '本品牌增购', value: 3 },
{ name: '其他品牌增购', value: 4 },
{ name: '本品牌置换', value: 5 },
{ name: '其他品牌置换', value: 6 }
]
},
increment: {
name: '增值信息',
value: [
{ name: '装潢', value: '1', key: 'hasDecorate' },
{ name: '金融', value: '2', key: 'hasFinance' },
{ name: '保险', value: '3', key: 'hasInsurance' },
{ name: '延保', value: '4', key: 'hasReinsurance' },
{ name: '上牌', value: '5', key: 'hasLicensePlate' },
{ name: '置换', value: '6', key: 'hasDisplace' }
]
}
}
// 所有下拉列表
const dropdown = {
orderStatus: [
{ text: '全部', value: '' },
{ text: '提交审核', value: 'APPROVAL' },
// { text: '成功', value: 'APPROVED' },
{ text: '审核失败', value: 'NOTPASS' },
{ text: '已下订', value: 'PLACEORDER' },
{ text: '下订失败', value: 'FAILURE' },
{ text: '结算', value: 'SETTLEMENT' },
{ text: '取消结算', value: 'CANCEL' },
{ text: '出库', value: 'DELIVERY' },
{ text: '拒绝', value: 'REJECTED' }
],
orderType: [
{ text: '全部', value: '' },
{ text: '展厅', value: 44 },
{ text: '二网', value: 45 },
{ text: '大客户', value: 46 },
{ text: '网电', value: 47 },
{ text: '平行进口', value: 48 }
]
}
export default Object.freeze({
Customer,
Order,
demand,
dropdown})
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-09 17:01:55
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:49:18
* @FilePath: \gh-hall\src\utils\eventBus.js
*/
/**
* eventBus,事件总线,可以在任意组件之间实现事件通信
* 使用方法,使用下面的两行代码即可创建一个 eventBus,创建好以后在 main,js 中引入
* 并通过 Vue.prototype.bus = bus 将 eventBus 挂载到 vue 的原型上就可以全局使用 eventBus 了
*
* 发送事件:在触发事件的地方使用 $emit 来发送事件
* this.bus.$emit(‘事件名’,eventData)
*
* 接收事件:在需要接收事件的地方使用 $on 来接收事件
* this.bus.$on(‘事件名’,(eventData)=>{
console.log(eventData)
})
*
* 注销事件:$emit 定义的事件必须要在组件销毁之前注销,不然事件会一直触发
* beforeDestroy() {
this.bus.$off(‘事件名’);
},
*/
import Vue from 'vue'
export default new Vue()
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:49:11
*/
import bus from './eventBus'
import * as tool from './tools'
const { debounce, throttle, ...tools } = tool
import datas from './data'
const { Customer: customerData, Order: orderData, demand: damandData, dropdown: dropdownData } = datas
import * as constants from './constants'
import store from './store'
export { bus, tools, debounce, throttle, customerData, orderData, damandData, dropdownData, constants, store }
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-15 14:46:31
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:49:04
*/
import store from 'storejs'
export default {
...store,
exp: {
set: function (key, val, exp = 24 * 60 * 60 * 1000) {
store.set(key, { val: val, exp: exp, time: new Date().getTime() })
},
get: function (key) {
var info = store.get(key)
if (!info) {
return null
}
if (new Date().getTime() - info.time > info.exp) {
store.remove(key)
return null
}
return info.val
}
},
consts: {
USER_KEY: 'USER_KEY',
WX_USERID_KEY: 'WX_USERID_KEY'
}
}
/**
* 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, ' ') +
'"}'
)
}
export function debounce(fn, delay = 500) {
// timer 是在闭包中的
let timer = null
return function() {
clearTimeout(timer)
timer = setTimeout(() => {
fn.apply(this, arguments)
}, delay)
}
}
export function throttle(fn, delay = 500) {
let timer = null
return function(e) {
if (timer) {
return
}
timer = setTimeout(() => {
fn.apply(this, arguments)
// fn(e)
timer = null
}, delay)
}
}
/**
* 深拷贝
* @param {} target
*/
export function deepClone(target) {
// 定义一个变量
let result
// 如果当前需要深拷贝的是一个对象的话
if (typeof target === 'object') {
// 如果是一个数组的话
if (Array.isArray(target)) {
result = [] // 将result赋值为一个数组,并且执行遍历
for (let i in target) {
// 递归克隆数组中的每一项
result.push(this.deepClone(target[i]))
}
// 判断如果当前的值是null的话;直接赋值为null
} else if (target === null) {
result = null
// 判断如果当前的值是一个RegExp对象的话,直接赋值
} else if (target.constructor === RegExp) {
result = target
} else {
// 否则是普通对象,直接for in循环,递归赋值对象的所有值
result = {}
for (let i in target) {
result[i] = this.deepClone(target[i])
}
}
// 如果不是对象的话,就是基本数据类型,那么直接赋值
} else {
result = target
}
// 返回最终结果
return result
}
export function fixed(num, decimal) {
num = num.toString()
let index = num.indexOf('.')
if (index !== -1) {
num = num.substring(0, decimal + index + 1)
} else {
num = num.substring(0)
}
return parseFloat(num).toFixed(decimal)
}
/**
* 四舍五入,保留指定小数位数,当原始数据不满足长度时,补 0
* @param number [Number | String] 原始数据,支持字符串和数值型
* @param i [Number] 保留的小数个数 >= 0
* @returns [Number] 转换后的数据
*/
export function transformDecimal(number, i) {
let decimalNum = null
// 先转换为数值型
let num = Number(number)
// 判断是否为数值型
if (!isNaN(num)) {
// 切分整数与小数
let arr = num.toString().split('.')
// 是小数且小数位大于保留个数
if (arr.length > 1 && arr[1].length > i) {
// 小数部分字符串
let decimal = arr[1].slice(i, i + 1)
// toFixed 有 bug,四舍六入五随机
// 当四舍五入的数为 5,给其 + 1
if (decimal === '5') {
// 这里可能会存在 0.1 ** 5 = 0.000010000000000000003 但不影响四舍五入
num += Math.pow(0.1, i + 1)
}
decimalNum = num.toFixed(i)
} else {
decimalNum = num
}
decimalNum = Number(decimalNum).toFixed(i)
}
return decimalNum
}
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-14 19:04:50
* @LastEditors: limin
* @LastEditTime: 2021-06-15 01:02:27
*/
import Vue from 'vue'
import { ValidationObserver, ValidationProvider, extend, localize } from 'vee-validate'
import { required, email } from 'vee-validate/dist/rules' // 验证规则导入
// import CN from 'vee-validate/dist/locale/zh_CN.json' // 加载语言包
extend('required', required)
extend('email', email)
localize('zh_CN', {
name: 'zh_CN',
messages: {
// your messages.
_default: (field) => `${field}无效`,
after: (field, [target]) => `${field}必须在${target}之后`,
alpha_dash: (field) => `${field}能够包含字母数字字符、破折号和下划线`,
alpha_num: (field) => `${field}只能包含字母数字字符`,
alpha_spaces: (field) => `${field}只能包含字母字符和空格`,
alpha: (field) => `${field}只能包含字母字符`,
before: (field, [target]) => `${field}必须在${target}之前`,
between: (field, [min, max]) => `${field}必须在${min}与${max}之间`,
confirmed: (field, [confirmedField]) =>
`${field}不能和${confirmedField}匹配`,
credit_card: (field) => `${field}格式错误`,
date_between: (field, [min, max]) => `${field}必须在${min}和${max}之间`,
date_format: (field, [format]) => `${field}必须符合${format}格式`,
decimal: (field, [decimals = '*'] = []) =>
`${field}必须是数字,且能够保留${
decimals === '*' ? '' : decimals}位小数`,
digits: (field, [length]) =>
`${field}必须是数字,且精确到${length}位数`,
dimensions: (field, [width, height]) =>
`${field}必须在${width}像素与${height}像素之间`,
email: (field) => `${field}不是一个有效的邮箱`,
ext: (field) => `${field}不是一个有效的文件`,
image: (field) => `${field}不是一张有效的图片`,
included: (field) => `${field}不是一个有效值`,
integer: (field) => `${field}必须是整数`,
ip: (field) => `${field}不是一个有效的地址`,
length: (field, [length, max]) => {
if (max) {
return `${field}长度必须在${length}到${max}之间`
}
return `${field}长度必须为${length}`
},
max: (field, [length]) => `${field}不能超过${length}个字符`,
max_value: (field, [max]) => `${field}必须小于或等于${max}`,
mimes: (field) => `${field}不是一个有效的文件类型`,
min: (field, [length]) => `${field}必须至少有${length}个字符`,
min_value: (field, [min]) => `${field}必须大于或等于${min}`,
excluded: (field) => `${field}不是一个有效值`,
numeric: (field) => `${field}只能包含数字字符`,
regex: (field) => `${field}格式无效`,
required: (field) => `请输入${field}`,
url: (field) => field + '不是一个有效的url'
}
})
// 手机号码验证
extend('mobile', {
message: `请输入正确的手机号码`,
validate: value => value.length === 11 && /^1[3456789]\d{9}$/.test(value)
})
Vue.component('ValidationObserver', ValidationObserver)
Vue.component('ValidationProvider', ValidationProvider)
export const Validator = {
/* 手机号码格式校验正则 */
PHONEREG: /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/,
/* 同时包含字母和数字 */
ISNUMANDLETTERS: /^[a-zA-Z0-9]+$/,
/* 特殊字符正则 */
SPECIALLETTER: new RegExp("[`~!@#$^&*=|{}':;',\\[\\]<>?~!@#¥……&*——|{}【】‘;:”“'。,、? ]"),
/* 邮箱地址格式正则 */
// EMAILREG:/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/,
EMAILREG: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
/* 判断是否为中文 */
ISCHINESE: /^[\u0391-\uFFE5]+$/,
/* 判断是否为英文字母 */
ISENGLISH: /^[a-zA-Z]+$/,
/* 是否包含空格 */
ISHAVENULL: /^[^\s]*$/,
/* 保留两位小数 */
TWODECIMAL: /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/,
/* 判断是否为正整数 */
ISDECIMAL: /^[0-9]*$/,
/**
* 账号管理-手机号码校验
*/
checkPhoneNumber: (str) => {
return Validator.PHONEREG.test(str)
},
// 判断是否含有数字或字母
checkNumOrLetters: (str) => {
return Validator.ISNUMANDLETTERS.test(str)
},
// 身份证验证
checkIdCard: (code) => {
var city = {
11: '北京',
12: '天津',
13: '河北',
14: '山西',
15: '内蒙古',
21: '辽宁',
22: '吉林',
23: '黑龙江',
31: '上海',
32: '江苏',
33: '浙江',
34: '安徽',
35: '福建',
36: '江西',
37: '山东',
41: '河南',
42: '湖北',
43: '湖南',
44: '广东',
45: '广西',
46: '海南',
50: '重庆',
51: '四川',
52: '贵州',
53: '云南',
54: '西藏 ',
61: '陕西',
62: '甘肃',
63: '青海',
64: '宁夏',
65: '新疆',
71: '台湾',
81: '香港',
82: '澳门',
91: '国外 '
}
// var tip = ''
var pass = true
// 身份证位数为15或18位
if (![15, 18].includes(code.length)) {
pass = false
} else if (!code || (code.length === 18 && !/^\d{6}(18|19|20)\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code))) {
// tip = '身份证号格式错误'
pass = false
} else if (code.length === 15 && !/^\d{6}\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}$/i.test(code)) {
pass = false
} else if (!city[code.substr(0, 2)]) {
// tip = '地址编码错误'
pass = false
} else {
// 18位身份证需要验证最后一位校验位
if (code.length === 18) {
code = code.split('')
// ∑(ai×Wi)(mod 11)
// 加权因子
var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
// 校验位
var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2]
var sum = 0
var ai = 0
var wi = 0
for (var i = 0; i < 17; i++) {
ai = code[i]
wi = factor[i]
sum += ai * wi
}
// var last = parity[sum % 11]
if (parity[sum % 11] != code[17]) {
// tip = '校验位错误'
pass = false
}
}
}
// if (!pass) alert(tip)
return pass
}
}
<!-- home -->
<template>
<div class="about-container"></div>
</template>
<script>
// 请求接口
export default {
data() {
return {
wechat: `${this.$cdn}/wx/640.gif`
}
}
}
</script>
<style lang="scss">
.about-container {
.logo {
width: 120px;
height: 120px;
background: url($cdn + '/weapp/logo.png') center / contain no-repeat;
}
}
</style>
<!-- home -->
<template>
<van-empty image="error" description="尚无权限访问,请联系管理员授权" />
</template>
<script>
// 请求接口
export default {}
</script>
<style lang="scss"></style>
<!-- home -->
<template>
<div class="index-container">
<div class="warpper">
<h1 class="demo-home__title">VUE</h1>
<h2 class="demo-home__desc">A vue h5 template with Vant UI</h2>
</div>
<van-cell icon="success" v-for="item in list" :key="item" :title="item" />
</div>
</template>
<script>
export default {
data() {
return {
list: [
'Vue-cli4',
'配置多环境变量',
'VantUI 组件按需加载',
'Sass 全局样式',
'Webpack 4',
'Vuex 状态管理',
'Axios 封装及接口管理',
'Vue-router',
'Webpack 4 vue.config.js 基础配置',
'配置 proxy 跨域',
'配置 alias 别名',
'配置 打包分析',
'配置 externals 引入 cdn 资源',
'去掉 console.log',
'splitChunks 单独打包第三方模块',
'添加 IE 兼容',
'Eslint+Pettier 统一开发规范'
]
}
},
computed: {},
mounted() {},
methods: {}
}
</script>
<style lang="scss" scoped>
.index-container {
.warpper {
padding: 12px;
background: #fff;
.demo-home__title {
margin: 0 0 6px;
font-size: 32px;
.demo-home__title img,
.demo-home__title span {
display: inline-block;
vertical-align: middle;
}
img {
width: 32px;
}
span {
margin-left: 16px;
font-weight: 500;
}
}
.demo-home__desc {
margin: 0 0 20px;
color: rgba(69, 90, 100, 0.6);
font-size: 14px;
}
}
}
</style>
<!-- login -->
<template>
<div class="box">
<div class="loader"></div>
</div>
</template>
<script>
import { mapActions } from 'vuex'
export default {
data() {
return {}
},
mounted() {
const {
query: { path, type },
params: { code }
} = this.$route
if (code) {
this.login({ code, type })
.then(res => {
if (path) {
this.$router.push(path)
}
})
.catch(res => {
this.$notify(res)
})
} else {
// store.dispatch('logout').then(() =>
// Dialog.alert({
// title: '提示',
// message: '请重新进入',
// theme: 'round-button',
// }).then(() => {}))
}
},
methods: {
...mapActions(['login'])
}
}
</script>
<style lang="scss" scoped>
.box {
font-size: 20px;
margin-top: 20px;
color: rgba(10, 36, 106, 0.5);
text-align: center;
}
.loader {
position: relative;
display: inline-block;
width: 1em;
height: 1em;
color: inherit;
vertical-align: middle;
pointer-events: none;
background: currentcolor;
position: relative;
-webkit-animation: animat 1s ease-in-out infinite;
animation: animat 1s ease-in-out infinite;
-webkit-animation-delay: 0.4s;
animation-delay: 0.4s;
width: 0.25em;
height: 0.5em;
}
.loader:after,
.loader:before {
content: '';
position: absolute;
width: inherit;
height: inherit;
background: inherit;
-webkit-animation: inherit;
animation: inherit;
}
.loader:before {
right: 0.5em;
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s;
}
.loader:after {
left: 0.5em;
-webkit-animation-delay: 0.6s;
animation-delay: 0.6s;
}
@keyframes animat {
0%,
100% {
box-shadow: 0 0 0 currentcolor, 0 0 0 currentcolor;
}
50% {
box-shadow: 0 -0.25em 0 currentcolor, 0 0.25em 0 currentcolor;
}
}
</style>
<template>
<div class="app-container">
<div class="layout-content">
<NavBar :meta="app.pageMeta">
<!-- <keep-alive v-if="$route.meta.keepAlive">
<router-view></router-view>
</keep-alive>
<router-view v-else></router-view> -->
<!--缓存想要缓存的页面,实现后退不刷新-->
<!--加上v-if的判断,可以自定义想要缓存的组件,自定义在router里面-->
<div class="container">
<transition :name="app.transitionName" mode="out-in">
<keep-alive :include="app.keepAlives">
<router-view />
</keep-alive>
</transition>
</div>
</NavBar>
</div>
<div class="layout-footer"></div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'AppLayout',
computed: {
...mapGetters(['app'])
}
}
</script>
<style lang="scss" scoped>
.app-container {
.layout-content {
.container {
height: calc(100vh - 46px);
}
}
}
</style>
<!-- home -->
<template>
<div class="index-container">
dasfdfa
</div>
</template>
<script>
export default {
name: 'Work',
data() {
return {
list: [
'Vue-cli4',
'配置多环境变量',
'VantUI 组件按需加载',
'Sass 全局样式',
'Webpack 4',
'Vuex 状态管理',
'Axios 封装及接口管理',
'Vue-router',
'Webpack 4 vue.config.js 基础配置',
'配置 proxy 跨域',
'配置 alias 别名',
'配置 打包分析',
'配置 externals 引入 cdn 资源',
'去掉 console.log',
'splitChunks 单独打包第三方模块',
'添加 IE 兼容',
'Eslint+Pettier 统一开发规范'
]
}
},
computed: {},
mounted() {},
methods: {}
}
</script>
<style lang="scss" scoped>
.index-container {
.warpper {
padding: 12px;
background: #fff;
.demo-home__title {
margin: 0 0 6px;
font-size: 32px;
.demo-home__title img,
.demo-home__title span {
display: inline-block;
vertical-align: middle;
}
img {
width: 32px;
}
span {
margin-left: 16px;
font-weight: 500;
}
}
.demo-home__desc {
margin: 0 0 20px;
color: rgba(69, 90, 100, 0.6);
font-size: 14px;
}
}
}
</style>
<!-- home -->
<template>
<div class="index-container">
44444444444444444
</div>
</template>
<script>
export default {
name: 'Work',
data() {
return {
list: [
'Vue-cli4',
'配置多环境变量',
'VantUI 组件按需加载',
'Sass 全局样式',
'Webpack 4',
'Vuex 状态管理',
'Axios 封装及接口管理',
'Vue-router',
'Webpack 4 vue.config.js 基础配置',
'配置 proxy 跨域',
'配置 alias 别名',
'配置 打包分析',
'配置 externals 引入 cdn 资源',
'去掉 console.log',
'splitChunks 单独打包第三方模块',
'添加 IE 兼容',
'Eslint+Pettier 统一开发规范'
]
}
},
computed: {},
mounted() {},
methods: {}
}
</script>
<style lang="scss" scoped>
.index-container {
.warpper {
padding: 12px;
background: #fff;
.demo-home__title {
margin: 0 0 6px;
font-size: 32px;
.demo-home__title img,
.demo-home__title span {
display: inline-block;
vertical-align: middle;
}
img {
width: 32px;
}
span {
margin-left: 16px;
font-weight: 500;
}
}
.demo-home__desc {
margin: 0 0 20px;
color: rgba(69, 90, 100, 0.6);
font-size: 14px;
}
}
}
</style>
static/me.png

45.2 KB

'use strict'
const path = require('path')
const defaultSettings = require('./src/config/conf.js')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const resolve = dir => path.join(__dirname, dir)
// page title
const name = defaultSettings.title || 'vue mobile template'
// 生产环境,测试和正式
const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV)
// externals
// const externals = {
// vue: 'Vue',
// 'vue-router': 'VueRouter',
// vuex: 'Vuex',
// vant: 'vant',
// axios: 'axios'
// }
// CDN外链,会插入到index.html中
// const cdn = {
// // 开发环境
// dev: {
// css: [],
// js: []
// },
// // 生产环境
// build: {
// css: ['https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.css'],
// js: [
// 'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js',
// 'https://cdn.jsdelivr.net/npm/vue-router@3.1.5/dist/vue-router.min.js',
// 'https://cdn.jsdelivr.net/npm/axios@0.19.2/dist/axios.min.js',
// 'https://cdn.jsdelivr.net/npm/vuex@3.1.2/dist/vuex.min.js',
// 'https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.min.js'
// ]
// }
// }
module.exports = {
// publicPath: './', // 署应用包时的基本 URL。 vue-router hash 模式使用
publicPath: '/hall', // 署应用包时的基本 URL。 vue-router history模式使用
outputDir: 'dist', // 生产环境构建文件的目录
assetsDir: 'static', // outputDir的静态资源(js、css、img、fonts)目录
lintOnSave: !IS_PROD,
productionSourceMap: false, // 如果不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
devServer: {
port: 9527, // 端口
open: false, // 启动后打开浏览器
overlay: {
// 当出现编译器错误或警告时,在浏览器中显示全屏覆盖层
warnings: false,
errors: true
}
// proxy: {
// //配置跨域
// '/api': {
// target: "https://test.xxx.com",
// // ws:true,
// changOrigin:true,
// pathRewrite:{
// '^/api':'/'
// }
// }
// }
},
css: {
extract: IS_PROD, // 是否将组件中的 CSS 提取至一个独立的 CSS 文件中 (而不是动态注入到 JavaScript 中的 inline 代码)。
sourceMap: false,
loaderOptions: {
scss: {
// 向全局sass样式传入共享的全局变量, $src可以配置图片cdn前缀
// 详情: https://cli.vuejs.org/guide/css.html#passing-options-to-pre-processor-loaders
prependData: `
@import "assets/css/mixin.scss";
@import "assets/css/variables.scss";
$cdn: "${defaultSettings.cdn}";
`
}
}
},
configureWebpack: config => {
config.name = name
// 为生产环境修改配置...
// if (IS_PROD) {
// // externals
// config.externals = externals
// }
},
chainWebpack: config => {
config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test
// 别名 alias
config.resolve.alias
.set('@', resolve('src'))
.set('assets', resolve('src/assets'))
.set('api', resolve('src/api'))
.set('views', resolve('src/views'))
.set('components', resolve('src/components'))
.set('plugins', resolve('src/components'))
.set('utils', resolve('src/utils'))
/**
* 添加CDN参数到htmlWebpackPlugin配置中
*/
// config.plugin('html').tap(args => {
// if (IS_PROD) {
// args[0].cdn = cdn.build
// } else {
// args[0].cdn = cdn.dev
// }
// return args
// })
/**
* 设置保留空格
*/
config.module
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap(options => {
options.compilerOptions.preserveWhitespace = true
return options
})
.end()
/**
* 打包分析
*/
if (IS_PROD) {
config.plugin('webpack-report').use(BundleAnalyzerPlugin, [
{
analyzerMode: 'static'
}
])
}
config
// https://webpack.js.org/configuration/devtool/#development
.when(!IS_PROD, config => config.devtool('cheap-source-map'))
config.when(IS_PROD, config => {
config
.plugin('ScriptExtHtmlWebpackPlugin')
.after('html')
.use('script-ext-html-webpack-plugin', [
{
// 将 runtime 作为内联引入不单独存在
inline: /runtime\..*\.js$/
}
])
.end()
config.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
// cacheGroups 下可以可以配置多个组,每个组根据test设置条件,符合test条件的模块
commons: {
name: 'chunk-commons',
test: resolve('src/components'),
minChunks: 3, // 被至少用三次以上打包分离
priority: 5, // 优先级
reuseExistingChunk: true // 表示是否使用已有的 chunk,如果为 true 则表示如果当前的 chunk 包含的模块已经被抽取出去了,那么将不会重新生成新的。
},
node_vendors: {
name: 'chunk-libs',
chunks: 'initial', // 只打包初始时依赖的第三方
test: /[\\/]node_modules[\\/]/,
priority: 10
},
vantUI: {
name: 'chunk-vantUI', // 单独将 vantUI 拆包
priority: 20, // 数字大权重到,满足多个 cacheGroups 的条件时候分到权重高的
test: /[\\/]node_modules[\\/]_?vant(.*)/
}
}
})
config.optimization.runtimeChunk('single')
})
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!