From 127d4143797490f230ce1c039032db7fa3d5b33e Mon Sep 17 00:00:00 2001 From: yuanlei <18627959669@163.com> Date: Fri, 7 Nov 2025 17:28:40 +0800 Subject: [PATCH] 1 --- pages/setting/about.vue | 4 +- pages/setting/contact.vue | 4 +- pages/setting/setting.vue | 2 +- pages/user/login.vue | 20 ++++- static/style/nine-btn-001.scss | 2 +- uni_modules/vrapile-im/pages/chat/chatFriend.vue | 100 ++++++++++++++++++--- uni_modules/vrapile-im/pages/home/chatHome.vue | 13 ++- .../static/style/nine-chat-friend-001.scss | 44 +++++++++ uni_modules/vrapile-im/store/modules/chat.js | 1 + uni_modules/vrapile-im/store/modules/socket.js | 12 ++- 10 files changed, 177 insertions(+), 25 deletions(-) diff --git a/pages/setting/about.vue b/pages/setting/about.vue index dd8f25a..1a61811 100644 --- a/pages/setting/about.vue +++ b/pages/setting/about.vue @@ -30,10 +30,10 @@ - 九云科技有限公司《服务协议》 + 开放平台《服务协议》 - 九云科技 版权所有 + 平台开发者 版权所有 Copyright © 2024-2031 NineCloud. diff --git a/pages/setting/contact.vue b/pages/setting/contact.vue index 59d83f2..69a536c 100644 --- a/pages/setting/contact.vue +++ b/pages/setting/contact.vue @@ -40,10 +40,10 @@ - 九云科技有限公司《服务协议》 + 开放平台《服务协议》 - 九云科技 版权所有 + 平台开发者 版权所有 Copyright © 2024-2031 NineCloud. diff --git a/pages/setting/setting.vue b/pages/setting/setting.vue index 29ee848..88da276 100644 --- a/pages/setting/setting.vue +++ b/pages/setting/setting.vue @@ -2,7 +2,7 @@ - + 公告中心 diff --git a/pages/user/login.vue b/pages/user/login.vue index 71cb2dd..2bb567b 100644 --- a/pages/user/login.vue +++ b/pages/user/login.vue @@ -37,11 +37,23 @@ 登 录 - 没有账号? + 没有账号? 立即注册 + + + 演示账号登录 + + + + + + + 微信一键登录 + + @@ -131,6 +143,12 @@ this.verifyText = "发送验证码"; } }, + visitorLogin(){ + this.loginType = 0; + this.userName = "visitor"; + this.password = "visitor"; + this.loginClick(); + }, loginClick(){ if(!this.userName){ this.usernamefocus(); diff --git a/static/style/nine-btn-001.scss b/static/style/nine-btn-001.scss index 8734588..c8877d4 100644 --- a/static/style/nine-btn-001.scss +++ b/static/style/nine-btn-001.scss @@ -9,7 +9,7 @@ padding: 20rpx; border-radius: 10rpx; color: #fff; - background-color: #0000ff; + background-color: #0294ee; text-align: center; } // 退出登录 diff --git a/uni_modules/vrapile-im/pages/chat/chatFriend.vue b/uni_modules/vrapile-im/pages/chat/chatFriend.vue index 7f5670e..4a3a771 100644 --- a/uni_modules/vrapile-im/pages/chat/chatFriend.vue +++ b/uni_modules/vrapile-im/pages/chat/chatFriend.vue @@ -16,9 +16,23 @@ - {{getUserName(item.fromId, item.fromName)}} - {{formatTime(item.sendTime)}} - {{item.content}} + {{getUserName(item.fromId, item.toId, item.fromName)}} + {{formatTime(item.sendTime)}} + + + + + + + + + {{item.content}}" + + + {{item.content}} + @@ -30,7 +44,11 @@ - + 按住 说话 @@ -68,6 +86,8 @@ isVoice: false, inputText: "", + startTime: 0, + // 消息唯一key key: null, @@ -168,13 +188,31 @@ handleVoice() { this.isVoice = !this.isVoice; }, + handleTouchStart(e){ + this.startTime = Date.now(); + // 阻止默认行为 + e.preventDefault(); + }, + handleTouchEnd(e) { + this.handleSay(); + // 阻止默认行为 + e.preventDefault(); + }, + startRecord(e) { + // 阻止默认行为 + e.preventDefault(); + }, // 语音消息处理, 暂时先发送个提示 handleSay() { + const duration = Date.now() - this.startTime + if (duration < 500) { + return + } let sendInfo = { code: 2, message: { - //消息文件类型 0-文本|1-图片|2-附件|3-语言|4-撤回 - messageType: 0, + //消息文件类型 0-文本|1-图片|2-表情|3-语音|4-视频|5-附件|9-混合|99-撤回 + messageType: 3, //聊天室id toId: this.chatObject.id, //消息发送人 @@ -182,7 +220,7 @@ //消息发送人账号 fromName: this.userInfo.userName, //消息内容 - content: "您发送了一条语音消息", + content: Math.ceil(duration/1000), //消息类型:0-私聊|1-群聊 sendType: this.chatObject.type, //扩展消息 @@ -195,11 +233,24 @@ }, // 表情消息处理, 暂时先发送个提示 handleEmoji() { + let emojiList = [ + 'daxiao.png', + 'danao.png', + 'shengqi.png', + 'sile.png', + 'xianwen.png' + ] + let randomIndex + let content = [] + do{ + randomIndex = Math.floor(Math.random() * emojiList.length) + content.push(emojiList[randomIndex]) + }while(randomIndex % 3 != 0); let sendInfo = { code: 2, message: { - //消息文件类型 0-文本|1-图片|2-附件|3-语言|4-撤回 - messageType: 0, + //消息文件类型 0-文本|1-图片|2-表情|3-语音|4-视频|5-附件|9-混合|99-撤回 + messageType: 2, //聊天室id toId: this.chatObject.id, //消息发送人 @@ -207,7 +258,7 @@ //消息发送人账号 fromName: this.userInfo.userName, //消息内容 - content: "您发送了一个表情消息", + content: content, //消息类型:0-私聊|1-群聊 sendType: this.chatObject.type, //扩展消息 @@ -224,7 +275,7 @@ code: 2, message: { //消息文件类型 0-文本|1-图片|2-附件|3-语言|4-撤回 - messageType: 0, + messageType: 1, //聊天室id toId: this.chatObject.id, //消息发送人 @@ -232,7 +283,7 @@ //消息发送人账号 fromName: this.userInfo.userName, //消息内容 - content: "您发送了一个更多的消息", + content: this.userInfo.avatar || "https://www.ninecloud.top/unine/static/image/app/nine-app-all.png", //消息类型:0-私聊|1-群聊 sendType: this.chatObject.type, //扩展消息 @@ -305,10 +356,18 @@ this.chatObject["messageList"] = this.messageList; let lastMessage = res.data[res.data.length-1]; this.chatObject["messageLast"] = lastMessage; + let content = lastMessage["content"] + if(lastMessage["messageType"] == 3){ + content = "[语音]" + }else if(lastMessage["messageType"] == 2){ + content = "[表情]" + }else if(lastMessage["messageType"] == 1){ + content = "[图片]" + } if(lastMessage["sendType"] == 0){ - this.chatObject["messageShow"] = lastMessage["content"]; + this.chatObject["messageShow"] = content; }else{ - this.chatObject["messageShow"] = store.getters.getUserName(lastMessage["fromId"], lastMessage["fromName"]) + ": " + lastMessage["content"] + this.chatObject["messageShow"] = store.getters.getUserName(lastMessage["fromId"], lastMessage["fromName"]) + ": " + content } this.chatObject["messageTime"] = this.formatDate(lastMessage["sendTime"]); } @@ -326,6 +385,19 @@ this.scrollToBottom(); } }); + }, + getEmojiList(content){ + if(typeof content === 'object'){ + return content; + } + try{ + return JSON.parse(content.replace(/(\w+\.png)/g, '"$1"')); + }catch(e){ + return new Array; + } + }, + getEmoji(image){ + return '/uni_modules/vrapile-im/static/image/emoji/'+image } } } diff --git a/uni_modules/vrapile-im/pages/home/chatHome.vue b/uni_modules/vrapile-im/pages/home/chatHome.vue index abdfb41..8695832 100644 --- a/uni_modules/vrapile-im/pages/home/chatHome.vue +++ b/uni_modules/vrapile-im/pages/home/chatHome.vue @@ -146,6 +146,7 @@ // 获取历史消息 handleHistoryMessage(i, scrollFlag){ let limit = this.getChatList[i]["messageList"].length + 10; + // 后续将作废此接口,改为批量查询/im/message/getMessageByPatchChatKey getMessageByChatKey({ type: this.getChatList[i].type, key: this.getChatList[i]["key"], @@ -156,10 +157,18 @@ this.getChatList[i]["messageList"] = res.data; let lastMessage = res.data[res.data.length-1]; this.getChatList[i]["messageLast"] = lastMessage; + let content = lastMessage["content"] + if(lastMessage["messageType"] == 3){ + content = "[语音]" + }else if(lastMessage["messageType"] == 2){ + content = "[表情]" + }else if(lastMessage["messageType"] == 1){ + content = "[图片]" + } if(lastMessage["sendType"] == 0){ - this.getChatList[i]["messageShow"] = lastMessage["content"]; + this.getChatList[i]["messageShow"] = content; }else{ - this.getChatList[i]["messageShow"] = store.getters.getUserName(lastMessage["fromId"], lastMessage["fromName"]) + ": " + lastMessage["content"] + this.getChatList[i]["messageShow"] = store.getters.getUserName(lastMessage["fromId"], lastMessage["fromName"]) + ": " + content } this.getChatList[i]["messageTime"] = this.formatDate(lastMessage["sendTime"]); } diff --git a/uni_modules/vrapile-im/static/style/nine-chat-friend-001.scss b/uni_modules/vrapile-im/static/style/nine-chat-friend-001.scss index 3adce89..761fc7a 100644 --- a/uni_modules/vrapile-im/static/style/nine-chat-friend-001.scss +++ b/uni_modules/vrapile-im/static/style/nine-chat-friend-001.scss @@ -107,6 +107,50 @@ html, body, #app{ padding: 5rpx; border-radius: 10rpx; } +.chat-conversation-text-image{ + padding: 5px; + width: 100%; +} +.chat-conversation-text-image-image{ + width: 100%; +} +.chat-conversation-text-emoji{ + flex-direction: row; + flex-wrap: wrap; + align-content: flex-start; +} +.chat-conversation-text-emoji-image{ + width: 80rpx; + height: 80rpx; + margin: 2rpx; +} +.chat-conversation-text-voice{ + flex-direction: row; + align-items: center; + padding: 15rpx; +} +.chat-conversation-text-voice-number{ + text-align: left; + white-space: nowrap; + overflow: hidden; + flex: 1; +} +.chat-conversation-text-voice-image{ + margin-right: 25rpx; + width: 30rpx; + height: 30rpx; +} +.chat-conversation-mine .chat-conversation-text-voice{ + flex-direction: row-reverse; +} +.chat-conversation-mine .chat-conversation-text-voice-number{ + text-align: right; +} +.chat-conversation-mine .chat-conversation-text-voice-image{ + margin-right: 0rpx; + margin-left: 25rpx; + transform: rotate(180deg); +} .chat-footer { position: fixed; diff --git a/uni_modules/vrapile-im/store/modules/chat.js b/uni_modules/vrapile-im/store/modules/chat.js index 70222fc..8e6d880 100644 --- a/uni_modules/vrapile-im/store/modules/chat.js +++ b/uni_modules/vrapile-im/store/modules/chat.js @@ -104,6 +104,7 @@ const chat = { delete itemGroup["updateTime"]; listGroup.push({type: 1, ...itemGroup}); // 查询群组人员 + // 后面将作废此接口 改为批量查询 /im/groupUser/getPatchGroupUser getGroupUser(itemGroup.id).then(res2 => { for(let itemGroupUser of res2.data){ delete itemGroupUser["createBy"]; diff --git a/uni_modules/vrapile-im/store/modules/socket.js b/uni_modules/vrapile-im/store/modules/socket.js index aed2847..c2f1fb9 100644 --- a/uni_modules/vrapile-im/store/modules/socket.js +++ b/uni_modules/vrapile-im/store/modules/socket.js @@ -36,10 +36,18 @@ const socket = { // if(store.state.user.userInfo.userId && store.state.user.userInfo.userId != message["fromId"]){ store.state.chat.chatList[i]["messageNum"] += 1; // } + let content = message["content"] + if(message["messageType"] == 3){ + content = "[语音]" + }else if(message["messageType"] == 2){ + content = "[表情]" + }else if(message["messageType"] == 1){ + content = "[图片]" + } if(store.state.chat.chatList[i]["type"] == 0){ - store.state.chat.chatList[i]["messageShow"] = message["content"]; + store.state.chat.chatList[i]["messageShow"] = content; }else{ - store.state.chat.chatList[i]["messageShow"] = store.getters.getUserName(message["fromId"], message["fromName"]) + ": " + message["content"] + store.state.chat.chatList[i]["messageShow"] = store.getters.getUserName(message["fromId"], message["fromName"]) + ": " + content } storage.set(constant.chatList, store.state.chat.chatList); break;