瀏覽代碼

二级话题

liyongli 4 年之前
父節點
當前提交
3314f13ef3
共有 3 個文件被更改,包括 82 次插入44 次删除
  1. 2 0
      package.json
  2. 42 39
      src/view/index/index.vue
  3. 38 5
      yarn.lock

+ 2 - 0
package.json

@@ -11,9 +11,11 @@
     "@antv/data-set": "^0.11.7",
     "@antv/f2": "^3.8.9",
     "axios": "^0.21.0",
+    "echarts": "^5.1.2",
     "vant": "^2.11.2",
     "vue": "^2.6.11",
     "vue-axios": "^3.2.0",
+    "vue-echarts": "^6.0.0-rc.6",
     "vue-router": "^3.4.9"
   },
   "devDependencies": {

+ 42 - 39
src/view/index/index.vue

@@ -160,7 +160,7 @@
           opacity: item.style.opacity,
           transform: item.style.transform,
           zIndex: item.style.zIndex,
-          fontSize: item.style.fontSize + 'px'
+          fontSize: item.style.fontSize + 'px',
         }"
         >{{ item.name }}</span
       >
@@ -280,7 +280,8 @@
 }
 
 .wordCloud__tagBall {
-  margin: 50px auto;
+  margin-top: 50px;
+  margin-bottom: 50px;
   position: relative;
 }
 
@@ -303,7 +304,12 @@
 </style>
 
 <script>
