Commit e28ef25f by 李伟康

init

0 parents
Showing 68 changed files with 3560 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`
}
}
}
\ 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
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",
"dev": "npm run serve"
},
"dependencies": {
"@antv/f2": "^3.8.10-beta.1",
"autoprefixer": "^8.0.0",
"core-js": "^3.6.4",
"dayjs": "^1.10.5",
"glsx-common": "^1.4.8",
"lib-flexible": "^0.3.2",
"postcss-loader": "^6.2.0",
"sha1": "^1.1.1",
"storejs": "^1.1.0",
"vant": "^2.12.21",
"vconsole": "^3.7.0",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuex": "^3.4.0",
"webpack-spritesmith": "^1.1.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">
<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">
<template v-if="showWindow">
<router-view />
</template>
</div>
</template>
<script>
export default {
name: 'App',
data() {
return {
showWindow: false
}
},
watch: {
watchFlag: {
immediate: true,
handler(newval) {
this.showWindow = newval
this.hideLoading()
}
}
},
computed: {
watchFlag() {
return this.$store.state.app.showWindow
}
}
}
</script>
<style lang="scss"></style>
/*
* @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 ssoApi from './ssoApi'
import wxConfig from './wxConfig'
import reportApi from './reportApi'
export {
ssoApi,
wxConfig,
reportApi
}
\ No newline at end of file
const url = '/rop-scrm-carlife/router'
export default {
/**获取当前门店周报月报产值统计 */
getReport(data) {
data.method = 'scrm.api.carlife.weekly.report.get'
return window.$HTTP({
url,
data,
returnAll:true
})
}
}
const url = '/rop-scrm-sso/router'
const returnAll = true
export default {
/**OAuth2授权登陆 */
login(data) {
data.method = 'scrm.api.sso.ww.oauth.login'
return window.$HTTP({
url,
data,
returnAll
})
},
/** 选择登录账号 */
selectAccount(data) {
data.method = 'scrm.api.sso.user.login.select'
return window.$HTTP({
url,
data,
returnAll
})
}
}
\ No newline at end of file
import util from '@/utils/util'
import { Notify } from 'vant'
const WxConfig = {
init(jsApiList) {
return new Promise((resolve, reject) => {
jsApiList.map(e => {
if (e == 'chooseImage') jsApiList.push('getLocalImgData')
})
let [redirectUrl] = window.location.href.split('#')
const { corpId } = util.getLocalStorage('dj_scrm_corpId')
/** 获取企微应用AgentConfig */
let data = {
corpId,
method: 'scrm.api.work.wechat.get.agent.config',
url: redirectUrl,
appCode: 'DJQWGJ'
}
window.$HTTP({
url: '/rop-scrm-wechat/router',
data
}).then(obj => {
if (obj) {
wx.agentConfig({
corpid: obj.corpId, // 必填,企业微信的corpid,必须与当前登录的企业一致
agentid: obj.agentId, // 必填,企业微信的应用id (e.g. 1000247)
timestamp: obj.timestamp, // 必填,生成签名的时间戳
nonceStr: obj.nonceStr, // 必填,生成签名的随机串
signature: obj.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法,
jsApiList,
success(res) {
console.log(res, 'wx_config')
resolve()
},
fail(err) {
console.log(err, 'wx_config')
reject()
}
})
} else {
Notify('网络异常')
}
})
})
},
getContext(callBack) {
/**
* entry String 场景值
* shareTicket String 仅当转发时设置了withShareTicket转发到会话的消息进入才返回该字段,详见私密消息
**/
return new Promise((resolve, reject) => {
wx.invoke('getContext', {}, (res) => {
console.log(res)
let { err_msg, entry, shareTicket } = res
/** entry 说明
*contact_profile 从联系人详情进入 3.0.24
*single_chat_tools 从单聊会话的工具栏进入 3.0.24
*group_chat_tools 从群聊会话的工具栏进入 3.0.24
*chat_attachment 从会话的聊天附件栏进入 3.1.6
*normal 除以上场景之外进入,例如工作台,聊天会话等 3.0.24
**/
if (err_msg == 'getContext:ok') {
//entry 返回进入H5页面的入口类型,目前有normal、contact_profile、single_chat_tools、group_chat_tools、chat_attachment
//shareTicket可用于调用getShareInfo接口
callBack(resolve, {
entry,
shareTicket
})
} else {
callBack(reject)
}
})
})
},
/**获取当前外部联系人userid */
getCurExternalContact() {
return new Promise((resolve, reject) => {
wx.invoke('getCurExternalContact', {}, res => {
if (res.err_msg == 'getCurExternalContact:ok') {
resolve(res.userId)
} else {
reject(res)
}
})
})
},
/** 外部联系人选人接口 */
selectExternalContact() {
return new Promise((resolve) => {
wx.invoke('selectExternalContact', {
filterType: 0, //0表示展示全部外部联系人列表,1表示仅展示未曾选择过的外部联系人。默认值为0;除了0与1,其他值非法。在企业微信2.4.22及以后版本支持该参数
}, res => {
if (res.err_msg == "selectExternalContact:ok") {
resolve(res)
}
})
})
},
/**分享消息到当前会话 */
sendChatMessage(params) {
console.log(params)
return new Promise((resolve) => {
wx.invoke('sendChatMessage', params, res => {
console.log(res)
if (res.err_msg == 'sendChatMessage:ok') {
resolve()
}
})
})
},
/**群发消息给客户 */
shareToExternalContact(params) {
return new Promise((resolve) => {
wx.invoke('shareToExternalContact', params, res => {
if (res.err_msg == 'shareToExternalContact:ok') {
resolve()
}
})
})
},
/**群发消息到客户群 */
shareToExternalChat(params) {
return new Promise((resolve) => {
wx.invoke('shareToExternalChat', params, res => {
if (res.err_msg == 'shareToExternalChat:ok') {
resolve()
}
})
})
},
/**进入添加客户界面 */
navigateToAddCustomer() {
wx.invoke('navigateToAddCustomer')
},
/**发表内容到客户朋友圈 */
shareToExternalMoments(params) {
return new Promise((resolve) => {
wx.invoke('shareToExternalMoments', params, res => {
if (res.err_msg == 'shareToExternalMoments:ok') {
resolve()
}
})
})
},
/**打开会话 */
openEnterpriseChat({
externalUserIds = [],
groupName = '',
userIds = [],
chatId = ''
}) {
return new Promise((resolve) => {
userIds = userIds.join(';')
externalUserIds = externalUserIds.join(';')
wx.openEnterpriseChat({
// 注意:userIds和externalUserIds至少选填一个。内部群最多2000人;外部群最多500人;如果有微信联系人,最多40人
userIds, //参与会话的企业成员列表,格式为userid1;userid2;...,用分号隔开。
externalUserIds, // 参与会话的外部联系人列表,格式为userId1;userId2;…,用分号隔开。
groupName, // 会话名称。单聊时该参数传入空字符串""即可。
chatId, // 若要打开已有会话,需指定此参数。如果是新建会话,chatId必须为空串
success(res) {
resolve(res)
},
fail(res) {
if (res.errMsg.indexOf('function not exist') > -1) {
Notify('版本过低请升级')
}
}
})
})
},
/**企业微信扫一扫 */
scanQRCode(needResult) {
return new Promise((resolve) => {
wx.scanQRCode({
desc: 'scanQRCode desc',
needResult, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是条形码(一维码),默认二者都有
success(res) {
resolve(res)
},
error: function(res) {
if (res.errMsg.indexOf('function_not_exist') > 0) {
alert('版本过低请升级')
}
}
})
})
},
/**获取本地图片接口 */
getLocalImgData(localId) {
return new Promise((resolve, reject) => {
wx.getLocalImgData({
localId, // 图片的
success(res) {
resolve(res) //localData是图片的base64数据,可以用img标签显示
},
fail(err) {
reject(err)
}
})
})
},
/**拍照或从手机相册中选图接口 */
chooseImage(count = 1) {
return new Promise((resolve) => {
wx.chooseImage({
count, // 默认1
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success(res) {
let { localIds } = res
let imgs = []
localIds.map((e, index) => {
wx.getLocalImgData({
localId: e,
success(img) {
imgs.push(img)
if (index == localIds.length - 1) resolve(imgs)
}
})
})
}
})
})
},
/**预览图片接口 */
previewImage(obj) {
/**current 当前显示图片的http链接
* urls 需要预览的图片http链接列表
*/
wx.previewImage(obj)
},
/**上传图片接口 */
uploadImage(localId) {
return new Promise((resolve) => {
wx.uploadImage({
localId, // 需要上传的图片的本地ID,由chooseImage接口获得
isShowProgressTips: 1, // 默认为1,显示进度提示
success(res) {
resolve(res) // 返回图片的服务器端ID
/**备注:上传图片有效期3天,可用素材管理接口下载图片到自己的服务器,此处获得的 serverId 即 media_id。 */
}
})
})
},
/**下载图片接口 */
downloadImage(serverId) {
return new Promise((resolve) => {
wx.downloadImage({
serverId, // 需要下载的图片的服务器端ID,由uploadImage接口获得
isShowProgressTips: 1, // 默认为1,显示进度提示
success(res) {
resolve(res) // 返回图片下载后的本地ID
}
})
})
},
/**使用企业微信内置地图查看位置接口 */
openLocation(obj) {
/**
latitude: 0, // 纬度,浮点数,范围为90 ~ -90
longitude: 0, // 经度,浮点数,范围为180 ~ -180。
name: '', // 位置名
address: '', // 地址详情说明
scale, // 地图缩放级别,整形值,范围从1~28。默认为16
*/
wx.openLocation(obj)
},
/**获取地理位置接口 */
getLocation(type = 'wgs84') {
return new Promise((resolve) => {
wx.getLocation({
type, // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success(res) {
resolve(res)
}
})
})
},
/**自定义转发到会话 */
shareAppMessage(obj) {
// title: '', // 分享标题
// desc: '', // 分享描述
// link: '', // 分享链接
// imgUrl: '' // 分享封面
return new Promise((resolve) => {
wx.invoke("shareAppMessage", obj,
function(res) {
if (res.err_msg == "shareAppMessage:ok") {
}
}
)
})
}
}
export default WxConfig
\ No newline at end of file
@import './sprite.scss';
html,
body .app {
color: #333333;
font-family: Arial, Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, sans-serif;
-webkit-overflow-scrolling: touch;
height: 100%;
// overflow: hidden;
}
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%);
}
.sticky {
position: static;
}
canvas {
user-select: none;
}
\ No newline at end of file
.sprite-icon { background-image: url(../images/sprite.png);background-size: 345px 205px;}
.icon-bg { width: 345px; height: 180px; background-position: 0px 0px;}
.icon-message { width: 14px; height: 13px; background-position: -24px -190px;}
.icon-huangguan { width: 14px; height: 15px; background-position: 0px -190px;}
\ No newline at end of file
.statistics {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0 15px;
color: #333333;
font-size: 14px;
.up {
transform: rotate(180deg);
}
.title {
padding: 10px 0 10px;
font-size: 18px;
font-weight: 500;
.count {
font-weight: 400;
margin-left: auto;
font-size: 12px;
span {
color: #3975C6;
font-size: 14px;
}
}
}
.count-box {
height: 220px;
background: #ffffff;
box-shadow: 0px 6px 12px 0px rgba(166, 162, 217, 0.2);
border-radius: 6px;
position: relative;
overflow: hidden;
.icon-bg {
position: absolute;
top: 0;
left: 0;
}
.top {
position: relative;
height: 180px;
box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
border-radius: 6px;
flex-wrap: wrap;
z-index: 2;
.item {
width: 50%;
height: 50%;
flex-direction: column;
color: #fff;
font-size: 10px;
.count {
font-size: 20px;
text-shadow: 0px 3px 3px #5e41de;
margin: 5px 0;
}
.ratio {
color: rgba(255, 255, 255, 0.75);
span {
color: #fff;
}
}
}
}
.bottom {
height: 40px;
padding: 0 10px;
font-size: 12px;
color: #4b4a57;
.icon-message {
margin-right: 6px;
}
}
}
.tab {
margin: 40px 0 10px;
}
.canvas-view {
width: calc(100% + 30px);
margin-left: -15px;
overflow-x: hidden;
.box {
position: relative;
display: flex;
transition: all .5s;
.canvas-box {
position: relative;
user-select: none;
width: 100%;
height: 196px;
.canvas {
width: 100%;
height: 100%;
}
.line-tooltip {
opacity: 0;
position: absolute;
width: 140px;
height: 70px;
border-radius: 6px;
box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
background: #ffffff;
z-index: 99;
flex-direction: column;
font-size: 12px;
box-sizing: border-box;
padding: 10px;
left: 0;
top: 0;
/deep/.time {
color: #a9a9a9;
}
/deep/.item,
/deep/.time {
width: 100%;
text-align: left;
font-size: 12px;
}
/deep/.arc {
border-radius: 100%;
font-size: 5px;
margin-right: 4px;
}
}
}
.list-box {
width: 100%;
.item {
padding: 17px 0;
border-bottom: 1px solid #e8e8f2;
color: #333333;
font-size: 12px;
margin: 0 15px;
.label {
width: 196px;
word-break: break-all;
}
.index {
width: 20px;
height: 20px;
background: #d4d4f0;
box-shadow: 0px 3px 11px 0px rgba(166, 162, 217, 0.2);
border-radius: 100%;
margin: 0 8px 0 5px;
}
.no1 {
background: #3975C6;
color: #fff;
}
.value {
margin-left: auto;
font-weight: 500;
}
&:last-child {
border-bottom: none;
}
}
}
}
.single {
width: 100%;
}
.type-0{
left: 0;
}
.type-1 {
left: -100%;
}
.type-2 {
left: -200%;
}
}
}
<template>
<div class="canvas-tab flex">
<template v-for="(i,index) in data">
<div
@click="click(index)"
:class="['item', 'text-center',`${tabIndex == index ? 'active':''}`]"
:key="index"
>{{i}}</div>
</template>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'CanvasTab',
props: {
list: {
type: Array,
default: () => {
return []
}
},
index: {
type: Number,
default: 0
},
activeColor: {
type: String,
default: '#F6F6FF'
}
},
watch: {
index(n) {
this.tabIndex = n
}
},
data() {
return {
tabIndex: this.index,
data: this.list
}
},
mounted() {},
methods: {
click(tabIndex) {
this.tabIndex = tabIndex
this.$emit('change', tabIndex)
}
}
}
</script>
<style scoped lang='scss'>
.canvas-tab {
width: 100%;
height: 40px;
background-color: #fff;
box-sizing: border-box;
padding: 3px;
font-size: 12px;
box-shadow: 0px 3px 11px 0px rgba(166, 162, 217, 0.2);
border-radius: 5px;
.item {
color: #333333;
flex: 1;
height: 100%;
transition: all 0.5s;
}
.active {
background: #ebf1f8;
border-radius: 4px;
font-size: 14px;
color: #3975c6;
}
}
</style>
\ No newline at end of file
<template>
<div class="statistics">
<div class="title flex">
客户统计
<div class="count">企微客户总数:8972</div>
</div>
<div class="count-box">
<div class="sprite-icon icon-bg"></div>
<div class="top flex">
<template v-for="(item, index) in statisticsList">
<div :key="index" class="item text-center">
{{ item.text }}
<div class="count">1000</div>
<template v-if="item.ratio">
<div class="ratio">
环比
<span>
<van-icon name="down" size="10px" :class="`${index == 0 ? 'up' : ''}`" />
10%
</span>
</div>
</template>
<template v-else>
<div class="ratio">
线上化占
<span>84%</span>
</div>
</template>
</div>
</template>
</div>
<div class="bottom flex">
<div class="sprite-icon icon-message"></div>
新增客户数排行榜冠军:李四
</div>
</div>
<template v-if="data.userInfo && data.userInfo.accountLevel != 4">
<div class="tab">
<canvas-tab :list="['趋势图', '客户分布']" @change="change"></canvas-tab>
</div>
<div class="canvas-view">
<div :class="['box', 'flex', `type-${tabIndex}`]">
<div class="canvas-box">
<canvas id="lineChart" class="canvas"></canvas>
<div class="line-tooltip flex" ref="lineTooltip"></div>
</div>
<div class="canvas-box">
<canvas class="canvas" id="pieChart"></canvas>
</div>
</div>
</div>
</template>
<template v-else>
<div class="canvas-view">
<div class="box single">
<div class="canvas-box">
<canvas class="canvas" id="pieChart"></canvas>
</div>
</div>
</div>
</template>
</div>
</template>
<script type="text/ecmascript-6">
import { canvasMixin } from '@/mixins'
export default {
name: 'CustomerStatistics',
mixins: [canvasMixin],
props: {
reportType: {
type: [Number, String],
default: 0
},
data: {
type: Object,
default: () => {}
}
},
data () {
return {
tabIndex: 0,
statisticsList: [
{
text: '发起申请客户数',
ratio: true
},
{
text: '新增企微客户数',
ratio: true
},
{
text: '流失客户',
ratio: true
},
{
text: '客户总数',
}
],
}
},
mounted() {
},
methods: {
change (e) {
this.tabIndex = e
}
}
}
</script>
<style scoped lang="scss">
@import '@/assets/css/statistics.scss';
</style>
<template>
<div class="statistics">
<div class="title flex">
产值统计
<div class="count">
今年累计产值:
<span>¥{{ centsToyuan(data.yearProductionValue) || 0 }}</span>
</div>
</div>
<div class="count-box">
<div class="sprite-icon icon-bg"></div>
<div class="top flex">
<div class="item">
新增总产值
<div class="num flex">
<div>
<span class="unit">¥</span>
{{ centsToyuan(data.newProductionValue) || 0 }}
</div>
<div class="num-ratio">
<span>环比</span>
<template v-if="data.newProductionValueSequential">
<van-icon name="down" size="10px" :class="`${data.newProductionValueSequential > 0 ? 'up' : ''}`" />
</template>
{{ data.newProductionValueSequential || '0' }}%
</div>
</div>
</div>
<div class="item">
新增权益提单数
<div class="num flex">
<div>{{ data.newEquityBillLadingNum || 0 }}</div>
<div class="num-ratio">
<span>环比</span>
<template v-if="data.newEquityBillLadingSequential">
<van-icon name="down" size="10px" :class="`${data.newEquityBillLadingSequential > 0 ? 'up' : ''}`" />
</template>
{{ data.newEquityBillLadingSequential || '0' }}%
</div>
</div>
</div>
</div>
<div class="bottom flex">
<div class="sprite-icon icon-message"></div>
增长速度最快的业务:{{ orderSource[data.fastOrderSource] }}
</div>
</div>
<template v-if="true">
<!-- <template v-if="data.userInfo && data.userInfo.accountLevel != 4"> -->
<div class="tab">
<canvas-tab :list="tab" @change="change"></canvas-tab>
</div>
<div class="canvas-view">
<div :class="['box', `type-${tabIndex}`]" :style="`width:${tab.length}00%;`">
<div class="list-box">
<template v-for="(i,index) in data.merchantProductionValueReportList">
<div class="item flex" :key="index">
<div :class="['index','text-center',`${index == 0 ?'no1':''}` ]">{{index + 1}}</div>
<div class="label">{{i.merchantName}}</div>
<div class="value">{{i.newProductionValue}}</div>
</div>
</template>
</div>
<div class="canvas-box">
<canvas class="canvas" id="pieChart"></canvas>
</div>
<template v-if="tab.length == 3">
<div class="canvas-box">
<canvas id="lineChart" class="canvas"></canvas>
<div class="line-tooltip flex" ref="lineTooltip"></div>
</div>
</template>
</div>
</div>
</template>
<template v-else>
<div class="canvas-view">
<div class="box single">
<div class="canvas-box">
<canvas class="canvas" id="pieChart"></canvas>
</div>
</div>
</div>
</template>
</div>
</template>
<script type="text/ecmascript-6">
import { canvasMixin } from '@/mixins'
export default {
name: 'OutputStatistics',
mixins: [canvasMixin],
props: {
reportType: {
type: [Number, String],
default: 0
},
data: {
type: Object,
default: () => {}
}
},
data() {
return {
tabIndex: 0,
tab:['门店产值排行', '产值分布']
}
},
mounted() {
let {reportType} = this
if(reportType == 1) this.tab.push('趋势图')
},
methods: {
change(e) {
this.tabIndex = e
let {reportType} = this
if(e == 1) this.initPieChart()
else if(e == 0 && reportType == 1) this.initLineChart()
}
}
}
</script>
<style scoped lang="scss">
@import '@/assets/css/statistics.scss';
.statistics {
.count-box {
.top {
flex-direction: column;
padding: 0 35px;
.item {
width: 100%;
box-sizing: border-box;
display: flex;
justify-content: center;
.num {
font-size: 20px;
margin-top: 10px;
justify-content: space-between;
.unit {
font-size: 12px;
}
&-ratio {
font-size: 11px;
span {
margin-right: 20px;
}
}
}
}
}
}
}
</style>
<template>
<van-popup
v-model="show"
round
position="bottom"
class="popup"
@close="close"
>
<div class="content">
<div class="title flex">
会员套餐名称
<div class="all flex">
<template v-if="true">
<div class="sprite-icon icon-active"></div>
</template>
<template v-else>
<div class="radio"></div>
</template>
全选
</div>
</div>
<div class="img-box">
<template v-for="(item,ind) in 17">
<div
:key="ind"
class="item"
>
<img src="@/assets/images/test.jpg">
<div class="radio-box">
<template v-if="item.active">
<div class="sprite-icon icon-active"></div>
</template>
<template v-else>
<div class="radio">
</div>
</template>
</div>
</div>
</template>
</div>
<div class="footer flex">
<div
class="cancel text-center"
@click="close"
>取消</div>
<div class="confirm text-center">确定</div>
</div>
</div>
</van-popup>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'ResourcePopup',
props: ['value'],
data () {
return {
show: false
}
},
watch: {
'value' (n) {
this.show = n
}
},
mounted () {
},
methods: {
close () {
this.show = false
this.$emit('close')
}
}
}
</script>
<style scoped lang='scss'>
.popup {
height: 510px;
.content {
height: 100%;
.title {
height: 56px;
padding: 0 16px;
font-weight: 500;
font-size: 16px;
color: #333333;
.all {
margin-left: auto;
font-weight: 400;
color: #3a3a3a;
font-size: 14px;
.radio {
width: 20px;
height: 20px;
box-sizing: border-box;
border: 1.5px solid #999999;
border-radius: 100%;
overflow: hidden;
}
.sprite-icon,
.radio {
margin-right: 4px;
}
}
}
.img-box {
padding: 4px 26px;
display: flex;
flex-wrap: wrap;
box-sizing: border-box;
height: 405px;
overflow-y: scroll;
.item {
width: 102px;
height: 102px;
margin-bottom: 10px;
margin-right: 8px;
position: relative;
&:nth-of-type(3n + 3) {
margin-right: 0;
}
.radio-box {
position: absolute;
bottom: 2px;
right: 2px;
.radio {
width: 20px;
height: 20px;
background: #999999;
box-sizing: border-box;
border: 1.5px solid #fff;
border-radius: 100%;
overflow: hidden;
}
}
}
}
.footer {
height: 49px;
padding: 0 16px;
justify-content: space-between;
div {
width: 164px;
height: 38px;
border: 1px solid transparent;
font-size: 14px;
border-radius: 100px;
}
.cancel {
border-color: #dcdee0;
color: #323233;
}
.confirm {
border-color: #3975C6;
color: #fff;
background: #3975C6;
}
}
}
}
</style>
\ No newline at end of file
<template>
<div :class="['scroll-view', ScrollViewclass]">
<van-list
v-model="loading"
:finished="finished"
finished-text="到底啦!!"
@load="onLoad"
offset="100"
:immediate-check="false"
>
<slot></slot>
</van-list>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'ScrollView',
data () {
return {
loading: false,
finished: false,
}
},
props: ['ScrollViewclass'],
mounted () {
},
methods: {
onLoad () {
this.$emit('ReachBottom')
},
}
}
</script>
<style scoped lang='scss'>
.scroll-view {
overflow-y: scroll;
box-sizing: border-box;
}
</style>
\ No newline at end of file
<template>
<div class="search">
<van-search
v-model="value"
:placeholder="placeholder"
@search="onSearch"
/>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'Search',
props: {
keyword: {
type: String,
default: ''
},
placeholder: {
type: String,
default: '请输入内容搜索'
}
},
data () {
return {
value: this.keyword
}
},
mounted () {
},
methods: {
onSearch (e) {
this.$emit('search', e)
}
}
}
</script>
<style scoped lang='scss'>
.van-search {
padding: 9px 16px;
height: 50px;
background: #fff;
.van-search__content {
background-color: #fff;
border: 1px solid #cdd1d4;
border-radius: 16px;
}
.van-cell {
padding: 5px 16px 5px 0;
}
}
</style>
\ No newline at end of file
<template>
<div :class="[{'sticky':sticky},'Tab']">
<van-tabs
v-model="tabIndex"
:color="activeColor"
title-inactive-color="#BBB"
title-active-color="#2c2c2c"
@click="click"
:key="updata"
:line-width="lineWidth"
>
<template v-for="(i,index) in data">
<van-tab
:title="i"
:key="index"
>
<slot />
</van-tab>
</template>
</van-tabs>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'Tab',
props: {
list: {
type: Array,
default: () => {
return []
}
},
sticky: Boolean,
index: {
type: Number,
default: 0
},
activeColor: {
type: String,
default: '#3975C6'
},
updata: null,
lineWidth: null
},
data () {
return {
tabIndex: this.index,
data: this.list
}
},
watch: {
'index' (n) {
this.tabIndex = n
},
'updata' (n) {
this.data = this.list
this.tabIndex = this.index
}
},
mounted () {
},
methods: {
click (tabIndex) {
this.tabIndex = tabIndex
this.$emit('change', tabIndex)
}
}
}
</script>
<style lang='scss'>
.sticky {
position: sticky;
top: 0;
z-index: 99;
}
.Tab {
.van-tabs__wrap {
height: 50px !important;
}
.van-tab__text {
transition: all 0.25s;
}
.van-tab--active {
font-size: 16px !important;
}
}
</style>
\ No newline at end of file
<template>
<van-tabbar
route
@change="change"
v-model="value"
:border="false"
>
<template v-for="(i,index) in data">
<van-tabbar-item
:key="index"
replace
:to="`/${i.name}`"
:icon="i.icon"
:name="i.name"
>{{i.title}}</van-tabbar-item>
</template>
</van-tabbar>
</template>
<script>
export default {
name: 'TabBar',
props: {
data: {
type: Array,
default: () => {
return []
}
}
},
data () {
return {
value: ''
}
},
methods: {
change (value) {
this.$emit('change', value)
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang='scss'>
.van-tabbar {
box-shadow: 0px -2px 4px 0px rgba(0, 0, 0, 0.1), 0px 0px 0px 0px #e5e5e5;
.van-tabbar-item--active {
color: #3975C6;
}
}
</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)
})
// export default [Icon, NavBar, TabBar, Organization, CustomerList, CustomerDetail, OrderList, OrderDetail, TimerTabs, CarType, RadioCell, CheckBoxCell, ValidateField]
\ No newline at end of file
/*
* @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: '活动中心',
request: {
// baseURL: 'http://scrm.test.glsx.com.cn/scrm-wechat' // 测试项目地址
baseURL: 'http://192.168.1.5:8083/scrm-wechat' // 测试项目地址
},
APPID: 'xxx',
APPSECRET: 'xxx',
cdn: 'https://www.xxx.cn/static'
}
\ No newline at end of file
module.exports = {
title: '活动中心',
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'
}
\ 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
/*
* @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://oss-config.test.glsx.com.cn/mock/617918601072f92988f05a11/base/scrm-wx-work-report-config', {}).then(res => res.json())
}
export const cfg = {
install(vue, config) {
vue.prototype.$config = config
}
}
\ No newline at end of file
/*
* @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 '@/assets/css/index.scss'
import { bus, tools, store as local, util } from './utils'
import './utils/util'
import 'components'
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'
Vue.config.productionTip = false
import VConsole from 'vconsole'
// const vConsole = new VConsole()
const isMock = true
fetchConfig(!isMock).then(res => {
// 从配置服务器获取动态配置
// 设置 js中可以访问 $cdn
Vue.use(cfg)
window.$fetchConfig = res
/**登录过期 重新登录 */
window.reLogin = () => {
console.log('重新登录')
util.clearSessionId()
store.dispatch('navigation')
}
window.vm = new Vue({
el: '#app',
router,
store,
render: h => h(App)
})
})
import F2 from '@antv/f2/lib/index-all'
const orderSource = {
1: '商城订单',
2: '直播订单',
3: '活动订单',
4: '门店套餐'
}
export default {
data() {
return {
chart: null,
lineChart: null,
orderSource
}
},
mounted() {
let { userInfo } = this.data
if (userInfo) {
this.$nextTick(() => {
this.initCanvas(userInfo.accountLevel)
})
}
},
watch: {
data(n) {
let { userInfo } = n
if (userInfo) {
this.$nextTick(() => {
this.initCanvas(userInfo.accountLevel)
})
}
}
},
methods: {
initCanvas(type) {
let { reportType } = this
if (type != 4 && reportType == 1) this.initLineChart()
this.initPieChart()
},
initLineChart(id = 'lineChart') {
let { tabIndex } = this.$parent
this.lineChart && this.lineChart.clear()
this.lineChart = null
this.lineChart = new F2.Chart({
id,
padding: [50, 50, 20, 50],
pixelRatio: window.devicePixelRatio
})
if (tabIndex == 0) {
this.lineChart.source([], {
date: {
range: [0, 1]
},
number: {
type: 'linear',
formatter(e) {
return Math.ceil(e)
}
}
})
this.lineChart.axis('date', {
label(text, index, total) {
const textCfg = {}
if (index === 0) {
textCfg.textAlign = 'left'
} else if (index === total - 1) {
textCfg.textAlign = 'end'
}
return textCfg
}
})
const tooltipEl = this.$refs.lineTooltip
this.lineChart.tooltip({
custom: true,
showCrosshairs: false,
onChange(ev) {
const currentData = ev.items[0]
const text = currentData.value
tooltipEl.innerHTML = `<div class="time">2021年10月27日</div>
<div class="item flex"><span class="arc" style="color:#3975C6;">●</span>新增企微客户:23</div>
<div class="item flex"><span class="arc" style="color:#FA7C0B;">●</span>流失客户:23</div>`
tooltipEl.style.opacity = 1
// tooltipEl.style.left = currentData.x - 140 / 2 + 'px'
// tooltipEl.style.top = currentData.y - 70 - 15 + 'px'
},
onHide() {
tooltipEl.style.opacity = 0
}
})
this.lineChart.legend(false)
this.lineChart
.area()
.position('date*number')
.color('country', val => {
if (val == '新增企微客户') return ['#DADAFF', '#F7F7F7']
return ['#FFECDB', '#F7F7F7']
})
.adjust('stack')
this.lineChart
.line()
.position('date*number')
.color('country', val => {
if (val == '新增企微客户') return '#3975C6'
return '#FA7C0B'
})
.adjust('stack')
} else {
let { trendList } = this.data
this.lineChart.source(trendList, {
dataDateStr: {
type: 'timeCat',
mask: 'MM/DD',
tickCount: 8,
range: [0, 1]
},
orderMoneyTotalSum: {
formatter(e) {
return Math.ceil(e)
}
}
})
this.lineChart.axis('dataDateStr', {
label: function label(text, index, total) {
var textCfg = {}
if (index === 0) {
textCfg.textAlign = 'left'
} else if (index === total - 1) {
textCfg.textAlign = 'right'
}
return textCfg
}
})
this.lineChart.tooltip(false)
this.lineChart.line().position('dataDateStr*orderMoneyTotalSum').shape('smooth').color('#3975C6')
this.lineChart.point().position('dataDateStr*orderMoneyTotalSum').shape('smooth').style({
stroke: '#fff',
lineWidth: 1
})
}
const textObj = {
top: true,
position() {
return [0, 0] // 位置信息
},
style: {
fill: '#888', // 文本颜色
fontSize: '10' // 文本大小
}
}
this.lineChart.guide().text({
...textObj,
content: '日期',
offsetX: window.screen.width - 70,
offsetY: 14
})
this.lineChart.guide().text({
...textObj,
content: '数量',
offsetX: -10,
offsetY: -160
})
this.lineChart.render()
},
initPieChart(id = 'pieChart') {
let { productionValueReportList } = this.data
productionValueReportList.map(e => (e.count = 'count'))
this.chart && this.chart.clear()
this.chart = null
this.chart = new F2.Chart({
id,
pixelRatio: window.devicePixelRatio,
padding: [40, 40, 40, 40]
})
this.chart.source(productionValueReportList)
this.chart.coord('polar', {
transposed: true,
radius: 0.9,
innerRadius: 0.5
})
this.chart.axis(false)
this.chart.legend(false)
this.chart.tooltip(false)
this.chart.guide().html({
position: ['50%', '50%'],
html: '<div style="text-align: center;width:150px;height: 50px;">\n <p style="font-size: 12px;color: #999;margin: 0" id="title"></p>\n <p style="font-size: 18px;color: #343434;margin: 0;font-weight: bold;" id="money"></p>\n </div>'
})
this.chart.interval().position('count*newProductionValue').adjust('stack').color('orderSource', ['#3975C6', '#43B899', '#FFC667', '#FF9DAA'])
this.chart.pieLabel({
sidePadding: 30,
activeShape: true,
label1(data) {
return {
text: `${orderSource[data.orderSource]}-占${data.newProductionValueRate}`,
fill: '#333'
}
},
label2(data) {
return {
text: `¥${data.newProductionValue}`,
fill: '#333',
fontSize: 12,
fontWeight: 'bold'
}
},
onClick(ev) {
const data = ev.data
if (data) {
console.log(data)
}
}
})
this.chart.render()
}
}
}
import canvasMixin from './canvasMixin'
export {
canvasMixin,
}
\ No newline at end of file
/*
* @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,
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,
ShareSheet,
Overlay,
loading,
Swipe,
SwipeItem
} 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,
ShareSheet,
Overlay,
loading,
Swipe, SwipeItem
]
\ No newline at end of file
/*
* @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'
// 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-attachment-activity/
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
if (to.meta.title) {
store.dispatch('setPageMeta', to.meta)
} else {
store.dispatch('setPageMeta', { title: '嘀加·Win Consumer' })
}
document.documentElement.style.backgroundColor = to.meta.backgroundColor || '#fff'
store.commit('SET_LAST_PATH', to.name)
if (to.matched.some(recode => recode.meta.noAuth)) {
store.state.app.showWindow = true
} else {
store.dispatch('navigation')
}
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
const pages = {
report: [{
name: 'index',
meta: {
backgroundColor: '#F7F7F7'
}
}],
}
const redirect = 'report'
let routes = []
const keepAlives = []
Object.keys(pages).map(parent => {
pages[parent].map(val => {
const isIndex = parent == redirect && val.name == 'index'
let childrenPath = `${parent}/${val.name}`
let { meta } = val
const path = isIndex ?
'/' :
`/${val.name == 'index' ? parent : childrenPath}`
const name = val.name == 'index' ? parent : childrenPath.replace('/', '.')
if (meta && meta.keepAlive) keepAlives.push(name)
let route = {
component: resolve => require([`views/${childrenPath}.vue`], resolve),
path,
name,
meta
}
routes.push(route)
})
})
console.log(routes)
export const keeps = keepAlives
export default routes
\ 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
*/
import { ssoApi } from '@/api'
import { store, util } from 'utils'
import { Http } from 'glsx-common'
import { Notify } from 'vant'
const state = {
pageMeta: '',
keepAlives: [],
lastPath: ''
}
const mutations = {
SET_PAGE_META(state, meta) {
state.pageMeta = meta
},
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_LAST_PATH(state, path) {
state.lastPath = path
}
}
const actions = {
setPageMeta({ commit }, meta) {
document.title = meta.title
commit('SET_PAGE_META', meta)
},
setLoginToken({ commit }, val) {
commit('SET_LOGIN_TOKEN', val)
},
setAccountList({ commit }, list) {
commit('SET_ACCOUNT_LIST', list)
},
pushKeep({ commit }, name) {
commit('PUSH_KEEP', name)
},
removeKeep({ commit }, names) {
commit('REMOVE_KEEP', names)
},
login({ dispatch }) {
let [redirectUrl] = window.location.href.split('?')
// 以下是 本地调试
if (process.env.NODE_ENV == 'development') {
const code = getParams('code')
if (code) {
const { corpId } = util.getLocalStorage('dj_scrm_corpId')
ssoApi
.login({
code,
corpId
})
.then(({ code, data, message }) => {
let route = state.lastPath == 'coupon' ? '' : state.lastPath || ''
route = route.replace('.', '/')
if (code == '0') {
if (data.loginList.length) {
if (data.loginList.length > 1) {
let userInfo = data.loginList[0]
let { merchantId, accountName } = userInfo
let loginAccount = accountName
ssoApi
.selectAccount({
loginAccount,
merchantId,
loginToken: data.loginToken,
loginSource: 'WW',
loginType: 3
})
.then(res => {
util.setLocalStorage('dj_scrm_userInfo', res.data)
util.setSessionId(res.data.sessionId)
dispatch('registerHttp', res.data.sessionId)
state.showWindow = true
window.location.replace(`${redirectUrl}#/${route}`)
})
} else {
let [userInfo] = data.loginList
util.setLocalStorage('dj_scrm_userInfo', userInfo)
util.setSessionId(userInfo.sessionId)
dispatch('registerHttp', userInfo.sessionId)
// 只有一个账号 history.back()
console.log(`${redirectUrl}${route}`)
state.showWindow = true
window.location.replace(`${redirectUrl}#/${route}`)
}
} else {
/**没有账号 */
Notify('没有账号')
// window.location.href = `${url}common/nothing`
}
} else {
/**账号过期 (暂时没有字段判断是否过期) */
Notify(message)
// window.location.href = `${url}common/overdue`
}
})
} else {
util.showLoading()
let appid = getParams('corpId') //从链接获取
let dj_scrm = util.getLocalStorage('dj_scrm_corpId')
if (!appid) appid = (dj_scrm && dj_scrm.corpId) || 'ww7ee69c648ae1b7e6'
util.setLocalStorage('dj_scrm_corpId', { corpId: appid })
// 'ww657a2d4ae89a4424'
const wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize'
window.location.href = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
}
} else {
const storage_corpId = util.getLocalStorage('dj_scrm_corpId')
const { baseURL } = window.$fetchConfig.request
let url = `${baseURL}/dj-scrm-wx-work-main/#/`
window.location.href = `${url}?redirect_uri=${redirectUrl}&corpId=${storage_corpId.corpId}`
}
},
navigation({ dispatch }) {
let { sessionId, corpId } = getParams()
const storage_corpId = util.getLocalStorage('dj_scrm_corpId')
if (!corpId) corpId = storage_corpId && storage_corpId.corpId
if (corpId && storage_corpId) {
if (corpId != storage_corpId.corpId) {
util.removeLocalStorage('dj_scrm_userInfo')
util.clearSessionId()
}
}
util.setLocalStorage('dj_scrm_corpId', { corpId })
const storage_sessionId = util.getSessionId()
if (sessionId || storage_sessionId) {
state.showWindow = true
util.setSessionId(sessionId || storage_sessionId)
dispatch('registerHttp', sessionId || storage_sessionId)
} else {
util.showLoading()
dispatch('registerHttp')
dispatch('login')
return
}
state.showWindow = true
},
registerHttp({}, sessionId = '') {
window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
}
}
const getParams = 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
}
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'
/*
* @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 util from './util'
import * as tool from './tools'
const { debounce, throttle, ...tools } = tool
import * as constants from './constants'
import store from './store'
export { bus, tools, debounce, throttle, constants, store ,util}
\ No newline at end of file
/*
* @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',
}
}
\ No newline at end of file
/**
* 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
}
\ 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
}
}
}
/**防止重复点击 */
const showLoading = (title = '加载中...') => {
Toast({
type: 'loading',
message: title,
forbidClick: true,
duration: 0
})
}
const hideLoading = () => {
Toast.clear()
}
/**num:要转换的数值,fixed:精确几位小数 */
const decimal = (num, fixed) => {
let pow = Math.pow(10, fixed)
return Math.round(num * pow) / pow
}
const showToast = (message = '', callBack) => {
let params = {
message,
forbidClick: true,
duration: 1500
}
Toast(params)
if (callBack && typeof callBack == 'function') {
setTimeout(() => {
callBack()
}, 1500)
}
}
/**触摸样式 */
const touchstart = e => {
e.target.classList.add('btn-on-leave')
}
const touchend = e => {
e.target.classList.remove('btn-on-leave')
}
const setSessionId = val => {
window.localStorage.setItem('dj_scrm_session_id', val)
}
const getSessionId = () => {
return window.localStorage.getItem('dj_scrm_session_id')
}
const clearSessionId = () => {
window.localStorage.removeItem('dj_scrm_session_id')
}
const setLocalStorage = (key, item) => {
window.localStorage.setItem(key, JSON.stringify(item))
}
const getLocalStorage = key => {
return JSON.parse(window.localStorage.getItem(key))
}
const removeLocalStorage = key => {
window.localStorage.removeItem(key)
}
const dialog = (params = {}) => {
if (!params.confirmButtonColor) params.confirmButtonColor = '#FF7336'
return Dialog.confirm(params)
}
/**拨打电话 */
const makePhoneCall = phoneNumber => {
window.location.href = `tel://${phoneNumber}`
}
/**是否全面屏 */
const isFullSucreen = () => {
let result = false
const rate = window.screen.height / window.screen.width
let limit = window.screen.height == window.screen.availHeight ? 1.8 : 1.65 // 临界判断值
result = rate > limit
return result
}
const jumpChildrenPage = (to, params) => {
let { name } = window.vm._route
window.vm.$router.push({ name: `${name}.${to}`, params })
}
/**拷贝 */
const setClipboardData = data => {
wx.setClipboardData({
data,
success(res) {
Toast('复制成功')
}
})
}
/**接口请求时失败让用户刷新 */
const refreshPage = (message = '系统异常') => {
return Dialog.alert({
message,
theme: 'round-button',
confirmButtonText: '点击重试',
confirmButtonColor: '#3975C6'
})
}
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 watchPageBack = () => {
return new Promise(resolve => {
if (window.$back) {
window.$back = false
resolve()
}
})
}
/**分转元 */
const centsToyuan = price => {
return Number(Number(price / 100, 2).toFixed(2))
}
const utils = {
removeLocalStorage,
setClipboardData,
jumpChildrenPage,
setLocalStorage,
getLocalStorage,
clearSessionId,
makePhoneCall,
isFullSucreen,
watchPageBack,
setSessionId,
getSessionId,
showLoading,
hideLoading,
centsToyuan,
refreshPage,
touchstart,
showToast,
getParams,
touchend,
throttle,
decimal,
dialog,
toTop
}
Object.keys(utils).map(key => {
Vue.prototype[key] = utils[key]
})
export default utils
<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>
</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>
<template>
<div class="layout">
<div class="top flex">
<div class="report-name text-hide">
{{ outputData.reportName || '' }}
</div>
<template v-if="outputData.reportTimeStart">
<div
class="time"
@click="showDateSelect = true"
>
{{ new Date(outputData.reportTimeStart).format('yyyy.MM.dd') }}- {{ new Date(outputData.reportTimeEnd).format('yyyy.MM.dd') }}
<van-icon name="arrow-down" />
</div>
</template>
</div>
<template v-if="tabIndex == 0">
<customer-statistics
:data="customerData"
:reportType="reportType"
/>
</template>
<template v-else>
<output-statistics
:data="outputData"
:reportType="reportType"
/>
</template>
<div class="bottom">
<tab
:list="['客户统计', '产值统计']"
@change="change"
:index="tabIndex"
></tab>
</div>
<van-popup
v-model="showDateSelect"
position="bottom"
>
<van-picker
show-toolbar
:title="reportType == 0 ? '选择周报' : '选择月报'"
:columns="dateColumns"
:default-index="dateColumns.length"
@confirm="confirmDate"
@cancel="showDateSelect = false"
/>
</van-popup>
</div>
</template>
<script>
import { reportApi } from '@/api'
export default {
name: '',
data() {
return {
tabIndex: 1,
reportType: 0, //0 周 1 月
customerData: {},
outputData: {},
detail: {},
showDateSelect: false,
dateColumns: []
}
},
mounted() {
this.initDate()
this.getOutputReport()
},
methods: {
initDate() {
let { reportType } = this
let now = new Date()
let dateColumns = []
if (reportType == 0) {
let dateTime = now.getTime()
let day = now.getDay() || 7
let oneDayTime = 24 * 60 * 60 * 1000
for (let i = 24; i > 0; i--) {
let monday = new Date(dateTime - (day - 1 + i * 7) * oneDayTime).format('yyyy-MM-dd') // 获取周一
let sunday = new Date(dateTime + (7 - day - i * 7) * oneDayTime).format('yyyy-MM-dd') // 获取周日
dateColumns.push(`${monday}~${sunday}`)
}
this.dateColumns = dateColumns
} else {
let nowMonth = now.getMonth()
for (let i = nowMonth - 12; i <= nowMonth - 1; i++) {
dateColumns.push(new Date(new Date().setMonth(i)).format('yyyy-MM'))
}
this.dateColumns = dateColumns
}
},
change(e) {
this.tabIndex = e
},
getOutputReport(reportTimeStart = '') {
let userInfo = this.getLocalStorage('dj_scrm_userInfo')
let { reportType } = this
reportApi
.getReport({
reportType,
reportTimeStart
})
.then(({ code, data, message }) => {
this.hideLoading()
if (code == 0) {
if (data) {
if (data.newProductionValueSequential) data.newProductionValueSequential = Number(data.newProductionValueSequential.replace('%', ''))
if (data.newEquityBillLadingSequential) data.newEquityBillLadingSequential = Number(data.newEquityBillLadingSequential.replace('%', ''))
if (data.merchantProductionValueReportList) {
data.merchantProductionValueReportList.map(e => Number((e.newProductionValue = this.centsToyuan(e.newProductionValue))))
}
if (data.productionValueReportList) {
data.productionValueReportList.map(e => Number((e.newProductionValue = this.centsToyuan(e.newProductionValue))))
}
if (data.trendList) {
data.trendList.map(e => Number((e.orderMoneyTotalSum = this.centsToyuan(e.orderMoneyTotalSum))))
}
data.userInfo = userInfo
this.outputData = data
}
} else {
this.refreshPage(`产值统计:${message}`).then(() => {
this.getOutputReport(reportTimeStart)
})
}
})
},
confirmDate(e) {
let { reportType } = this
this.showLoading('加载中...')
if (reportType == 1) {
this.getOutputReport(`${e}-01`)
this.showDateSelect = false
} else {
let [start] = e.split('~')
this.getOutputReport(start)
this.showDateSelect = false
}
}
}
}
</script>
<style lang="scss" scoped>
.layout {
color: #333333;
font-size: 14px;
padding-bottom: 65px;
.top {
position: sticky;
height: 44px;
padding: 0 16px;
background: #ffffff;
box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
z-index: 9;
top: 0;
.report-name{
width: 50%;
}
.time {
margin-left: auto;
font-weight: 500;
font-size: 12px;
}
}
.bottom {
position: fixed;
bottom: 0;
left: 0;
background: #ffffff;
z-index: 2;
width: 100%;
}
}
</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'
// ]
// }
// }
/**
* 雪碧图插件
*/
const SpritesmithPlugin = require('webpack-spritesmith')
const spritesmithFunction = data => {
let { spritesheet, sprites } = data
let shared = `.sprite-icon { background-image: url(${data.sprites[0].image});background-size: ${spritesheet.width / 2}px ${spritesheet.height / 2}px;}`
let perSprite = sprites.map(sprite => {
let { name, width, height, offset_x, offset_y } = sprite
return `.icon-${name} { width: ${width / 2}px; height: ${height / 2}px; background-position: ${offset_x / 2}px ${offset_y / 2}px;}`
}).join('\n')
return `${shared}\n${perSprite}`
}
module.exports = {
publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-main/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-attachment-customer/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: '/dj-scrm-wx-work-attachment-customer/', // 署应用包时的基本 URL。 vue-router history模式使用
outputDir: 'dist', // 生产环境构建文件的目录
assetsDir: 'static', // outputDir的静态资源(js、css、img、fonts)目录
lintOnSave: !IS_PROD,
productionSourceMap: false, // 如果不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
devServer: {
disableHostCheck: true,
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: `
$cdn: "${defaultSettings.cdn}";
`
}
}
},
configureWebpack: config => {
config.name = name
config.resolve.modules = ['node_modules', './src/assets/spritesmith']
const Plugins = [
new SpritesmithPlugin({
// 引入图片文件夹
src: {
cwd: path.resolve(__dirname, './src/assets/spritesmith'),
glob: ['*.png', '*.jpg']
},
// 生成图片的路径
target: {
image: path.resolve(__dirname, './src/assets/images/sprite.png'),
// 生成SCSS
css: [
[path.resolve(__dirname, './src/assets/css/sprite.scss'), {
format: 'function_based_template'
}]
]
},
customTemplates: {
'function_based_template': spritesmithFunction,
},
//background引用路径
apiOptions: {
cssImageRef: '../images/sprite.png'
},
// 每个图片间距
spritesmithOptions: {
padding: 20
}
})
]
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')
})
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!