liyongli 2 年之前
父節點
當前提交
e252338000

+ 8 - 0
src/api/index.js

@@ -330,4 +330,12 @@ export function jsonCalendarTwo(data) {
   });
 }
 
+export function lastTime(data) {
+  return ajax({
+    urlType: "cxzx",
+    url: `/zhoubao/data/defult-dt.json?${data.time}`,
+    method: "GET",
+  });
+}
+
 export default {};

+ 0 - 1
src/main.js

@@ -14,7 +14,6 @@ router.beforeEach((to, from, next) => {
   const Mobile = /^\/Mobile/g.test(to.path);
   const menuDiet1 = /^\/menuDiet/g.test(to.path);
   const Calendar = /^\/Calendar/g.test(to.path);
-  console.log(traditional,to.path)
   if (traditional || advertisement || Mobile || menuDiet1 || Calendar) return next();
   if (!localStorage.user) {
     // apply 必须拿到oa用户数据

+ 27 - 1
src/utils/tool.js

@@ -1,3 +1,5 @@
+import dayjs from "dayjs";
+
 import { getAPPUser, getAPPToken, getAPPUserDetail } from "../api/index";
 
 export function formatDate(T) {
@@ -42,7 +44,7 @@ export function isIOS() {
 
 export function getUser(call) {
   let search = urlSearchData();
-    if (!search.ticket) return;
+  if (!search.ticket) return;
   getAPPUser({
     ticket: search.ticket,
   }).then(r => {
@@ -57,3 +59,27 @@ export function getUser(call) {
     });
   });
 }
+
+export function defaultDate(type, dateText) {
+  let D = dateText ? new dayjs(dateText) : new dayjs();
+  let lastWeekD = "";
+  let firstWeekD = "";
+  let lastWeekDFunc = "";
+  let out = "";
+  switch (type) {
+    case "Month":
+      if (D.$M == 0) out = [D.$y - 1, 12].join("-");
+      else out = [D.$y, D.$M].join("-");
+      break;
+    case "Week":
+      lastWeekDFunc = dayjs(D.valueOf() - 86400000 * D.$W);
+      lastWeekD = lastWeekDFunc.format("YYYYMMDD");
+      firstWeekD = dayjs(D.valueOf() - 86400000 * (D.$W + 6)).format(
+        "YYYYMMDD"
+      );
+      out = [firstWeekD, lastWeekD, lastWeekDFunc.format("YYYY*MM*DD")].join("-");
+      break;
+  }
+
+  return out;
+}

+ 50 - 47
src/views/report/Advertisement/index.vue

@@ -3,11 +3,7 @@
     <div class="Advertisement" style="padding: 0">
       <img
         class="item"
-        :src="
-          'https://cxzx.smcic.net/zhoubao/assets/guanggao' +
-          $route.query.date +
-          '.jpg'
-        "
+        :src="'https://cxzx.smcic.net/zhoubao/assets/guanggao' + date + '.jpg'"
         width="100%"
         style="margin-bottom: 1em; display: block"
         alt=""
@@ -183,6 +179,9 @@ import { Col as vanCol, Row as vanRow } from "vant";
 import "vant/lib/col/style/index";
 import "vant/lib/row/style/index";
 
+import { defaultDate } from "@/utils/tool.js";
+import report from "../mixin/index.js";
+
 import {
   advertisementSpendInit,
   advertisementRingRatioInit,
@@ -196,52 +195,56 @@ export default {
     return {
       orgin: {},
       fontSize: 17,
+      date: "",
     };
   },
-  mounted() {
-    if (
-      this.$route.query.auto !==
-      "06fd56cdf5a6cfc3a2139cc8514d05aa0439ee8c1fb4d81145bc9647"
-    )
-      return;
-    this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
-    if (document.body.offsetWidth > 677) this.fontSize = 20;
-    watermark.setWaterMark({
-      w_texts: ["陕西视听大数据"],
-      w_options: {
-        w_opacity: "0.1",
-        w_width: 360,
-        w_height: 280,
-      },
-    });
-    jsonAdvertisement({
-      date: this.$route.query.date,
-      time: Date.now(),
-    }).then(r => {
-      const Res = r || {};
-      const brand_top = Res.brand_top || { list: [] };
-      for (let i = 0; i < brand_top.list.length; i++) {
-        brand_top.list[i].fee = this.formatType(brand_top.list[i].fee, 2, true);
-        brand_top.list[i].huanbi = (brand_top.list[i].huanbi * 100).toFixed(2);
-      }
-      Res.brand_top = brand_top;
-      this.orgin = Res;
-      console.log(this.orgin);
-      this.$nextTick(() => {
-        this.createChart();
-        window.onresize = () => {
-          watermark.setWaterMark({
-            w_texts: ["陕西视听大数据"],
-            w_options: {
-              w_opacity: "0.1",
-            },
-          });
-        };
-      });
-    });
-  },
+  mixins: [report],
   computed: {},
   methods: {
+    init() {
+      this.date = this.$route.query.date || this.lastTimeDate.ad || defaultDate("Month");
+      this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
+      if (document.body.offsetWidth > 677) this.fontSize = 20;
+      watermark.setWaterMark({
+        w_texts: ["陕西视听大数据"],
+        w_options: {
+          w_opacity: "0.1",
+          w_width: 360,
+          w_height: 280,
+        },
+      });
+      jsonAdvertisement({
+        date: this.date,
+        time: Date.now(),
+      }).then(r => {
+        const Res = r || {};
+        const brand_top = Res.brand_top || { list: [] };
+        for (let i = 0; i < brand_top.list.length; i++) {
+          brand_top.list[i].fee = this.formatType(
+            brand_top.list[i].fee,
+            2,
+            true
+          );
+          brand_top.list[i].huanbi = (brand_top.list[i].huanbi * 100).toFixed(
+            2
+          );
+        }
+        Res.brand_top = brand_top;
+        this.orgin = Res;
+        console.log(this.orgin);
+        this.$nextTick(() => {
+          this.createChart();
+          window.onresize = () => {
+            watermark.setWaterMark({
+              w_texts: ["陕西视听大数据"],
+              w_options: {
+                w_opacity: "0.1",
+              },
+            });
+          };
+        });
+      });
+    },
     formatNum(num, w) {
       if (isNaN(num)) return 0;
       return Number(num).toFixed(w || 4) - 0;

+ 56 - 60
src/views/report/Calendar/index.vue

@@ -146,10 +146,9 @@
 // @ is an alias to /src
 import watermark from "watermark-package";
 import DayJs from "dayjs";
-// import {} from "../utils/tool";
 import { jsonCalendarOne } from "../../../api/index";
 
-// import echarts from "../../../utils/echarts";
+import report from "../mixin/index.js";
 
 export default {
   name: "Calendar",
@@ -160,68 +159,65 @@ export default {
     };
   },
   watch: {},
-  mounted() {
-    if (
-      this.$route.query.auto !==
-      "06fd56cdf5a6cfc3a2139cc8514d05aa0439ee8c1fb4d81145bc9647"
-    )
-      return;
-    this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
-    if (document.body.offsetWidth > 677) this.fontSize = 22;
-    watermark.setWaterMark({
-      w_texts: ["陕西新媒体大数据"],
-      w_options: {
-        w_opacity: "0.1",
-      },
-    });
-    jsonCalendarOne({
-      date: this.$route.params.date,
-      time: Date.now(),
-    }).then(res => {
-      let dataOne = res || [];
-      for (let i = 0; i < dataOne.length; i++) {
-        const item1 = dataOne[i].data ? dataOne[i].data || [] : [];
-        for (let o = 0; o < item1.length; o++) {
-          const item2 =
-            dataOne[i].data && dataOne[i].data
-              ? dataOne[i].data[o] || []
-              : undefined;
-          if (item2 === undefined) continue;
-          const dayjs_Start =
-            item2.list[0] && item2.list[0].dt
-              ? new DayJs(item2.list[0].dt)
+  mixins: [report],
+  computed: {},
+  methods: {
+    init() {
+      this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
+      if (document.body.offsetWidth > 677) this.fontSize = 22;
+      watermark.setWaterMark({
+        w_texts: ["陕西新媒体大数据"],
+        w_options: {
+          w_opacity: "0.1",
+        },
+      });
+      let D = this.$route.params.date == 'auto' ? this.lastTimeDate.calendar : this.$route.params.date;
+      jsonCalendarOne({
+        date: D,
+        time: Date.now(),
+      }).then(res => {
+        let dataOne = res || [];
+        for (let i = 0; i < dataOne.length; i++) {
+          const item1 = dataOne[i].data ? dataOne[i].data || [] : [];
+          for (let o = 0; o < item1.length; o++) {
+            const item2 =
+              dataOne[i].data && dataOne[i].data
+                ? dataOne[i].data[o] || []
+                : undefined;
+            if (item2 === undefined) continue;
+            const dayjs_Start =
+              item2.list[0] && item2.list[0].dt
+                ? new DayJs(item2.list[0].dt)
+                : undefined;
+            const item2_Length = item2.list.length ? item2.list.length - 1 : 0;
+            const dayjs_Last = item2.list[item2_Length]
+              ? new DayJs(item2.list[item2_Length].dt)
               : undefined;
-          const item2_Length = item2.list.length ? item2.list.length - 1 : 0;
-          const dayjs_Last = item2.list[item2_Length]
-            ? new DayJs(item2.list[item2_Length].dt)
-            : undefined;
-          let first = dayjs_Start ? dayjs_Start.format("d") : undefined;
-          let last = dayjs_Last ? dayjs_Last.format("d") : undefined;
-          last && last != 0 && (last = 7 - last);
-          first && dataOne[i].data[o].list.unshift(...new Array(first - 1));
-          last && dataOne[i].data[o].list.push(...new Array(last - 0));
-          let li = [];
-          for (let p = 0; p < dataOne[i].data[o].list.length; p++) {
-            const item3 = dataOne[i].data[o].list[p] || undefined;
-            if (p % 7 === 0) li.push([]);
-            let end = li.length ? li.length - 1 : 0;
-            if (!item3) {
-              li[end].push(undefined);
-              continue;
+            let first = dayjs_Start ? dayjs_Start.format("d") : undefined;
+            let last = dayjs_Last ? dayjs_Last.format("d") : undefined;
+            last && last != 0 && (last = 7 - last);
+            first && dataOne[i].data[o].list.unshift(...new Array(first - 1));
+            last && dataOne[i].data[o].list.push(...new Array(last - 0));
+            let li = [];
+            for (let p = 0; p < dataOne[i].data[o].list.length; p++) {
+              const item3 = dataOne[i].data[o].list[p] || undefined;
+              if (p % 7 === 0) li.push([]);
+              let end = li.length ? li.length - 1 : 0;
+              if (!item3) {
+                li[end].push(undefined);
+                continue;
+              }
+              let dt3 = new DayJs(item3.dt);
+              item3.day = dt3.format("D");
+              item3.weeks = dt3.format("d");
+              li[end].push(item3);
             }
-            let dt3 = new DayJs(item3.dt);
-            item3.day = dt3.format("D");
-            item3.weeks = dt3.format("d");
-            li[end].push(item3);
+            dataOne[i].data[o].list = li;
           }
-          dataOne[i].data[o].list = li;
         }
-      }
-      this.dataOne = dataOne;
-    });
-  },
-  computed: {},
-  methods: {
+        this.dataOne = dataOne;
+      });
+    },
     isQDXW(t) {
       return /起点新闻/g.test(t);
     },

+ 58 - 51
src/views/report/Mobile/index.vue

@@ -2,11 +2,7 @@
   <div style="font-size: 0; background-color: #fff">
     <div class="content">
       <img
-        :src="
-          'https://cxzx.smcic.net/zhoubao/assets/moblie' +
-          $route.params.date +
-          '.jpg'
-        "
+        :src="'https://cxzx.smcic.net/zhoubao/assets/moblie' + date + '.jpg'"
         width="100%"
         class="content"
         style="margin-bottom: 1em; display: block"
@@ -149,7 +145,10 @@
                         p-id="2537"
                       ></path>
                     </svg>
-                    <span v-show="sortActive !== '发稿量'" style="display: inline-block; width: 14px; height: 14px;"></span>
+                    <span
+                      v-show="sortActive !== '发稿量'"
+                      style="display: inline-block; width: 14px; height: 14px"
+                    ></span>
                   </van-col>
                   <van-col
                     span="4"
@@ -173,9 +172,12 @@
                         p-id="2537"
                       ></path>
                     </svg>
-                    <span v-show="sortActive !== '传播量'" style="display: inline-block; width: 14px; height: 14px;"></span>
+                    <span
+                      v-show="sortActive !== '传播量'"
+                      style="display: inline-block; width: 14px; height: 14px"
+                    ></span>
                   </van-col>
-                  <van-col span="5" class="td" @click="() => sortFunc('环比')"> 
+                  <van-col span="5" class="td" @click="() => sortFunc('环比')">
                     环比<svg
                       v-show="sortActive === '环比'"
                       t="1667611409259"
@@ -193,8 +195,11 @@
                         p-id="2537"
                       ></path>
                     </svg>
-                    <span v-show="sortActive !== '环比'" style="display: inline-block; width: 14px; height: 14px;"></span>
-                 </van-col>
+                    <span
+                      v-show="sortActive !== '环比'"
+                      style="display: inline-block; width: 14px; height: 14px"
+                    ></span>
+                  </van-col>
                 </van-row>
                 <van-row
                   class="item"
@@ -329,10 +334,10 @@ import "vant/lib/popup/style/index";
 import "vant/lib/icon/style/index";
 import "vant/lib/col/style/index";
 import "vant/lib/row/style/index";
-// import {} from "../utils/tool";
 import { jsonZhouMobile } from "../../../api/index";
 
-// import echarts from "../../../utils/echarts";
+import { defaultDate } from "@/utils/tool.js";
+import report from "../mixin/index.js";
 
 export default {
   name: "Mobile",
@@ -353,37 +358,35 @@ export default {
       width: document.body.offsetWidth || 0,
       desc: "",
       topic_desc: "",
+      date: "",
     };
   },
+  mixins: [report],
   watch: {},
-  mounted() {
-    if (
-      this.$route.query.auto !==
-      "06fd56cdf5a6cfc3a2139cc8514d05aa0439ee8c1fb4d81145bc9647"
-    )
-      return;
-    this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
-    if (document.body.offsetWidth > 677) this.fontSize = 22;
-    document.documentElement.style.fontSize = this.fontSize + "px";
-    watermark.setWaterMark({
-      w_texts: ["陕西新媒体大数据"],
-      w_options: {
-        w_opacity: "0.1",
-      },
-    });
-    jsonZhouMobile({
-      date: this.$route.params.date,
-      time: Date.now(),
-    }).then(res => {
-      this.article = res.article || [];
-      this.dep = res.dep || [];
-      this.topic = res.topic || [];
-      this.desc = res.desc || "";
-      this.topic_desc = res.topic_desc || "";
-    });
-  },
   computed: {},
   methods: {
+    init() {
+      this.date = this.$route.params.date !== 'auto' ? this.$route.params.date : this.lastTimeDate.new_media ? this.lastTimeDate.new_media : defaultDate("Week");
+      this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
+      if (document.body.offsetWidth > 677) this.fontSize = 22;
+      document.documentElement.style.fontSize = this.fontSize + "px";
+      watermark.setWaterMark({
+        w_texts: ["陕西新媒体大数据"],
+        w_options: {
+          w_opacity: "0.1",
+        },
+      });
+      jsonZhouMobile({
+        date: this.date,
+        time: Date.now(),
+      }).then(res => {
+        this.article = res.article || [];
+        this.dep = res.dep || [];
+        this.topic = res.topic || [];
+        this.desc = res.desc || "";
+        this.topic_desc = res.topic_desc || "";
+      });
+    },
     valueDate(v) {
       let out = "";
       for (let i = 0; i < v.length; i++) {
@@ -427,29 +430,33 @@ export default {
       ratios.publish_count = publish_count;
       let read_count = this.timeFormat(ratios.read_count);
       ratios.read_count = read_count;
-      let key = "read_count"
+      let key = "read_count";
       switch (this.sortActive) {
-        case '发稿量':
-            key = 'publish_count'
-            break;
+        case "发稿量":
+          key = "publish_count";
+          break;
       }
-      ratios.detail = ratios.detail.sort((newitem,olditem)=>olditem[key] - newitem[key])
+      ratios.detail = ratios.detail.sort(
+        (newitem, olditem) => olditem[key] - newitem[key]
+      );
       this.ratios = ratios;
       this.$nextTick(() => {});
     },
     sortFunc(text) {
       if (text === this.sortActive) return;
       this.sortActive = text;
-      let key = "read_count"
+      let key = "read_count";
       switch (text) {
-        case '发稿量':
-            key = 'publish_count'
-            break;
-        case '环比':
-            key = 'read_huanbi'
-            break;
+        case "发稿量":
+          key = "publish_count";
+          break;
+        case "环比":
+          key = "read_huanbi";
+          break;
       }
-      this.ratios.detail = this.ratios.detail.sort((newitem,olditem)=>olditem[key] - newitem[key])
+      this.ratios.detail = this.ratios.detail.sort(
+        (newitem, olditem) => olditem[key] - newitem[key]
+      );
     },
   },
   beforeUnmount() {},

+ 76 - 84
src/views/report/Traditional/index.vue

@@ -1,9 +1,7 @@
 <template>
   <div style="font-size: 0; background-color: #fff">
     <img
-      :src="
-        'https://cxzx.smcic.net/zhoubao/assets/tv' + $route.query.date + '.jpg'
-      "
+      :src="'https://cxzx.smcic.net/zhoubao/assets/tv' + date + '.jpg'"
       width="100%"
       class="content"
       style="margin-bottom: 1em; display: block"
@@ -154,7 +152,7 @@
                 <van-col span="7" class="td">
                   {{ ratios.timecount }}小时
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -177,13 +175,11 @@
                 <van-col span="7" class="td">
                   {{ ratios.hitcount }}
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
-                      ratios.hitcount_ring > 0
-                        ? 'color: red'
-                        : 'color: #04c15f'
+                      ratios.hitcount_ring > 0 ? 'color: red' : 'color: #04c15f'
                     "
                   >
                     {{ ratios.hitcount_ring }}%
@@ -201,7 +197,7 @@
                 <van-col span="7" class="td">
                   {{ ratios.usrcount }}
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -224,7 +220,7 @@
                   {{ formatType1(ratios.touchfreq, 2) }}次
                 </van-col>
 
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -251,7 +247,7 @@
                 <van-col span="7" class="td"
                   >{{ formatNum(ratios.reachrate, 2) }}%
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -274,7 +270,7 @@
                 <van-col span="7" class="td"
                   >{{ timeFormat(ratios.user_duration, 0) }}分钟
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -297,7 +293,7 @@
                 <van-col span="7" class="td">
                   {{ formatNum(ratios.watchrate, 2) }}%
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -320,13 +316,11 @@
                 <van-col span="7" class="td"
                   >{{ formatNum(ratios.occrate, 2) }}%
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
-                      ratios.occrate_ring > 0
-                        ? 'color: red'
-                        : 'color: #04c15f'
+                      ratios.occrate_ring > 0 ? 'color: red' : 'color: #04c15f'
                     "
                   >
                     {{ ratios.occrate_ring }}%
@@ -343,13 +337,11 @@
                 <van-col span="7" class="td"
                   >{{ formatNum(ratios.loyalty, 2) }}%
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
-                      ratios.loyalty_ring > 0
-                        ? 'color: red'
-                        : 'color: #04c15f'
+                      ratios.loyalty_ring > 0 ? 'color: red' : 'color: #04c15f'
                     "
                   >
                     {{ ratios.loyalty_ring }}%
@@ -378,11 +370,13 @@
           </div>
         </van-popup>
       </div>
-      
+
       <p
         class="content"
         :style="
-          'font-weight: 700;word-break: normal;text-align: justify;  padding: 0.5em 3px;font-size: ' + fontSize + 'px;'
+          'font-weight: 700;word-break: normal;text-align: justify;  padding: 0.5em 3px;font-size: ' +
+          fontSize +
+          'px;'
         "
         v-html="title.dataSource"
       ></p>
@@ -418,9 +412,9 @@ import "vant/lib/popup/style/index";
 import "vant/lib/icon/style/index";
 import "vant/lib/col/style/index";
 import "vant/lib/row/style/index";
-// import {} from "../utils/tool";
-import Dayjs from "dayjs";
 import { jsonZhou } from "../../../api/index";
+import { defaultDate } from "@/utils/tool.js";
+import report from "../mixin/index.js";
 
 import echarts from "../../../utils/echarts";
 
@@ -440,71 +434,69 @@ export default {
       dayEcharts: undefined,
       title: {},
       width: document.body.offsetWidth || 0,
+      date: "",
     };
   },
   watch: {},
-  mounted() {
-    if (
-      this.$route.query.auto !==
-      "06fd56cdf5a6cfc3a2139cc8514d05aa0439ee8c1fb4d81145bc9647"
-    )
-      return;
-    this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
-    if (document.body.offsetWidth > 677) this.fontSize = 22;
-    watermark.setWaterMark({
-      w_texts: ["陕西视听大数据"],
-      w_options: {
-        w_opacity: "0.1",
-      },
-    });
-    const time = new Date(this.$route.query.date);
-    let D = new Date(time);
-    const lasetDay = new Dayjs(D.getTime() - D.getDay() * 86400000);
-    const firstDay = new Dayjs(lasetDay - 6 * 86400000);
-    jsonZhou({
-      start: firstDay.format("YYYYMMDD"),
-      end: lasetDay.format("YYYYMMDD"),
-      time: Date.now(),
-    })
-      .then(res => {
-        const title = {
-          company: res.company || "",
-          name: res.name || "",
-          title: res.title || "",
-          desc: res.desc || "",
-          dataSource: res.dataSource || ""
-        };
-        this.title = title;
-        this.platfromData = res.list || [];
-        this.$emit("start", {
-          status: 200,
-        });
+  mixins: [report],
+  computed: {},
+  methods: {
+    init() {
+      this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
+      if (document.body.offsetWidth > 677) this.fontSize = 22;
+      watermark.setWaterMark({
+        w_texts: ["陕西视听大数据"],
+        w_options: {
+          w_opacity: "0.1",
+        },
+      });
+      const date = defaultDate(
+        "Week",
+        this.$route.query.date || this.lastTimeDate.tv
+      ).split("-");
+      this.date = (date[2] || "").replace(/\*/g, "-");
+      jsonZhou({
+        start: date[0],
+        end: date[1],
+        time: Date.now(),
       })
-      .catch(err => {
-        this.$emit("start", {
-          status: err,
+        .then(res => {
+          const title = {
+            company: res.company || "",
+            name: res.name || "",
+            title: res.title || "",
+            desc: res.desc || "",
+            dataSource: res.dataSource || "",
+          };
+          this.title = title;
+          this.platfromData = res.list || [];
+          this.$emit("start", {
+            status: 200,
+          });
+        })
+        .catch(err => {
+          this.$emit("start", {
+            status: err,
+          });
         });
-      });
 
-    window.onresize = () => {
-      const doc = document.body;
-      const width = doc.offsetWidth - 32;
-      let height = (width / 4) * 3;
-      this.width = document.body.offsetWidth || 0;
-      this.dayEcharts &&
-        this.dayEcharts.resize({
-          width,
-          height: width,
-        });
-      this.echarts &&
-        this.echarts.resize({
-          width,
-          height,
-        });
-    };
-  },
-  computed: {},
-  methods: {
+      window.onresize = () => {
+        const doc = document.body;
+        const width = doc.offsetWidth - 32;
+        let height = (width / 4) * 3;
+        this.width = document.body.offsetWidth || 0;
+        this.dayEcharts &&
+          this.dayEcharts.resize({
+            width,
+            height: width,
+          });
+        this.echarts &&
+          this.echarts.resize({
+            width,
+            height,
+          });
+      };
+    },
     formatType1(num, W) {
       let N = this.formatNum(num, W || 0);
       if (N >= 100000000) {

+ 97 - 110
src/views/report/TraditionalAndXian/index.vue

@@ -1,9 +1,8 @@
 <template>
   <div style="font-size: 0; background-color: #fff">
     <img
-      :src="
-        'https://cxzx.smcic.net/zhoubao/assets/tv' + $route.query.date + '.jpg'
-      "
+      v-if="date"
+      :src="'https://cxzx.smcic.net/zhoubao/assets/tv' + date + '.jpg'"
       width="100%"
       class="content"
       style="margin-bottom: 1em; display: block"
@@ -130,11 +129,8 @@
     </div>
 
     <img
-      :src="
-        'https://cxzx.smcic.net/zhoubao/assets/xatv' +
-        $route.query.date +
-        '.jpg'
-      "
+      v-if="date"
+      :src="'https://cxzx.smcic.net/zhoubao/assets/xatv' + date + '.jpg'"
       width="100%"
       class="content"
       style="margin-bottom: 1em; display: block"
@@ -263,7 +259,7 @@
                 <van-col span="7" class="td">
                   {{ ratios.timecount }}小时
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -286,13 +282,11 @@
                 <van-col span="7" class="td">
                   {{ ratios.hitcount }}
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
-                      ratios.hitcount_ring > 0
-                        ? 'color: red'
-                        : 'color: #04c15f'
+                      ratios.hitcount_ring > 0 ? 'color: red' : 'color: #04c15f'
                     "
                   >
                     {{ ratios.hitcount_ring }}%
@@ -310,7 +304,7 @@
                 <van-col span="7" class="td">
                   {{ ratios.usrcount }}
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -333,7 +327,7 @@
                   {{ formatType1(ratios.touchfreq, 2) }}次
                 </van-col>
 
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -360,7 +354,7 @@
                 <van-col span="7" class="td"
                   >{{ formatNum(ratios.reachrate, 2) }}%
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -383,7 +377,7 @@
                 <van-col span="7" class="td"
                   >{{ timeFormat(ratios.user_duration, 0) }}分钟
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -406,7 +400,7 @@
                 <van-col span="7" class="td">
                   {{ formatNum(ratios.watchrate, 2) }}%
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -429,13 +423,11 @@
                 <van-col span="7" class="td"
                   >{{ formatNum(ratios.occrate, 2) }}%
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
-                      ratios.occrate_ring > 0
-                        ? 'color: red'
-                        : 'color: #04c15f'
+                      ratios.occrate_ring > 0 ? 'color: red' : 'color: #04c15f'
                     "
                   >
                     {{ ratios.occrate_ring }}%
@@ -452,13 +444,11 @@
                 <van-col span="7" class="td"
                   >{{ formatNum(ratios.loyalty, 2) }}%
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
-                      ratios.loyalty_ring > 0
-                        ? 'color: red'
-                        : 'color: #04c15f'
+                      ratios.loyalty_ring > 0 ? 'color: red' : 'color: #04c15f'
                     "
                   >
                     {{ ratios.loyalty_ring }}%
@@ -529,12 +519,12 @@ import "vant/lib/popup/style/index";
 import "vant/lib/icon/style/index";
 import "vant/lib/col/style/index";
 import "vant/lib/row/style/index";
-// import {} from "../utils/tool";
-import Dayjs from "dayjs";
 import { jsonZhouXian, jsonZhou } from "../../../api/index";
-
+import { defaultDate } from "@/utils/tool.js";
 import echarts from "../../../utils/echarts";
 
+import report from "../mixin/index.js";
+
 export default {
   name: "TraditionalAndXian",
   data() {
@@ -556,93 +546,90 @@ export default {
     };
   },
   watch: {},
-  mounted() {
-    if (
-      this.$route.query.auto !==
-      "06fd56cdf5a6cfc3a2139cc8514d05aa0439ee8c1fb4d81145bc9647"
-    )
-      return;
-    this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
-    if (document.body.offsetWidth > 677) this.fontSize = 22;
-    watermark.setWaterMark({
-      w_texts: ["陕西视听大数据"],
-      w_options: {
-        w_opacity: "0.1",
-      },
-    });
-    const time = new Date(this.$route.query.date);
-    let D = new Date(time);
-    const lasetDay = new Dayjs(D.getTime() - D.getDay() * 86400000);
-    const firstDay = new Dayjs(lasetDay - 6 * 86400000);
-    jsonZhouXian({
-      start: firstDay.format("YYYYMMDD"),
-      end: lasetDay.format("YYYYMMDD"),
-      time: Date.now(),
-    })
-      .then(res => {
-        const title = {
-          company: res.company || "",
-          name: res.name || "",
-          title: res.title || "",
-          desc: res.desc || "",
-          dataSource: res.dataSource || "",
-        };
-        this.title = title;
-        this.platfromData = res.list || [];
-        this.$emit("start", {
-          status: 200,
-        });
+  mixins: [report],
+  computed: {},
+  methods: {
+    init() {
+      this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
+      if (document.body.offsetWidth > 677) this.fontSize = 22;
+      watermark.setWaterMark({
+        w_texts: ["陕西视听大数据"],
+        w_options: {
+          w_opacity: "0.1",
+        },
+      });
+      const date = defaultDate(
+        "Week",
+        this.$route.query.date || this.lastTimeDate.tv
+      ).split("-");
+      this.date = (date[2] || "").replace(/\*/g, "-");
+      jsonZhouXian({
+        start: date[0],
+        end: date[1],
+        time: Date.now(),
       })
-      .catch(err => {
-        this.$emit("start", {
-          status: err,
+        .then(res => {
+          const title = {
+            company: res.company || "",
+            name: res.name || "",
+            title: res.title || "",
+            desc: res.desc || "",
+            dataSource: res.dataSource || "",
+          };
+          this.title = title;
+          this.platfromData = res.list || [];
+          this.$emit("start", {
+            status: 200,
+          });
+        })
+        .catch(err => {
+          this.$emit("start", {
+            status: err,
+          });
         });
-      });
 
-    jsonZhou({
-      start: firstDay.format("YYYYMMDD"),
-      end: lasetDay.format("YYYYMMDD"),
-      time: Date.now(),
-    })
-      .then(res => {
-        const title = {
-          company: res.company || "",
-          name: res.name || "",
-          title: res.title || "",
-          desc: res.desc || "",
-          dataSource: res.dataSource || "",
-        };
-        this.title1 = title;
-        this.platfromData1 = res.list || [];
-        this.$emit("start", {
-          status: 200,
-        });
+      jsonZhou({
+        start: date[0],
+        end: date[1],
+        time: Date.now(),
       })
-      .catch(err => {
-        this.$emit("start", {
-          status: err,
+        .then(res => {
+          const title = {
+            company: res.company || "",
+            name: res.name || "",
+            title: res.title || "",
+            desc: res.desc || "",
+            dataSource: res.dataSource || "",
+          };
+          this.title1 = title;
+          this.platfromData1 = res.list || [];
+          this.$emit("start", {
+            status: 200,
+          });
+        })
+        .catch(err => {
+          this.$emit("start", {
+            status: err,
+          });
         });
-      });
 
-    window.onresize = () => {
-      const doc = document.body;
-      const width = doc.offsetWidth - 32;
-      let height = (width / 4) * 3;
-      this.width = document.body.offsetWidth || 0;
-      this.dayEcharts &&
-        this.dayEcharts.resize({
-          width,
-          height: width,
-        });
-      this.echarts &&
-        this.echarts.resize({
-          width,
-          height,
-        });
-    };
-  },
-  computed: {},
-  methods: {
+      window.onresize = () => {
+        const doc = document.body;
+        const width = doc.offsetWidth - 32;
+        let height = (width / 4) * 3;
+        this.width = document.body.offsetWidth || 0;
+        this.dayEcharts &&
+          this.dayEcharts.resize({
+            width,
+            height: width,
+          });
+        this.echarts &&
+          this.echarts.resize({
+            width,
+            height,
+          });
+      };
+    },
     formatType1(num, W) {
       let N = this.formatNum(num, W || 0);
       if (N >= 100000000) {

+ 75 - 85
src/views/report/TraditionalXian/index.vue

@@ -1,11 +1,7 @@
 <template>
   <div style="font-size: 0; background-color: #fff">
     <img
-      :src="
-        'https://cxzx.smcic.net/zhoubao/assets/xatv' +
-        $route.query.date +
-        '.jpg'
-      "
+      :src="'https://cxzx.smcic.net/zhoubao/assets/xatv' + date + '.jpg'"
       width="100%"
       class="content"
       style="margin-bottom: 1em; display: block"
@@ -155,7 +151,7 @@
                 <van-col span="7" class="td">
                   {{ ratios.timecount }}小时
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -178,13 +174,11 @@
                 <van-col span="7" class="td">
                   {{ ratios.hitcount }}
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
-                      ratios.hitcount_ring > 0
-                        ? 'color: red'
-                        : 'color: #04c15f'
+                      ratios.hitcount_ring > 0 ? 'color: red' : 'color: #04c15f'
                     "
                   >
                     {{ ratios.hitcount_ring }}%
@@ -202,7 +196,7 @@
                 <van-col span="7" class="td">
                   {{ ratios.usrcount }}
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -225,7 +219,7 @@
                   {{ formatType1(ratios.touchfreq, 2) }}次
                 </van-col>
 
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -252,7 +246,7 @@
                 <van-col span="7" class="td"
                   >{{ formatNum(ratios.reachrate, 2) }}%
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -275,7 +269,7 @@
                 <van-col span="7" class="td"
                   >{{ timeFormat(ratios.user_duration, 0) }}分钟
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -298,7 +292,7 @@
                 <van-col span="7" class="td">
                   {{ formatNum(ratios.watchrate, 2) }}%
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
@@ -321,13 +315,11 @@
                 <van-col span="7" class="td"
                   >{{ formatNum(ratios.occrate, 2) }}%
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
-                      ratios.occrate_ring > 0
-                        ? 'color: red'
-                        : 'color: #04c15f'
+                      ratios.occrate_ring > 0 ? 'color: red' : 'color: #04c15f'
                     "
                   >
                     {{ ratios.occrate_ring }}%
@@ -344,13 +336,11 @@
                 <van-col span="7" class="td"
                   >{{ formatNum(ratios.loyalty, 2) }}%
                 </van-col>
-                <van-col span="10" class="td" style="text-align: left;">
+                <van-col span="10" class="td" style="text-align: left">
                   环比:
                   <span
                     :style="
-                      ratios.loyalty_ring > 0
-                        ? 'color: red'
-                        : 'color: #04c15f'
+                      ratios.loyalty_ring > 0 ? 'color: red' : 'color: #04c15f'
                     "
                   >
                     {{ ratios.loyalty_ring }}%
@@ -382,7 +372,9 @@
       <p
         class="content"
         :style="
-          'font-weight: 700;word-break: normal;text-align: justify;  padding: 0.5em 3px;font-size: ' + fontSize + 'px;'
+          'font-weight: 700;word-break: normal;text-align: justify;  padding: 0.5em 3px;font-size: ' +
+          fontSize +
+          'px;'
         "
         v-html="title.dataSource"
       ></p>
@@ -418,11 +410,11 @@ import "vant/lib/popup/style/index";
 import "vant/lib/icon/style/index";
 import "vant/lib/col/style/index";
 import "vant/lib/row/style/index";
-// import {} from "../utils/tool";
-import Dayjs from "dayjs";
 import { jsonZhouXian } from "../../../api/index";
+import { defaultDate } from "@/utils/tool.js";
 
 import echarts from "../../../utils/echarts";
+import report from "../mixin/index.js";
 
 export default {
   name: "TraditionalXian",
@@ -443,68 +435,66 @@ export default {
     };
   },
   watch: {},
-  mounted() {
-    if (
-      this.$route.query.auto !==
-      "06fd56cdf5a6cfc3a2139cc8514d05aa0439ee8c1fb4d81145bc9647"
-    )
-      return;
-    this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
-    if (document.body.offsetWidth > 677) this.fontSize = 22;
-    watermark.setWaterMark({
-      w_texts: ["陕西视听大数据"],
-      w_options: {
-        w_opacity: "0.1",
-      },
-    });
-    const time = new Date(this.$route.query.date);
-    let D = new Date(time);
-    const lasetDay = new Dayjs(D.getTime() - D.getDay() * 86400000);
-    const firstDay = new Dayjs(lasetDay - 6 * 86400000);
-    jsonZhouXian({
-      start: firstDay.format("YYYYMMDD"),
-      end: lasetDay.format("YYYYMMDD"),
-      time: Date.now(),
-    })
-      .then(res => {
-        const title = {
-          company: res.company || "",
-          name: res.name || "",
-          title: res.title || "",
-          desc: res.desc || "",
-          dataSource: res.dataSource || "",
-        };
-        this.title = title;
-        this.platfromData = res.list || [];
-        this.$emit("start", {
-          status: 200,
-        });
+  mixins: [report],
+  mounted() {},
+  computed: {},
+  methods: {
+    init() {
+      this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
+      if (document.body.offsetWidth > 677) this.fontSize = 22;
+      watermark.setWaterMark({
+        w_texts: ["陕西视听大数据"],
+        w_options: {
+          w_opacity: "0.1",
+        },
+      });
+      const date = defaultDate(
+        "Week",
+        this.$route.query.date || this.lastTimeDate.tv
+      ).split("-");
+      this.date = (date[2] || "").replace(/\*/g, "-");
+      jsonZhouXian({
+        start: date[0],
+        end: date[1],
+        time: Date.now(),
       })
-      .catch(err => {
-        this.$emit("start", {
-          status: err,
+        .then(res => {
+          const title = {
+            company: res.company || "",
+            name: res.name || "",
+            title: res.title || "",
+            desc: res.desc || "",
+            dataSource: res.dataSource || "",
+          };
+          this.title = title;
+          this.platfromData = res.list || [];
+          this.$emit("start", {
+            status: 200,
+          });
+        })
+        .catch(err => {
+          this.$emit("start", {
+            status: err,
+          });
         });
-      });
 
-    window.onresize = () => {
-      const doc = document.body;
-      const width = doc.offsetWidth - 32;
-      let height = (width / 4) * 3;
-      this.width = document.body.offsetWidth || 0;
-      this.dayEcharts &&
-        this.dayEcharts.resize({
-          width,
-          height: width,
-        });
-      this.echarts &&
-        this.echarts.resize({
-          width,
-          height,
-        });
-    };
-  },
-  computed: {},
-  methods: {
+      window.onresize = () => {
+        const doc = document.body;
+        const width = doc.offsetWidth - 32;
+        let height = (width / 4) * 3;
+        this.width = document.body.offsetWidth || 0;
+        this.dayEcharts &&
+          this.dayEcharts.resize({
+            width,
+            height: width,
+          });
+        this.echarts &&
+          this.echarts.resize({
+            width,
+            height,
+          });
+      };
+    },
     formatType1(num, W) {
       let N = this.formatNum(num, W || 0);
       if (N >= 100000000) {

+ 22 - 0
src/views/report/mixin/index.js

@@ -0,0 +1,22 @@
+import { lastTime } from "@/api/index";
+export default {
+  data() {
+    return {
+      lastTimeDate: {},
+      date: "",
+    };
+  },
+  mounted() {
+    if (
+      this.$route.query.auto !==
+      "06fd56cdf5a6cfc3a2139cc8514d05aa0439ee8c1fb4d81145bc9647"
+    )
+      return;
+    lastTime({ time: Date.now() }).then(res => {
+      this.lastTimeDate = res || {};
+      this.init && this.init();
+    }).catch(()=>{
+      this.init && this.init();
+    });
+  },
+};