zxl
昨天 2bf5b87e82dd2c4abea65454cd0b66cb0f254356
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
<template>
  <div class="wrapper">
    <Affix :offset-top="100">
      <Card class="card fixed-bottom">
        <affixTime @selected="clickBreadcrumb" />
      </Card>
    </Affix>
<!--    <Card class="card">-->
<!--      <div class="my-chart-container">-->
<!--        &lt;!&ndash; 数据概览卡片 &ndash;&gt;-->
<!--&lt;!&ndash;        <div class="stats-cards">&ndash;&gt;-->
<!--&lt;!&ndash;          <div class="stat-card">&ndash;&gt;-->
<!--&lt;!&ndash;            <div class="stat-header">&ndash;&gt;-->
<!--&lt;!&ndash;              <span class="stat-title">总浏览量</span>&ndash;&gt;-->
<!--&lt;!&ndash;              <i class="fa fa-eye stat-icon"></i>&ndash;&gt;-->
<!--&lt;!&ndash;            </div>&ndash;&gt;-->
<!--&lt;!&ndash;            <div class="stat-value">{{ totalPv }}</div>&ndash;&gt;-->
<!--&lt;!&ndash;            <div class="stat-trend positive">&ndash;&gt;-->
<!--&lt;!&ndash;              <i class="fa fa-arrow-up"></i> 12.5% 较上月&ndash;&gt;-->
<!--&lt;!&ndash;            </div>&ndash;&gt;-->
<!--&lt;!&ndash;          </div>&ndash;&gt;-->
 
<!--&lt;!&ndash;          <div class="stat-card">&ndash;&gt;-->
<!--&lt;!&ndash;            <div class="stat-header">&ndash;&gt;-->
<!--&lt;!&ndash;              <span class="stat-title">平均日浏览量</span>&ndash;&gt;-->
<!--&lt;!&ndash;              <i class="fa fa-calendar stat-icon"></i>&ndash;&gt;-->
<!--&lt;!&ndash;            </div>&ndash;&gt;-->
<!--&lt;!&ndash;            <div class="stat-value">{{ avgDailyPv }}</div>&ndash;&gt;-->
<!--&lt;!&ndash;            <div class="stat-trend positive">&ndash;&gt;-->
<!--&lt;!&ndash;              <i class="fa fa-arrow-up"></i> 8.3% 较上月&ndash;&gt;-->
<!--&lt;!&ndash;            </div>&ndash;&gt;-->
<!--&lt;!&ndash;          </div>&ndash;&gt;-->
 
<!--&lt;!&ndash;          <div class="stat-card">&ndash;&gt;-->
<!--&lt;!&ndash;            <div class="stat-header">&ndash;&gt;-->
<!--&lt;!&ndash;              <span class="stat-title">最高单日浏览量</span>&ndash;&gt;-->
<!--&lt;!&ndash;              <i class="fa fa-trophy stat-icon"></i>&ndash;&gt;-->
<!--&lt;!&ndash;            </div>&ndash;&gt;-->
<!--&lt;!&ndash;            <div class="stat-value">{{ maxDailyPv }}</div>&ndash;&gt;-->
<!--&lt;!&ndash;            <div class="stat-trend">{{ maxPvDate }}</div>&ndash;&gt;-->
<!--&lt;!&ndash;          </div>&ndash;&gt;-->
<!--&lt;!&ndash;        </div>&ndash;&gt;-->
 
<!--        &lt;!&ndash; 图表区域 &ndash;&gt;-->
<!--        <div class="chart-wrapper">-->
<!--          <div class="chart-header">-->
<!--            <h2>PV/UV 趋势图</h2>-->
<!--          </div>-->
<!--          <div ref="chartDom" class="chart-container"></div>-->
<!--        </div>-->
 
