|
@@ -22,7 +22,7 @@ |
|
@@ -22,7 +22,7 @@ |
22
|
<img :src="item.authorHeadIco">
|
22
|
<img :src="item.authorHeadIco">
|
23
|
</div>
|
23
|
</div>
|
24
|
<p class="user-name">{{item.authorName}}</p>
|
24
|
<p class="user-name">{{item.authorName}}</p>
|
25
|
- <div class="zan-container">
|
25
|
+ <div class="zan-container" :data-praised="item.hasPraised" :data-index="index" :data-id="item.articleId" @click="updatePraise">
|
26
|
<i :class="[item.hasPraised === 'Y' ? 'iconzan-fill' : 'iconzan_n', 'iconfont', 'btn-zan']"></i>
|
26
|
<i :class="[item.hasPraised === 'Y' ? 'iconzan-fill' : 'iconzan_n', 'iconfont', 'btn-zan']"></i>
|
27
|
<p class="zan-count">{{item.praiseCount ? item.praiseCount : '赞'}}</p>
|
27
|
<p class="zan-count">{{item.praiseCount ? item.praiseCount : '赞'}}</p>
|
28
|
</div>
|
28
|
</div>
|
|
@@ -45,11 +45,11 @@ export default { |
|
@@ -45,11 +45,11 @@ export default { |
45
|
name: 'waterFallList',
|
45
|
name: 'waterFallList',
|
46
|
components: {WaterFall},
|
46
|
components: {WaterFall},
|
47
|
props: {
|
47
|
props: {
|
48
|
- listData: {
|
48
|
+ listData: { // 列表数据
|
49
|
type: Array,
|
49
|
type: Array,
|
50
|
default: []
|
50
|
default: []
|
51
|
},
|
51
|
},
|
52
|
- listInfo: {
|
52
|
+ listInfo: { // 列表基础信息
|
53
|
type: Object,
|
53
|
type: Object,
|
54
|
default: {}
|
54
|
default: {}
|
55
|
},
|
55
|
},
|
|
@@ -61,7 +61,7 @@ export default { |
|
@@ -61,7 +61,7 @@ export default { |
61
|
type: Number,
|
61
|
type: Number,
|
62
|
default: 18
|
62
|
default: 18
|
63
|
},
|
63
|
},
|
64
|
- isLoading: {
|
64
|
+ isLoading: { // 是否正在调用列表接口
|
65
|
type: Boolean,
|
65
|
type: Boolean,
|
66
|
default: false
|
66
|
default: false
|
67
|
}
|
67
|
}
|
|
@@ -69,9 +69,10 @@ export default { |
|
@@ -69,9 +69,10 @@ export default { |
69
|
data() {
|
69
|
data() {
|
70
|
return {
|
70
|
return {
|
71
|
col: 2,
|
71
|
col: 2,
|
72
|
- scrollTop: 0,
|
|
|
73
|
- isLogin: false,
|
|
|
74
|
- loadText: ''
|
72
|
+ scrollTop: 0, // 页面滚动高度
|
|
|
73
|
+ isLogin: false, // 是否登录
|
|
|
74
|
+ loadText: '', // 加载新列表提示文字
|
|
|
75
|
+ isUpdatingPraise: false, // 是否正在调用点赞接口
|
75
|
};
|
76
|
};
|
76
|
},
|
77
|
},
|
77
|
computed: {
|
78
|
computed: {
|
|
@@ -104,17 +105,15 @@ export default { |
|
@@ -104,17 +105,15 @@ export default { |
104
|
this.isLogin = val;
|
105
|
this.isLogin = val;
|
105
|
},
|
106
|
},
|
106
|
isLoading(newVal) {
|
107
|
isLoading(newVal) {
|
107
|
- console.log('isLoading', newVal);
|
|
|
108
|
if (newVal === true) {
|
108
|
if (newVal === true) {
|
109
|
this.loadText = '加载中...';
|
109
|
this.loadText = '加载中...';
|
110
|
} else {
|
110
|
} else {
|
111
|
this.loadText = '';
|
111
|
this.loadText = '';
|
112
|
}
|
112
|
}
|
113
|
- console.log(this.loadText);
|
|
|
114
|
}
|
113
|
}
|
115
|
},
|
114
|
},
|
116
|
methods: {
|
115
|
methods: {
|
117
|
- ...mapActions(['articleAddLike']),
|
116
|
+ ...mapActions(['updateArticlePraise']),
|
118
|
loadMore() {
|
117
|
loadMore() {
|
119
|
this.$emit('load-more');
|
118
|
this.$emit('load-more');
|
120
|
},
|
119
|
},
|
|
@@ -141,6 +140,16 @@ export default { |
|
@@ -141,6 +140,16 @@ export default { |
141
|
}
|
140
|
}
|
142
|
});
|
141
|
});
|
143
|
}
|
142
|
}
|
|
|
143
|
+ },
|
|
|
144
|
+ updatePraise(e) {
|
|
|
145
|
+ let articleId = e.currentTarget.dataset.id;
|
|
|
146
|
+ let index = e.currentTarget.dataset.index;
|
|
|
147
|
+ let status = e.currentTarget.dataset.praised === 'Y' ? 1 : 0;
|
|
|
148
|
+
|
|
|
149
|
+ console.log(articleId,index, status);
|
|
|
150
|
+ this.updateArticlePraise({articleId, status, index}).then(result => {
|
|
|
151
|
+ console.log(result);
|
|
|
152
|
+ });
|
144
|
}
|
153
|
}
|
145
|
}
|
154
|
}
|
146
|
};
|
155
|
};
|