123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- <template>
- <view class="comment-section">
- <view class="section-header">
- <!-- <text class="fa fa-comments"></text> -->
- <!-- <text class="section-title">评论区</text> -->
- <text class="comment-count">共 {{ tableTotal }} 条评论</text>
- </view>
- <CComment ref="ccRef" :myInfo="myInfo" :userInfo="userInfo" :tableData="tableData" :tableTotal.sync="tableTotal"
- :deleteMode="deleteMode" @likeFun="likeFun" @replyFun="replyFun" @deleteFun="deleteFun"></CComment>
- <view class="comment-button" @tap="openComment">
- <text class="fa fa-pencil"></text>
- <text>发表新评论</text>
- </view>
- <view class="bottomFixed" @tap="openComment">
- <view class="inbutBox">
- <view class="left-box">
- <image src="@/static/icon/cz_icon_xiugaifengmian.png"></image>
- <text>发表你的想法...</text>
- </view>
- <view class="emoji-trigger" >
- <text class="fa fa-smile-o"></text>
- </view>
- </view>
- <view class="giveTheThumbsUpBox">
- <image v-if="true" src="@/static/icon/icon-19.png"></image>
- <image v-else src="@/static/icon/icon-18.png"></image>
- <!-- {{}} -->
- 0
- </view>
- </view>
- </view>
- </template>
- <script>
- import CComment from "@/components/cc-comment/cc-comment.vue";
- export default {
- name: 'CommentSection',
- components: {
- CComment
- },
- props: {
- myInfo: {
- type: Object,
- required: true
- },
- userInfo: {
- type: Object,
- required: true
- },
- articleId: {
- type: [Number, String],
- required: true
- },
- type: {
- type: String,
- default: 'work'
- }
- },
- data() {
- return {
- deleteMode: "all",
- tableTotal: 0,
- tableData: []
- }
- },
- created() {
- this.loadCommentData();
- },
- methods: {
- loadCommentData() {
- uni.request({
- url: this.$apiHost + '/Article/getcomments',
- data: {
- uuid: getApp().globalData.uuid,
- type: this.type,
- id: this.articleId,
- page: 1,
- limit: 10
- },
- header: {
- "content-type": "application/json",
- 'sign': getApp().globalData.headerSign
- },
- success: (res) => {
- console.log("评论列表:", res.data);
- if (res.data.success == "yes") {
- this.$set(this, 'tableData', res.data.list);
- this.tableTotal = res.data.total;
- let newData = res.data.total
- this.$emit('totalNumberOfComments', newData);
- console.log("tabddd", this.tableData)
- } else {
- uni.showToast({
- title: '获取评论列表失败',
- icon: 'none'
- });
- }
- },
- fail: (e) => {
- console.log("----e:", e);
- }
- });
- },
- openComment() {
- let ccRef = this.$refs["ccRef"];
- ccRef.newCommentFun();
- },
- likeFun({ params }, callback) {
- console.log("likeFun", params);
- uni.request({
- url: this.$apiHost + '/Article/zanComment',
- data: {
- uuid: getApp().globalData.uuid,
- id: params.id
- },
- header: {
- "content-type": "application/json",
- 'sign': getApp().globalData.headerSign
- },
- success: (res) => {
- console.log("点赞结果:", res.data);
- if (res.data.success !== "yes") {
- callback(res); // 请求失败时重置点赞效果
- }
- },
- fail: (e) => {
- console.log("点赞失败:", e);
- callback(e); // 请求失败时重置点赞效果
- }
- });
- },
- replyFun({ params }, callback) {
- console.log("replyFun", {
- uuid: getApp().globalData.uuid,
- type: this.type,
- article_id: this.articleId,
- content: params.user_content,
- parent_id: params.parent_id || 0,
- reply_id: params.reply_id || 0,
- reply_name: params.reply_name || ''
- });
- uni.request({
- url: this.$apiHost + '/Article/newComment',
- data: {
- uuid: getApp().globalData.uuid,
- type: this.type,
- article_id: this.articleId,
- content: params.user_content,
- parent_id: params.parent_id || 0,
- reply_id: params.reply_id || 0,
- reply_name: params.reply_name || ''
- },
- header: {
- "content-type": "application/json",
- 'sign': getApp().globalData.headerSign
- },
- success: (res) => {
- console.log("评论结果:", res.data);
- if (res.data.success === "yes") {
- callback(res.data);
- this.loadCommentData(); // 重新加载评论列表
- }
- },
- fail: (e) => {
- console.log("评论失败:", e);
- uni.showToast({
- title: '评论失败,请重试',
- icon: 'none'
- });
- }
- });
- },
- deleteFun({ params, mode }, callback) {
- console.log("deleteFun", { params, mode });
- const idsString = Array.isArray(params) ? params.join(',') : params.toString();
- console.log("删除评论", idsString, mode)
- uni.request({
- url: this.$apiHost + '/Article/delComment',
- data: {
- uuid: getApp().globalData.uuid,
- ids: idsString,
- mode: mode
- },
- header: {
- "content-type": "application/json",
- 'sign': getApp().globalData.headerSign
- },
- success: (res) => {
- console.log("删除结果:", res.data);
- if (res.data.success === "yes") {
- callback(res);
- this.loadCommentData(); // 重新加载评论列表
- }
- },
- fail: (e) => {
- console.log("删除失败:", e);
- uni.showToast({
- title: '删除失败,请重试',
- icon: 'none'
- });
- }
- });
- },
- }
- }
- </script>
- <style lang="scss">
- .comment-section {
- background-color: #fff;
- padding: 20rpx;
- margin-top: 20rpx;
- border-radius: 12rpx;
- .section-header {
- display: flex;
- align-items: center;
- margin-bottom: 20rpx;
- .fa {
- font-size: 36rpx;
- color: #666;
- margin-right: 10rpx;
- }
- .section-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- }
- .comment-count {
- font-size: 28rpx;
- margin-left: 10rpx;
- font-family: 'PingFang SC-Medium';
- font-weight: 400;
- color: #1F1F1F;
- }
- }
- .comment-button {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 80rpx;
- margin-top: 20rpx;
- background-color: #f8f8f8;
- border-radius: 40rpx;
- cursor: pointer;
- .fa {
- font-size: 32rpx;
- color: #666;
- margin-right: 10rpx;
- }
- text {
- font-size: 28rpx;
- color: #666;
- }
- &:active {
- background-color: #f0f0f0;
- }
- }
- .bottomFixed {
- width: 100vw;
- height: 104rpx;
- padding: 20rpx 32rpx 16rpx 32rpx;
- background-color: #fff;
- // position: fixed;
- left: 0;
- bottom: var(--window-bottom);
- display: flex;
- align-items: center;
- justify-content: space-between;
- .inbutBox {
- background: #F6F6F6;
- border-radius: 34rpx;
- width: 576rpx;
- height: 68rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 24rpx 18rpx;
- .left-box{
- display: flex;
- align-items: center;
-
- }
- image{
- width: 32rpx;
- height: 32rpx;
- margin-right: 12rpx;
- }
- .emoji-trigger{
- font-size: 48rpx;
- }
- }
- .giveTheThumbsUpBox{
- display: flex;
- align-items: center;
- justify-content: center;
-
- image{
- width: 40rpx;
- height: 40rpx;
- margin-right: 10rpx;
- }
- }
- }
- }
- </style>
|