From d56c37facb58a2d905a88214023bce795547fcbc Mon Sep 17 00:00:00 2001 From: 15004070936 <1097449274@qq.com> Date: Fri, 11 Sep 2026 17:53:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8A=95=E8=AF=89=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 37 ++- common/enums.js | 4 +- common/utils.js | 12 +- main.js | 1 + manifest.json | 4 +- pages.json | 33 ++- pages/chatbox/chat-box.vue | 293 ++++++++++++++++++- pages/chatbox/report.vue | 563 +++++++++++++++++++++++++++++++++++++ pages/login/login.vue | 54 ++-- pages/user/userEdit.vue | 23 +- store/chatStore.js | 69 ++++- utils/utils.js | 20 +- 12 files changed, 1033 insertions(+), 80 deletions(-) create mode 100644 pages/chatbox/report.vue diff --git a/App.vue b/App.vue index b726a1b..ccc2c3e 100644 --- a/App.vue +++ b/App.vue @@ -29,7 +29,7 @@ }, computed: { ...mapState('chatStore', ['chats']) - }, + }, onLaunch() { // 判断版本更新 需要真机进行测试 //checkupdate(); @@ -114,19 +114,19 @@ // url: `/pages/chatbox/chat` // }); } - + if(!extras){ uni.reLaunch({ url: `/pages/chatbox/chat` }); } } - + // 消息推送事件 if (notificationEventType == 'notificationArrived') { - + } - + }); jpushModule.getRegistrationID(result => { console.log("极光推送--注册ID", result.registerID) @@ -164,8 +164,8 @@ uni.navigateTo({ url: "/pages/login/login" }) - } - + } + // 未读消息总数(用于角标) let count = 0 myCache("this.chats",this.chats); @@ -176,9 +176,9 @@ }); myCache("massageCount",count); console.log("massageCountmassageCount",count); - + //--------------------------------------------------- - }, + }, methods: { ...mapActions('chatStore'), //--------------------------------------------------- @@ -307,7 +307,9 @@ } }, handlePrivateMessage(msg) { - msg.selfSend = msg.sendId === this.userId; + msg.selfSend = String(msg.sendId) === String(this.userId); + console.log("msg.sendId",msg.sendId) + console.log("this.userId",this.userId) const friendId = msg.selfSend ? msg.recvId : msg.sendId; const chatInfo = { type: 'PRIVATE', targetId: friendId }; const type=Number(msg.type) @@ -326,10 +328,17 @@ this.$store.dispatch('chatStore/readedMessage', { friendId: msg.sendId }); return; } + //撤回 if (type === enums.MESSAGE_TYPE.RECALL) { this.$store.dispatch('chatStore/recallMessage', { msgInfo: msg, chatInfo }); return; } + //屏蔽违规信息 + if (type === enums.MESSAGE_TYPE.BLOCKED) { + this.$store.dispatch('chatStore/blockMessage', { msgInfo: msg, chatInfo }); + return; + } + //更新好友列表 if (type === enums.MESSAGE_TYPE.FRIEND_NEW) { this.$store.dispatch('friendStore/addFriend', JSON.parse(msg.content)); // this.friendStore.addFriend(JSON.parse(msg.content)); @@ -355,7 +364,8 @@ }, handleGroupMessage(msg) { - msg.selfSend = msg.sendId === this.userId; + msg.selfSend = String(msg.sendId) === String(this.userId); + // msg.selfSend = msg.sendId === this.userId; const chatInfo = { type: 'GROUP', targetId: msg.groupId }; const type=Number(msg.type) if (type === enums.MESSAGE_TYPE.LOADING) { @@ -383,6 +393,11 @@ this.$store.dispatch('chatStore/recallMessage', { msgInfo: msg, chatInfo }); return; } + //屏蔽违规信息 + if (type === enums.MESSAGE_TYPE.BLOCKED) { + this.$store.dispatch('chatStore/blockMessage', { msgInfo: msg, chatInfo }); + return; + } if (type === enums.MESSAGE_TYPE.GROUP_NEW) { this.$store.dispatch('groupStore/addGroup', JSON.parse(msg.content)); return; diff --git a/common/enums.js b/common/enums.js index 1521c87..fea5c87 100644 --- a/common/enums.js +++ b/common/enums.js @@ -7,6 +7,7 @@ const MESSAGE_TYPE = { VIDEO: 4, ORDER: 5, PRODUCT: 6, + BLOCKED: 7, RECALL: 10, READED: 11, RECEIPT: 12, @@ -57,7 +58,8 @@ const MESSAGE_STATUS = { UNSEND: 0, SENDED: 1, RECALL: 2, - READED: 3 + READED: 3, + BLOCKED:4 } export { diff --git a/common/utils.js b/common/utils.js index e9d6462..b1cf623 100644 --- a/common/utils.js +++ b/common/utils.js @@ -1,4 +1,4 @@ - + var utils = { //时间格式化 formatDate: (value) => { @@ -47,10 +47,10 @@ MM = MM < 10 ? ('0' + MM) : MM; let d = date.getDate(); d = d < 10 ? ('0' + d) : d; - + return y + '/' + MM + '/' + d; }, - + //字典数据根据key显示文字 dataFilter:(arr, val='')=> { let name = ""; @@ -63,7 +63,7 @@ }); return name; }, - + //列表转换为树格式 listtoTree:(data)=>{ let result = []; @@ -88,8 +88,8 @@ return result; }, getRemoteFile: (path) => { - return `https://www.sanduolantoyoga.com/yoga${path}`; + return `https://yoga.runpengsoft.com/yoga${path}`; } } // 格式化日期 - export default utils; \ No newline at end of file + export default utils; diff --git a/main.js b/main.js index 3d13af4..7f50ce3 100644 --- a/main.js +++ b/main.js @@ -95,6 +95,7 @@ $http.afterRequest = function (response) { }, 2000); } else { + return } } diff --git a/manifest.json b/manifest.json index 45e1e9e..381dfe0 100644 --- a/manifest.json +++ b/manifest.json @@ -18,7 +18,7 @@ } }, "compatible" : { - "ignoreVersion" : true //true表示忽略版本检查提示框,HBuilderX1.9.0及以上版本支持 + "ignoreVersion" : true //true表示忽略版本检查提示框,HBuilderX1.9.0及以上版本支持 }, "splashscreen" : { "alwaysShowBeforeRender" : true, @@ -385,7 +385,7 @@ "disableHostCheck" : true, //禁用 Host 检查 "proxy" : { "/apis" : { - "target" : "https://www.sanduolantoyoga.com", + "target" : "https://yoga.runpengsoft.com", "changeOrigin" : true, "secure" : false, "pathRewrite" : { diff --git a/pages.json b/pages.json index 4d6aba1..cb8b818 100644 --- a/pages.json +++ b/pages.json @@ -172,11 +172,28 @@ "path" : "pages/chatbox/chat-box", "style" : { - "navigationBarTitleText": "消息2", - "enablePullDownRefresh": false + "navigationBarTitleText": "消息", + "enablePullDownRefresh": false, + "app-plus": { + "titleNView": { + "buttons": [ + { + "text": "\uE684", // 使用 unicode 或字体图标,此处为三个点的 Unicode(需引入 iconfont) + "fontSrc": "/static/font.ttf", // 如果使用自定义字体需指定 + "fontSize": "22px", + "float": "right" + } + ] + } + } + } + }, + { + "path": "pages/chatbox/report", + "style": { + "navigationBarTitleText": "投诉举报" } }, - { "path" : "pages/product/list", "style": { @@ -440,10 +457,10 @@ "enablePullDownRefresh": false } }, - + { "path" : "pages/user/info", - "style" : + "style" : { "navigationBarTitleText": "", "enablePullDownRefresh": false @@ -451,7 +468,7 @@ }, { "path" : "pages/user/infofw", - "style" : + "style" : { "navigationBarTitleText": "用户服务协议", "enablePullDownRefresh": false @@ -459,13 +476,13 @@ }, { "path" : "pages/user/infoys", - "style" : + "style" : { "navigationBarTitleText": "隐私政策条款", "enablePullDownRefresh": false } }, - + // ……其他页面配置 更新版本 { diff --git a/pages/chatbox/chat-box.vue b/pages/chatbox/chat-box.vue index fff01db..e547975 100644 --- a/pages/chatbox/chat-box.vue +++ b/pages/chatbox/chat-box.vue @@ -11,6 +11,31 @@ > + + + + + + + + + + + + + @@ -34,6 +60,23 @@ + + + + 已选 {{ selectedMessageIds.length }} 条 + + + + + + + + + 请选择操作 + 投诉 + 取消 + + @@ -81,7 +124,12 @@ export default { isReadOnly: false, playingAudio: null, isInBottom: true, - newMessageSize: 0 + newMessageSize: 0, + // ===== 投诉选择模式 ===== + selectionMode: false, // 是否处于选择模式 + selectedMessageIds: [], // 已选中的消息ID列表 + showReportMenu: false, // 是否显示投诉底部弹窗(投诉 / 取消) + selectableTypes: [0, 'TEXT', 1, 'IMAGE', 2, 'AUDIO', 3, 'VIDEO'] // 可选的消息类型 }; }, computed: { @@ -206,6 +254,9 @@ export default { }, onUnload() { this.unListenKeyboard(); + // 退出时重置选择模式 + this.selectionMode = false; + this.selectedMessageIds = []; }, onShow() { if (this.needScrollToBottom) { @@ -216,6 +267,113 @@ export default { }, methods: { + // ==================== 投诉选择模式 ==================== + /** + * 获取可选的消息列表(排除系统提示消息) + */ + getAvailableMessages() { + return (this.chat?.messages || []).filter(msg => { + // 排除系统提示类型 + if (msg.type === 'TIP_TEXT') return false; + // 排除已经被撤回的消息 + if (msg.isRecalled) return false; + return true; + }); + }, + canReport(msgInfo) { + if (!msgInfo) return false + // 1. 本人发送的消息不能投诉 + if (msgInfo.selfSend) return false + // 2. 系统提示消息不能投诉(如"撤回了一条消息"等) + if (msgInfo.type === 21) return false + + if (msgInfo.type === 20) return false + return true + }, + /** + * 切换选择模式 + */ + enterSelectionMode() { + this.showReportMenu = false; // 关闭底部弹窗 + this.selectionMode = true; + this.selectedMessageIds = []; + // 隐藏键盘 + uni.hideKeyboard(); + // 关闭其他面板 + this.switchChatTabBox('none'); + }, + + /** + * 关闭投诉底部弹窗 + */ + closeReportMenu() { + this.showReportMenu = false; + }, + + /** + * 取消选择模式 + */ + cancelSelection() { + this.selectionMode = false; + this.selectedMessageIds = []; + }, + + /** + * 切换单条消息的选中状态 + */ + toggleSelectMessage(msgId) { + // 查找消息 + const msg = this.chat.messages.find(m => m.id === msgId); + if (!msg || !this.canReport(msg)) return + + const idx = this.selectedMessageIds.indexOf(msgId); + if (idx > -1) { + this.selectedMessageIds.splice(idx, 1); + } else { + this.selectedMessageIds.push(msgId); + } + }, + + /** + * 点击"下一步":校验选择并跳转到投诉页 + */ + nextStep() { + if (this.selectedMessageIds.length === 0) { + uni.showToast({ title: '请至少选择一条消息', icon: 'none' }); + return; + } + + // 构建投诉页参数 + const sendType = this.chat.type === 'GROUP' ? '1' : '2'; + const senderId = this.chat.targetId; + const senderName = this.chat.showName || ''; + const senderAvatar = this.chat.headImage || ''; + + // 将选中的消息ID存入本地缓存,供投诉页读取(避免URL参数过长) + // 按选中顺序提取完整聊天记录 + const selectedRecords = this.selectedMessageIds + .map(id => this.chat.messages.find(m => m.id === id)) + .filter(msg => !!msg); + // 直接存储完整聊天记录(含全部消息字段),供投诉页读取 + uni.setStorageSync('report_selected_messages', selectedRecords); + uni.setStorageSync('report_send_type', sendType); + uni.setStorageSync('report_sender_id', senderId); + uni.setStorageSync('report_sender_name', senderName); + uni.setStorageSync('report_sender_avatar', senderAvatar); + // 退出选择模式 + this.selectionMode = false; + this.selectedMessageIds = []; + + // 跳转投诉页 + uni.navigateTo({ + url: `/pages/chatbox/report?sendType=${sendType}&senderId=${senderId}&fromChat=true` + }); + }, + onNavigationBarButtonTap(e) { + // 点击右上角符号:弹出底部操作菜单(投诉 / 取消) + if (this.selectionMode) return; // 选择模式中忽略 + this.showReportMenu = true; + }, // 映射 Vuex actions ...mapActions('chatStore', [ 'insertMessage', @@ -1190,4 +1348,137 @@ export default { } } + +/* ========== 选择模式样式 ========== */ +.message-wrapper { + display: flex; + align-items: flex-start; + padding: 4rpx 0; + transition: background 0.2s; + + /* 本人发送的消息:整行靠右,保持消息原右侧位置不变 */ + &.self { + flex-direction: row-reverse; + justify-content: flex-start; + } +} + +.message-wrapper .checkbox-container { + padding: 20rpx 12rpx 0 16rpx; + flex-shrink: 0; + align-self: stretch; +} + +.checkbox { + width: 42rpx; + height: 42rpx; + border-radius: 50%; + border: 2rpx solid #ccc; + display: flex; + align-items: center; + justify-content: center; + font-size: 24rpx; + color: #fff; + flex-shrink: 0; + background: #fff; + transition: all 0.2s; + &.checked { + background: $im-color-primary; + border-color: $im-color-primary; + } +} + +/* ========== 底部选择操作栏 ========== */ +.selection-bar { + position: fixed; + bottom: 0; + left: 0; + right: 0; + background: #ffffff; + border-top: 1rpx solid #e8e8e8; + padding: 16rpx 24rpx; + padding-bottom: env(safe-area-inset-bottom, 16rpx); + display: flex; + align-items: center; + justify-content: flex-end; + z-index: 1000; + box-shadow: 0 -4rpx 20rpx rgba(0,0,0,0.06); + + .selection-right { + display: flex; + align-items: center; + gap: 16rpx; + .selection-count { + font-size: 26rpx; + color: #999; + margin-right: 8rpx; + } + .btn-cancel-selection { + padding: 10rpx 28rpx; + height: 60rpx; + line-height: 40rpx; + background: #f5f7fa; + color: #666; + font-size: 26rpx; + border-radius: 30rpx; + border: none; + } + .btn-confirm-selection { + padding: 10rpx 32rpx; + height: 60rpx; + line-height: 40rpx; + background: $im-color-primary; + color: #fff; + font-size: 26rpx; + border-radius: 30rpx; + border: none; + box-shadow: 0 4rpx 12rpx $im-color-primary; + &:disabled { + background: #ccc; + box-shadow: none; + } + } + } +} + +/* ========== 投诉底部弹窗样式 ========== */ +.report-menu-mask { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.45); + z-index: 999; + display: flex; + align-items: flex-end; +} +.report-menu-panel { + width: 100%; + background: #ffffff; + border-radius: 24rpx 24rpx 0 0; + padding-bottom: env(safe-area-inset-bottom, 24rpx); + overflow: hidden; +} +.report-menu-title { + text-align: center; + font-size: 26rpx; + color: #999999; + padding: 24rpx 0 12rpx; +} +.report-menu-item { + height: 100rpx; + line-height: 100rpx; + text-align: center; + font-size: 32rpx; + color: #333333; + border-top: 1rpx solid #f0f0f0; + &:active { + background: #f5f5f5; + } +} +.report-menu-complain { + color: $im-color-primary; + font-weight: 600; +} diff --git a/pages/chatbox/report.vue b/pages/chatbox/report.vue new file mode 100644 index 0000000..580cd57 --- /dev/null +++ b/pages/chatbox/report.vue @@ -0,0 +1,563 @@ +