<!--        &lt;!&ndash; 数据更新时间 &ndash;&gt;-->
<!--&lt;!&ndash;        <div class="update-time">&ndash;&gt;-->
<!--&lt;!&ndash;          数据更新时间: {{ updateTime }}&ndash;&gt;-->
<!--&lt;!&ndash;        </div>&ndash;&gt;-->
<!--      </div>-->
<!--    </Card>-->
<!--    <Card class="card">-->
<!--      <div class="my-chart-container">-->
<!--        <div class="chart-wrapper">-->
<!--          <div class="chart-header">-->
<!--            <h2>订单增长 趋势图</h2>-->
<!--          </div>-->
<!--          <div ref="orderCount-chartDom" class="chart-container"></div>-->
<!--        </div>-->
<!--      </div>-->
<!--    </Card>-->
    <Card class="card">
      <div>
        <h4>交易概况</h4>
        <div class="flex">
          <div class="transactionList">
            <div
              class="transaction-item"
              v-for="(item, index) in transactionList"
              :key="index"
            >
              <h4>{{ item.label }}</h4>
              <div class="transaction-card" v-if="item.label == '转换'">
                <div class="card-item">
                  <div class="card-item-label">访客数UV</div>
                  <div class="card-item-value">
                    {{ overViewList.uvNum || 0 }}
                  </div>
                </div>
                <div class="card-item">
                  <div class="card-item-label">下单转化率</div>
                  <div class="card-item-value">
                    {{ overViewList.orderConversionRate || "0%" }}
                  </div>
                </div>
                <div class="card-item">
                  <div class="card-item-label">付款转化率</div>
                  <div class="card-item-value">
                    {{ overViewList.paymentsConversionRate || "0%" }}
                  </div>
                </div>
                <div class="card-item">
                  <div class="card-item-label">全店转化率</div>
                  <div class="card-item-value">
                    {{ overViewList.overallConversionRate || "0%" }}
                  </div>
                </div>
              </div>
              <div class="transaction-card" v-if="item.label == '订单'">
                <div class="card-item">
                  <div class="card-item-label">下单笔数</div>
                  <div class="card-item-value">
                    {{ overViewList.orderNum || 0 }}
                  </div>
                </div>
                <div class="card-item">
                  <div class="card-item-label">下单人数</div>
                  <div class="card-item-value">
                    {{ overViewList.orderMemberNum || 0 }}
                  </div>
                </div>
                <div class="card-item">
                  <div class="card-item-label">下单金额</div>
                  <div class="card-item-value">
                    {{ overViewList.orderAmount || 0 | unitPrice("¥") }}
                  </div>
                </div>
                <div class="card-item">
                  <div class="card-item-label">付款笔数</div>
                  <div class="card-item-value">
                    {{ overViewList.paymentOrderNum || 0 }}
                  </div>
                </div>
                <div class="card-item">
                  <div class="card-item-label">付款人数</div>
                  <div class="card-item-value">
                    {{ overViewList.paymentsNum || 0 }}
                  </div>
                </div>
                <div class="card-item">
                  <div class="card-item-label">付款金额</div>
                  <div class="card-item-value">
                    {{ overViewList.paymentAmount || 0 | unitPrice("¥") }}
                  </div>
                </div>
              </div>
              <div class="transaction-card" v-if="item.label == '退单'">
                <div class="card-item">
                  <div class="card-item-label">退单笔数</div>
                  <div class="card-item-value">
                    {{ overViewList.refundOrderNum || 0 }}
                  </div>
                </div>
                <div class="card-item">
                  <div class="card-item-label">退单金额</div>
                  <div class="card-item-value">
                    {{ overViewList.refundOrderPrice || 0 | unitPrice("¥") }}
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="shap">
            <div id="overViewChart">
              <!-- 上 -->
              <div class="block">
                <div class="box">
                  <span>访客数</span>
                  <span>{{ overViewList.uvNum || 0 }}</span>
                </div>
              </div>
              <!-- 中 -->
              <div class="block">
                <div class="box">
                  <span>下单笔数</span>
                  <span>{{ overViewList.orderNum || 0 }}</span>
                </div>
              </div>
              <!-- 下 -->
              <div class="block">
                <div class="box">
                  <span>付款笔数</span>
                  <span>{{ overViewList.paymentOrderNum || 0 }}</span>
                </div>
              </div>
 
              <!-- 线 -->
              <div class="rightBorder"></div>
              <div class="leftTopBorder"></div>
              <div class="leftBottomBorder"></div>
              <!--数据 -->
              <div class="leftTopTips">
                <div>下单转化率</div>
                <div>{{ overViewList.orderConversionRate || "0%" }}</div>
              </div>
              <div class="leftBottomTips">
                <div>付款转化率</div>
                <div>{{ overViewList.paymentsConversionRate || "0%" }}</div>
              </div>
              <div class="rightTips">
                <div>整体转换率</div>
                <div>{{ overViewList.overallConversionRate || "0%" }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </Card>
 
    <Card class="card">
      <div>
        <h4>交易趋势</h4>
        <div></div>
      </div>
 
      <div>
        <div id="orderChart"></div>
      </div>
    </Card>
 
    <Card class="card">
      <div>
        <h4>订退单统计</h4>
        <div class="breadcrumb" style="margin-bottom: 20px">
          <RadioGroup
            v-model="orderOrRefund"
            type="button"
            size="small"
            button-style="solid"
          >
            <Radio :label="1">订单</Radio>
            <Radio :label="0">退单</Radio>
          </RadioGroup>
        </div>
        <div>
          <Table stripe :columns="columns" :data="data"></Table>
        </div>
        <!-- (index) => {
              refundParams.pageNumber = index;
            } -->
        <!-- (size) => {
              (refundParams.pageSize = size), (refundParams.pageNumber = 1);
            } -->
        <Page
          v-if="showRecords"
          size="small"
          @on-change="
            pageNumberChange
          "
          @on-page-size-change="
            pageSizeChange
          "
          class="mt_10"
          show-total
          show-sizer
          show-elevator
          :total="total"
        />
      </div>
    </Card>
  </div>
</template>
<script>
import * as API_Goods from "@/api/goods";
import { Chart } from "@antv/g2";
import orderRow from "./order/orderDetail";
import refundRow from "./order/refundOrder";
import affixTime from "@/components/affix-time";
import * as echarts from 'echarts';
import {pvUvData} from "../../api/orderStatistics";
 
export default {
  components: { orderRow, refundRow, affixTime },
 
  data() {
    return {
      // 图表实例
      chart: null, //pvuv
      orderCountChart:null, //订单日趋势
 
      // 统计数据
 
      orderOrRefund: 1, // 订单还是退单
      total: 0, // 总数
      // 订单状态
      orderStatusList: {
        UNDELIVERED: "待发货",
        UNPAID: "未付款",
        PAID: "已付款",
        DELIVERED: "已发货",
        CANCELLED: "已关闭",
        COMPLETED: "已完成",
        TAKE: "已完成",
      },
 
      serviceTypeList: {
        // 服务类型
        CANCEL: "取消",
        RETURN_GOODS: "退货",
        EXCHANGE_GOODS: "换货",
        RETURN_MONEY: "退款",
      },
      serviceStatusList: {
        // 服务状态
        APPLY: "申请售后",
        PASS: "通过售后",
        REFUSE: "拒绝售后",
        BUYER_RETURN: "买家退货,待卖家收货",
        SELLER_RE_DELIVERY: "商家换货/补发",
        SELLER_CONFIRM: "卖家确认收货",
        SELLER_TERMINATION: "卖家终止售后",
        BUYER_CONFIRM: "买家确认收货",
        BUYER_CANCEL: "买家取消售后",
        WAIT_REFUND: "等待平台退款",
        COMPLETE: "完成售后",
      },
      //
 
      data: [], //定退单存储值
 
      columns: [], // 定退单title
 
      orderColumns: [
        // 表头
        {
          type: "expand",
          width: 50,
          render: (h, params) => {
            return h(orderRow, {
              props: {
                res: params.row,
              },
            });
          },
        },
        {
          title: "商家名称",
          key: "storeName",
        },
        {
          title: "用户名",
          key: "memberName",
        },
 
        {
          title: "订单状态",
          key: "orderStatus",
          render: (h, params) => {
            return h("div", this.orderStatusList[params.row.orderStatus]);
          },
        },
        {
          title: "创建时间",
          key: "createTime",
        },
 
        {
          title: "支付时间",
          key: "paymentTime",
          render: (h, params) => {
            return h("div", params.row.paymentTime || "暂无");
          },
        },
        {
          title: "价格",
          key: "flowPrice",
          render: (h, params) => {
            return h("priceColorScheme", {props:{value:params.row.flowPrice,color:this.$mainColor}} );
          },
        },
        {
          title: "操作",
          key: "action",
          render: (h, params) => {
            return h('Button',{
              props:{
                size:'small'
              },
              on:{
                click: () => {
                 const { sn } = params.row
                  this.$router.push({
                    query: {sn},
                    path: this.orderOrRefund == 1 ? 'order-detail' : 'after-order-detail' + '?sn='+sn
                  })
                }
              }
            },'查看')
          },
        },
      ],
      refundColumns: [
        // 表头
        {
          type: "expand",
          width: 50,
          render: (h, params) => {
            return h(refundRow, {
              props: {
                res: params.row,
              },
            });
          },
        },
        {
          title: "商品图片",
          key: "goodsImage",
          render: (h, params) => {
            return h("img", {
              attrs: {
                src: params.row.goodsImage,
              },
              style: {
                width: "60px",
                verticalAlign: "middle",
              },
            });
          },
        },
 
        {
          title: "商品名称",
          key: "goodsName",
        },
        {
          title: "商家名称",
          key: "storeName",
        },
        {
          title: "售后单类型",
          key: "serviceType",
          render: (h, params) => {
            return h("div", this.serviceTypeList[params.row.serviceType]);
          },
        },
        {
          title: "售后单状态",
          key: "serviceStatus",
          render: (h, params) => {
            return h("div", this.serviceStatusList[params.row.serviceStatus]);
          },
        },
        {
          title: "退款时间",
          key: "refundTime",
          render: (h, params) => {
            return h("div", params.row.refundTime || "暂无");
          },
        },
        {
          title: "申请退款金额",
          key: "applyRefundPrice",
          render: (h, params) => {
            return h("priceColorScheme", {props:{value:params.row.applyRefundPrice,color:this.$mainColor}} );
          },
        },
        {
          title: "申请原因",
          key: "reason",
        },
        {
          title: "实际金额",
          key: "flowPrice",
          render: (h, params) => {
            return h(
              "div",
              this.$options.filters.unitPrice(params.row.flowPrice?params.row.flowPrice:0, "¥")
            );
          },
        },
        {
          title: "操作",
          key: "action",
          render: (h, params) => {
            return h('Button',{
              props:{
                size:'small'
              },
              on:{
                click: () => {
                 const { sn } = params.row
                  this.$router.push({
                    query: {sn},
                    path: this.orderOrRefund == 1 ? 'order-detail' : 'after-order-detail' + '?sn='+sn
                  })
                }
              }
            },'查看')
          },
        },
      ],
 
      // 交易概况
      transactionList: [
        {
          label: "转换",
          value: "",
        },
        {
          label: "订单",
          value: "",
        },
        {
          label: "退单",
          value: "",
        },
      ],
 
      chartList: [], // 绘制订单图表数据
      orderChart: "", //订单图表
 
      overViewList: {}, // 绘制订单统计概览
      overViewChart: "", //订单订单统计概览图标
 
      // 时间
      dateList: [
        {
          title: "今天",
          selected: false,
          value: "TODAY",
        },
        {
          title: "昨天",
          selected: false,
          value: "YESTERDAY",
        },
        {
          title: "过去7天",
          selected: true,
          value: "LAST_SEVEN",
        },
        {
          title: "过去30天",
          selected: false,
          value: "LAST_THIRTY",
        },
      ],
      // 订单传参
      orderParams: {
        searchType: "LAST_SEVEN", // TODAY ,  YESTERDAY , LAST_SEVEN , LAST_THIRTY
        year: "",
        shopId: "",
        memberId: "",
      },
      // 订单概念
      overViewParams: {
        month: "",
        searchType: "LAST_SEVEN", // TODAY ,  YESTERDAY , LAST_SEVEN , LAST_THIRTY
        storeId: "",
        year: "",
      },
      defaultParams: {
        month: "",
        searchType: "LAST_SEVEN", // TODAY ,  YESTERDAY , LAST_SEVEN , LAST_THIRTY
        storeId: "",
        year: "",
      },
      // 退单订单
      refundParams: {
        pageNumber: 1,
        pageSize: 10,
        searchType: "LAST_SEVEN",
        storeId: "",
        year: "",
      },
      showRecords:false,
 
      //
      //
    };
  },
  watch: {
    refundParams: {
      handler(val) {
        this.getOrderList();
      },
      deep: true,
      immediate: true,
    },
    orderOrRefund() {
      this.showRecords = false;
      this.$set(this.refundParams, "pageNumber", 1);
      this.getOrderList();
    },
    orderParams: {
      handler() {
        this.initOrderChartList();
      },
      deep: true,
    },
    overViewParams: {
      handler() {
        this.initOrderOverViewList();
      },
      deep: true,
    },
  },
  methods: {
    //------------- puvu
    handleResize() {
      if (this.chart) {
        this.chart.resize()
      }
    },
    initChart(){
      this.chart = echarts.init(this.$refs.chartDom)
      this.updateChartData(this.orderParams)
    },
    // 更新图表数据
    async updateChartData(param) {
      // 生成日期和PV数据
      const { dates, pvData ,uvData} = await this.generateChartData(param)
      console.log(dates, pvData ,uvData)
      // 更新统计数据
 
 
      // 设置图表配置
      this.chart.setOption(this.getChartOption(dates, pvData, uvData))
    },
// 获取图表配置项
    // 图表配置项(恢复原始颜色)
    getChartOption(dates, pvData, uvData) {
      return {
        tooltip: {
          trigger: 'axis',
          backgroundColor: 'rgba(255, 255, 255, 0.9)',
          borderColor: '#eee',
          borderWidth: 1,
          textStyle: { color: '#333' },
          formatter: (params) => {
            const date = params[0].name;
            const pv = params.find(item => item.seriesName === '浏览量(PV)')?.value || 0;
            const uv = params.find(item => item.seriesName === '独立访客(UV)')?.value || 0;
            // 优化:添加换行符转义,避免潜在格式问题(可选,不影响功能)
            return `<div class="font-medium">${date}</div>
                <div>浏览量(PV): <span style="color: #165DFF; font-weight: bold">${pv.toLocaleString()}</span></div>
                <div>独立访客(UV): <span style="color: #00b42a; font-weight: bold">${uv.toLocaleString()}</span></div>`;
          },
        },
        legend: {
          data: ['浏览量(PV)', '独立访客(UV)'],
          top: 0,
          textStyle: { color: '#666' }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true,
          top: '15%'
        },
        xAxis: {
          type: 'category',
          data: dates,
          axisLine: { lineStyle: { color: '#eee' } },
          axisTick: { show: false },
          axisLabel: { interval: 'auto', rotate: 0, color: '#86909C' },
          splitLine: { show: false }
        },
        yAxis: {
          type: 'value',
          axisLine: { show: false },
          axisTick: { show: false },
          axisLabel: { color: '#86909C', formatter: '{value}' },
          splitLine: { lineStyle: { color: '#f2f3f5' } },
          min: 0
        },
        series: [
          // PV折线(保留原始蓝色系,优化点线衔接)
          {
            name: '浏览量(PV)',
            type: 'line',
            data: pvData,
            symbol: 'circle',
            symbolSize: 6, // 保留原有点大小
            emphasis: {
              symbolSize: 8,
              showSymbol: true
            },
            lineStyle: {
              width: 3, // 保留原有线宽
              color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
                { offset: 0, color: '#165DFF' }, // 原始PV主色
                { offset: 1, color: '#36CFC9' }  // 原始渐变辅助色
              ]),
              // 关键优化1:线条端点设为圆角,避免“切口”空白
              cap: 'round',
              // 关键优化2:线条拐角设为圆角,避免衔接间隙
              join: 'round',
              // 辅助:控制拐角圆角大小(与线宽匹配,避免溢出)
              miterLimit: 3
            },
            itemStyle: {
              color: '#165DFF', // 原始点颜色
              borderColor: '#fff', // 保留白色边框(增强层次感)
              // 关键优化3:减小边框宽度,避免遮挡线条导致断层
              borderWidth: 0 // 从2调整为1.5
            },
            areaStyle: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                { offset: 0, color: 'rgba(22, 93, 255, 0.2)' }, // 原始填充色
                { offset: 1, color: 'rgba(22, 93, 255, 0)' }
              ])
            },
            smooth: true,
            showSymbol: true, // 保留你设置的“默认显示所有点”
          },
          // UV折线(保留原始绿色系,同PV优化逻辑)
          {
            name: '独立访客(UV)',
            type: 'line',
            data: uvData,
            symbol: 'circle',
            symbolSize: 6, // 保留原有点大小
            emphasis: {
              symbolSize: 8,
              showSymbol: true
            },
            lineStyle: {
              width: 3, // 保留原有线宽
              color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
                { offset: 0, color: '#00b42a' }, // 原始UV主色
                { offset: 1, color: '#72c140' }  // 原始渐变辅助色
              ]),
              // 同PV优化:端点圆角+拐角圆角
              cap: 'round',
              join: 'round',
              miterLimit: 3
            },
            itemStyle: {
              color: '#00b42a', // 原始点颜色
              borderColor: '#fff', // 保留白色边框
              // 同PV优化:减小边框宽度
              borderWidth: 0 // 从2调整为1.5
            },
            areaStyle: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                { offset: 0, color: 'rgba(0, 180, 42, 0.2)' }, // 原始填充色
                { offset: 1, color: 'rgba(0, 180, 42, 0)' }
              ])
            },
            smooth: true,
            showSymbol: true, // 保留“默认显示所有点”
          }
        ],
        animation: true,
        animationDuration: 1500,
        animationEasing: 'cubicOut'
      };
    },
