Commit 40253fc2 by chenwq

饼图

1 parent 9cc7dd04
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="pie-box"> <div class="pie-box">
<div :id="id" :style="{ height: height }" class="pie-chart"></div> <div :id="id" :style="{ height: height }" class="pie-chart"></div>
<div class="center-content" :style="{ fontSize: size }"> <div class="center-content" :style="{ fontSize: size }">
<div :class="[id, 'center-content-num']"></div> <div :class="[id, 'center-content-num', 'center-content-num-color']"></div>
</div> </div>
<div class="content-desc"> <div class="content-desc">
<div class="content-desc-icon" :style="{ background: descColor }"></div> <div class="content-desc-icon" :style="{ background: descColor }"></div>
...@@ -191,7 +191,17 @@ export default { ...@@ -191,7 +191,17 @@ export default {
}, },
setAnamiteText() { setAnamiteText() {
// document.querySelector(`.${this.id}`).nextElementSibling.style = 'animation-iteration-count:infinite;' // document.querySelector(`.${this.id}`).nextElementSibling.style = 'animation-iteration-count:infinite;'
if (document.querySelector(`.${this.id}`)) document.querySelector(`.${this.id}`).style = `--step:${this.mainValue}` // 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(() => { // setTimeout(() => {
// document.querySelector(`.${this.id}`).nextElementSibling.style = 'animation-iteration-count:0' // document.querySelector(`.${this.id}`).nextElementSibling.style = 'animation-iteration-count:0'
// }, 3000) // }, 3000)
...@@ -219,12 +229,14 @@ export default { ...@@ -219,12 +229,14 @@ export default {
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
text-align: center; text-align: center;
max-width: 40%; max-width: 40%;
&-num-color {
color: #fff;
}
&-num { &-num {
// overflow: hidden; // overflow: hidden;
// text-overflow: ellipsis; // text-overflow: ellipsis;
// white-space: nowrap; // white-space: nowrap;
// font-size: 0.6vw; // font-size: 0.6vw;
color: #fff;
--step: 0; --step: 0;
counter-reset: count var(--step); counter-reset: count var(--step);
z-index: var(--step); z-index: var(--step);
...@@ -243,7 +255,7 @@ export default { ...@@ -243,7 +255,7 @@ export default {
} }
} }
.content-desc { .content-desc {
display:flex; display: flex;
align-items: center; align-items: center;
font-size: 8px; font-size: 8px;
color: #c8c8c8; color: #c8c8c8;
...@@ -260,7 +272,7 @@ export default { ...@@ -260,7 +272,7 @@ export default {
width: 8px; width: 8px;
height: 4px; height: 4px;
border-radius: 2px; border-radius: 2px;
margin-right:4px; margin-right: 4px;
} }
} }
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
> >
</div> </div>
</template> </template>
<slot name="suffix"></slot>
</div> </div>
</template> </template>
......
<template> <template>
<div class="tabs"> <div class="tabs">
<div class="tab pointer"> <div class="tab">
<div class="tab-left box" @click="changeType('total')"> <div class="tab-left box" @click="changeType('total')">
<div :class="{ 'tab-total-box': true, active: tabType == 'total' }"> <div :class="{ 'tab-total-box': true, active: tabType == 'total' }">
<div class="total-title-box flex"> <div class="total-title-box flex">
...@@ -17,9 +17,11 @@ ...@@ -17,9 +17,11 @@
</div> </div>
<div class="tab-right box"> <div class="tab-right box">
<template v-for="(i, index) in tabs"> <template v-for="(i, index) in tabs">
<div :key="index" :class="['item', 'flex', tabType == i.key ? 'active' : '']" @click="changeType(i.key)"> <div :key="index" :class="['item', 'flex', tabType == i.key ? 'active' : '', ['applet', 'publiccus'].includes(i.key) ? '' : 'pointer']" @click="changeType(i.key)">
<div class="item-title">{{ i.title }}</div> <div class="item-title">{{ i.title }}</div>
<transition-number :num="pageData[i.key].totalNum" :idKey="`number-${i.key}`" class="item-total" /> <transition-number :num="pageData[i.key].totalNum" :idKey="`number-${i.key}`" class="item-total">
<span v-if="['applet', 'publiccus'].includes(i.key)" class="item-txt" slot="suffix">(总)</span>
</transition-number>
<div :class="['item-incr flex', { up: pageData[i.key].up }, { down: pageData[i.key].down }]"> <div :class="['item-incr flex', { up: pageData[i.key].up }, { down: pageData[i.key].down }]">
{{ req.queryType == 0 ? '上月' : '昨日' }} {{ req.queryType == 0 ? '上月' : '昨日' }}
<template v-if="pageData[i.key].up || pageData[i.key].down"> <template v-if="pageData[i.key].up || pageData[i.key].down">
...@@ -126,7 +128,7 @@ export default { ...@@ -126,7 +128,7 @@ export default {
updata: Date.now() updata: Date.now()
} }
}, },
mounted() {}, mounted() { },
methods: { methods: {
init(params) { init(params) {
this.isGroup = true this.isGroup = true
...@@ -144,6 +146,9 @@ export default { ...@@ -144,6 +146,9 @@ export default {
this.getOveralltrend(this.tabType) this.getOveralltrend(this.tabType)
}, },
changeType(type) { changeType(type) {
if (['applet', 'publiccus'].includes(type)) {
return true
}
let title = { let title = {
total: '客户总数', total: '客户总数',
wechat: '企微客户数', wechat: '企微客户数',
...@@ -383,8 +388,8 @@ export default { ...@@ -383,8 +388,8 @@ export default {
width: 27%; width: 27%;
padding-left: 0; padding-left: 0;
white-space: nowrap; white-space: nowrap;
.describe{ .describe {
font-size:8px; font-size: 8px;
color: #eb6001; color: #eb6001;
} }
} }
...@@ -418,6 +423,11 @@ export default { ...@@ -418,6 +423,11 @@ export default {
color: #e8e8e8; color: #e8e8e8;
padding-top: 0.5vh; padding-top: 0.5vh;
} }
&-txt {
font-size: 12px;
color: #e8e8e8;
font-weight: 400;
}
&-total { &-total {
font-size: 14px; font-size: 14px;
color: #eb6001; color: #eb6001;
......
...@@ -49,7 +49,6 @@ export default { ...@@ -49,7 +49,6 @@ export default {
}, },
getMerchantNum() { getMerchantNum() {
this.api.overview.getMerchantNum({}).then(res => { this.api.overview.getMerchantNum({}).then(res => {
console.log(res)
if (res.code === '0') { if (res.code === '0') {
this.merchantNum = res.data.dataList[0] this.merchantNum = res.data.dataList[0]
} }
......
...@@ -29,13 +29,18 @@ export default { ...@@ -29,13 +29,18 @@ export default {
this.distributionRank = '' this.distributionRank = ''
if (res.data.dataList.length > 0) { if (res.data.dataList.length > 0) {
let distribution = JSON.parse(res.data.dataList[0].distribution) let distribution = JSON.parse(res.data.dataList[0].distribution)
const keys = Object.keys(distribution) // 删掉“未知”
delete distribution['未知']
let keys = Object.keys(distribution)
let total = Object.values(distribution).reduce((prev, next) => prev + next)
keys.forEach((item, index) => { keys.forEach((item, index) => {
this.clientData.push({ this.clientData.push({
name: item, name: item,
value: distribution[item] // value: distribution[item]
value: (distribution[item] / total * 100).toFixed(1)
}) })
}) })
console.log(this.clientData)
this.distributionRank = JSON.parse(res.data.dataList[0].distributionRank) this.distributionRank = JSON.parse(res.data.dataList[0].distributionRank)
} }
}) })
...@@ -51,7 +56,7 @@ export default { ...@@ -51,7 +56,7 @@ export default {
pieAction(data) { pieAction(data) {
this.brandList = [] this.brandList = []
let array = this.distributionRank && this.distributionRank[data.name] let array = this.distributionRank && this.distributionRank[data.name]
if (array&&array.length > 0) { if (array && array.length > 0) {
for (let i of array) { for (let i of array) {
this.brandList.push(i && Object.keys(i)[0]) this.brandList.push(i && Object.keys(i)[0])
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!