boxChart.vue
6.48 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<template>
<div>
<div class='component'>
<div class='titles'>
<!-- <span>展业时间</span>-->
<!-- <span>业务</span>-->
<span>门店号</span>
<span>门店名称</span>
<span>订单数</span>
<span>订单金额</span>
</div>
<div
ref='forwardScrollBox'
class='list_dv'
@mouseenter='mouseenter'
@mouseleave='mouseleave'
>
<div ref='forwardContent' class='scroll_dv'>
<div v-for='(item, index) in boxList' :key='index' class='list_item dfac'>
<!-- @click='selectData(item)'-->
<div
class='dataList'
:class="currentIndex === index? 'selectMerchant' : ''"
@mouseleave="currentIndex = ''"
@mouseenter='mouseenterList(item,index)'>
<!-- <div>{{ item.date }}</div>-->
<!-- <div>-->
<!-- {{ item.businessName == '1.1' ? '1.1转化+'-->
<!-- : item.businessName == '1.2' ? '1.2膨胀金' :-->
<!-- item.businessName == '1.3' ? '1.3众筹'-->
<!-- : item.businessName == '2.1' ? '2.1车损无忧' : '' }}-->
<!-- </div>-->
<div>{{ item.merchantId }}</div>
<div>{{ item.merchantName }}</div>
<div>{{ item.orderNum }}</div>
<div>{{ item.orderPrice }}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'boxChart',
components: {},
props: {},
data() {
return {
totalCount: 10000, // 总数
scrollContentHeight: 0, // 滚动内容的高度
scrollBoxHeight: 0, // 滚动父级盒子的高度
scrollableHeight: 0, // 可以滚动的高度
scrollTop: 0, // 元素已经滚动的高度
timer2: null, // 定时器
boxList: [],
currentIndex: ''
}
},
computed: {},
watch: {},
created() {
},
async mounted() {
await this.getList()
// this.$nextTick(() => {
// 窗口大小变化时,重新获取滚动相关元素的高度
// setTimeout(() => {
// window.onresize = this.regainHeight()
// })
// 监听元素滚动事件
// this.$refs.forwardScrollBox.addEventListener('scroll', this.handleScroll, true)
// })
},
destroyed() {
// 离开时销毁定时器
clearInterval(this.timer2)
},
methods: {
getList() {
this.api.springbudAtion.getMerchantNumTrend().then(res => {
if (res.code == 0) {
this.boxList = res.data.dataList
// this.initThirtyDays({
// queryItem: 'transwork'
// })
this.$nextTick(() => {
this.regainHeight()
})
}
})
},
mouseenterList(item, index) {
this.currentIndex = index
},
// 页面第一次进入或者窗口大小变化时,获取滚动相关元素的高度
regainHeight() {
// 获取需要滚动元素的真实高度
this.scrollContentHeight = this.$refs.forwardContent.getBoundingClientRect().height
// 获取限制高度滚动容器的真实高度
this.scrollBoxHeight = this.$refs.forwardScrollBox.getBoundingClientRect().height
// 可以滚动的高度
this.scrollableHeight = this.scrollContentHeight - this.scrollBoxHeight
console.log('内容高度', this.scrollContentHeight, '盒子高度', this.scrollBoxHeight, '可以滚动的高度', this.scrollableHeight)
this.autoScroll()
},
// 自动滚动
autoScroll() {
this.timer2 = setInterval(() => {
if (this.scrollableHeight >= this.scrollTop) {
// 当为滚动到结尾时滚动
this.scrollTop = this.$refs.forwardScrollBox.scrollTop += 2
} else {
// 滚动结束,清除当前定时器,scrollTop重置为0,继续滚动
this.scrollTop = this.$refs.forwardScrollBox.scrollTop = 0
clearInterval(this.timer2)
this.autoScroll()
}
}, 100)
},
// 鼠标移入时停止滚动
mouseenter() {
clearInterval(this.timer2)
},
// 鼠标移开继续滚动
mouseleave() {
this.autoScroll()
},
// 滚动元素滚动时的方法
handleScroll(e) {
console.log(e.target.scrollTop)
}
// initThirtyDays(params, businessName = 'transwork', merchantName = '') {
// this.api.springbudAtion.getEveryMerMonthlyTrend(params).then(res => {
// if (res.code == 0) {
// let thirtyDaysList = res.data.dataList
//
// this.$bus.$emit('thirtyDays', { thirtyDaysList, businessName, merchantName })
// }
// })
// },
// selectData(item) {
// businessName, merchantId, merchantName
// const { merchantId } = item
// this.$bus.$emit('storeDetails', { merchantId })
// switch (businessName) {
// case '1.1':
// businessName = 'transwork'
// break
// case '1.2':
// businessName = 'expandedgold'
// break
// case '1.3':
// businessName = 'crowdfunding'
// break
// case '2.1':
// businessName = 'noworries'
// break
// }
// const params = {
// merchantId,
// queryItem: businessName
// }
// this.$bus.$emit('getMerchantTime', { merchantId, businessName })
// this.initThirtyDays(params, businessName, merchantName)
// }
}
}
</script>
<style lang='scss' scoped>
.component {
//padding: 1vw 0;
//padding-bottom: 1vw;
font-family: Source Han Sans CN, Source Han Sans CN-Regular;
letter-spacing: 0.1vw;
.titles {
//display: flex;
//justify-content: space-between;
display: grid;
//padding: 0 1vw;
grid-template-columns: 18% 46% 16% 20%;
font-size: 0.833vw;
}
.list_dv::-webkit-scrollbar {
display: none;
}
//针对火狐浏览器隐藏滚动条
.list_dv {
scrollbar-width: none
}
.list_dv {
//padding: 0 1vw;
width: 100%;
//height: 100%;
height: 31vh;
overflow-y: auto;
font-size: 0.6vw;
color: #d4eaf6;
.list_item {
width: 100%;
height: 3vh;
line-height: 3vh;;
//height: 26px;
//margin-bottom: 1vw;
.dataList {
display: grid;
grid-template-columns: 18% 46% 16% 20%;
cursor: pointer;
//div{
// width: 100%;
// &:nth-child(2){
// width: 70px;
// }
//}
}
.selectMerchant {
background: #6578FF;
}
}
}
}
</style>