// 生成pv/uv图表数据
    async generateChartData(param) { // 1. 声明为async函数
      const dates = [];
      const today = new Date();
      let days = 1;
 
      // 确定天数逻辑不变
      if (param.searchType === "TODAY") {
        days = 1;
      } else if (param.searchType === "YESTERDAY") {
        days = 1;
      } else if (param.searchType === "LAST_SEVEN") {
        days = 7;
      } else if (param.searchType === "LAST_THIRTY") {
        days = 30;
      }
 
      // 生成日期数组逻辑不变
      for (let i = days - 1; i >= 0; i--) {
        const date = new Date(today);
        date.setDate(today.getDate() - i);
        dates.push(this.formatDate(date, 'MM-dd'));
      }
 
      // 2. 使用await等待接口返回,确保数据获取后再继续
      let pvData = [];
      let uvData = [];
      try {
        const res = await pvUvData(param); // 等待接口响应
        if (res.code === 200) {
          pvData = res.data.pvData;
          uvData = res.data.uvData;
        }
      } catch (error) {
        console.error("接口调用失败", error);
        // 可根据需求添加错误处理(如默认数据)
      }
 
      // 3. 此时pvData和uvData已被接口数据填充,再返回
      return { dates, pvData, uvData };
    },
    //-------------
    //-------------订单日趋势
 
 
 
    //-------------
 
 
 
 
 
    formatDate(date) {
      const month = date.getMonth() + 1; // 月份从0开始,需+1
      const day = date.getDate();
      // 补零:如果是个位数,前面加0
      const formattedMonth = month < 10 ? `0${month}` : month;
      const formattedDay = day < 10 ? `0${day}` : day;
      return `${formattedMonth}-${formattedDay}`;
    },
 
    pageNumberChange(val){
      this.refundParams.pageNumber = val
      this.getOrderList();
    },
    pageSizeChange(val){
      this.refundParams.pageSize = val
      this.getOrderList();
    },
    // 订单图
    initOrderChart() {
      // 默认已经加载 legend-filter 交互
      let data = this.chartList;
 
      data.forEach((item) => {
        item.createTime = item.createTime.split(" ")[0];
        item.title = "交易额";
      });
      this.orderChart.data(data);
 
      this.orderChart.tooltip({
        showCrosshairs: true,
        shared: true,
      });
 
      this.orderChart
        .line()
        .position("createTime*price")
        .label("price")
        .color("title")
        .shape("smooth");
 
      this.orderChart
        .point()
        .position("createTime*price")
        .label("price")
        .color("title")
        .shape("circle")
        .style({
          stroke: "#fff",
          lineWidth: 1,
        });
         this.orderChart.area().position("createTime*price").color("title").shape("smooth");
 
      this.orderChart.render();
    },
 
    clickBreadcrumb(item, index) {
      let callback = JSON.parse(JSON.stringify(item));
      console.log("callback",callback)
      this.orderParams = callback;
 
      this.overViewParams = callback;
      this.refundParams = callback;
      this.refundParams.pageNumber = 1
      this.refundParams.pageSize = 10
 
      //更新表格
      this.updateChartData(this.orderParams)
    },
 
    // 实例化订单概览
    async initOrderOverViewList() {
      const res = await API_Goods.getOrderOverView(this.overViewParams);
      if (res.success) {
        this.overViewList = res.result;
      }
    },
    // 实例化订单图表
    async initOrderChartList(name) {
      this.orderChart ? this.orderChart.clear() : ''
      const res = await API_Goods.getOrderChart(this.orderParams);
      if (res.success) {
        this.chartList = res.result;
 
        if (!this.orderChart) {
          this.orderChart = new Chart({
            container: "orderChart",
            autoFit: true,
            height: 500,
            padding: [70, 70, 70, 70],
          });
        }
 
        this.initOrderChart(); //订单表
      }
    },
    // 统计相关订单统计
    async getOrderList() {
      let res;
      if (this.orderOrRefund == 1) {
        // 订单
        res = await API_Goods.statisticsOrderList(this.refundParams);
      } else {
        // 退单
        res = await API_Goods.statisticsOrderRefundList(this.refundParams);
      }
      if (res.success) {
        this.showRecords = true;
        this.data = res.result.records;
        this.columns =
          this.orderOrRefund == 1 ? this.orderColumns : this.refundColumns;
        this.total = res.result.total;
      }
    },
 
    // 实例化初始值
    initBaseParams() {
      let data = new Date();
      this.getOrderList();
      this.orderParams.year = data.getFullYear();
      this.overViewParams.year = data.getFullYear();
    },
  },
 
  mounted() {
    console.log('ECharts 是否存在:', typeof echarts !== 'undefined'); // 应输出 true
    this.initChart();
    this.initBaseParams();
    window.addEventListener('resize', this.handleResize)
  },
};
</script>
<style scoped lang="scss">
.active {
  color: $theme_color;
  position: relative;
 
  &::before {
    content: "";
    position: absolute;
    width: 100%;
    height: 3px;
    bottom: -5px;
    left: 0;
    background: $theme_color;
  }
}
.breadcrumb {
  span {
    cursor: pointer;
  }
}
 
