liyongli hace 2 años
padre
commit
f78ecb2791
Se han modificado 1 ficheros con 22 adiciones y 12 borrados
  1. 22 12
      src/views/History/index.vue

+ 22 - 12
src/views/History/index.vue

@@ -94,7 +94,12 @@
           v-for="(item, i) in oriData.total"
           :key="i + item.key"
           class="head-item"
-          @click="() => type !== item.key && changeData(item.key, item.name)"
+          @click="
+            () =>
+              item.key !== 'downloads' &&
+              type !== item.key &&
+              changeData(item.key, item.name)
+          "
           :style="{
             borderTopColor: type === item.key ? '#396fff' : '#fff',
           }"
@@ -240,10 +245,9 @@ export default {
     this.cycle = this.verifyList(appli, source, keys, false);
     this.channel = this.verifyList(appCLi, appC, keys, true);
     this.version = this.verifyList(appVLi, appV, keys, true);
-    console.log(appCLi, appC, keys)
     this.form = {
-    //   app: (this.cycle[0] || { value: "" }).value,
-        app: '起点新闻',
+      //   app: (this.cycle[0] || { value: "" }).value,
+      app: "起点新闻",
       version: [(this.version[0] || { value: "" }).value],
       channel: [(this.channel[0] || { value: "" }).value],
       date: [new Date(Date.now() - 604800000), new Date(Date.now() - 86400000)],
@@ -276,7 +280,6 @@ export default {
       let e = this.page * 10;
       let li = JSON.parse(JSON.stringify(this.oriData.list || []));
       let out = [];
-      li = li.reverse();
       for (let i = s; i < e; i++) {
         li[i] && out.push(li[i]);
       }
@@ -298,13 +301,19 @@ export default {
             keys = Object.keys(total),
             color = ["rgb(244, 127, 146)", "rgb(17, 160, 248)"],
             p = [];
+          let tab = undefined,
+            tabName = undefined;
           for (let i = 0; i < keys.length; i++) {
             const v = keys[i];
-            if (typeof total[v].value !== "number") continue;
+            if (!total[v].value && total[v].value !== 0) continue;
             let isNum = /duration/g.test(v);
-            let value = isNum
-              ? this.timeFormat(total[v].value)
-              : total[v].value;
+            let value = "";
+            if (isNum && typeof total[v].value === 'number') value = this.timeFormat(total[v].value);
+            else value = total[v].value;
+            if (!tab && v !== "downloads") {
+              tab = v;
+              tabName = total[v].name;
+            }
             p.push({
               name: total[v].name,
               value,
@@ -317,7 +326,7 @@ export default {
             list: oriData.list || [],
             total: p,
           };
-          this.changeData(p[0].key, p[0].name);
+          this.changeData(tab, tabName);
           chart.hideLoading();
           this.page = 1;
           this.pushShowList();
@@ -608,14 +617,15 @@ export default {
       getHistory(p).then(r => {
         // 生成数据
         let strcsv =
-          "data:text/csv;charset=utf-8,日期,活跃用户,新增用户,累计用户,人均使用时长\r\n";
+          "data:text/csv;charset=utf-8,日期,活跃用户,新增用户,累计用户,人均使用时长,次均使用时长\r\n";
         (r.list || []).map(v => {
           strcsv += [
             v.dt,
             v.activeUser,
             v.newUser,
             v.totalUser,
-            v.duration,
+            this.timeFormat(v.durationUser),
+            this.timeFormat(v.durationTimes),
             "\r\n",
           ].join(",");
         });