|
@@ -17,9 +17,9 @@
|
17
|
17
|
|
18
|
18
|
<div class="row" style="margin:0">
|
19
|
19
|
<div class="col-xs-6 col-md-6" style="padding 0;">
|
20
|
|
- <div class="pull-left">
|
|
20
|
+ <div class="pull-left" @click="postLike">
|
21
|
21
|
<span role="button" class="iconfont icon-zan"></span>
|
22
|
|
- <span>赞 | {{current.likeNum}}</span>
|
|
22
|
+ <span>赞 | {{current.likeNum || 0}}</span>
|
23
|
23
|
</div>
|
24
|
24
|
</div>
|
25
|
25
|
<div class="col-xs-6 col-md-6" style="padding 0;">
|
|
@@ -38,8 +38,8 @@
|
38
|
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
|
|
- <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 }}">
|
|
41
|
+ <div class="btn1 btn-link pull-left case-3 button-hover prev-page" v-if="brothers[0].id">
|
|
42
|
+ <router-link :to="{name: 'details', params: { id: brothers[0].id }}">
|
43
|
43
|
上一个案例
|
44
|
44
|
</router-link>
|
45
|
45
|
</div>
|
|
@@ -48,8 +48,8 @@
|
48
|
48
|
<button type="button" class="btn btn-default button-hover" @click="() => $router.go(-1)">返回</button>
|
49
|
49
|
</div>
|
50
|
50
|
<div class="col-xs-4 col-md-4 case-3">
|
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 }}">
|
|
51
|
+ <div class="btn1 btn-link pull-right case-3 button-hover next-page" v-if="brothers[1].id">
|
|
52
|
+ <router-link :to="{name: 'details', params: { id: brothers[1].id }}">
|
53
|
53
|
下一个案例
|
54
|
54
|
</router-link>
|
55
|
55
|
</div>
|
|
@@ -62,7 +62,7 @@
|
62
|
62
|
|
63
|
63
|
<div class="row home-case" style="padding:0;width: 100%;">
|
64
|
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 }}">
|
|
65
|
+ <router-link :to="{name: 'details', params: { id: item.id }}">
|
66
|
66
|
<div class="st4" :style="{background: `url(${item.caseCoverImg})`}">
|
67
|
67
|
<div class="casetitle">
|
68
|
68
|
<p>{{item.caseTitle}}</p>
|
|
@@ -96,7 +96,18 @@ export default {
|
96
|
96
|
return this.detail.current || {}
|
97
|
97
|
},
|
98
|
98
|
brothers() {
|
99
|
|
- return this.detail.brothers || []
|
|
99
|
+ let b = this.detail.brothers
|
|
100
|
+ if (!b || !b.length) {
|
|
101
|
+ b = [{}, {}]
|
|
102
|
+ } else if (b.length === 1) {
|
|
103
|
+ if (b[0].id > this.$route.params.id) {
|
|
104
|
+ b = [{}].concat(b)
|
|
105
|
+ } else {
|
|
106
|
+ b.push({})
|
|
107
|
+ }
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ return b
|
100
|
111
|
},
|
101
|
112
|
recommends() {
|
102
|
113
|
return (this.detail.recommends || []).slice(0, 4)
|
|
@@ -106,22 +117,43 @@ export default {
|
106
|
117
|
|
107
|
118
|
},
|
108
|
119
|
created () {
|
109
|
|
- this.getDetail()
|
|
120
|
+ this.getDetail(this.$route.params.id)
|
110
|
121
|
},
|
111
|
|
- beforeRouteUpdate () {
|
112
|
|
- // this.getDetail()
|
|
122
|
+ beforeRouteUpdate (to, from, next) {
|
|
123
|
+ this.getDetail(to.params.id)
|
|
124
|
+ next()
|
113
|
125
|
},
|
114
|
126
|
methods: {
|
115
|
|
- getDetail () {
|
116
|
|
- const id = this.$route.query.id;
|
117
|
|
-
|
|
127
|
+ getDetail (id) {
|
118
|
128
|
request({
|
119
|
129
|
...apis.case.get,
|
120
|
130
|
urlData: { id },
|
121
|
131
|
}).then(res => {
|
122
|
132
|
this.detail = res || {}
|
123
|
133
|
})
|
124
|
|
- }
|
|
134
|
+ },
|
|
135
|
+
|
|
136
|
+ postLike () {
|
|
137
|
+ const id = this.$route.params.id;
|
|
138
|
+
|
|
139
|
+ request({
|
|
140
|
+ ...apis.case.like,
|
|
141
|
+ urlData: { id },
|
|
142
|
+ }).then(res => {
|
|
143
|
+ this.detail = {
|
|
144
|
+ ...this.detail,
|
|
145
|
+ current: {
|
|
146
|
+ ...this.current,
|
|
147
|
+ likeNum: res || 0,
|
|
148
|
+ }
|
|
149
|
+ }
|
|
150
|
+
|
|
151
|
+ this.$message({
|
|
152
|
+ message: res == this.current.likeNum ? '已赞' : '赞 +1',
|
|
153
|
+ type: res == this.current.likeNum ? 'warning' : 'success'
|
|
154
|
+ });
|
|
155
|
+ })
|
|
156
|
+ },
|
125
|
157
|
|
126
|
158
|
},
|
127
|
159
|
|