.page-col {
  text-align: right;
  margin: 10px 0;
}
.wrapper {
  padding-bottom: 200px;
}
.page {
  text-align: right;
  margin: 20px 0;
}
#overViewChart {
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  position: relative;
  margin-left: 20px;
  > .leftTopTips {
    position: absolute;
    top: 68px;
    left: -2px;
    width: 85px;
    text-align: center;
    background: rgb(255, 255, 255);
    z-index: 1;
    padding: 5px 0px;
  }
  > .leftBottomTips {
    position: absolute;
    bottom: 100px;
    left: -2px;
    width: 85px;
    text-align: center;
    background: rgb(255, 255, 255);
    z-index: 1;
    padding: 5px 0px;
  }
  > .rightTips {
    position: absolute;
    bottom: 240px;
    right: 0px;
    width: 85px;
    text-align: center;
    background: rgb(255, 255, 255);
    z-index: 1;
    padding: 5px 0px;
  }
  > .rightBorder {
    width: 110px;
    position: absolute;
    top: 30px;
    right: 40px;
    border: 2px solid #d9d9d9;
    border-left: 0;
    height: 280px;
  }
  > .leftTopBorder {
    border: 2px solid #d9d9d9;
    height: 118px;
    width: 56px;
    position: absolute;
    left: 40px;
    top: 30px;
    border-right: 0;
  }
  > .leftBottomBorder {
    width: 108px;
    border: 2px solid #d9d9d9;
    height: 150px;
    position: absolute;
    bottom: 45px;
    left: 40px;
    border-right: 0;
  }
  > .block {
    height: 0px;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
    position: relative;
    background: rgb(255, 255, 255);
    z-index: 1;
    position: relative;
  }
  > .block:nth-of-type(1) {
    width: 240px;
    border-top: 90px solid #ff4646;
    > .box {
      left: -30px;
      top: -90px;
      width: 240px;
      height: 90px;
    }
  }
  > .block:nth-of-type(2) {
    width: 172px;
    border-top: 100px solid #ff8585;
    margin-top: 10px;
    > .box {
      left: -29px;
      top: -100px;
      width: 172px;
      height: 100px;
    }
  }
  > .block:nth-of-type(3) {
    width: 100px;
    margin-top: 10px;
    border-top: 150px solid #ffb396;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
 
    > .box {
      left: -50px;
      top: -150px;
      width: 100px;
      height: 120px;
      z-index: 2;
    }
  }
  /deep/ .box {
    color: #fff;
    position: absolute;
 
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    > span {
      font-size: 16px;
      font-weight: bold;
    }
  }
}
 
