uv-overview.vue
9.93 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<template>
<Card class="overview">
<div slot="title">
浏览总览
<Radio-group class="version-type" v-model="appEdition_origin" :change="change">
<Radio label="A">
<span>A版本</span>
</Radio>
<Radio label="B">
<span>B版本</span>
</Radio>
</Radio-group>
<Date-picker type="daterange" :value="dateRange" format="yyyy-MM-dd" placeholder="选择开始结束日期" style="width: 200px;margin-left:80px;" :options="timeOptions" placement="bottom-end" @on-change="datePickChange"></Date-picker>
<Button type="primary" size="large" @click="exportData"><Icon type="ios-download-outline"></Icon> 导出数据</Button>
</div>
<div class="overview-type" slot="extra">
<client-type v-model="type" ></client-type>
</div>
<Table :columns="overviewCol" :data="overviewData" ref="table"></Table>
</Card>
</template>
<script>
import clientType from 'common/client-type';
import * as service from 'service.pc';
import moment from 'moment';
export default {
name: 'uv-overview',
props: ['date','value'],
created() {
this.loadData();
},
watch: {
date: function() {
this.loadData();
},
type: function() {
this.loadData();
},
appEdition_origin(val){
this.loadData();
this.$emit("input", val);
}
},
methods: {
loadData: function() {
this.spinShow = true;
service.get('data-analysis-web/flowsurvey/overview', {
type: this.type,
date: this.date,
appEdition: this.appEdition_origin,
begin_date:Array.isArray(this.dateRange)?this.dateRange[0]:this.dateRange,
end_date:Array.isArray(this.dateRange)?this.dateRange[1]:this.dateRange
}).then(result => {
this.overviewData=result.data;
this.spinShow = false;
});
},
change(val) {
this.appEdition_origin = val;
},
datePickChange(val){
this.dateRange=val;
let mean=new Date(val[1]).getTime()-new Date(val[0]).getTime();
if(Math.floor(mean/(24*3600*1000))>30){
this.error();
return;
}
this.loadData();
},
exportData(){
this.$refs.table.exportCsv({
filename: '浏览总览'
});
},
error () {
this.$Message.error('开始日期与结束日期的跨度为一个月');
}
},
data() {
return {
type: 'all',
ovData: {},
spinShow: true,
appEdition_origin: this.value,
dateRange:moment().format('YYYY-MM-DD'),
timeOptions: {
disabledDate:(date)=> {
return moment(date).isAfter(new Date(), 'day');
},
shortcuts: [
{
text: '最近一周',
value () {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
return [start, end];
}
},
{
text: '最近一个月',
value () {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
return [start, end];
}
},
{
text: '最近三个月',
value () {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
return [start, end];
}
}
]
},
overviewCol: [
{
title: '日期',
width: 120,
align: 'center',
key: 'date',
render(row) {
return `<span>${row.dayDate}</span>`;
}
},
{
title: '平台',
width: 100,
align: 'center',
key: 'appType',
render(row) {
return `<span>${row.appType}</span>`;
}
},
{
title: '浏览量(PV)',
width: 120,
align: 'center',
key: 'pv',
render(row) {
return `<span>${row.pv}</span>`;
}
},
{
title: '访客数(UV)',
width: 120,
align: 'center',
key: 'uv',
render(row) {
return `<span>${row.uv}</span>`;
}
},
{
title: '跳失率',
width: 100,
align: 'center',
key: 'loss_rate',
align: 'loss_rate',
render(row) {
return `<span>${row.loss_rate}%</span>`;
}
},
{
title: '人均浏览量',
width: 120,
align: 'center',
key: 'avg_pv',
render(row) {
return `<span>${row.avg_pv}</span>`;
}
},
{
title: '平均停留时长',
width: 140,
align: 'center',
key: 'avg_stay',
render(row) {
return `<span>${row.avg_stay}</span>`;
}
},
{
title: '详情页PV',
width: 100,
align: 'center',
key: 'clickPv',
render(row) {
return `<span>${row.clickPv}</span>`;
}
},
{
title: '详情页UV',
width: 100,
align: 'center',
key: 'clickUv',
render(row) {
return `<span>${row.clickUv}</span>`;
}
},
{
title: '入蓝UV数',
width: 100,
align: 'center',
key: 'shopcart',
render(row) {
return `<span>${row.shopcart}</span>`;
}
},
{
title: '入篮次数',
width: 100,
align: 'center',
key: 'shopcartPv',
render(row) {
return `<span>${row.shopcartPv}</span>`;
}
},
{
title: '收订订单数',
width: 120,
align: 'center',
key: 'orderNum',
render(row) {
return `<span>${row.orderNum}</span>`;
}
},
{
title: '收订订单金额',
width: 140,
align: 'center',
key: 'amount',
render(row) {
return `<span>${row.amount}</span>`;
}
},
{
title: '支付订单金额',
width: 140,
align: 'center',
key: 'successAmount',
render(row) {
return `<span>${row.successAmount}</span>`;
}
},
{
title: '详情页入篮率',
width: 140,
align: 'center',
key: 'shopcartRate',
render(row) {
return `<span>${row.shopcartRate}</span>`;
}
},
{
title: '详情页进店率',
width: 150,
align: 'center',
key: 'clickToShopRate',
render(row) {
return `<span>${row.clickToShopRate}</span>`;
}
}
],
overviewData: []
};
},
components: {clientType}
};
</script>
<style lang="scss">
.overview {
.version-type {
margin-left: 20px;
}
.overview-content {
position: relative;
width: 100%;
height: 100px;
padding-left: 100px;
padding-right: 100px;
display: flex;
.oc-item {
text-align: center;
flex: 1;
.tit {
font-size: 18px;
}
.val {
height: 80px;
line-height: 80px;
font-size: 28px;
}
}
}
.ivu-date-picker{
display: inline-block;
}
.ivu-picker-panel-shortcut{
font-size: 12px;
}
.ivu-btn.ivu-btn-primary.ivu-btn-large{
margin-left: 20px;
}
}
</style>