Commit 6eae7ffd by 前端

commit:项目初始化

1 parent 5e3770bb
Showing 85 changed files with 3381 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 \ 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 \ 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: 1440, // 视窗的宽度,对应的是我们设计稿的宽度,一般是750
unitPrecision: 3, // 指定`px`转换为视窗单位值的小数位数(很多时候无法整除)
viewportUnit: 'vw', // 指定需要转换成的视窗单位,建议使用vw
selectorBlackList: ['.ignore', '.hairlines', 'ign-'], // 指定不转换为视窗单位的类,可以自定义,可以无限添加,建议定义一至两个通用的类名
minPixelValue: 1, // 小于或等于`1px`不转换为视窗单位,你也可以设置为你想要的值
mediaQuery: false // 允许在媒体查询中转换`px`
}
}
}
\ No newline at end of file \ No newline at end of file
{
"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
// 获取 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",
"dev": "npm run serve"
},
"dependencies": {
"autoprefixer": "^8.0.0",
"core-js": "^3.6.4",
"dayjs": "^1.10.5",
"echarts": "^5.3.3",
"lib-flexible": "^0.3.2",
"postcss-loader": "^6.2.0",
"sha1": "^1.1.1",
"storejs": "^1.1.0",
"vconsole": "^3.7.0",
"vue": "^2.6.11",
"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-loader": "^15.9.8",
"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,viewport-fit=cover">
<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>
<!-- 使用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-07 14:12:32
* @LastEditors: huyue
* @LastEditTime: 2022-06-28 15:12:48
*/
const modulesFiles = require.context('./modules', true, /\.js$/)
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
const value = modulesFiles(modulePath)
modules[moduleName] = value.default
return modules
}, {})
export default modules
/*
* @Description: 售后数据
* @Author: huyue
* @Date: 2022-06-28 16:55:48
* @LastEditors: huyue
* @LastEditTime: 2022-06-28 19:13:34
*/
// 品牌-售后档案客户
const getAfterSale = params => {
return window.$HTTP.get('brand/aftersale', params)
}
// 门店-售后档案客户
const getMerchantAfterSale = params => {
return window.$HTTP.get('merchant/aftersale', params)
}
// 获取品牌售后其他信息
const aftersaleother = params => {
return window.$HTTP.get('brand/aftersaleother', params)
}
// 获取门店品牌售后其他信息
const afterMerchantSaleother = params => {
return window.$HTTP.get('merchant/aftersaleother', params)
}
export default { getAfterSale, aftersaleother, afterMerchantSaleother, getMerchantAfterSale }
// window.$HTTP
export default {
/**获取品牌名称*/
getBrandList () {
return window.$HTTP.get('brand/getBrandName', {
req: {
queryTime: window.vm.getCurrentDate()
}
})
}
}
// 获取品牌年龄/性别/购车年限
const overalldistribution = params => {
return window.$HTTP.get('brand/overalldistribution', params)
}
// 获取门店年龄/性别/购车年限
const merchantOveralldistribution = params => {
return window.$HTTP.get('merchant/overalldistribution', params)
}
export default {
overalldistribution,
merchantOveralldistribution
}
// window.$HTTP
export default {
/** 获取品牌---总体模块信息(包括:总客户:total,企微客户:wechat,企微群:wechatGroup,小程序:applet,公众号:publiccus 的基础数据 和 前五排行/后五排行 ) */
getBrandOverallbase(req) {
return window.$HTTP.get('brand/overallbase', { req })
},
/* 获取品牌---总体模块趋势图指标(包括:总客户:total,企微客户:wechat,企微群:wechatGroup,小程序:applet,公众号:publiccus) */
getBrandOveralltrend(req) {
return window.$HTTP.get('brand/overalltrend', { req })
},
/* 获取门店总体相关信息 */
getMerchantOverallbase(req) {
return window.$HTTP.get('merchant/overallbase', { req })
},
/* 获取门店---总体模块趋势图指标(包括:总客户:total,企微客户:wechat,企微群:wechatGroup,小程序:applet,公众号:publiccus) */
getMerchantOveralltrend(req) {
return window.$HTTP.get('merchant/overalltrend', { req })
},
/**
* 获取接入门店数
*/
getMerchantNum(req) {
return window.$HTTP.get('brand/getMerchantNum', { req })
}
}
/*
* @Description: 获取品牌销售相关信息
* @Author: huyue
* @Date: 2022-06-28 14:58:30
* @LastEditors: huyue
* @LastEditTime: 2022-06-30 14:27:04
*/
// 集团相关
// 获取品牌销售模块其他相关信息
const getSales = params => {
return window.$HTTP.get('brand/saleothers', params)
}
// 获取品牌销售转化总数居
const saleTotal = params => {
return window.$HTTP.get('brand/saletotal', params)
}
// 获取品牌销售转化信息
const saleTrans = params => {
return window.$HTTP.get('brand/saleTrans', params)
}
// 获取品牌客流转化趋势
const saleTransTrend = params => {
return window.$HTTP.get('brand/saleTransTrend', params)
}
// 门店相关
// 获取门店销售转化总数据
const storeTotal = params => {
return window.$HTTP.get('merchant/saletotal', params)
}
// 获取门店销售转化相关信息
const storeSaleTrans = params => {
return window.$HTTP.get('merchant/saleTrans', params)
}
// 获取门店销售相关信息
const getMerchantSales = params => {
return window.$HTTP.get('merchant/sale', params)
}
// 获取门店客流转化趋势
const storeTransTrend = params => {
return window.$HTTP.get('merchant/saleTransTrend', params)
}
export default {
getSales,
saleTotal,
saleTrans,
storeTotal,
storeSaleTrans,
getMerchantSales,
saleTransTrend,
storeTransTrend
}
class Request {
DOMAIN = '/dev'
constructor(_request_) {
this.DOMAIN = _request_ ? _request_.baseURL : this.DOMAIN
}
get (url, params, returnAll) {
return this.request('GET', url, params, returnAll)
}
post (url, params, returnAll) {
return this.request('POST', url, params, returnAll)
}
request (method, url, params, returnAll) {
var requestConfig = {
headers: {
// 'Content-Type': method == 'GET' ? 'application/json' : 'application/x-www-form-urlencoded; charset=UTF-8'
'Content-Type': 'application/json'
},
method
}
params.req.corporateGroupName = '广汇'
const { reportParams } = window.vm.$store.state.app
if (reportParams) {
if (reportParams.brand) params.req.brandName = reportParams.brand.name
}
if (method === 'GET') {
var paramsArray = []
Object.keys(params.req).forEach(key => paramsArray.push('req.' + key + '=' + params.req[key]))
if (url.search(/\?/) === -1) {
url += '?' + paramsArray.join('&')
} else {
url += '&' + paramsArray.join('&')
}
}
if (method === 'POST') {
Object.defineProperty(requestConfig, 'body', {
value: JSON.stringify(params)
})
}
return window
.fetch(this.DOMAIN + `/${url}`, requestConfig)
.then(res => {
return res.json()
})
// .catch(error => {
// alert(error)
// })
}
}
export default Request
@import './normalize.scss';
@font-face {
font-family: 'PingFangSC-Regular';
src: url('../font/PingFang-Regular.ttf');
}
html,
body .app {
color: #333333;
font-family: 'PingFangSC-Regular', Arial, Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, sans-serif;
background-color: #fff;
-webkit-overflow-scrolling: touch;
height: 100%;
// overflow: hidden;
--themeColor: #3975c6;
}
img {
width: 100%;
height: 100%;
vertical-align: top;
}
.flex {
display: flex;
align-items: center;
}
.text-hide {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.text-two-line {
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
display: -webkit-box;
-webkit-box-orient: vertical;
}
.text-center {
display: flex;
align-items: center;
justify-content: center;
}
.x-center {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
.y-center {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.box-center {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.user-select {
user-select: none;
}
.pointer {
cursor: pointer;
}
.box {
background: #0b0e31;
// overflow: hidden;
}
.inline {
display: inline-block;
}
.title {
font-size: 0.75vw;
font-weight: 400;
font-size: 11px;
color: #ffffff;
user-select: none;
box-sizing: border-box;
height: 2.07vh;
margin-top:4px;
}
.title-icon {
display: flex;
align-items: center;
.icon {
display: inline-block;
width: 18px;
height: 10px;
margin-right: 4px;
background-image: url(../images/icon.png);
}
}
.container {
margin: 0 8px;
}
.empty {
display: flex;
width: 100%;
height: calc(100% - 4.1vh);
align-items: center;
justify-content: center;
img {
max-width: 20vh;
height: 9.5vh;
}
}
No preview for this file type
<template>
<div class="line-box">
<div :id="domId" class="line-chart"></div>
<div class="rank-box">
<div class="rank-title-block">
<p :class="['rank-title', rankFlag == 'top' ? 'rank-title-active' : '']" @click="handleRankChange('top')">前5{{ storeOrBrandTxt }}</p>
<p :class="['rank-title', rankFlag == 'last' ? 'rank-title-active' : '']" @click="handleRankChange('last')">后5{{ storeOrBrandTxt }}</p>
</div>
<div class="rank-block">
<div class="rank-line" v-for="(item, index) in rankList" :key="index">
<div class="line-item">
<marquee :direction="directionTimer" :delay="delayTimer" :text="item.label"></marquee>
</div>
<div class="line-item">
<marquee class="txt-orange" :direction="directionTimer" :delay="delayTimer" :text="item.value"></marquee>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import datas from '@/utils/data'
import * as echarts from 'echarts'
import getLineOptions from './lineOptions'
export default {
name: 'LineChart',
props: {
domId: {
type: String,
default: 'line-chart'
},
storeOrBrandTxt: {
type: String,
default: '品牌'
},
dataList: {
type: Array,
default: () => []
},
// 0-月表;1-日表
queryType: {
type: Number,
default: 0
},
tooltipFormatterObj: {
type: Array,
default: () => {
return [
{
label: '数量',
attrName: 'num'
},
{
label: '环比',
attrName: 'hrate',
addSymbol: '%'
},
{
label: '同比',
attrName: 'trate',
addSymbol: '%'
}
]
}
}
},
data() {
return {
directionTimer: datas.DefaultData.directionTimer,
delayTimer: datas.DefaultData.delayTimer,
rankFlag: 'top',
lineOptions: [],
rankList: [],
echartsLine: '',
moveAttr: {
// speed: 900,
seriesIndex: 0,
dataIndex: 0
},
timer: null
}
},
created() {
this.lineOptions = getLineOptions({ tooltipFormatter: this.tooltipFormatter })
},
mounted() {
this.lineDom = document.getElementById(this.domId)
this[this.domId] = echarts.init(this.lineDom)
this.chartBindEvent()
},
methods: {
resetRankList() {
this.rankList = new Array(5).fill({ label: '- -', value: '- -' })
},
tooltipFormatter(obj) {
var currentItem = this.dataList[obj[0].dataIndex]
var txt = ''
txt = currentItem.statDate
this.tooltipFormatterObj.forEach(item => {
if (txt) {
txt = txt + '<br>'
}
txt = txt + item.label + ':' + currentItem[item.attrName] + (item.addSymbol || '')
})
return txt
},
chartBindEvent() {
// resize
window.addEventListener('resize', () => {
this[this.domId].resize()
})
// 鼠标划入
// this[this.domId].on('mouseover', data => {
// console.log(data,'data')
// this.moveAttr.dataIndex = data.dataIndex
// console.log(2222222222)
// this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
// })
// 绑定点击事件
this[this.domId].getZr().on('mousemove', params => {
const pointInPixel = [params.offsetX, params.offsetY]
if (this[this.domId].containPixel('grid', pointInPixel)) {
this[this.domId].getZr().setCursorStyle('pointer')
var xIndex = this[this.domId].convertFromPixel({ seriesIndex: 0 }, [params.offsetX, params.offsetY])[0]
/* 事件处理代码书写位置 */
this.moveAttr.dataIndex = xIndex
this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
}
})
this[this.domId].on('mouseout', params => {
var pointInPixel = [params.offsetX, params.offsetY]
if (!this[this.domId].containPixel('grid', pointInPixel)) {
this[this.domId].getZr().setCursorStyle('default')
}
})
// 移除图表
this[this.domId].on('globalout', () => {
this.chartAction()
this.moveAttr.dataIndex = this.dataList.length - 1
this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
})
},
chartAction(type) {
this[this.domId].dispatchAction({
type: type || 'showTip',
seriesIndex: 0,
dataIndex: this.dataList.length - 1
})
},
getRankList(idx, attrName = 'topList') {
this.dataList[idx][attrName].length ? this.$set(this, 'rankList', this.dataList[idx][attrName]) : this.resetRankList()
},
drawLine() {
this.lineOptions.xAxis.data = []
this.dataList.map(e => {
let month = new Date(e.statDate).getMonth()
this.lineOptions.xAxis.data.push(this.queryType == 0 ? `${month == 0 ? '1月' : `${Number(month) + 1}月`}` : e.statDate.split('-').slice(1).join('-'))
})
var seriesDate = this.dataList.map(item => +item.num)
this.lineOptions.series[0].data = seriesDate
this.lineOptions.tooltip.textStyle.fontSize = this.setChartFontSize(10)
if (this.queryType == 0) {
this.lineOptions.yAxis.scale = true
} else {
this.lineOptions.yAxis.max = Math.ceil(Math.max(...seriesDate) / 10) * 10
this.lineOptions.yAxis.min = Math.floor(Math.min(...seriesDate) * 0.9 / 10) * 10
}
this[this.domId].setOption(this.lineOptions)
// 默认展示tooltip
this.chartAction()
this.moveAttr.dataIndex = this.dataList.length - 1
this.getRankList(this.moveAttr.dataIndex)
},
handleRankChange(value) {
this.rankFlag = value
this.moveAttr.dataIndex = this.dataList.length - 1
this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
}
}
}
</script>
<style lang="scss" scoped>
p {
margin: 0 0;
}
.line-box {
height: 100%;
color: #ffffff;
// padding: 4px 8px;
font-size: 0.75em;
overflow: hidden;
.txt-orange {
color: #eb6001;
}
.line-chart {
width: 100%;
height: calc(100% - 3.1vh - 4.6vh);
}
.rank-box {
box-sizing: border-box;
display: flex;
height: 4.6vh;
padding: 0.5vh 0.87vh;
border-top: 1px solid #373739;
.rank-title-block {
// flex: 0 0 55px;
width: 100%;
overflow: hidden;
width: 55px;
.rank-title {
box-sizing: border-box;
width: 100%;
text-align: center;
// font-size: 0.6em;
font-size: 9px;
background: #353535;
padding: 0.2vh 5px;
height: 1.8vh;
opacity: 0.7;
cursor: pointer;
}
.rank-title-active {
opacity: 1;
width: 100%;
color: #ffffff;
background: #eb6001;
}
}
.rank-block {
width: calc(100% - 55px);
display: flex;
.rank-line {
box-sizing: border-box;
width: 20%;
padding: 0 6px;
border-left: 1px solid rgba(96, 98, 102, 0.4);
.line-item {
height: 1.8vh;
width: 100%;
font-size: 0.55vw;
padding-bottom: 0.3vh;
}
.line-item:last-of-type {
padding-bottom: 0;
}
}
.rank-line:first-of-type {
border-width: 0;
}
}
}
}
::v-deep.line-chart {
width: 100%;
height: 100%;
div {
&:nth-child(1) {
width: 100% !important;
height: 100% !important;
canvas {
width: 100% !important;
height: 100% !important;
}
}
}
}
</style>
<template>
<div class="marquee-box" ref="marqueeBox">
<span class="marquee" ref="marqueeText" :style="[{ transition: `all ${move ? speed : 0}s linear` }, { left: target }]">{{ text }}</span>
</div>
</template>
<script type="text/ecmascript-6">
export default {
name: 'Marquee',
props: {
text: String,
direction: {
type: Number,
default: 5000
},
delay: {
type: Number,
default: 1000
}
},
data () {
return {
move: false,
valueWidth: 0,
target: 0,
boxWidth: 0,
speed: 0
}
},
watch:{
'text'(n){
if(n)setTimeout(() => {
let { marqueeBox, marqueeText } = this.$refs
if (!marqueeBox) return
let boxWidth = marqueeBox.offsetWidth,
valueWidth = marqueeText.offsetWidth
this.valueWidth = valueWidth
this.boxWidth = boxWidth
if (boxWidth - 10 <= valueWidth) this.run(valueWidth)
}, this.delay)
}
},
mounted () {
},
methods: {
run () {
let { valueWidth, direction } = this
this.target = `-${valueWidth}px`
this.move = true
this.speed = direction / 1000
setTimeout(() => {
this.again()
}, direction)
},
again () {
let { boxWidth, valueWidth, direction } = this
this.move = false
this.target = `${boxWidth}px`
setTimeout(() => {
this.speed = direction * (boxWidth / valueWidth).toFixed(2) / 1000
this.move = true
this.reset()
}, 500)
},
reset () {
let awaitTime = (this.speed + 2) * this.delay
this.target = 0
setTimeout(() => {
this.run()
}, awaitTime)
}
}
}
</script>
<style scoped lang="scss">
.marquee-box {
width: 100%;
height: 100%;
overflow: hidden;
position: relative;
.marquee {
position: absolute;
white-space: nowrap;
display: flex;
align-items: center;
}
.move {
transform: translateX(-100%);
}
}
</style>
<template>
<div class="pie-box">
<div :id="id" :style="{ height: height }" class="pie-chart"></div>
<div class="center-content" :style="{ fontSize: size }">
<div :class="[id, 'center-content-num', 'center-content-num-color']"></div>
</div>
<div class="content-desc">
<div class="content-desc-icon" :style="{ background: descColor }"></div>
{{ numDesc }}
</div>
</div>
</template>
<script>
import * as echarts from 'echarts'
export default {
name: 'PieChart',
props: {
id: {
type: String,
default: ''
},
keys: {
type: Array,
default: () => ['name', 'value']
},
height: {
type: String,
default: '12.7vh'
},
list: {
type: Array,
default: () => []
},
radius: {
type: Array,
default: () => ['50%', '70%']
},
colors: {
type: Array,
default: () => ['#4FA0FF', '#FF6E76', '#7CFFB2', '#FDF006', '#EB6001', '#F5AA01', '#BF98FF', '#58D9F9']
},
size: {
type: String,
default: '0.6vw'
}
},
data() {
return {
option: '',
echartsPie: '',
mTime: '',
viewData: [],
text: '',
subtext: '',
currentIndex: -1,
mainValue: 0,
numDesc: '',
descColor: ''
}
},
watch: {
list: {
handler(newVal) {
if (newVal.length > 0) {
this.initData()
this.$nextTick(() => {
this.draw()
})
}
},
immediate: true
}
},
mounted() {
// this.initData()
// this.draw()
},
methods: {
//初始化数据
initData() {
let { list, keys } = this
this.viewData = []
list.forEach(item => {
this.viewData.push({
name: item[keys[0]],
value: item[keys[1]]
})
})
},
draw() {
if (this.mTime) clearInterval(this.mTime)
this.echartsPie = echarts.init(document.getElementById(this.id))
window.addEventListener('resize', () => {
this.echartsPie.resize()
})
// 指定图表的配置项和数据
this.option = {
// tooltip: {
// trigger: 'item'
// },
color: this.colors,
series: [
{
name: '客户年龄分布',
type: 'pie',
radius: this.radius,
center: ['50%', '50%'],
avoidLabelOverlap: false,
label: {
normal: {
show: false,
position: 'center'
},
show: false,
position: 'center'
},
emphasis: {
label: {
show: false,
fontSize: '14',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
data: this.viewData,
minAngle: 30
}
]
}
this.echartsPie.clear()
this.mainValue = 0
this.numDesc = ''
// this.setAnamiteText()
this.echartsPie.setOption(this.option)
this.pieActive()
this.mTime = setInterval(this.pieActive, 15000)
// 鼠标划出
this.echartsPie.on('mouseout', () => {
if (this.mTime) clearInterval(this.mTime)
this.mTime = setInterval(this.pieActive, 15000)
})
this.echartsPie.on('mouseover', data => {
this.mainValue = data.data.value
this.numDesc = data.data.name
this.descColor = data.color
this.setAnamiteText()
// 停止定时器,清除之前的高亮
clearInterval(this.mTime)
this.currentIndex = data.dataIndex
this.highlightPie()
this.emitEvent(data.data)
})
},
// 事件触发
emitEvent(data) {
this.text = data.name
this.subtext = data.value
this.echartsPie.setOption(this.option)
this.$emit('pieAction', data)
},
highlightPie() {
// 取消所有高亮并高亮当前图形
// 遍历饼图数据,取消所有图形的高亮效果
for (var idx in this.option.series[0].data)
this.echartsPie.dispatchAction({
type: 'downplay',
seriesIndex: 0,
dataIndex: idx
})
// 高亮当前图形
this.echartsPie.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: this.currentIndex
})
//高亮项this.currentIndex
this.mainValue = this.option.series[0].data[this.currentIndex].value
this.numDesc = this.option.series[0].data[this.currentIndex].name
this.descColor = this.option.color[this.currentIndex]
this.setAnamiteText()
},
setAnamiteText() {
// document.querySelector(`.${this.id}`).nextElementSibling.style = 'animation-iteration-count:infinite;'
// if (document.querySelector(`.${this.id}`))
if (document.querySelector(`.${this.id}`)) {
if (typeof this.mainValue == 'string') {
let dom = document.querySelector(`.${this.id}`)
dom.classList.remove('center-content-num')
dom.innerText = this.mainValue + '%'
} else {
document.querySelector(`.${this.id}`).style = `--step:${this.mainValue}`
}
}
// document.querySelector("div").style.setProperty("--percent", Math.random())
// setTimeout(() => {
// document.querySelector(`.${this.id}`).nextElementSibling.style = 'animation-iteration-count:0'
// }, 3000)
},
//高亮
pieActive() {
const dataLen = this.option.series[0].data.length
this.currentIndex = (this.currentIndex + 1) % dataLen
this.highlightPie()
this.emitEvent(this.viewData[this.currentIndex])
}
}
}
</script>
<style lang="scss" scoped>
.pie-box {
// background: #262525;
position: relative;
flex: 1;
.center-content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
max-width: 40%;
&-num-color {
color: #fff;
}
&-num {
// overflow: hidden;
// text-overflow: ellipsis;
// white-space: nowrap;
// font-size: 0.6vw;
--step: 0;
counter-reset: count var(--step);
z-index: var(--step);
transition: --step 0.5s;
&::before {
content: counter(count);
}
}
&-desc {
font-size: 0.5vw;
color: #606266;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
animation: rotateIn 3s infinite;
}
}
.content-desc {
display: flex;
align-items: center;
font-size: 8px;
color: #c8c8c8;
text-align: center;
font-weight: 400;
position: absolute;
top: 91%;
left: 50%;
transform: translateX(-50%);
text-align: center;
height: 14px !important;
white-space: nowrap;
&-icon {
width: 8px;
height: 4px;
border-radius: 2px;
margin-right: 4px;
}
}
}
@property --step {
syntax: '<integer>';
inherits: false;
initial-value: 15;
}
@keyframes rotateIn {
from {
transform: rotateY(0turn);
}
to {
transform: rotateY(-1turn);
}
}
</style>
<!--
* @Description:
* @Author: huyue
* @Date: 2022-06-28 15:20:14
* @LastEditors: huyue
* @LastEditTime: 2022-07-08 19:03:36
-->
<template>
<div class="ranking-container">
<div class="ranking-title">{{ this.$store.state.app.reportParams.brand ? '门店' : '品牌' }}排名</div>
<div class="ranking">
<div class="brand flex" v-for="(item, index) in brandList" :key="index">
<span class="brand-num">{{ index + 1 }}</span>
<marquee class="marquee" :direction="directionTimer" :delay="delayTimer" :text="item" />
</div>
</div>
</div>
</template>
<script>
export default {
name: 'RanKing',
props: {
list: {
type: Array,
default: () => []
}
},
watch: {
list: {
handler(newVal) {
this.brandList = newVal
}
}
},
data() {
return {
delayTimer: 3000,
directionTimer: 3000,
brandList: this.list,
isBrandName: false
}
}
}
</script>
<style lang="scss" scoped>
.ranking-container {
flex: 1;
margin-left: 0.6vw;
box-sizing: border-box;
height: 12.7vh;
background: #262525;
.ranking-title {
background: rgba(53, 53, 53, 0.6);
font-size: 0.694vw;
color: #eb6001;
font-weight: 400;
padding: 0.4vh 0 0.4vh 20%;
box-sizing: border-box;
}
.ranking {
font-size: 0.694vw;
color: #ffffff;
letter-spacing: 0;
font-weight: 400;
padding: 0.2vh 0 0.3vh 8px;
.brand {
// line-height: 1.9vh;
height: 1.9vh;
display: flex;
align-items: center;
.brand-num {
color: #606266;
margin-right: 0.6vw;
display: inline-block;
width: 0.3vw;
text-align: center;
}
.marquee {
width: 80%;
height: 1.9vh;
font-weight: 400;
}
}
}
}
</style>
<template>
<div class="number-box flex">
<template v-if="numList.length">
<template v-for="(i,index) in numList">
<div :key="index">
{{i}}
</div>
<template v-if="index != numList.length - 1">,</template>
</template>
</template>
<template v-else>
<div
class="transition-number"
:id="idKey"
>
</div>
</template>
<slot name="suffix"></slot>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'TransitionNumber',
props: {
num: [String, Number],
idKey: String,
split: Boolean
},
data () {
return {
numList: []
}
},
watch: {
num (n) {
this.numList = []
setTimeout(() => {
if (n > 0) {
document.querySelector(`#${this.idKey}`).style = `--step:${n}`
setTimeout(() => {
this.numList = this.setPrice(n)
}, 1000)
} else document.querySelector(`#${this.idKey}`).style = `--step:0`
}, 200)
}
},
mounted () {
},
methods: {
setPrice (price) {
let number = (price.toString() || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
return number.split(',')
}
}
}
</script>
<style scoped lang='scss'>
.number-box {
}
.transition-number {
color: inherit;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
--step: 0;
counter-reset: count var(--step);
z-index: var(--step);
transition: --step 1s;
font-size: inherit;
&::before {
content: counter(count);
}
}
@property --step {
syntax: '<integer>';
inherits: false;
initial-value: 15;
}
</style>
<template>
<div class="ViewContainer">
<div class="ViewContainer-title">
<slot name="title" />
</div>
<div class="ViewContainer-body">
<slot name="content" />
</div>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'ViewContainer',
props: {
},
data () {
return {
}
},
mounted () { },
methods: {}
}
</script>
<style scoped lang='scss'>
.ViewContainer {
width: 100vw;
height: 100vh;
&-title {
height: 6.1vh;
width:100%;
background-image: url('../assets/images/bg-title.jpg');
background-repeat: no-repeat;
background-size:cover;
}
&-body {
height: 93.9vh;
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<div class="content">
<view-content-left />
<view-content-right />
</div>
</template>
<script>
export default {
name: 'ViewContent',
props: {
},
data () {
return {
}
},
methods: {
}
}
</script>
<style scoped lang='scss'>
.content {
width: 100%;
height: 100%;
box-sizing: border-box;
position: relative;
padding: 1.46vh 24px 1.95vh;
gap: 0 16px;
display: flex;
justify-content: space-between;
> div {
height: 100%;
}
}
</style>
<template>
<div class="left">
<div class="top">
<view-sub-title title="企业客户总览" />
<view-tabs />
<view-surface/>
<view-pie-group>
<div slot="1"><Area :height="defaultHeight"></Area></div>
<div slot="2"><Brand :height="defaultHeight"></Brand></div>
<div slot="3"><Store :height="defaultHeight"></Store></div>
</view-pie-group>
</div>
<div class="bottom">
<view-sub-title title="SaaS订阅业务总览" />
<OverSize></OverSize>
</div>
</div>
</template>
<script type="text/ecmascript-6">
import datas from '../utils/data'
import Area from '../views/customer/area'
import Store from '../views/customer/store'
import Brand from '../views/customer/brand'
import OverSize from '../views/saas/overview.vue'
export default {
name: 'ViewContentLeft',
components: {
Area,
Store,
Brand,
OverSize
},
data() {
return {
defaultHeight: datas.DefaultData.defaultPieHeight
}
},
mounted() {},
methods: {}
}
</script>
<style scoped lang="scss">
.left {
display: flex;
flex-direction: column;
width: 43.89vw;
overflow: hidden;
.top {
height: 50.49vh;
width: 100%;
background-image: url('../assets/images/bg-1.png');
background-repeat: no-repeat;
background-size: 100% 100%;
padding: 0 16px;
box-sizing: border-box;
}
.bottom {
// height: calc(41% - 16px);
height: 38.05vh;
margin-top: auto;
background-image: url('../assets/images/bg-2.png');
background-repeat: no-repeat;
background-size: 100% 100%;
padding: 0 16px;
box-sizing: border-box;
}
}
</style>
<!--
* @Description:
* @Author: huyue
* @Date: 2022-06-23 10:52:23
* @LastEditors: huyue
* @LastEditTime: 2022-06-24 14:44:50
-->
<template>
<div class="right">
<div class="top">
<view-sub-title title="SaaS+增值转化业务" />
<Business></Business>
<Project></Project>
</div>
<div class="bottom">
<view-sub-title title="私域用户池总结" />
<UserTab></UserTab>
<view-line-group>
<div slot="1"><Analyse :height="defaultHeight"></Analyse></div>
<div slot="2"><Brand :height="defaultHeight"></Brand></div>
<div slot="3"><Area :height="defaultHeight"></Area></div>
</view-line-group>
</div>
</div>
</template>
<script type="text/ecmascript-6">
import datas from '../utils/data'
import Business from '../views/saas/business'
import Project from '../views/saas/project'
import Analyse from '../views/user/analyse'
import Brand from '../views/user/brand'
import Area from '../views/user/area'
import UserTab from '../views/user/usertab'
export default {
name: 'ViewContentRight',
components: {
Business,
Project,
Analyse,
Brand,
Area,
UserTab
},
data() {
return {
defaultHeight: datas.DefaultData.defaultLineHeight
}
},
mounted() {},
methods: {}
}
</script>
<style scoped lang="scss">
.right {
width: 51.67vw;
display: flex;
flex-direction: column;
.top {
height: 33.41vh;
background-image: url('../assets/images/bg-3.png');
background-repeat: no-repeat;
background-size: 100% 100%;
padding: 0 16px;
box-sizing: border-box;
}
.bottom {
height: 55.12vh;
margin-top: auto;
background-image: url('../assets/images/bg-4.png');
background-repeat: no-repeat;
background-size: 100% 100%;
padding: 0 16px;
box-sizing: border-box;
}
}
</style>
<!--
* @Description: 一行两个一组
* @Author: huyue
* @Date: 2022-06-23 11:28:03
* @LastEditors: huyue
* @LastEditTime: 2022-06-24 14:57:41
-->
<template>
<div class="line-group">
<template v-for="(i, index) in items">
<div class="box" :key="index" :style="[{ height: height }, { 'margin-bottom': hideMargin ? 0 : '1vh' }]">
<slot :name="i"></slot>
</div>
</template>
</div>
</template>
<script type="text/ecmascript-6">
import datas from '../utils/data'
export default {
name: 'ViewLineGroup',
props: {
height: {
type: String,
default: datas.DefaultData.defaultLineHeight + 'vh'
},
hideMargin: Boolean
},
data() {
return {
items: [1, 2, 3]
}
},
mounted() {},
methods: {}
}
</script>
<style scoped lang="scss">
.line-group {
display: flex;
gap: 0 4px;
}
</style>
<template>
<div class="pie-group">
<template v-for="(i, index) in items">
<div class="box" :key="index">
<slot :name="i"></slot>
</div>
</template>
</div>
</template>
<script type="text/ecmascript-6">
export default {
name: 'ViewPieGroup',
props: {},
data() {
return {
items: [1, 2, 3]
}
},
mounted() {
},
methods: {
}
}
</script>
<style scoped lang="scss">
.pie-group {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0 8px;
.box {
height:13.05vh;
}
}
</style>
<template>
<div class="sub-title user-select">
<div class="text">{{ title }}</div>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'ViewSubTitle',
props: ['title'],
data() {
return {}
},
mounted() {},
methods: {}
}
</script>
<style scoped lang='scss'>
.sub-title {
width:11.88vw;
height: 2.93vh;
font-size: 12px;
margin-top: 8px;
margin-left:-12px;
background-image: url('../assets/images/title.png');
background-repeat: no-repeat;
background-size: 100% 100%;
.text {
color: #ffffff;
-webkit-background-clip: text;
margin-left: 2.36vw;
line-height: 2.93vh ;
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<div class="surface box">
</div>
</template>
<script type="text/ecmascript-6">
import * as echarts from 'echarts'
export default {
name: 'ViewSurface',
data() {
return {}
},
mounted() {},
methods: {}
}
</script>
<style scoped lang="scss">
.surface {
height:21.46vh;
margin-bottom:0.98vh;
}
</style>
<template>
<div class="tabs box">
<div class="tab">
</div>
</div>
</template>
<script type="text/ecmascript-6">
const tabs = [
{
title: '企微客户',
key: 'wechat'
},
{
title: '企微群数',
key: 'wechatGroup'
},
{
title: '小程序客户数',
key: 'applet'
},
{
title: '公众号客户数',
key: 'publiccus'
}
]
import * as echarts from 'echarts'
export default {
name: 'ViewTabs',
data() {
return {}
},
mounted() {},
methods: {}
}
</script>
<style scoped lang="scss">
.tabs {
margin:1.22vh 0 0.98vh 0;
height:6.95vh;
}
</style>
<template>
<div class="content flex">
<div class="logo user-select">
<img style="height:3.17vh" src="@/assets/images/logo.png" alt="logo" />
</div>
<div class="view-title user-select">嘀加智慧门店运营看板</div>
<div class="time">
<div class="top flex">
<img src="@/assets/images/time.png" class="icon" />
<div class="now">{{ now }}</div>
</div>
</div>
</div>
</template>
<script type="text/ecmascript-6">
export default {
name: 'ViewTitle',
data() {
return {
now: new Date().format('yyyy-MM-dd hh:mm:ss')
}
},
mounted() {
this.timer()
},
methods: {
timer() {
setInterval(() => {
this.now = new Date().format('yyyy-MM-dd hh:mm:ss')
}, 1e3)
}
}
}
</script>
<style scoped lang="scss">
.content {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0 42px 0 76px;
justify-content: space-between;
.view-title {
font-weight: 600;
font-size: 24px;
color: #ffffff;
letter-spacing: 8px;
text-align: center;
}
.time {
text-align: right;
font-size: 14px;
color: #ffffff;
.top {
justify-content: flex-end;
}
.icon {
width: 14px;
height: 14px;
margin-right: 8px;
}
}
}
</style>
/*
* @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)
})
\ No newline at end of file \ No newline at end of file
function getLineOptions(obj) {
const { tooltipFormatter } = obj
var lineOptions = {
tooltip: {
trigger: 'axis',
borderWidth: 0,
backgroundColor: 'rgba(68,68,68,0.80)',
textStyle: {
color: 'rgba(255,255,255,0.6)',
fontSize: '1.5px'
},
formatter: tooltipFormatter || '',
confine: true
},
grid: {
left: '3%',
right: '4%',
top: '10%',
bottom: '10%',
containLabel: true
},
xAxis: {
type: 'category',
axisLabel: {
color: '#606266',
fontSize: '0.8em'
},
data: []
},
yAxis: {
type: 'value',
splitLine: {
lineStyle: {
color: 'rgba(96,98,102,0.2)'
}
},
splitNumber: 4
},
series: [
{
type: 'line',
symbol: 'circle',
itemStyle: {
color: '#F5AA01'
},
// 平滑曲线
smooth: true,
showSymbol: false,
// 折线背景色
areaStyle: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: 'rgba(254, 84, 0, 0.3)'
},
{
offset: 1,
color: 'rgba(254, 84, 0, 0.01)'
}
]
}
},
data: []
}
]
}
return lineOptions
}
export default getLineOptions
/*
* @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: huyue
* @LastEditTime: 2022-07-11 11:01:00
*/
// 本地环境配置
module.exports = {
envVersion: 'trial',
title: '嘀加智慧门店',
request: {
// baseURL: 'http://192.168.3.126:8081', // 本地测试项目地址,
// baseURL: 'http://192.168.1.160:8081', // 本地开发项目地址,
// baseURL: 'http://192.168.1.158:9996',
// baseURL: 'http://192.168.1.152:8081',
baseURL: 'http://bi-view.beta.glsx.com.cn',
// 设置超时时间
timeout: 180000,
// 携带凭证
withCredentials: true,
// 返回数据类型
responseType: 'json'
},
response: {
data_key: 'data',
message_key: 'message',
code_key: 'code',
code_success_value: '0',
errId_logout_value: '21',
logout_function: 'reLogin',
code_message_map: {}
},
}
module.exports = {
title: '嘀加智慧门店',
request: {
// baseURL: 'http://ghwx.cgacar.com/scrm-wechat' // 生产
baseURL: 'http://bi-view.beta.glsx.com.cn' // 生产
// baseURL: 'http://cim.chinagrandauto.com' // 生产
},
APPID: 'xxx',
APPSECRET: 'xxx',
cdn: 'https://www.xxx.cn/static'
}
\ No newline at end of file \ No newline at end of file
module.exports = {
title: '嘀加智慧门店',
request: {
baseURL: 'http://xxxxx' // 项目地址
},
APPID: 'xxx',
APPSECRET: 'xxx',
cdn: 'https://www.xxx.cn/static'
}
\ No newline at end of file \ No newline at end of file
/*
* @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)
}
/**测试mock */ return window.fetch('https://oss-config.dev.glsx.com.cn/mock/6352681802322627d6b83e8c/dj-data-view/config', {}).then(res => res.json())
// return window.fetch('https://oss-config.test.glsx.com.cn/mock/62cbf569f5137cf37678b828/data-view/config', {}).then(res => res.json())
}
export const cfg = {
install(vue, config) {
vue.prototype.$config = config
}
}
/*
* @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 Request from './api/request'
import { fetchConfig, cfg } from '@/config'
import '@/assets/css/index.scss'
import './utils/util'
import 'components'
Vue.prototype.to = function (name, params) {
if (name === -1) {
router.go(-1)
return
}
router.push({ name, params })
}
// 移动端适配 rem
// import 'lib-flexible/flexible.js'
Vue.config.productionTip = false
const isMock = ['prod','production'].includes(process.env.NODE_ENV)
fetchConfig(!isMock).then(res => {
console.log(res)
// 从配置服务器获取动态配置
// 设置 js中可以访问 $cdn
Vue.use(cfg)
// if (res.vconsole) new VConsole()
window.$HTTP = new Request(res.request)
Vue.prototype.api = api
window.vm = new Vue({
el: '#app',
router,
store,
render: h => h(App)
})
})
export default {
watch: {
watchReportParams: {
immediate: true,
handler(newval) {
this && this.init && this.init(newval)
}
}
},
computed: {
watchReportParams() {
return this.$store.state.app.reportParams
}
}
}
import { changeMixin } from './index'
export default {
data() {
return {
clientData: [],
brandList: [],
distributionRank: '',
isBrand: false,
brandName: ''
}
},
mixins: [changeMixin],
created() {
// this.getClientData()
},
methods: {
getClientData() {
let clientApi = !this.isBrand ? 'overalldistribution' : 'merchantOveralldistribution'
const params = {
req: {
queryItem: this.type,
queryTime: this.getCurrentDate()
}
}
if (this.isBrand) params.req.brandName = this.brandName
this.api.customer[clientApi](params).then(res => {
this.clientData = []
this.brandList = []
this.distributionRank = ''
if (res.data.dataList.length > 0) {
let distribution = JSON.parse(res.data.dataList[0].distribution)
// 删掉“未知”
delete distribution['未知']
let keys = Object.keys(distribution)
let total = Object.values(distribution).reduce((prev, next) => prev + next)
keys.forEach((item, index) => {
this.clientData.push({
name: item,
// value: distribution[item]
value: (distribution[item] / total * 100).toFixed(1)
})
})
console.log(this.clientData)
this.distributionRank = JSON.parse(res.data.dataList[0].distributionRank)
}
})
},
init(newVal) {
this.isBrand = false
if (newVal.brand) {
this.isBrand = true
this.brandName = newVal.brand.name
}
this.getClientData()
},
pieAction(data) {
this.brandList = []
let array = this.distributionRank && this.distributionRank[data.name]
if (array && array.length > 0) {
for (let i of array) {
this.brandList.push(i && Object.keys(i)[0])
}
}
}
}
}
import changeMixin from './changeMixin'
import clientMixin from './clientMixin'
import salesMixin from './salesMixin'
export {
changeMixin,
clientMixin,
salesMixin
}
\ No newline at end of file \ No newline at end of file
import { changeMixin } from './index'
export default {
data() {
return {
salesData: [],
brandList: [],
typeRanking: '',
isBrand: false,
brandName: ''
}
},
mixins: [changeMixin],
created() {
// this.getSalesData()
},
methods: {
getSalesData() {
let salesApi = !this.isBrand ? 'getSales' : 'getMerchantSales'
const params = {
req: {
queryItem: this.type,
queryTime: this.getCurrentDate(),
queryType: this.watchReportParams.reportType
}
}
if (this.isBrand) params.req.brandName = this.brandName
this.api.sales[salesApi](params).then(res => {
this.salesData = []
this.typeRanking = ''
this.brandList = []
if (res.data.dataList.length > 0) {
let typeNum = JSON.parse(res.data.dataList[0].typeNum)
Object.keys(typeNum).forEach((item, index) => {
this.salesData.push({
name: item,
value: typeNum[item]
})
})
this.typeRanking = JSON.parse(res.data.dataList[0].typeRanking)
}
})
},
init(newVal) {
this.isBrand = false
if (newVal.brand) {
this.isBrand = true
this.brandName = newVal.brand.name
}
this.getSalesData()
},
pieAction(data) {
this.brandList = []
let array = this.typeRanking && this.typeRanking[data.name]
if (array&&array.length > 0) {
for (let i of array) {
this.brandList.push(i && Object.keys(i)[0])
}
}
}
}
}
/*
* @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'
// 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
})
}
// http://scrm.dev.glsx.com.cn/dj-scrm-wx-work-main/
router.beforeEach((to, from, next) => {
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
\ No newline at end of file \ No newline at end of file
const pages = [
{
name: 'home',
meta: {
isTab: true,
keepAlive: true,
backgroundColor: '#F7F7F7'
},
children: []
}
]
const keepAlives = []
const setChildren = (e, parent) => {
let arr = []
e.children.map(child => {
const { children, meta } = child
let url = `${parent}/${child.name}`
let name = url.replace(/\//g, '.')
let route = {
path: `/${url}`,
name,
meta: meta || {},
component: resolve => require([`views/${url}.vue`], resolve)
}
if (meta && meta.keepAlive) keepAlives.push(name)
if (children) route.children = setChildren(child, url)
arr.push(route)
})
return arr
}
const getPages = _ => {
let router = {
path: '/',
name: 'home',
redirect: '/home',
component: resolve => require([`views/home.vue`], resolve),
}
router.children = pages.map(e => {
let name = `${e.name}`
let route = {
path: `/${name}`,
name,
meta: e.meta || {},
component: resolve => require([`views/${name}/index.vue`], resolve)
}
if (e.children) route.children = setChildren(e, name)
if (e.meta && e.meta.keepAlive) keepAlives.push(name)
return route
})
return [router]
}
export const keeps = keepAlives
export default getPages()
\ No newline at end of file \ No newline at end of file
/*
* @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
*/
const state = {
reportParams: {
reportType: 0 //月表0,日表1
}
}
const mutations = {
SET_PAGE_META (state, meta) {
state.pageMeta = meta
},
}
const actions = {
// 设置name
setUserInfo ({ commit }, user) {
commit('SET_USER_INFO', user)
},
}
export default {
state,
mutations,
actions
}
/*
* @Description: 公共数据
* @Author: huyue
* @Date: 2022-06-23 17:38:33
* @LastEditors: huyue
* @LastEditTime: 2022-06-29 19:47:34
*/
const DefaultData = {
defaultLineHeight: '17.32',
defaultPieHeight: '13.05',
directionTimer: 3000,
delayTimer: 3000
}
const Customer = {
age: {
name: '年龄区间',
value: [
{ name: '未知', value: 0 },
{ name: '18~25', value: 1 },
{ name: '26~30', value: 2 },
{ name: '31~35', value: 3 },
{ name: '36~40', value: 4 },
{ name: '41~45', value: 5 },
{ name: '46~50', value: 6 },
{ name: '50+', value: 7 }
]
},
sex: {
name: '性别',
value: [
{ name: '未知', value: 0 },
{ name: '男', value: 1 },
{ name: '女', value: 2 }
]
},
carPeriod: {
name: '购车年限',
value: [
{ name: '未知', value: 0 },
{ name: '1年内', value: 0 },
{ name: '1年', value: 0 },
{ name: '2年', value: 0 },
{ name: '3年', value: 0 },
{ name: '4年', value: 0 },
{ name: '5年', value: 0 },
{ name: '5年+', value: 0 }
]
},
enterCategory: {
name: '进店类型',
value: [
{ name: '展厅客户', value: 15 },
{ name: '网电客户', value: 16 },
{ name: '其他客户', value: 17 }
]
},
infoFrom: {
name: '信息来源',
value: [
{ name: '自然进店', value: 25 },
{ name: '报纸', value: 26 },
{ name: '电台', value: 27 },
{ name: '网络', value: 28 },
{ name: '朋友介绍', value: 31 },
{ name: '广告牌', value: 32 },
{ 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 }
]
},
valueType: {
name: '价值类型',
value: [
{ name: '重要价值', value: 1 },
{ name: '重要发展', value: 2 },
{ name: '重要召回', value: 3 },
{ name: '重要挽留', value: 4 },
{ name: '一般价值', value: 5 },
{ name: '一般发展', value: 6 },
{ name: '一般召回', value: 7 },
{ name: '一般挽留', value: 8 }
]
}
}
export default Object.freeze({
DefaultData,
Customer
})
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:49:11
*/
import util from './util'
export { util }
\ No newline at end of file \ No newline at end of file
import Vue from 'vue'
import { Toast, Dialog } from 'vant'
/**
* 日期格式化
* let time = new Date().format('yyyy-MM-dd hh:mm:ss')
*/
Date.prototype.format = function (fmt) {
let o = {
'M+': this.getMonth() + 1, //月份
'd+': this.getDate(), //日
'h+': this.getHours(), //小时
'm+': this.getMinutes(), //分
's+': this.getSeconds(), //秒
//季度
'q+': Math.floor((this.getMonth() + 3) / 3),
S: this.getMilliseconds() //毫秒
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (let k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
}
}
return fmt
}
const throttle = (fn, gapTime) => {
if (gapTime == null || gapTime == undefined) {
gapTime = 1500
}
let _lastTime = null
return function () {
let _nowTime = +new Date()
if (_nowTime - _lastTime > gapTime || !_lastTime) {
fn.apply(this, arguments)
_lastTime = _nowTime
}
}
}
/**num:要转换的数值,fixed:精确几位小数 */
const decimal = (num, fixed) => {
let pow = Math.pow(10, fixed)
return Math.round(num * pow) / pow
}
const toTop = () => {
let bodySrcollTop = document.body.scrollTop
if (bodySrcollTop !== 0) {
document.body.scrollTop = 0
return
}
let docSrcollTop = document.documentElement.scrollTop
if (docSrcollTop !== 0) {
document.documentElement.scrollTop = 0
}
}
const getParams = () => {
return window.vm.$route.params
}
const getQuery = name => {
let [url, paramsList] = window.location.href.split('?')
if (!paramsList) return name ? null : {}
let param = paramsList.split('&')
let obj = {}
param.map(e => {
let [key, value] = e.split('=')
obj[key] = value
})
return name ? obj[name] : obj
}
/** 三个数字加一个逗号 */
const numAddSymbol = val => {
return (val + '').replace(/\B(?=(?:\d{3})+\b)/g, ',')
}
// 获取当前时间
const getCurrentDate = (fmt = 'yyyy-MM-dd') => {
return new Date().format(fmt)
}
/** 获取前/后n天
* 负数:今天前n天
* 正数:今天后n天
*/
const getNDate = (n, fmt = 'yyyy-MM-dd') => {
return new Date(new Date().setDate(new Date().getDate() + n)).format(fmt)
}
/** 获取前/后n月
* 负数:今天前n月
* 正数:今天后n月
*/
const getNMonth = (n, fmt = 'yyyy-MM-dd') => {
return new Date(new Date().setMonth(new Date().getMonth() + n)).format(fmt)
}
const debounce = function (func, wait = 200) {
let timeout
return function (event) {
clearTimeout(timeout)
timeout = setTimeout(() => {
func.call(this, event)
}, wait)
}
}
const setChartFontSize = fontSize => {
let clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
if (!clientWidth) return fontSize
return fontSize * clientWidth / 1440
}
const utils = {
getParams,
getQuery,
throttle,
decimal,
toTop,
numAddSymbol,
getCurrentDate,
getNDate,
getNMonth,
debounce,
setChartFontSize
}
Object.keys(utils).map(key => {
Vue.prototype[key] = utils[key]
})
export default utils
<template>
<div>
<div class="title title-icon">
<span class="icon"></span>
<span>区域分布</span>
</div>
<div class="container flex">
</div>
</div>
</template>
<script>
import { clientMixin } from '../../mixins/index'
export default {
name: 'Area',
mixins: [clientMixin],
data() {
return {
}
}
}
</script>
<template>
<div>
<div class="title title-icon">
<span class="icon"></span>
<span>品牌分布</span>
</div>
<div class="container flex">
</div>
</div>
</template>
<script>
import { clientMixin } from '../../mixins/index'
export default {
name: 'Brand',
mixins: [clientMixin],
data() {
return {
type: 'gender',
chart: {
id: 'sex-pie',
colors: ['#EB6001', '#BF98FF', '#FF6E76']
}
}
}
}
</script>
<!--
* @Description: 客户购车年限
* @Author: huyue
* @Date: 2022-06-23 15:06:32
* @LastEditors: huyue
* @LastEditTime: 2022-06-23 17:03:19
-->
<template>
<div>
<div class="title title-icon">
<span class="icon"></span>
<span>门店类型</span>
</div>
<div class="container flex">
</div>
</div>
</template>
<script>
import { clientMixin } from '../../mixins/index'
export default {
name: 'Store',
mixins: [clientMixin],
data() {
return {
type: 'buycarRange',
chart: {
id: 'car-pie'
}
}
}
}
</script>
<!-- home -->
<template>
<div class="data-view-container">
<transition name="fade">
<keep-alive v-if="$route.meta.keepAlive">
<router-view></router-view>
</keep-alive>
</transition>
<transition name="fade">
<router-view v-if="!$route.meta.keepAlive"></router-view>
</transition>
</div>
</template>
<script>
export default {
data () {
return {
}
},
mounted () { },
methods: {}
}
</script>
<style lang="scss" scoped>
.data-view-container{
background: #090E2B;
}
</style>
<template>
<div class="layout">
<view-container>
<template #title>
<view-title>
</view-title>
</template>
<template #content>
<view-content></view-content>
</template>
</view-container>
</div>
</template>
<script>
export default {
name: '',
data () {
return {}
},
mounted () { },
methods: {
}
}
</script>
<style lang="scss" scoped>
</style>
<!--
* @Description: 售后客户价值分析
* @Author: huyue
* @Date: 2022-06-23 15:05:21
* @LastEditors: huyue
* @LastEditTime: 2022-06-29 19:47:17
-->
<template>
<div class="business-wrap flex">
<div class="business-data"></div>
<div class="business-category"></div>
</div>
</template>
<script>
import * as echarts from 'echarts'
import datas from '../../utils/data'
export default {
name: 'Business',
data() {
return {
}
},
mounted() {},
methods: {
}
}
</script>
<style lang="scss" scoped>
.business-wrap{
height:13.9vh;
margin-bottom:0.98vh;
.business-data{
margin-right:4px;
width:36.11vw;
height:100%;
}
.business-category{
width:13.06vw;
height:100%;
}
}
</style>
<!--
* @Description: 售后客户价值分析
* @Author: huyue
* @Date: 2022-06-23 15:05:21
* @LastEditors: huyue
* @LastEditTime: 2022-06-29 19:47:17
-->
<template>
<div>
</div>
</template>
<script>
import datas from '../../utils/data'
export default {
name: 'oversize',
data() {
return {
}
},
mounted() {},
methods: {
}
}
</script>
<style lang="scss" scoped>
</style>
<!--
* @Description: 售后客户价值分析
* @Author: huyue
* @Date: 2022-06-23 15:05:21
* @LastEditors: huyue
* @LastEditTime: 2022-06-29 19:47:17
-->
<template>
<div class="project-wrap flex">
</div>
</template>
<script>
import * as echarts from 'echarts'
import datas from '../../utils/data'
export default {
name: 'Project',
data() {
return {
}
},
mounted() {},
methods: {
}
}
</script>
<style lang="scss" scoped>
.project-wrap{
height:11.71vh;
}
</style>
<template>
<div class="analyse">
<div class="title title-icon">
<span class="icon"></span>
<span>门店类型</span>
</div>
<div class="container">
</div>
</div>
</template>
<script>
export default {
name: 'Analyse',
data() {
return {
}
}
}
</script>
<style scoped lang="scss">
.analyse{
width:18.06vw;
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<div class="user-tab">
</div>
</template>
<script>
export default {
name: 'UserTab',
data() {
return {
}
}
}
</script>
<style scoped lang="scss">
.user-tab{
height:29.51vh;
margin:1.46vh 0 0.98vh 0;
}
</style>
'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)
module.exports = {
publicPath: IS_PROD ? './' : '/dj-scrm-wx-work/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: '/dj-scrm-wx-work-main/', // 署应用包时的基本 URL。 vue-router history模式使用 微信开发环境需打开
outputDir: 'dist', // 生产环境构建文件的目录
assetsDir: 'static', // outputDir的静态资源(js、css、img、fonts)目录
lintOnSave: !IS_PROD,
productionSourceMap: false, // 如果不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
devServer: {
disableHostCheck: true,
host: '0.0.0.0',
port: 9527, // 端口
open: false, // 启动后打开浏览器.
// public: 'http://scrm.dev.glsx.com.cn/dj-scrm-wx-work-lwk/#/',
overlay: {
// 当出现编译器错误或警告时,在浏览器中显示全屏覆盖层
warnings: false,
errors: true
},
proxy: {
'/dev': {
target: 'http://192.168.1.152:8081',
changeOrigin: true,
ws: true,
pathRewrite: {
'^/dev': ''
},
onProxyReq: (proxyReq, req, res) => {
}
},
'/test': {
target: 'http://192.168.3.126:8081',
changeOrigin: true,
ws: true,
pathRewrite: {
'^/test': ''
},
onProxyReq: (proxyReq, req, res) => {
}
}
}
},
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: `
$cdn: "${defaultSettings.cdn}";
`
}
}
},
configureWebpack: config => {
config.name = name
config.resolve.modules = ['node_modules', './src/assets/spritesmith']
const Plugins = []
config.plugins = [...config.plugins, ...Plugins]
// 为生产环境修改配置...
// 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!