|
@@ -19,11 +19,19 @@
|
|
|
</el-col>
|
|
|
<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" @click.native="chatBtn"><i class="el-icon-chat-line-round"></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>
|
|
|
+ <van-dialog class="dialog" v-model="dialog" title="填写评论" :close-on-click-overlay="true" :show-confirm-button="false">
|
|
|
+ <van-form @submit="onSubmit">
|
|
|
+ <van-field v-model="form.content" rows="4" autosize label="评论内容" type="textarea" maxlength="100" placeholder="请输入内容" show-word-limit />
|
|
|
+ <div style="margin: 16px;">
|
|
|
+ <van-button round block type="info" native-type="submit">发送</van-button>
|
|
|
+ </div>
|
|
|
+ </van-form>
|
|
|
+ </van-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -34,6 +42,8 @@ import top from '@/layout/common/top.vue';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions: mapTopic } = createNamespacedHelpers('topic');
|
|
|
const { mapActions: mapThumbs } = createNamespacedHelpers('thumbs');
|
|
|
+const { mapActions: reply } = createNamespacedHelpers('reply');
|
|
|
+const moment = require('moment');
|
|
|
export default {
|
|
|
name: 'detail',
|
|
|
props: {},
|
|
@@ -50,29 +60,13 @@ export default {
|
|
|
// 评论
|
|
|
active: 'first',
|
|
|
// 用户评论列表
|
|
|
- commentList: [
|
|
|
- {
|
|
|
- icon: require('@a/system.png'),
|
|
|
- name: '测试用户',
|
|
|
- content: '你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好',
|
|
|
- renew_time: '2021-02-01 10:00:00',
|
|
|
- },
|
|
|
- {
|
|
|
- icon: require('@a/system.png'),
|
|
|
- name: '测试用户1',
|
|
|
- content: '你好1',
|
|
|
- renew_time: '2021-02-01 10:00:00',
|
|
|
- },
|
|
|
- {
|
|
|
- icon: require('@a/system.png'),
|
|
|
- name: '测试用户2',
|
|
|
- content: '你好2',
|
|
|
- renew_time: '2021-02-01 10:00:00',
|
|
|
- },
|
|
|
- ],
|
|
|
+ commentList: [],
|
|
|
// 点赞
|
|
|
zan: require('@a/zan.png'),
|
|
|
zan2: require('@a/zan2.png'),
|
|
|
+ // 评论
|
|
|
+ dialog: false,
|
|
|
+ form: {},
|
|
|
};
|
|
|
},
|
|
|
async created() {
|
|
@@ -85,12 +79,17 @@ export default {
|
|
|
methods: {
|
|
|
...mapTopic(['fetch']),
|
|
|
...mapThumbs(['create']),
|
|
|
+ ...reply({ replyQuery: 'query', replyCreate: 'create' }),
|
|
|
async search() {
|
|
|
if (this.id) {
|
|
|
let res = await this.fetch(this.id);
|
|
|
if (this.$checkRes(res)) {
|
|
|
this.$set(this, `detailInfo`, res.data);
|
|
|
}
|
|
|
+ res = await this.replyQuery({ article_id: this.id });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `commentList`, res.data);
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
// 返回上一页
|
|
@@ -106,10 +105,34 @@ export default {
|
|
|
};
|
|
|
let res = await this.create(data);
|
|
|
if (this.$checkRes(res)) {
|
|
|
+ this.$set(this.detailInfo, `thumbs`, res.data);
|
|
|
this.$toast({ type: 'success', message: this.detailInfo.thumbs ? '取消点赞' : '点赞成功' });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 打开评论
|
|
|
+ chatBtn() {
|
|
|
+ this.dialog = true;
|
|
|
+ },
|
|
|
+ // 发送评论
|
|
|
+ async onSubmit() {
|
|
|
+ let data = this.form;
|
|
|
+ data.name = this.user.name;
|
|
|
+ data.icon = this.user.icon;
|
|
|
+ data.openid = this.user.openid;
|
|
|
+ data.reply_time = moment().format('YYYY-MM-DD HH:mm:ss');
|
|
|
+ data.article_id = this.id;
|
|
|
+ let res = await this.replyCreate(data);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$toast({ type: 'success', message: '评论成功' });
|
|
|
+ this.dialogClose();
|
|
|
this.search();
|
|
|
}
|
|
|
},
|
|
|
+ // 关闭弹框
|
|
|
+ dialogClose() {
|
|
|
+ this.form = {};
|
|
|
+ this.dialog = false;
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['user']),
|