linwenxin 1 rok pred
rodič
commit
b135112e6c
1 zmenil súbory, kde vykonal 82 pridanie a 3 odobranie
  1. 82 3
      src/views/valueAddedService/home/index.vue

+ 82 - 3
src/views/valueAddedService/home/index.vue

@@ -102,6 +102,18 @@
 		</div>
     <div class="container_bottom">
 			<div class="chart">
+				<div class="flex_asb">
+					<div class="title">增值服务数据看板</div>
+          <el-date-picker
+            v-model="times"
+            @change="refreshData" 
+            value-format="yyyy-MM-dd HH:mm:ss"
+            type="daterange"
+            range-separator="至"
+            start-placeholder="开始日期"
+            end-placeholder="结束日期">
+          </el-date-picker>
+				</div>
 				<div ref="chart" style="width: 100%;height: 330px;"></div>
 			</div>
 		</div>
@@ -113,7 +125,8 @@
 	export default {
 		data() {
 			return{
-				collectData: {}
+				collectData: {},
+        times: []
 			}
 		},
 		created() {
@@ -121,9 +134,12 @@
 		},
 		methods: {
       refreshData(){
-        dataCountIncreCount().then(res=>{
+        dataCountIncreCount({
+          startTime: this.times?.[0],
+          endTime: this.times?.[1]
+        }).then(res=>{
           this.collectData = res.data
-          console.log(res,"999")
+          this.drawChat(res.data.lineList, res.data.onLineList, this.times)
         })
       },
       gotopage(name,pageName,pageCode,type){
@@ -141,6 +157,69 @@
             name: name
           })
         }
+      },
+      drawChat(data1, data2, times = []) {
+				this.$echarts.init(this.$refs.chart).setOption({
+          grid: {
+            left: 30,   
+            right: 10,  
+            top: 40,    
+            bottom: 50, 
+          },
+          tooltip: {
+						trigger: 'axis'
+					},
+					legend: {
+						data: ['新增线下订单','新增线上订单']
+					},
+					xAxis: {
+						type: 'category',
+						boundaryGap: false,
+						data: this.getDaysBetweenDates(times?.[0],times?.[1])
+					},
+					yAxis: {
+						type: 'value'
+					},
+					series: [
+						{
+							name: '新增线下订单',
+							data: data1,
+							type: 'line',
+							smooth: true,
+						},
+						{
+							name: '新增线上订单',
+							data: data2,
+							type: 'line',
+							smooth: true,
+						}
+					]
+				})
+			},
+      getDaysBetweenDates(startDate, endDate) {
+        if(!startDate || !endDate){
+          // 获取今天的日期
+          var today = new Date();
+          // 创建一个数组来存储日期
+          var dateList = [];
+          // 循环获取十五天内的日期
+          for (var i = 0; i < 15; i++) {
+              // 将日期添加到数组中
+              dateList.push(new Date(today.getFullYear(), today.getMonth(), today.getDate() + i).toLocaleDateString());
+          }
+          return dateList
+        }
+        var dateArray = [];
+        var currentDate = new Date(startDate);
+        var jieshu = new Date(endDate);
+        // 循环获取开始时间和结束时间之间的日期
+        while (currentDate <= jieshu) {
+            // 将日期添加到数组中
+            dateArray.push(new Date(currentDate).toLocaleDateString());
+            // 将当前日期增加一天
+            currentDate.setDate(currentDate.getDate() + 1);
+        }
+        return dateArray;
       }
 		}
 	}