Authored by 陈峰

commit

... ... @@ -599,7 +599,6 @@ const yoho = {
},
getInput(args, success, fail) {
console.log('get.Input')
if (this.isYohoBuy && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'get.Input',
... ...
... ... @@ -14,9 +14,15 @@
:option="favOption"></WidgetFav>
</div>
<div class="comment-cont" @click="replyComment(parentComment.id)" :data-parent-id="parentComment.parentId" :data-root-id="parentComment.rootId">
<CommentPlaceholder
class="comment-cont"
:dest-id="parentComment.id"
:add-type="1"
:user="parentComment.userName"
:column-type="columnType"
@on-comment="onReply">
{{parentComment.content}}
</div>
</CommentPlaceholder>
<div class="reply-main" v-if="replayShowList.length">
<p class="reply-item" v-for="(reply, replyIndex) in replayShowList" :key="replyIndex">
<span class="reply-user">
... ... @@ -25,9 +31,15 @@
<span v-if="reply.parentUserName">
回复<em class="reply-to-user">@{{reply.parentUserName}}</em>
</span>:
<span @click="replyComment(reply.id)" :data-parent-id="reply.parentId" :data-root-id="reply.rootId">
{{reply.content}}
</span>
<CommentPlaceholder
tag="span"
:dest-id="reply.id"
:add-type="1"
:user="reply.userName"
:column-type="columnType"
@on-comment="onReply">
{{reply.content}}
</CommentPlaceholder>
</p>
<p class="reply-more" v-if="moreReplyNum > 0" @click="onShowMore">
{{replyMoreText}}
... ... @@ -85,17 +97,8 @@ export default {
onShowMore() {
this.isShowAllReply = !this.isShowAllReply;
},
async replyComment(commentId) {
const result = await this.postComment({
content: '这还是一条测试回复',
commentId: commentId,
addType: 1,
columnType: this.columnType
});
if (result.code === 200) {
this.$emit('on-reply', {commentId: this.parentComment.id});
}
async onReply({destId}) {
this.$emit('on-reply', {commentId: destId});
}
}
};
... ...
... ... @@ -7,13 +7,17 @@
:key="index"
:parent-comment="comment.parentComment"
:children-comments="comment.childrenComments"
:column-type="columnType"
@on-reply="onReply">
:column-type="columnType">
</CommentItem>
</Scroll>
</div>
<div class="comment-footer">
<CommentPlaceholder class="comment-input">
<CommentPlaceholder
class="comment-input"
:dest-id="destId"
:add-type="0"
:column-type="columnType"
@on-comment="onComment">
参与评论
</CommentPlaceholder>
</div>
... ... @@ -41,6 +45,7 @@ export default {
page: 1,
commentList: [],
scrollOption: {
bounce: false,
pullUpLoad: {
threshold: 200,
txt: {
... ... @@ -104,22 +109,7 @@ export default {
this.fetchComments();
},
async onComment() {
const result = await this.postComment({
content: '这还是一条测试回复1',
destId: this.destId,
addType: 0,
columnType: this.columnType
});
if (result.code === 200) {
this.init();
} else {
this.$createToast({
txt: result.message || '服务器开小差了',
type: 'warn',
time: 1000
}).show();
}
this.init();
},
async init() {
this.page = 1;
... ...
import {createNamespacedHelpers} from 'vuex';
const {mapActions} = createNamespacedHelpers('comment');
export default {
name: 'CommentPlaceholder',
props: {
... ... @@ -8,19 +11,61 @@ export default {
type: Number,
default: 1001
},
placeholder: String
user: {
type: String,
default: ''
}
},
methods: {
...mapActions(['postComment']),
openComentInput() {
this.$yoho.getInput({
hint: '你好',
success: (content) => {
console.log(content)
},
fail: (e) => {
console.log('fail', e)
}
const hint = this.user ? `回复${this.user}:` : '';
if (this.$yoho.isYohoBuy) {
this.$yoho.getInput({
hint,
success: (content) => {
this.comment(content);
},
fail: (e) => {
console.log('fail', e)
}
});
} else {
this.$createDialog({
type: 'prompt',
title: '测试-输入',
prompt: {
placeholder: hint
},
onConfirm: (e, promptValue) => {
this.comment(promptValue);
}
}).show();
}
},
async comment(content) {
const result = await this.postComment({
content: content,
destId: this.addType === 0 ? this.destId : void 0,
commentId: this.addType === 1 ? this.destId : void 0,
addType: this.addType,
columnType: this.columnType
});
if (result.code === 200) {
this.$emit('on-comment', {
destId: this.destId,
addType: this.addType,
columnType: this.columnType
});
} else {
this.$createToast({
txt: result.message || '服务器开小差了',
type: 'warn',
time: 1000
}).show();
}
}
},
render(h) {
... ...