|
|
@@ -94,12 +94,15 @@
|
|
|
<span class="message-sender">{{ item.userName || item.title || "未知" }}</span>
|
|
|
<span class="message-date">{{ item.date }}</span>
|
|
|
</div>
|
|
|
- <div class="message-content">
|
|
|
+ <div class="message-content" v-if="item.title == '关注通知' || item.title == '动态通知'">
|
|
|
+ {{ item.userName }} {{ item.content }}
|
|
|
+ </div>
|
|
|
+ <div class="message-content" v-else>
|
|
|
{{ processContent(item) }}
|
|
|
</div>
|
|
|
- <!-- <div class="message-actions">
|
|
|
+ <div class="message-actions">
|
|
|
<el-button size="small" type="default" @click.stop="handleDelete(item, index)"> 删除 </el-button>
|
|
|
- </div> -->
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -159,6 +162,10 @@
|
|
|
<span v-else-if="item.isNotDisturb === '1' && (item.notReadCount ?? 0) > 0" class="message-dot" />
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <!-- 未关注人消息、消息列表:删除按钮(接口 deleteMessageByPhoneId) -->
|
|
|
+ <div class="message-actions">
|
|
|
+ <el-button size="small" type="default" @click.stop="handleDeleteMessage(item, index)"> 删除 </el-button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div v-if="currentMessageList.length === 0" class="empty-tip">暂无数据</div>
|
|
|
@@ -169,7 +176,10 @@
|
|
|
|
|
|
<!-- 详情弹窗 -->
|
|
|
<el-dialog v-model="detailVisible" :title="currentDetail?.title" width="500px">
|
|
|
- <div class="detail-dialog-content">
|
|
|
+ <div class="detail-dialog-content" v-if="currentDetail?.title == '关注通知' || currentDetail?.title == '动态通知'">
|
|
|
+ {{ currentDetail?.userName }} {{ currentDetail?.content }}
|
|
|
+ </div>
|
|
|
+ <div class="detail-dialog-content" v-else>
|
|
|
{{ currentDetail?.content }}
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
@@ -180,13 +190,16 @@
|
|
|
import { ref, computed, onMounted, watch, markRaw } from "vue";
|
|
|
import { useRouter } from "vue-router";
|
|
|
import { House, List, User, Loading, Message, UserFilled } from "@element-plus/icons-vue";
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
import { localGet } from "@/utils";
|
|
|
import {
|
|
|
getNoticeListForHeader,
|
|
|
readNoticeById,
|
|
|
+ deleteNoticeById,
|
|
|
getCountUnreadByType,
|
|
|
getMessageList,
|
|
|
- getStrangerMessageNum
|
|
|
+ getStrangerMessageNum,
|
|
|
+ deleteMessageByPhoneId
|
|
|
} from "@/api/modules/headerNotice";
|
|
|
import type { NoFriendMessageItem } from "@/api/modules/headerNotice";
|
|
|
|
|
|
@@ -450,6 +463,30 @@ function handleMessageItemClick(item: MessageItem) {
|
|
|
router.push(`/storeDecorationManagement/decorationChat?${params.toString()}`);
|
|
|
}
|
|
|
|
|
|
+// 删除消息(未关注人消息、消息列表通用,接口 deleteMessageByPhoneId)
|
|
|
+async function handleDeleteMessage(item: MessageItem, index: number) {
|
|
|
+ const receiverId = getReceiverId();
|
|
|
+ const senderId = item.phoneId ?? item.senderId;
|
|
|
+ if (!receiverId || !senderId) {
|
|
|
+ ElMessage.error("无法删除");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ await deleteMessageByPhoneId({
|
|
|
+ receiverId: "store_" + receiverId,
|
|
|
+ senderId: String(senderId)
|
|
|
+ });
|
|
|
+ const key = messageCategory.value;
|
|
|
+ messageListByCategory.value[key] = currentMessageList.value.filter((_, i) => i !== index);
|
|
|
+ const cat = messageCategories.value.find(c => c.key === key);
|
|
|
+ if (cat && cat.unread > 0) cat.unread = Math.max(0, cat.unread - (item.notReadCount ?? 1));
|
|
|
+ if (key === "unfollowed") await fetchUnfollowedUnreadCount();
|
|
|
+ ElMessage.success("删除成功");
|
|
|
+ } catch (e) {
|
|
|
+ ElMessage.error("删除失败");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// 根据类型显示内容(与商家端一致)
|
|
|
function getVoiceDuration(item: { voiceDuration?: number; duration?: number; [key: string]: any }): string {
|
|
|
const sec = item?.voiceDuration ?? item?.duration ?? 0;
|
|
|
@@ -619,11 +656,18 @@ async function handleViewDetail(item: NoticeItem) {
|
|
|
detailVisible.value = true;
|
|
|
}
|
|
|
|
|
|
-function handleDelete(item: NoticeItem, index: number) {
|
|
|
- const key = activeCategory.value;
|
|
|
- listByCategory.value[key] = currentList.value.filter((_, i) => i !== index);
|
|
|
- const cat = noticeCategories.value.find(c => c.key === key);
|
|
|
- if (cat && item.unread) cat.unread = Math.max(0, cat.unread - 1);
|
|
|
+async function handleDelete(item: NoticeItem, index: number) {
|
|
|
+ try {
|
|
|
+ await deleteNoticeById({ id: item.id });
|
|
|
+ const key = activeCategory.value;
|
|
|
+ listByCategory.value[key] = currentList.value.filter((_, i) => i !== index);
|
|
|
+ const cat = noticeCategories.value.find(c => c.key === key);
|
|
|
+ if (cat && item.unread) cat.unread = Math.max(0, cat.unread - 1);
|
|
|
+ paginationByCategory.value[key].total = Math.max(0, paginationByCategory.value[key].total - 1);
|
|
|
+ ElMessage.success("删除成功");
|
|
|
+ } catch (e) {
|
|
|
+ ElMessage.error("删除失败");
|
|
|
+ }
|
|
|
}
|
|
|
/** 刷新全部(供 WebSocket 消息到达时实时更新,与商家端一致) */
|
|
|
function refresh() {
|