diff --git a/im-uniapp/common/recorder-app.js b/im-uniapp/common/recorder-app.js index dce0cbf..e525ef4 100644 --- a/im-uniapp/common/recorder-app.js +++ b/im-uniapp/common/recorder-app.js @@ -39,12 +39,18 @@ let upload = () => { filePath: wavFile.tempFilePath, name: 'file', success: (res) => { - const duration = (new Date().getTime() - startTime.getTime()) / 1000 - const data = { - duration: Math.round(duration), - url: JSON.parse(res.data).data + let r = JSON.parse(res.data); + if (r.code != 200) { + reject(r.message); + } else { + const duration = (new Date().getTime() - startTime.getTime()) / + 1000 + const data = { + duration: Math.round(duration), + url: r.data + } + resolve(data); } - resolve(data); }, fail: (e) => { reject(e); diff --git a/im-uniapp/common/recorder-h5.js b/im-uniapp/common/recorder-h5.js index 1f435ca..b174081 100644 --- a/im-uniapp/common/recorder-h5.js +++ b/im-uniapp/common/recorder-h5.js @@ -33,11 +33,17 @@ let upload = () => { file: file, name: 'file', success: (res) => { - const data = { - duration: parseInt(rc.duration), - url: JSON.parse(res.data).data + let r = JSON.parse(res.data); + if(r.code != 200){ + console.log(res) + reject(r.message); + }else { + const data = { + duration: parseInt(rc.duration), + url: r.data + } + resolve(data); } - resolve(data); }, fail: (e) => { reject(e); diff --git a/im-uniapp/components/chat-item/chat-item.vue b/im-uniapp/components/chat-item/chat-item.vue index 894e832..5db43c3 100644 --- a/im-uniapp/components/chat-item/chat-item.vue +++ b/im-uniapp/components/chat-item/chat-item.vue @@ -8,9 +8,12 @@ + + + {{chat.showName}} - + {{$date.toTimeText(chat.lastSendTime,true)}} @@ -121,7 +124,13 @@ display: flex; line-height: 44rpx; height: 44rpx; - + + .chat-tag { + display: flex; + align-items: center; + margin-right: 3rpx; + } + .chat-name-text { flex: 1; font-size: 30rpx; diff --git a/im-uniapp/components/chat-message-item/chat-message-item.vue b/im-uniapp/components/chat-message-item/chat-message-item.vue index 9ed32be..b447b2e 100644 --- a/im-uniapp/components/chat-message-item/chat-message-item.vue +++ b/im-uniapp/components/chat-message-item/chat-message-item.vue @@ -2,62 +2,68 @@ - {{msgInfo.content}} + {{msgInfo.content}} + {{$date.toTimeText(msgInfo.sendTime)}} - - + {{showName}} - - - - + + + + + - - - - - + + + + + + + - - - - {{fileSize}} + + + + + {{fileSize}} + + + - - - + - - - {{JSON.parse(msgInfo.content).duration+'"'}} - - - - - - - {{msgInfo.content}} - + + + + {{JSON.parse(msgInfo.content).duration+'"'}} + + + + + + + + + {{msgInfo.content}} + + 已读 @@ -72,8 +78,7 @@ - + @@ -106,36 +111,8 @@ style: "" } } - }, methods: { - onShowMenu(e) { - uni.getSystemInfo({ - success: (res) => { - let touches = e.touches[0]; - let style = ""; - /* 因 非H5端不兼容 style 属性绑定 Object ,所以拼接字符 */ - if (touches.clientY > (res.windowHeight / 2)) { - style = `bottom:${res.windowHeight-touches.clientY}px;`; - } else { - style = `top:${touches.clientY}px;`; - } - if (touches.clientX > (res.windowWidth / 2)) { - style += `right:${res.windowWidth-touches.clientX}px;`; - } else { - style += `left:${touches.clientX}px;`; - } - this.menu.style = style; - // - this.$nextTick(() => { - this.menu.show = true; - }); - } - }) - }, - onHideMenu(){ - this.menu.show = false; - }, onSendFail() { uni.showToast({ title: "该文件已发送失败,目前不支持自动重新发送,建议手动重新发送", @@ -148,11 +125,12 @@ this.innerAudioContext = uni.createInnerAudioContext(); let url = JSON.parse(this.msgInfo.content).url; this.innerAudioContext.src = url; + console.log(url); this.innerAudioContext.onEnded((e) => { console.log('停止') this.audioPlayState = "STOP" }) - this.innerAudioContext.onError((e) =>{ + this.innerAudioContext.onError((e) => { console.log("播放音频出错"); console.log(e) }); @@ -226,7 +204,7 @@ } return items; }, - isAction(){ + isAction() { return this.$msgType.isAction(this.msgInfo.type); }, isNormal() { @@ -292,7 +270,7 @@ display: block; word-break: break-all; white-space: pre-line; - + &:after { content: ""; @@ -484,6 +462,7 @@ padding-right: 0; padding-left: 8px; } + .icon-voice-play { transform: rotateY(180deg); } diff --git a/im-uniapp/components/chat-record/chat-record.vue b/im-uniapp/components/chat-record/chat-record.vue index c692da8..ce77c32 100644 --- a/im-uniapp/components/chat-record/chat-record.vue +++ b/im-uniapp/components/chat-record/chat-record.vue @@ -99,7 +99,6 @@ }) }).finally(() => { this.$rc.close(); - console.log("录音完成") }) }, startTimer() { @@ -132,7 +131,7 @@ return `bottom:${bottom}px;` }, recordBarStyle() { - const bgColor = this.recording ? "royalblue" : "#f8f8f8"; + const bgColor = this.recording ? "royalblue" : "white"; const textColor = this.recording ? "white" : "black"; return `background-color:${bgColor}; color:${textColor};` diff --git a/im-uniapp/components/pop-menu/pop-menu.vue b/im-uniapp/components/pop-menu/pop-menu.vue index 9be47f7..31c611d 100644 --- a/im-uniapp/components/pop-menu/pop-menu.vue +++ b/im-uniapp/components/pop-menu/pop-menu.vue @@ -1,7 +1,11 @@ @@ -36,6 +35,7 @@ show: false, style: "", chatIdx: -1, + isTouchMove: false, items: [{ key: 'DELETE', name: '删除该聊天', @@ -52,49 +52,19 @@ } }, methods: { - onSelectMenu(item) { + onSelectMenu(item,chatIdx) { switch (item.key) { case 'DELETE': - this.removeChat(this.menu.chatIdx); + this.removeChat(chatIdx); break; case 'TOP': - this.moveToTop(this.menu.chatIdx); + this.moveToTop(chatIdx); break; default: break; } this.menu.show = false; }, - onShowMenu(e, chatIdx) { - this.menu.chatIdx = chatIdx; - uni.getSystemInfo({ - success: (res) => { - let touches = e.touches[0]; - let style = ""; - /* 因 非H5端不兼容 style 属性绑定 Object ,所以拼接字符 */ - if (touches.clientY > (res.windowHeight / 2)) { - style = `bottom:${res.windowHeight-touches.clientY}px;`; - } else { - style = `top:${touches.clientY}px;`; - } - if (touches.clientX > (res.windowWidth / 2)) { - style += `right:${res.windowWidth-touches.clientX}px;`; - } else { - style += `left:${touches.clientX}px;`; - } - this.menu.style = style; - this.menu.chatIdx = chatIdx; - // - this.$nextTick(() => { - this.menu.show = true; - }); - } - }) - }, - onCloseMenu() { - this.menu.chatIdx = -1; - this.menu.show = false; - }, removeChat(chatIdx) { this.$store.commit("removeChat", chatIdx); }, diff --git a/im-uniapp/pages/login/login.vue b/im-uniapp/pages/login/login.vue index d686bef..cf8489a 100644 --- a/im-uniapp/pages/login/login.vue +++ b/im-uniapp/pages/login/login.vue @@ -10,8 +10,7 @@ - + 没有账号,前往注册 diff --git a/im-uniapp/pages/register/register.vue b/im-uniapp/pages/register/register.vue index 1d302df..fd7c853 100644 --- a/im-uniapp/pages/register/register.vue +++ b/im-uniapp/pages/register/register.vue @@ -16,7 +16,7 @@ -