From 47d56a8b0f22fb15a46b69dfd46fac23560ad2cd Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期二, 12 五月 2026 09:07:49 +0800
Subject: [PATCH] 改bug
---
mini-program/pages/article-details/article-details.vue | 140 +++++++++++++++++++++++++++++++++++++---------
1 files changed, 111 insertions(+), 29 deletions(-)
diff --git a/mini-program/pages/article-details/article-details.vue b/mini-program/pages/article-details/article-details.vue
index 31fe3b0..7d94abf 100644
--- a/mini-program/pages/article-details/article-details.vue
+++ b/mini-program/pages/article-details/article-details.vue
@@ -7,50 +7,52 @@
</view>
<view class="xian"></view>
<view class="pl">
- <view class="pl-title">璇勮 {{info.commentCount || 0}}</view>
+ <view class="pl-title">璇勮 {{total}}</view>
<view class="pl-wu" v-if="commentList.length === 0">
<image src="/static/images/default_nocomment@2x.png" mode="widthFix"></image>
</view>
- <view class="pl-item" v-for="(item, index) in commentList" :key="item.id" v-else @click="openTwo(item.id, item)">
+ <view class="pl-item" v-for="(item, index) in commentList" :key="item.id" v-else @longpress="openDele(item, index)">
<view class="pl-item-tx">
- <image :src="item.memberImgUrl" mode="widthFix"></image>
+ <image :src="item.memberImgUrl || '/static/icon/default.png'" mode="widthFix"></image>
</view>
- <view class="pl-item-info">
+ <view class="pl-item-info" @click.stop="openTwo(item.id, item, item.nikeName)">
<view class="pl-item-info-name">{{item.nikeName}}</view>
<view class="pl-item-info-content" v-if="item.content">
{{item.content}}
</view>
<view class="pl-item-info-list" v-if="item.multifileList && item.multifileList.length > 0">
- <view class="pl-item-info-list-image" v-for="(child, i) in item.multifileList" :key="i" @click="yulan(child.fileFullUrl, item.multifileList)">
+ <view class="pl-item-info-list-image" v-for="(child, i) in item.multifileList" :key="i" @click.stop="yulan(child.fileFullUrl, item.multifileList)">
<image :src="child.fileFullUrl" mode="widthFix"></image>
</view>
<view style="width: 132rpx; height: 0;"></view>
<view style="width: 132rpx; height: 0;"></view>
</view>
<view class="pl-item-info-data">
- <view class="pl-item-info-data-time">{{$u.timeFormat(new Date(item.createDate).getTime())}}</view>
+ <view class="pl-item-info-data-time">{{item.createDate }}</view>
<view class="pl-item-info-data-list">
- <view class="pl-item-info-data-list-item" @click="sendChild(item.id, index)">
- <image src="/static/icon/ic_reply2@2x.png" mode="widthFix"></image>
+ <view class="pl-item-info-data-list-item" >
+ <!-- @click.stop="openTwo(item.id, item)" -->
+ <image src="/static/icon/ic_reply2@2x.png" mode="widthFix"></image>
</view>
- <view class="pl-item-info-data-list-item" @click.stop="dianzanpl(item)">
- <image src="/static/icon/dianzan.png" mode="widthFix" v-if="!item.zanStatus || item.zanStatus == 0"></image>
- <image src="/static/icon/detail_ic_zan_sel@2x.png" mode="widthFix" v-else></image>
- <text :style="{color: (!item.zanStatus || item.zanStatus == 0) ? '#AAAAAA' : '#004096'}">{{item.zanCount}}</text>
+ <view class="pl-item-info-data-list-item" >
+ <image src="/static/icon/dianzan.png" mode="widthFix" v-if="!item.zanStatus || item.zanStatus == 0" @click.stop="dianzanpl(item)"></image>
+ <image src="/static/icon/detail_ic_zan_sel@2x.png" mode="widthFix" v-else @click.stop="dianzanpl(item)"></image>
+ <text :style="{color: (!item.zanStatus || item.zanStatus == 0) ? '#AAAAAA' : '#004096'}" @click.stop="dianzanpl(item)">{{item.zanCount}}</text>
</view>
</view>
</view>
- <view class="pl-item" style="border: none;" v-for="(child, a) in item.childern" :key="child.id" @click="openTwo(item.id, child)">
+ <view class="pl-item" style="border: none;" v-for="(child, a) in item.childern" :key="child.id" @click.stop="openTwo(item.id, child, child.nikeName)" @longpress.stop="openDele(child, index, a)">
<view class="pl-item-tx">
- <image :src="child.memberImgUrl" mode="widthFix"></image>
+ <image :src="child.memberImgUrl || '/static/icon/default.png'" mode="widthFix"></image>
</view>
<view class="pl-item-info">
<view class="pl-item-info-name">{{child.nikeName}}</view>
<view class="pl-item-info-content" v-if="child.content">
+ <text v-if="child.replyMemberNikeName"> 鍥炲<text style="color: #AAAAAA;margin-left: 6rpx;margin-right: 6rpx;">{{child.replyMemberNikeName}}</text>: </text>
{{child.content}}
</view>
<view class="pl-item-info-list" v-if="child.multifileList && child.multifileList.length > 0">
- <view class="pl-item-info-list-image" v-for="(child1, i) in child.multifileList" :key="i">
+ <view class="pl-item-info-list-image" v-for="(child1, i) in child.multifileList" :key="i" @click.stop="yulan(child1.fileFullUrl, child.multifileList)">
<image :src="child1.fileFullUrl" mode="widthFix"></image>
</view>
<view style="width: 132rpx; height: 0;"></view>
@@ -71,7 +73,7 @@
</view>
</view>
</view>
- <view class="pl-more" v-if="item.childern.length > 0" @click.stop="more(item)">灞曞紑{{item.replyCount - 1}}鏉″洖澶�</view>
+ <view class="pl-more" v-if="item.childern&&item.childern.length < item.replyCount" @click.stop="moreReply(index)">灞曞紑{{item.replyCount - item.childern.length}}鏉″洖澶�</view>
</view>
</view>
</view>
@@ -94,10 +96,10 @@
<view style="width: 100%; height: env(safe-area-inset-bottom);"></view>
</view>
<!-- 鍒犻櫎璇勮 -->
- <u-popup :show="show" round="5" mode="bottom">
+ <u-popup :show="show" round="5" mode="bottom" @close="show = false">
<view class="dele">
<view class="dele-title">鍒犻櫎鎴戠殑璇勮</view>
- <view class="dele-item" style="color: #E4001D;">鍒犻櫎</view>
+ <view class="dele-item" style="color: #E4001D;" @click="deleOne">鍒犻櫎</view>
<view class="dele-item" @click="show = false">鍙栨秷</view>
</view>
</u-popup>
@@ -105,7 +107,7 @@
<u-popup :show="show1" round="5" mode="bottom" @close="closePush">
<view class="pus">
<view class="pus-content">
- <textarea placeholder="璇寸偣浠�涔堝惂锝�" v-model="value"></textarea>
+ <textarea :placeholder="nikeName ? `鍥炲${nikeName}鐨勮瘎璁篳 : '璇寸偣浠�涔堝惂锝�'" v-model="value"></textarea>
<view class="pus-content-list" v-if="multifileList.length > 0">
<view class="pus-content-list-item" v-for="(item, index) in multifileList" :key="index">
<view class="shanchu" @click.stop="deleImg(index)">
@@ -124,15 +126,18 @@
</view>
</view>
</u-popup>
+ <Login ref="login" />
</view>
</template>
<script>
import { mapState } from 'vuex'
import { dateConversion } from '@/utils/utils.js'
+ import Login from '@/components/login/login.vue'
export default {
+ components: { Login },
computed: {
- ...mapState(['userInfo', 'token'])
+ ...mapState(['userInfo', 'token','recshopid','recuserid'])
},
data() {
return {
@@ -142,13 +147,18 @@
info: null,
content: '',
commentList: [],
+ total: 0,
page: 1,
next: true,
value: '',
+ nikeName: '',
multifileList: [],
commentId: null,
- item: null
+ pl: null,
+ item: null,
+ one: null,
+ two: null
}
},
onLoad(option) {
@@ -164,8 +174,41 @@
}
},
methods: {
+ openDele(item, one, two) {
+ this.one = one
+ this.two = two
+ this.pl = item
+
+ if ((item.memberId === this.userInfo.id) && item.isdeleted !== 1) {
+ this.show = true
+ }
+ },
+ deleOne() {
+ this.$u.api.deleteComment(this.pl.id)
+ .then(res => {
+ if (res.code === 200) {
+ this.pl.content = '璇ヨ瘎璁哄凡琚師浣滆�呭垹闄�'
+ this.pl.isdeleted = 1
+ // if (this.one && !this.two) {
+ // this.commentList[this.one].content = '璇ヨ瘎璁哄凡琚師浣滆�呭垹闄�'
+ // this.commentList[this.one].isdeleted = 1
+ // } else if (this.one && this.two) {
+ // this.commentList[this.one].childern[this.two].content = '璇ヨ瘎璁哄凡琚師浣滆�呭垹闄�'
+ // this.commentList[this.one].childern[this.two].isdeleted = 1
+ // }
+ // this.one = null
+ // this.two = null
+ this.pl = null
+ this.show = false
+ }
+ })
+ },
// 鐐硅禐
dianzanpl(item) {
+ if (!this.userInfo) {
+ this.$refs.login.open()
+ return;
+ }
if (!item.zanStatus || item.zanStatus == 0) {
this.$u.api.zanCreate({
objId: item.id,
@@ -189,9 +232,14 @@
}
},
// 浜岀骇璇勮
- openTwo(commentId, item) {
+ openTwo(commentId, item, nikeName) {
+ if (!this.userInfo) {
+ this.$refs.login.open()
+ return;
+ }
this.item = item
this.commentId = commentId
+ this.nikeName = nikeName
this.show1 = true
},
// 鍒犻櫎鍥剧墖
@@ -244,27 +292,47 @@
closePush() {
this.item = null
this.commentId = null
+ this.nikeName = ''
this.value = ''
this.multifileList = []
this.show1 = false
},
// 灞曞紑璇勮
- more(item) {
+ moreReply(index) {
this.$u.api.findActivityReplyCommentDTOPage({
capacity: 10,
- page: 1,
+ page: this.commentList[index].page,
model: {
type: 1,
- commentId: item.id
+ commentId: this.commentList[index].id
}
}).then(res => {
if (res.code === 200) {
- console.log(res)
+ this.commentList[index].page++
+ this.commentList[index].childern = this.uniqueById([
+ ...this.commentList[index].childern,
+ ...res.data.records
+ ])
}
})
},
+ // 鏁扮粍鍘婚噸
+ uniqueById(arr) {
+ const map = new Map();
+ return arr.filter(item => {
+ if (!map.has(item.id)) {
+ map.set(item.id, true);
+ return true;
+ }
+ return false;
+ });
+ },
// 璇勮
sendComment() {
+ if (!this.userInfo) {
+ this.$refs.login.open()
+ return;
+ }
if (!this.value && this.multifileList.length === 0) return uni.showToast({
title: '璇勮鍐呭涓嶈兘涓虹┖',
icon: 'none'
@@ -273,7 +341,7 @@
activityId: this.info.id,
content: this.value,
multifileList: this.multifileList,
- // commentId: this.commentId,
+ commentId: this.commentId,
replyId: this.item ? this.item.id : null
}).then(res => {
if (res.code === 200) {
@@ -283,15 +351,17 @@
if (this.commentId) {
this.commentList.forEach(item => {
if (item.id === this.commentId) {
+ item.childern = item.childern||[]
item.childern.unshift(res.data)
}
})
} else {
+ this.commentList = this.commentList||[]
this.commentList.unshift(res.data)
}
this.multifileList = []
this.value = ''
- this.show1 = false
+ this.closePush()
}
})
},
@@ -309,8 +379,10 @@
}
}).then(res => {
if (res.code === 200) {
+ this.total = res.data.total
res.data.records.forEach(item => {
- item.createDate = dateConversion(item.createDate)
+ // item.createDate = dateConversion(item.createDate)
+ item.page = 1
item.childern = []
if (item.activityReplyCommentDTO) {
item.activityReplyCommentDTO.createDate = dateConversion(item.activityReplyCommentDTO.createDate)
@@ -326,6 +398,10 @@
})
},
shoucang(type) {
+ if (!this.userInfo) {
+ this.$refs.login.open()
+ return;
+ }
if (type === 1) {
this.$u.api.cancelbatch({
ids: this.info.id,
@@ -347,6 +423,10 @@
}
},
dianzan(type) {
+ if (!this.userInfo) {
+ this.$refs.login.open()
+ return;
+ }
if (type === 1) {
this.$u.api.zanCancel({
objId: this.info.id,
@@ -606,6 +686,7 @@
font-weight: 400;
font-size: 28rpx;
color: #333333;
+ word-break: break-word;
margin-top: 16rpx;
}
.pl-item-info-list {
@@ -620,6 +701,7 @@
height: 132rpx;
border-radius: 16rpx;
overflow: hidden;
+ margin-bottom: 15rpx;
image {
width: 100%;
}
--
Gitblit v1.9.3