DigitalMarketingRight.vue
6.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<template>
<div class="marketing-right">
<PullDownSelect ref="rightDownSelect" v-show="!switchShow" :selectList="selectList" @selectVal="selectVal"></PullDownSelect>
<div class="patch-title" v-show="switchShow">活动订单金额分布</div>
<inner-tab ref="innerTabRef" class="inner-tab" :list="tabList" :width="tabWidth" :itemPadding="0.5" @changeTab="changeTab"></inner-tab>
<!-- 1.3售后众筹显示占比和价格区间切换 -->
<div class="switch-box" v-if="switchShow">
<div class="text">收入占比:{{ ratio }}%</div>
<PriceSwitch :selectList="priceList" @selectPrice="selectPrice"></PriceSwitch>
</div>
<BarChart ref="merchantChartRef" domId="merchantChart" :label="barChartLabel" :height="barchartHeight" :colorList="colorList" :barWidth="'50'" :valueName="valueName"></BarChart>
</div>
</template>
<script>
import PullDownSelect from './PullDownSelect.vue'
import BarChart from './BarChart.vue'
import PriceSwitch from './PriceSwitch.vue'
import { digitalMarketingPriceObj, digitalMarketingRightSelectList } from './constant'
export default {
name: 'DigitalMarketingRight',
components: {
PullDownSelect,
BarChart,
PriceSwitch
},
data() {
return {
tabList: ['门店数', '总金额'],
tabWidth: 7.3,
priceList: digitalMarketingPriceObj.merchantOrderlist,
selectList: digitalMarketingRightSelectList[0],
selectType: '',
marketingDistributionList: [],
colorList: ['#22D8FF', '#223FA9', '#061422'],
barchartHeight: '16vh',
switchShow: false,
valueName: 'outputMerchantNum',
downSelectNum: 0,
ratio: '',
digitalMarketingTab: 0,
barChartLabel: 'statYear',
marketingCrowdFundingDistr: [],
startPrice: '',
endPrice: '',
crowfundDistrType: ''
}
},
created() {
// :门店订单金额分布 && 门店订单量分布
this.getMarketingDistribution()
},
mounted() {
this.$bus.$on('digitalMarketingTabChange', data => {
this.digitalMarketingTab = data
this.tabShow = false
this.selectList = digitalMarketingRightSelectList[data]
switch (data) {
case 0:
this.switchShow = false
this.tabWidth = 7.3
this.tabList = ['门店数', '总金额']
this.valueName = 'outputMerchantNum'
this.barChartLabel = 'statYear'
this.getMarketingDistribution()
break
case 1:
this.switchShow = true
this.tabWidth = 10.8
this.tabList = ['门店数', '订单数', '总金额']
this.valueName = 'num'
this.barChartLabel = 'statDate'
this.getMarketingCrowdFundingDistr('merData')
break
}
})
},
methods: {
selectVal(val) {
this.$refs.innerTabRef.tabActive = 0
switch (val.val) {
case 'outputMerchantNum':
this.tabWidth = 7.3
this.tabList = ['门店数', '总金额']
this.valueName = 'outputMerchantNum'
this.downSelectNum = 0
this.$nextTick(() => {
this.$refs.merchantChartRef.drawBar(this.marketingDistributionList)
})
break
case 'orderMerchantNum':
this.tabList = ['门店数', '总订单数']
this.tabWidth = 8.1
this.valueName = 'orderMerchantNum'
this.downSelectNum = 1
this.$nextTick(() => {
this.$refs.merchantChartRef.drawBar(this.marketingDistributionList)
})
break
}
},
changeTab(val) {
console.log(val)
switch (val) {
case 0:
// 1.1精品升级
if (this.digitalMarketingTab === 0) {
this.valueName = this.downSelectNum === 0 ? 'outputMerchantNum' : 'orderMerchantNum'
this.$refs.merchantChartRef.drawBar(this.marketingDistributionList)
} else {
// 1.3售后众筹
this.crowfundDistrType = 'merData'
this.marketingDistributionList = this.marketingCrowdFundingDistr.merData.trendData
this.ratio = this.marketingCrowdFundingDistr.merData.ratio
}
break
case 1:
// 1.1精品升级
if (this.digitalMarketingTab === 0) {
this.valueName = this.downSelectNum === 0 ? 'outputMoney' : 'orderMoney'
this.$refs.merchantChartRef.drawBar(this.marketingDistributionList)
} else {
// 1.3售后众筹
this.crowfundDistrType = 'orderData'
this.marketingDistributionList = this.marketingCrowdFundingDistr.orderData.trendData
this.ratio = this.marketingCrowdFundingDistr.merData.ratio
}
break
case 2:
// 只有1.3售后众筹
this.crowfundDistrType = 'incomeData'
this.marketingDistributionList = this.marketingCrowdFundingDistr.incomeData.trendData
this.ratio = this.marketingCrowdFundingDistr.merData.ratio
break
}
this.$nextTick(() => {
this.$refs.merchantChartRef.drawBar(this.marketingDistributionList)
})
},
async getMarketingDistribution() {
const _data = await this.api.internal.getMarketingDistribution()
const _dataList = _data.data.dataList
this.marketingDistributionList = _dataList
this.$refs.merchantChartRef.drawBar(_dataList)
},
// 活动订单金额分布
async getMarketingCrowdFundingDistr(queryItem) {
const params = {
startPrice: this.startPrice,
endPrice: this.endPrice
}
const _data = await this.api.internal.getMarketingCrowdFundingDistr(params)
const _queryItem = queryItem || this.crowfundDistrType
const _dataList = _data.data.dataList[0][_queryItem].trendData
this.marketingCrowdFundingDistr = _data.data.dataList[0]
this.marketingDistributionList = _dataList
this.ratio = _data.data.dataList[0][_queryItem].ratio
this.$refs.merchantChartRef.drawBar(_dataList)
},
selectPrice(val) {
if (val.label === '全部') {
this.startPrice = ''
this.endPrice = ''
this.getMarketingCrowdFundingDistr()
return
}
this.startPrice = val.startPrice
this.endPrice = val.endPrice
this.getMarketingCrowdFundingDistr()
}
}
}
</script>
<style lang="scss" scoped>
.marketing-right {
width: 22.78vw;
height: 25vh;
display: flex;
flex-direction: column;
justify-content: space-between;
.inner-tab {
/deep/.tab-item-box {
margin: 0;
}
}
.switch-box {
display: flex;
justify-content: space-between;
.text {
font-weight: 600;
font-size: 10px;
color: #ffffff;
}
}
}
</style>