-import { getAllPlatform, getPlatform, getList } from "@/api/getList.js";
+import {
+  getAllPlatform,
+  getPlatform,
+  getList,
+  getBase,
+} from "@/api/getList.js";
 import filters from "@/utils/filters/index";
 import live from "@/view/index/components/live/index.vue";
 import {
@@ -359,7 +365,6 @@ export default {
       minFontSize: 12,
       maxFontSize: 18,
       list: [
-        
         {
           name: "云图",
           value: 1000,
@@ -420,7 +425,17 @@ export default {
     };
   },
   created() {
-    this.initData();
+    this.baseData = JSON.parse(this.$route.query.data || "{}");
+    let title = this.$route.query.title.split(" / ") || [];
+    this.baseData.topic_name && this.initData();
+    !this.baseData.topic_name &&
+      getBase({
+        season: this.$route.query.season,
+        topic_name: title[title.length - 1],
+      }).then(res => {
+        this.baseData = res || {};
+        this.initData();
+      });
   },
   methods: {
     initData() {
@@ -429,7 +444,6 @@ export default {
         width: clientWidth,
         height: (clientWidth / 16) * 9,
       };
-      this.baseData = JSON.parse(this.$route.query.data);
       getAllPlatform({
         season: this.$route.query.season,
         topic_name: this.baseData.topic_name,
@@ -821,7 +835,7 @@ export default {
       call && call();
     },
     cloud() {
-      const RADIUSX = (this.client.width - 50) / 2;
+      const RADIUSX = (this.client.width - 150) / 2;
       const RADIUSY = (this.client.height - 50) / 2;
       let contentEle = [];
       for (let i = 0; i < this.list.length; i += 1) {
@@ -848,58 +862,47 @@ export default {
       this.animate();
     },
     animate() {
-      this.rotateX();
-      this.rotateY();
-      this.move();
+      let newContentEle = this.rotateXY(this.contentEle);
+      newContentEle = this.move(newContentEle);
+      this.contentEle = newContentEle;
       window.requestAnimationFrame(this.animate);
     },
-    rotateX() {
+    rotateXY(contentEle) {
       const angleX = ["-1", "1"].includes(this.direction)
         ? Math.PI / Infinity
         : Math.PI / ((Number(this.direction) / 2) * Number(this.speed));
-      const cos = Math.cos(angleX);
-      const sin = Math.sin(angleX);
-      this.contentEle = this.contentEle.map(t => {
-        const y1 = t.y * cos - t.z * sin;
-        const z1 = t.z * cos + t.y * sin;
-        return {
-          ...t,
-          y: y1,
-          z: z1,
-        };
-      });
-    },
-    rotateY() {
       const angleY = ["-2", "2"].includes(this.direction)
         ? Math.PI / Infinity
         : Math.PI / (Number(this.direction) * Number(this.speed));
-      const cos = Math.cos(angleY);
-      const sin = Math.sin(angleY);
-      this.contentEle = this.contentEle.map(t => {
-        const x1 = t.x * cos - t.z * sin;
-        const z1 = t.z * cos + t.x * sin;
+      const cosx = Math.cos(angleX);
+      const sinx = Math.sin(angleX);
+      const cosy = Math.cos(angleY);
+      const siny = Math.sin(angleY);
+      return contentEle.map(t => {
+        const y1 = t.y * cosx - t.z * sinx;
+        let z1 = t.z * cosx + t.y * sinx;
+        const x1 = t.x * cosy - t.z * siny;
+        z1 = z1 * cosy + t.x * siny;
         return {
           ...t,
-          x: x1,
+          y: y1,
           z: z1,
+          x: x1,
         };
       });
     },
-    move() {
-      const CX = this.client.width / 2;
-      const CY = this.client.height / 2;
-      this.contentEle = this.contentEle.map(singleEle => {
+    move(contentEle) {
+      return contentEle.map(singleEle => {
         const { x, y, z } = singleEle;
         const fallLength = 500;
         const RADIUS = (this.client.width - 50) / 2;
         const scale = fallLength / (fallLength - z);
-        const alpha = (z + RADIUS) / (2 * RADIUS);
-        const left = `${x + CX - 15}px`;
-        const top = `${y + CY - 15}px`;
-        const transform = `translate(${left}, ${top}) scale(${scale})`;
+        const transform = `translate(${x + this.client.width / 2 - 15}px, ${y +
+          this.client.height / 2 -
+          15}px) scale(${scale})`;
         const style = {
           ...singleEle.style,
-          opacity: alpha + 0.5,
+          opacity: (z + RADIUS) / (2 * RADIUS),
           zIndex: parseInt(scale * 100, 10),
           transform,
         };

+ 38 - 5
yarn.lock

@@ -3526,6 +3526,14 @@ ecc-jsbn@~0.1.1:
     jsbn "~0.1.0"
     safer-buffer "^2.1.0"
 
+echarts@^5.1.2:
+  version "5.1.2"
+  resolved "https://registry.nlark.com/echarts/download/echarts-5.1.2.tgz#aa1ab0cef5b74fa2f7c620261a5f286893d30fd1"
+  integrity sha1-qhqwzvW3T6L3xiAmGl8oaJPTD9E=
+  dependencies:
+    tslib "2.0.3"
+    zrender "5.1.1"
+
 ee-first@1.1.1:
   version "1.1.1"
   resolved "https://registry.npm.taobao.org/ee-first/download/ee-first-1.1.1.tgz"
@@ -7478,6 +7486,11 @@ requires-port@^1.0.0:
   resolved "https://registry.npm.taobao.org/requires-port/download/requires-port-1.0.0.tgz"
   integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=
 
+resize-detector@^0.3.0:
+  version "0.3.0"
+  resolved "https://registry.npm.taobao.org/resize-detector/download/resize-detector-0.3.0.tgz#fe495112e184695500a8f51e0389f15774cb1cfc"
+  integrity sha1-/klREuGEaVUAqPUeA4nxV3TLHPw=
+
 resolve-cwd@^2.0.0:
   version "2.0.0"
   resolved "https://registry.npm.taobao.org/resolve-cwd/download/resolve-cwd-2.0.0.tgz"
@@ -8539,6 +8552,11 @@ ts-pnp@^1.1.6:
   resolved "https://registry.npm.taobao.org/ts-pnp/download/ts-pnp-1.2.0.tgz"
   integrity sha1-pQCtCEsHmPHDBxrzkeZZEshrypI=
 
+tslib@2.0.3:
+  version "2.0.3"
+  resolved "https://registry.nlark.com/tslib/download/tslib-2.0.3.tgz#8e0741ac45fc0c226e58a17bfc3e64b9bc6ca61c"
+  integrity sha1-jgdBrEX8DCJuWKF7/D5kubxsphw=
+
 tslib@^1.9.0:
   version "1.14.1"
   resolved "https://registry.npm.taobao.org/tslib/download/tslib-1.14.1.tgz?cache=0&sync_timestamp=1602286724979&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftslib%2Fdownload%2Ftslib-1.14.1.tgz"
@@ -8851,6 +8869,19 @@ vue-axios@^3.2.0:
   resolved "https://registry.npm.taobao.org/vue-axios/download/vue-axios-3.2.4.tgz?cache=0&sync_timestamp=1612149079370&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-axios%2Fdownload%2Fvue-axios-3.2.4.tgz"
   integrity sha1-IzQVjbisKg9gOqQxwmJvv212ZyQ=
 
+vue-demi@^0.9.1:
+  version "0.9.1"
+  resolved "https://registry.nlark.com/vue-demi/download/vue-demi-0.9.1.tgz?cache=0&sync_timestamp=1622101043497&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fvue-demi%2Fdownload%2Fvue-demi-0.9.1.tgz#25d6e1ebd4d4010757ff3571e2bf6a1d7bf3de82"
+  integrity sha1-Jdbh69TUAQdX/zVx4r9qHXvz3oI=
+
+vue-echarts@^6.0.0-rc.6:
+  version "6.0.0-rc.6"
+  resolved "https://registry.nlark.com/vue-echarts/download/vue-echarts-6.0.0-rc.6.tgz#c12afdbe2e858c941d434996e9bb9b7af3c8c631"
+  integrity sha1-wSr9vi6FjJQdQ0mW6bubevPIxjE=
+  dependencies:
+    resize-detector "^0.3.0"
+    vue-demi "^0.9.1"
+
 vue-eslint-parser@^7.6.0:
   version "7.6.0"
   resolved "https://registry.npm.taobao.org/vue-eslint-parser/download/vue-eslint-parser-7.6.0.tgz?cache=0&sync_timestamp=1614679624052&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-eslint-parser%2Fdownload%2Fvue-eslint-parser-7.6.0.tgz"
@@ -8924,11 +8955,6 @@ vue@^2.6.11:
   resolved "https://registry.npm.taobao.org/vue/download/vue-2.6.12.tgz"
   integrity sha1-9evU+mvShpQD4pqJau1JBEVskSM=
 
-vuex@^3.6.0:
-  version "3.6.0"
-  resolved "https://registry.npm.taobao.org/vuex/download/vuex-3.6.0.tgz?cache=0&sync_timestamp=1606318238493&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvuex%2Fdownload%2Fvuex-3.6.0.tgz"
-  integrity sha1-le+lalj3YHwTWwUzUIM6CeAaqBM=
-
 watchpack-chokidar2@^2.0.1:
   version "2.0.1"
   resolved "https://registry.npm.taobao.org/watchpack-chokidar2/download/watchpack-chokidar2-2.0.1.tgz"
@@ -9265,3 +9291,10 @@ yorkie@^2.0.0:
     is-ci "^1.0.10"
     normalize-path "^1.0.0"
     strip-indent "^2.0.0"
+
+zrender@5.1.1:
+  version "5.1.1"
+  resolved "https://registry.nlark.com/zrender/download/zrender-5.1.1.tgz#0515f4f8cc0f4742f02a6b8819550a6d13d64c5c"
+  integrity sha1-BRX0+MwPR0LwKmuIGVUKbRPWTFw=
+  dependencies:
+    tslib "2.0.3"