guhongwei 4 years ago
parent
commit
8c4d4270b7
1 changed files with 12 additions and 15 deletions
  1. 12 15
      src/views/user/detail.vue

+ 12 - 15
src/views/user/detail.vue

@@ -54,29 +54,26 @@ export default {
     };
   },
   async created() {
-    await this.Detail();
-    await this.setTitle();
+    await this.search();
   },
   methods: {
     ...journnews(['fetch']),
     ...scienceNews({ xwzxFetch: 'fetch' }),
-    async Detail() {
-      let res = await this.fetch(this.id);
-      if (this.$checkRes(res)) {
-        this.$set(this, `tztgInfo`, res.data);
-      }
-      res = await this.xwzxFetch(this.id);
-      if (this.$checkRes(res)) {
-        this.$set(this, `xwzxInfo`, res.data);
-      }
-    },
-    //设置标题
-    setTitle() {
+    //查询
+    async search() {
       let type = this.type;
       if (type == 'tztg') {
         this.$set(this, `title`, '通知通告详情');
-      } else if (type == 'xwzx') {
+        let res = await this.fetch(this.id);
+        if (this.$checkRes(res)) {
+          this.$set(this, `tztgInfo`, res.data);
+        }
+      } else {
         this.$set(this, `title`, '新闻资讯详情');
+        res = await this.xwzxFetch(this.id);
+        if (this.$checkRes(res)) {
+          this.$set(this, `xwzxInfo`, res.data);
+        }
       }
     },
     // 返回首页