.transaction-item {
  margin: 10px 0;
}
h4 {
  margin: 0 0 20px 0;
}
.transactionList {
  flex: 7;
  padding: 0 20px;
}
.shap {
  width: 400px;
  margin-left: 20px;
  margin-top: 50px;
}
 
.transaction-card {
  height: 120px;
  border-radius: 0.4em;
  display: flex;
  background: #f3f5f7;
}
.card-item-label {
  font-weight: bold;
  font-size: #666;
  font-size: 15px;
  margin-bottom: 10px;
}
.card-item-value {
  font-size: 15px;
  font-weight: bold;
  color: $theme_color;
}
.card-item {
  height: 100%;
 
  width: 20%;
  align-items: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
 
.order-col {
  display: flex;
  > div {
    margin-right: 8px;
    padding: 16px;
    font-size: 15px;
  }
}
.order-list {
  display: flex;
}
.tips {
  margin: 0 8px;
}
.card {
  margin-bottom: 10px;
}
.my-chart-container {
  padding: 20px;
  background-color: #f9fafb;
}
 
.stats-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
}
 
.stat-card {
  flex: 1;
  min-width: 250px;
  background-color: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
 
.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(22, 93, 255, 0.1);
}
 
.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}
 
.stat-title {
  color: #86909c;
  font-size: 14px;
}
 
.stat-icon {
  color: #165dff;
  font-size: 18px;
}
 
.stat-value {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #1d2129;
}
 
.stat-trend {
  font-size: 13px;
  display: flex;
  align-items: center;
}
 
.stat-trend.positive {
  color: #00b42a;
}
 
.chart-wrapper {
  background-color: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  margin-bottom: 15px;
}
 
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
 
.chart-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: #1d2129;
}
 
//.time-filters {
//  display: flex;
//  gap: 10px;
//}
 
//.time-filters button {
//  padding: 6px 12px;
//  border-radius: 4px;
//  border: none;
//  background-color: #f2f3f5;
//  color: #1d2129;
//  font-size: 14px;
//  cursor: pointer;
//  transition: all 0.2s ease;
//}
//
//.time-filters button.active {
//  background-color: #ff4c16;
//  color: #fff;
//}
 
.chart-container {
  width: 100%;
  height: 400px;
}
 
.update-time {
  color: #86909c;
  font-size: 12px;
  text-align: right;
}
 
@media (max-width: 768px) {
  .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
 
  .chart-container {
    height: 300px;
  }
}
</style>