Forráskód Böngészése

添加飘窗点击跳转文章或链接

asd123a20 2 éve
szülő
commit
7f640b47ed
2 módosított fájl, 14 hozzáadás és 3 törlés
  1. 12 1
      src/components/upwindow.vue
  2. 2 2
      src/store/index.js

+ 12 - 1
src/components/upwindow.vue

@@ -3,6 +3,7 @@
     v-if="show"
     @mouseover="mouseover"
     @mouseout="mouseout"
+    @click="btn"
     class="box"
     :style="{ top: top + 'px', left: left + 'px', backgroundImage: `${img}`}"
   >
@@ -42,7 +43,17 @@ export default {
     clearInterval(this.timer);
   },
   methods: {
-    ...mapActions(['upWindewQuery']),
+    ...mapActions(['upWindewQuery', 'contentsQuery']),
+    // 点击窗口
+    async btn() {
+      console.log(this.upwindow);
+      if (this.upwindow[0].url && this.upwindow[0].url !== '') {
+        window.open(this.upwindow[0].url);
+        return false;
+      }
+      const res = await this.contentsQuery({ title: this.upwindow[0]?.title });
+      this.$router.push(`/details/${res.data[0]._id}`);
+    },
     // 初始化飘窗规则
     init() {
       // 设置最大的top和left值:根元素可视区域宽高 - 飘窗的宽高 - 边距

+ 2 - 2
src/store/index.js

@@ -46,8 +46,8 @@ const actions = {
     commit('imgNewsQuery', res);
     return res;
   },
-  async contentsQuery ({ commit }, { parentCode, bind, limit }) {
-    const res = await $axios.get(api.contentsQuery, { parentCode, bind, skip: 0, limit: limit || 5 });
+  async contentsQuery ({ commit }, { parentCode, bind, limit, title }) {
+    const res = await $axios.get(api.contentsQuery, { title, parentCode, bind, skip: 0, limit: limit || 5 });
     return res;
   },
   async linkTypeQuery ({ commit }) {