Browse Source

第三方文章,点击时,新打开一个窗口并跳转到该地址

yellowtaotao 3 years ago
parent
commit
a113ace622

+ 15 - 7
src/views/home/learn/page-learn-child.vue

@@ -27,13 +27,16 @@
             <van-cell
               v-for="(contentItem, contentIndex) in contentList"
               :key="contentIndex"
-              @click="chooseContent(contentIndex)"
+              @click="chooseContent(contentItem, contentIndex)"
             >
               <div slot="default" class="contentItemDiv">
                 <div class="contentItemTitleTitleRow">
                   <!-- 文章 -->
                   <div
-                    v-if="contentItem.type == 'ARTICLE'"
+                    v-if="
+                      contentItem.type == 'ARTICLE' ||
+                        contentItem.type == 'THIRD_PARTY'
+                    "
                     class="contentItemTitleTitleRow"
                   >
                     <div class="contentItemTitle">
@@ -221,11 +224,16 @@ export default {
     onLoad() {
       this.getContentList();
     },
-    chooseContent(index) {
-      this.$router.push({
-        name: "learn-content",
-        params: { materialId: this.contentList[index].id }
-      });
+    chooseContent(contentItem, index) {
+      if (contentItem.type === "THIRD_PARTY") {
+        // window.location.href = contentItem.contents;
+        window.open(contentItem.contents);
+      } else {
+        this.$router.push({
+          name: "learn-content",
+          params: { materialId: this.contentList[index].id }
+        });
+      }
     },
     onRefresh() {
       this.getChildList();

+ 15 - 7
src/views/home/learn/page-learn-recommend.vue

@@ -24,12 +24,15 @@
         <van-cell
           v-for="(contentItem, contentIndex) in contentList"
           :key="contentIndex"
-          @click="chooseContent(contentIndex)"
+          @click="chooseContent(contentItem, contentIndex)"
         >
           <div slot="default" class="contentItemDiv" v-if="contentItem">
             <!-- 文章 -->
             <div
-              v-if="contentItem.type == 'ARTICLE'"
+              v-if="
+                contentItem.type == 'ARTICLE' ||
+                  contentItem.type == 'THIRD_PARTY'
+              "
               class="contentItemTitleTitleRow"
             >
               <div class="contentItemTitle">
@@ -185,11 +188,16 @@ export default {
       this.contentList = datas;
     },
     onLoad() {},
-    chooseContent(index) {
-      this.$router.push({
-        name: "learn-content",
-        params: { materialId: this.contentList[index].id }
-      });
+    chooseContent(contentItem, index) {
+      if (contentItem.type === "THIRD_PARTY") {
+        // window.location.href = contentItem.contents;
+        window.open(contentItem.contents);
+      } else {
+        this.$router.push({
+          name: "learn-content",
+          params: { materialId: this.contentList[index].id }
+        });
+      }
     },
     onRefresh() {
       this.getNewsfeed();