张延森 5 年之前
父節點
當前提交
0fc7b36ce8
共有 3 個檔案被更改,包括 61 行新增76 行删除
  1. 11
    30
      package-lock.json
  2. 5
    0
      src/config/api.js
  3. 45
    46
      src/views/Details.vue

+ 11
- 30
package-lock.json 查看文件

@@ -5481,8 +5481,7 @@
5481 5481
         "ansi-regex": {
5482 5482
           "version": "2.1.1",
5483 5483
           "bundled": true,
5484
-          "dev": true,
5485
-          "optional": true
5484
+          "dev": true
5486 5485
         },
5487 5486
         "aproba": {
5488 5487
           "version": "1.2.0",
@@ -5503,14 +5502,12 @@
5503 5502
         "balanced-match": {
5504 5503
           "version": "1.0.0",
5505 5504
           "bundled": true,
5506
-          "dev": true,
5507
-          "optional": true
5505
+          "dev": true
5508 5506
         },
5509 5507
         "brace-expansion": {
5510 5508
           "version": "1.1.11",
5511 5509
           "bundled": true,
5512 5510
           "dev": true,
5513
-          "optional": true,
5514 5511
           "requires": {
5515 5512
             "balanced-match": "^1.0.0",
5516 5513
             "concat-map": "0.0.1"
@@ -5525,20 +5522,17 @@
5525 5522
         "code-point-at": {
5526 5523
           "version": "1.1.0",
5527 5524
           "bundled": true,
5528
-          "dev": true,
5529
-          "optional": true
5525
+          "dev": true
5530 5526
         },
5531 5527
         "concat-map": {
5532 5528
           "version": "0.0.1",
5533 5529
           "bundled": true,
5534
-          "dev": true,
5535
-          "optional": true
5530
+          "dev": true
5536 5531
         },
5537 5532
         "console-control-strings": {
5538 5533
           "version": "1.1.0",
5539 5534
           "bundled": true,
5540
-          "dev": true,
5541
-          "optional": true
5535
+          "dev": true
5542 5536
         },
5543 5537
         "core-util-is": {
5544 5538
           "version": "1.0.2",
@@ -5655,8 +5649,7 @@
5655 5649
         "inherits": {
5656 5650
           "version": "2.0.3",
5657 5651
           "bundled": true,
5658
-          "dev": true,
5659
-          "optional": true
5652
+          "dev": true
5660 5653
         },
5661 5654
         "ini": {
5662 5655
           "version": "1.3.5",
@@ -5668,7 +5661,6 @@
5668 5661
           "version": "1.0.0",
5669 5662
           "bundled": true,
5670 5663
           "dev": true,
5671
-          "optional": true,
5672 5664
           "requires": {
5673 5665
             "number-is-nan": "^1.0.0"
5674 5666
           }
@@ -5683,7 +5675,6 @@
5683 5675
           "version": "3.0.4",
5684 5676
           "bundled": true,
5685 5677
           "dev": true,
5686
-          "optional": true,
5687 5678
           "requires": {
5688 5679
             "brace-expansion": "^1.1.7"
5689 5680
           }
@@ -5691,14 +5682,12 @@
5691 5682
         "minimist": {
5692 5683
           "version": "0.0.8",
5693 5684
           "bundled": true,
5694
-          "dev": true,
5695
-          "optional": true
5685
+          "dev": true
5696 5686
         },
5697 5687
         "minipass": {
5698 5688
           "version": "2.3.5",
5699 5689
           "bundled": true,
5700 5690
           "dev": true,
5701
-          "optional": true,
5702 5691
           "requires": {
5703 5692
             "safe-buffer": "^5.1.2",
5704 5693
             "yallist": "^3.0.0"
@@ -5717,7 +5706,6 @@
5717 5706
           "version": "0.5.1",
5718 5707
           "bundled": true,
5719 5708
           "dev": true,
5720
-          "optional": true,
5721 5709
           "requires": {
5722 5710
             "minimist": "0.0.8"
5723 5711
           }
@@ -5798,8 +5786,7 @@
5798 5786
         "number-is-nan": {
5799 5787
           "version": "1.0.1",
5800 5788
           "bundled": true,
5801
-          "dev": true,
5802
-          "optional": true
5789
+          "dev": true
5803 5790
         },
5804 5791
         "object-assign": {
5805 5792
           "version": "4.1.1",
@@ -5811,7 +5798,6 @@
5811 5798
           "version": "1.4.0",
5812 5799
           "bundled": true,
5813 5800
           "dev": true,
5814
-          "optional": true,
5815 5801
           "requires": {
5816 5802
             "wrappy": "1"
5817 5803
           }
@@ -5897,8 +5883,7 @@
5897 5883
         "safe-buffer": {
5898 5884
           "version": "5.1.2",
5899 5885
           "bundled": true,
5900
-          "dev": true,
5901
-          "optional": true
5886
+          "dev": true
5902 5887
         },
5903 5888
         "safer-buffer": {
5904 5889
           "version": "2.1.2",
@@ -5934,7 +5919,6 @@
5934 5919
           "version": "1.0.2",
5935 5920
           "bundled": true,
5936 5921
           "dev": true,
5937
-          "optional": true,
5938 5922
           "requires": {
5939 5923
             "code-point-at": "^1.0.0",
5940 5924
             "is-fullwidth-code-point": "^1.0.0",
@@ -5954,7 +5938,6 @@
5954 5938
           "version": "3.0.1",
5955 5939
           "bundled": true,
5956 5940
           "dev": true,
5957
-          "optional": true,
5958 5941
           "requires": {
5959 5942
             "ansi-regex": "^2.0.0"
5960 5943
           }
@@ -5998,14 +5981,12 @@
5998 5981
         "wrappy": {
5999 5982
           "version": "1.0.2",
6000 5983
           "bundled": true,
6001
-          "dev": true,
6002
-          "optional": true
5984
+          "dev": true
6003 5985
         },
6004 5986
         "yallist": {
6005 5987
           "version": "3.0.3",
6006 5988
           "bundled": true,
6007
-          "dev": true,
6008
-          "optional": true
5989
+          "dev": true
6009 5990
         }
6010 5991
       }
6011 5992
     },

+ 5
- 0
src/config/api.js 查看文件

@@ -16,6 +16,11 @@ const apis = {
16 16
       url: `${commPrefix}/case/:type/list`,
17 17
       method: 'get',
18 18
     },
19
+
20
+    get: {
21
+      url: `${commPrefix}/case/:id`,
22
+      method: 'get',
23
+    }
19 24
   },
20 25
   caseType: {
21 26
     list: {

+ 45
- 46
src/views/Details.vue 查看文件

@@ -1,25 +1,25 @@
1 1
 <template>
2 2
   <div class="details">
3 3
     <div class="head">
4
-      <img :src="datas.caseCoverImg" width="100%" />
4
+      <img :src="cover.coverImg" width="100%" />
5 5
     </div>
6 6
 
7 7
     <div class="contanier st">
8
-      <h1 style>{{datas.caseTitle}}</h1>
8
+      <h1 style>{{current.caseTitle}}</h1>
9 9
 
10 10
       <p style>
11 11
         客户:
12
-        <img :src="datas.caseLogoImg" alt />
13
-        &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 所属行业:{{datas.caseIndustry}}
12
+        <img :src="current.caseLogoImg" alt />
13
+        &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 所属行业:{{current.caseIndustry}}
14 14
       </p>
15 15
 
16
-      <div class="border-top" v-html="datas.content"></div>
16
+      <div class="border-top" v-html="current.content"></div>
17 17
 
18 18
       <div class="row" style="margin:0">
19 19
         <div class="col-xs-6 col-md-6" style="padding 0;">
20 20
           <div class="pull-left">
21 21
             <span role="button" class="iconfont icon-zan"></span>
22
-            <span>赞 | 234</span>
22
+            <span>赞 | {{current.likeNum}}</span>
23 23
           </div>
24 24
         </div>
25 25
         <div class="col-xs-6 col-md-6" style="padding 0;">
@@ -35,16 +35,24 @@
35 35
         </div>
36 36
       </div>
37 37
     </div>
38
-    <div class="contanier center-block next-prev" style>
38
+    <div class="contanier center-block next-prev">
39 39
       <div class="row case-2">
40 40
         <div class="col-xs-4 col-md-4 case-3">
41
-          <button type="button" class="btn1 btn-link pull-left case-3 button-hover prev-page">上一个案例</button>
41
+          <div class="btn1 btn-link pull-left case-3 button-hover prev-page" v-if="brothers.length">
42
+            <router-link :to="{name: 'details', query: { id: brothers[0].id }}">
43
+              上一个案例
44
+            </router-link>
45
+          </div>
42 46
         </div>
43 47
         <div class="col-xs-4 col-md-4 case-3">
44
-          <button type="button" class="btn btn-default button-hover">返回</button>
48
+          <button type="button" class="btn btn-default button-hover" @click="() => $router.go(-1)">返回</button>
45 49
         </div>
46 50
         <div class="col-xs-4 col-md-4 case-3">
47
-          <button type="button" class="btn1 btn-link pull-right case-3 button-hover next-page">下一个案例</button>
51
+          <div class="btn1 btn-link pull-right case-3 button-hover next-page" v-if="brothers.length > 1">
52
+            <router-link :to="{name: 'details', query: { id: brothers[1].id }}">
53
+              下一个案例
54
+            </router-link>
55
+          </div>
48 56
         </div>
49 57
       </div>
50 58
     </div>
@@ -53,14 +61,14 @@
53 61
       <h2>更多好案例</h2>
54 62
 
55 63
       <div class="row home-case" style="padding:0;width: 100%;">
56
-        <div class="col-xs-6 col-md-3 home-case" style="margin:0" v-for="(item,index) in 4" :key="index">
57
-          <a href="/details">
58
-            <div class="st4" style="{background: `url(${../assets/image/home/Case2.jpg})`}">
64
+        <div class="col-xs-6 col-md-3 home-case" style="margin:0" v-for="(item,index) in recommends" :key="index">
65
+          <router-link :to="{name: 'details', query: { id: item.id }}">
66
+            <div class="st4" :style="{background: `url(${item.caseCoverImg})`}">
59 67
               <div class="casetitle">
60 68
                 <p>{{item.caseTitle}}</p>
61 69
               </div>
62 70
             </div>
63
-          </a>
71
+          </router-link>
64 72
         </div>
65 73
       </div>
66 74
     </div>
@@ -68,59 +76,50 @@
68 76
 </template>
69 77
 
70 78
 <script>
71
-
72
-
73
-export default {
74
-
75
-}
76
-</script>
77
-
78
-
79
-<script scoped>
80 79
 // @ is an alias to /src
81 80
 import request from '../../utils/request'
82 81
 import apis from '../config/api';
83 82
 
84 83
 export default {
85
-  name: 'details',
84
+  name: 'CaseDetails',
86 85
 
87 86
   data () {
88 87
     return {
89
-      datas: {},
90
-      morecase: [],
88
+      detail: {},
91 89
     }
92 90
   },
91
+  computed: {
92
+    cover() {
93
+      return this.detail.cover || {}
94
+    },
95
+    current() {
96
+      return this.detail.current || {}
97
+    },
98
+    brothers() {
99
+      return this.detail.brothers || []
100
+    },
101
+    recommends() {
102
+      return (this.detail.recommends || []).slice(0, 4)
103
+    },
104
+  },
93 105
   components: {
94 106
 
95 107
   },
96 108
   created () {
97 109
     this.getDetail()
98 110
   },
111
+  beforeRouteUpdate () {
112
+    // this.getDetail()
113
+  },
99 114
   methods: {
100 115
     getDetail () {
101 116
       const id = this.$route.query.id;
102
-      const type = this.$route.query.type;
103
-      const taCaseTypeId = this.$route.query.taCaseTypeId;
104
-      request({
105
-        ...apis.case.list,
106
-        urlData: { type: type },
107
-        params: { pageNum: 1, pageSize: 1, id: id },
108
-        query: {}
109
-      }).then(con => {
110
-        console.log(con, "124")
111
-        this.datas = con.records[0];
112
-        // window.console.log(this.caselist, "543");
113
-      })
114 117
 
115 118
       request({
116
-        ...apis.case.list,
117
-        urlData: { type: type },
118
-        params: { pageNum: 1, pageSize: 4, }
119
-      }).then(con => {
120
-        console.log(con, "456")
121
-        console.log(taCaseTypeId, "456")
122
-        // this.morecase = con.records[0];
123
-        // window.console.log(this.caselist, "543");
119
+        ...apis.case.get,
120
+        urlData: { id },
121
+      }).then(res => {
122
+        this.detail = res || {}
124 123
       })
125 124
     }
126 125