|
@@ -20,7 +20,7 @@
|
|
|
<el-col :span="24" class="foot">
|
|
|
<el-col :span="8" class="button"><i class="el-icon-position"></i>分享</el-col>
|
|
|
<el-col :span="8" class="button"><i class="el-icon-chat-line-round"></i>评论</el-col>
|
|
|
- <el-col :span="8" class="button"><i class="el-icon-thumb"></i>点赞</el-col>
|
|
|
+ <el-col :span="8" class="button zan" @click.native="zanBtn"><img :src="detailInfo.thumbs ? zan2 : zan" /><span>点赞</span></el-col>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -33,6 +33,7 @@ import comment from './parts/comment.vue';
|
|
|
import top from '@/layout/common/top.vue';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions: mapTopic } = createNamespacedHelpers('topic');
|
|
|
+const { mapActions: mapThumbs } = createNamespacedHelpers('thumbs');
|
|
|
export default {
|
|
|
name: 'detail',
|
|
|
props: {},
|
|
@@ -69,6 +70,9 @@ export default {
|
|
|
renew_time: '2021-02-01 10:00:00',
|
|
|
},
|
|
|
],
|
|
|
+ // 点赞
|
|
|
+ zan: require('@a/zan.png'),
|
|
|
+ zan2: require('@a/zan2.png'),
|
|
|
};
|
|
|
},
|
|
|
async created() {
|
|
@@ -80,6 +84,7 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
...mapTopic(['fetch']),
|
|
|
+ ...mapThumbs(['create']),
|
|
|
async search() {
|
|
|
if (this.id) {
|
|
|
let res = await this.fetch(this.id);
|
|
@@ -92,6 +97,19 @@ export default {
|
|
|
upBack() {
|
|
|
this.$router.push({ path: '/community/index' });
|
|
|
},
|
|
|
+ // 点赞
|
|
|
+ async zanBtn() {
|
|
|
+ let data = {
|
|
|
+ openid: this.user.openid,
|
|
|
+ type: '1',
|
|
|
+ article_id: this.detailInfo.id,
|
|
|
+ };
|
|
|
+ let res = await this.create(data);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$toast({ type: 'success', message: this.detailInfo.thumbs ? '取消点赞' : '点赞成功' });
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['user']),
|
|
@@ -146,6 +164,15 @@ export default {
|
|
|
.button:last-child {
|
|
|
border-right: none;
|
|
|
}
|
|
|
+ // 点赞
|
|
|
+ .zan {
|
|
|
+ img {
|
|
|
+ width: 15px;
|
|
|
+ height: 15px;
|
|
|
+ position: relative;
|
|
|
+ top: 2px;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</style>
|