update 群聊
This commit is contained in:
parent
9d2bec920f
commit
b99bce26e4
@ -7,8 +7,8 @@ var hostGo = ''
|
|||||||
|
|
||||||
// if (_NODE_) {
|
// if (_NODE_) {
|
||||||
// host = 'https://love.ufutx.com/api' // 线上环境
|
// host = 'https://love.ufutx.com/api' // 线上环境
|
||||||
// hostGo = 'https://love.ufutx.com/go/api' // 线上环境
|
hostGo = 'https://love.ufutx.com/go/api' // 线上环境
|
||||||
host = 'http://love.ufutx.net/go/api' // 本地环境
|
// host = 'http://love.ufutx.net/go/api' // 本地环境
|
||||||
// hostGo = 'http://health.ufutx.net/go/api' // 本地环境
|
// hostGo = 'http://health.ufutx.net/go/api' // 本地环境
|
||||||
// } else {
|
// } else {
|
||||||
// host = 'https://love.ufutx.com/api' // 线上环境
|
// host = 'https://love.ufutx.com/api' // 线上环境
|
||||||
|
|||||||
@ -560,7 +560,7 @@ page {
|
|||||||
<template>
|
<template>
|
||||||
<view class="ui-chitchat">
|
<view class="ui-chitchat">
|
||||||
<image class="m_tips_icon" src="https://image.fulllinkai.com/202305/05/2172ea48286be34e3a4e80a8c2a4571a.png" mode="aspectFit" @tap="reportShow = true"></image>
|
<image class="m_tips_icon" src="https://image.fulllinkai.com/202305/05/2172ea48286be34e3a4e80a8c2a4571a.png" mode="aspectFit" @tap="reportShow = true"></image>
|
||||||
<scroll-view class="ui-scroll-view" style="height: {{windowHeight - bottomBoxH}}rpx;" scroll-y="true" upper-threshold="50" bindscrolltoupper="getHistoryMsg" scroll-into-view="{{toView}}" enable-flex="{{true}}">
|
<scroll-view class="ui-scroll-view" style="height: {{windowHeight - bottomBoxH}}rpx;" :scroll-y="scrollY" upper-threshold="50" bindscrolltoupper="getHistoryMsg" scroll-into-view="{{toView}}" enable-flex="{{true}}">
|
||||||
<view class="ui-top-placeholder"></view>
|
<view class="ui-top-placeholder"></view>
|
||||||
<block v-show="loading">
|
<block v-show="loading">
|
||||||
<image v-if="chatInfoData.other_real_approved != 1" class="ui-tips-pic" src="https://image.fulllinkai.com/202203/22/2a0d6bba0289f28b8d816e4deb1efa4c.png" mode="widthFix"></image>
|
<image v-if="chatInfoData.other_real_approved != 1" class="ui-tips-pic" src="https://image.fulllinkai.com/202203/22/2a0d6bba0289f28b8d816e4deb1efa4c.png" mode="widthFix"></image>
|
||||||
@ -715,6 +715,7 @@ wepy.page({
|
|||||||
|
|
||||||
recorderManager: wx.getRecorderManager(),
|
recorderManager: wx.getRecorderManager(),
|
||||||
startPoint: 0,
|
startPoint: 0,
|
||||||
|
scrollY: true,
|
||||||
sendLock: true, // audio发送锁
|
sendLock: true, // audio发送锁
|
||||||
microphoneShow: false,
|
microphoneShow: false,
|
||||||
microphoneType: false, // 按住或松开
|
microphoneType: false, // 按住或松开
|
||||||
@ -838,7 +839,6 @@ wepy.page({
|
|||||||
vm.openShow = false
|
vm.openShow = false
|
||||||
vm.uploadState = true
|
vm.uploadState = true
|
||||||
vm.progressValue = 5
|
vm.progressValue = 5
|
||||||
try {
|
|
||||||
app.globalData.nim.msg.sendImageMsg({
|
app.globalData.nim.msg.sendImageMsg({
|
||||||
scene: 'p2p',
|
scene: 'p2p',
|
||||||
to: vm.otherUserId,
|
to: vm.otherUserId,
|
||||||
@ -876,9 +876,6 @@ wepy.page({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (err) {
|
|
||||||
vm.sendFileError()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
// 发送视频
|
// 发送视频
|
||||||
sendVideos(file) {
|
sendVideos(file) {
|
||||||
@ -1081,6 +1078,8 @@ wepy.page({
|
|||||||
}
|
}
|
||||||
if (item.content_type == 'text' && /\[[^\]]+\]/.test(item.content)) {
|
if (item.content_type == 'text' && /\[[^\]]+\]/.test(item.content)) {
|
||||||
item.body = vm.transitionMsg(item.content)
|
item.body = vm.transitionMsg(item.content)
|
||||||
|
} else {
|
||||||
|
item.body = item.content
|
||||||
}
|
}
|
||||||
vm.lastTime = format(item.time)
|
vm.lastTime = format(item.time)
|
||||||
})
|
})
|
||||||
@ -1091,7 +1090,7 @@ wepy.page({
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
data.forEach((item) => {
|
data.forEach((item) => {
|
||||||
vm.msgList.unshift({
|
vm.msgList.unshift({
|
||||||
text: item.content,
|
text: item.body,
|
||||||
attach: vm.calculatePic(item.attach, item.content_type),
|
attach: vm.calculatePic(item.attach, item.content_type),
|
||||||
id: `id_${item.time}`,
|
id: `id_${item.time}`,
|
||||||
timestamp: item.time,
|
timestamp: item.time,
|
||||||
@ -1109,21 +1108,24 @@ wepy.page({
|
|||||||
})
|
})
|
||||||
console.log(vm.msgList, data[0].time, '88888888888888888')
|
console.log(vm.msgList, data[0].time, '88888888888888888')
|
||||||
vm.$nextTick(() => {
|
vm.$nextTick(() => {
|
||||||
if (vm.msgList.length < 8) {
|
|
||||||
vm.toView = `id_${data[0].time}`
|
vm.toView = `id_${data[0].time}`
|
||||||
|
if (vm.msgList.length > 15) {
|
||||||
|
vm.scrollY = false
|
||||||
}
|
}
|
||||||
vm.lastId = `${data[data.length - 1].id}`
|
vm.lastId = `${data[data.length - 1].id}`
|
||||||
vm.loading = true
|
vm.loading = true
|
||||||
// 防止撑开触发加载历史数据
|
// 防止撑开触发加载历史数据
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
vm.uploadState = false
|
vm.uploadState = false
|
||||||
|
vm.scrollY = true
|
||||||
}, 500)
|
}, 500)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
vm.loading = true
|
vm.loading = true
|
||||||
|
vm.scrollY = true
|
||||||
}
|
}
|
||||||
if (data && data.length < 7) {
|
if (data && data.length < 15) {
|
||||||
vm.finished = true
|
vm.finished = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -529,7 +529,7 @@ page {
|
|||||||
<template>
|
<template>
|
||||||
<view class="ui-groupChitchat">
|
<view class="ui-groupChitchat">
|
||||||
<image class="m_tips_icon" @tap="jumpDetailPath" src="https://image.fulllinkai.com/202307/24/8c9d68ecf83230ea5e394aa98ef1765d.png" mode="aspectFit"></image>
|
<image class="m_tips_icon" @tap="jumpDetailPath" src="https://image.fulllinkai.com/202307/24/8c9d68ecf83230ea5e394aa98ef1765d.png" mode="aspectFit"></image>
|
||||||
<scroll-view class="ui-scroll-view" style="height: {{windowHeight - bottomBoxH}}rpx;" scroll-y="true" upper-threshold="50" bindscrolltoupper="getHistoryMsg" scroll-into-view="{{toView}}" enable-flex="{{true}}">
|
<scroll-view class="ui-scroll-view" style="height: {{windowHeight - bottomBoxH}}rpx;" :scroll-y="scrollY" upper-threshold="50" bindscrolltoupper="getHistoryMsg" scroll-into-view="{{toView}}" enable-flex="{{true}}">
|
||||||
<view class="ui-top-placeholder"></view>
|
<view class="ui-top-placeholder"></view>
|
||||||
<view class="ui-tips-box" v-show="loading">
|
<view class="ui-tips-box" v-show="loading">
|
||||||
<view class="font_28 color333 bold">
|
<view class="font_28 color333 bold">
|
||||||
@ -543,7 +543,7 @@ page {
|
|||||||
<view class="ui-msg-data-box" v-show="msgList.length > 0">
|
<view class="ui-msg-data-box" v-show="msgList.length > 0">
|
||||||
<!-- <view class="text-center font_2 ui-pb-24 color666" v-if="finished">没有更多消息了</view>-->
|
<!-- <view class="text-center font_2 ui-pb-24 color666" v-if="finished">没有更多消息了</view>-->
|
||||||
<view v-for="(item, index) in msgList" :key="index" class="ui-msg-data" id="{{item.id}}">
|
<view v-for="(item, index) in msgList" :key="index" class="ui-msg-data" id="{{item.id}}">
|
||||||
<block v-if="item.msgType == 'notification' && item.tips">
|
<block v-if="item.msgType == '7' && item.tips">
|
||||||
<!--群消息通知-->
|
<!--群消息通知-->
|
||||||
<view class="text-center color999 font_24">{{item.tips}}</view>
|
<view class="text-center color999 font_24">{{item.tips}}</view>
|
||||||
</block>
|
</block>
|
||||||
@ -555,20 +555,20 @@ page {
|
|||||||
<view class="ui-relative">
|
<view class="ui-relative">
|
||||||
<view v-if="!item.isSelf && membersData.user_team.show_other_nick" class="font_26 color999 ui-pb-8">{{item.name}}</view>
|
<view v-if="!item.isSelf && membersData.user_team.show_other_nick" class="font_26 color999 ui-pb-8">{{item.name}}</view>
|
||||||
<!--文本加表情信息-->
|
<!--文本加表情信息-->
|
||||||
<view class="{{!item.isSelf ? 'ui-left-msg-radius ui-msg-left color3' : 'ui-right-msg-radius ui-msg-right white'}} font_28" v-if="item.msgType == 'text'">
|
<view class="{{!item.isSelf ? 'ui-left-msg-radius ui-msg-left color3' : 'ui-right-msg-radius ui-msg-right white'}} font_28" v-if="item.msgType == '0'">
|
||||||
<rich-text nodes="{{item.text}}"></rich-text>
|
<rich-text nodes="{{item.text}}"></rich-text>
|
||||||
</view>
|
</view>
|
||||||
<!--图片信息-->
|
<!--图片信息-->
|
||||||
<image v-if="item.msgType == 'image'" class="ui-msg-left-pic" :style="{maxWidth: item.attach.w + 'rpx', maxHeight: item.attach.h + 'rpx'}" :src="item.attach.url" mode="aspectFill" @tap.stop="previewImage(item.attach.url)"></image>
|
<image v-if="item.msgType == '1'" class="ui-msg-left-pic" :style="{maxWidth: item.attach.w + 'rpx', maxHeight: item.attach.h + 'rpx'}" :src="item.attach.url" mode="aspectFill" @tap.stop="previewImage(item.attach.url)"></image>
|
||||||
<!--音频信息-->
|
<!--音频信息-->
|
||||||
<view v-if="item.msgType == 'audio'" class="{{!item.isSelf ? 'ui-left-msg-radius ui-left-audio' : 'ui-right-msg-radius ui-right-audio white' }} ui-audio-box font_36 f-fc" :style="{width: item.audioDur < 20 ? '120rpx' :item.audioDur < 40 ? '180rpx' : '320rpx', maxWidth: '320rpx!important', minWidth: '120rpx!important'}" @tap.stop="playAudio(item.attach, index)">
|
<view v-if="item.msgType == '2'" class="{{!item.isSelf ? 'ui-left-msg-radius ui-left-audio' : 'ui-right-msg-radius ui-right-audio white' }} ui-audio-box font_36 f-fc" :style="{width: item.audioDur < 20 ? '120rpx' :item.audioDur < 40 ? '180rpx' : '320rpx', maxWidth: '320rpx!important', minWidth: '120rpx!important'}" @tap.stop="playAudio(item.attach, index)">
|
||||||
<image v-if="!item.isSelf" class="{{!audioState || playAudioIndex != index ? 'ui-audio-icon' : 'ui-audio-icon-l-play'}}" src="https://image.fulllinkai.com/202308/09/a0e320ef4f498309745d35f6798e970f.png" mode="aspectFit" lazy-load="false"></image>
|
<image v-if="!item.isSelf" class="{{!audioState || playAudioIndex != index ? 'ui-audio-icon' : 'ui-audio-icon-l-play'}}" src="https://image.fulllinkai.com/202308/09/a0e320ef4f498309745d35f6798e970f.png" mode="aspectFit" lazy-load="false"></image>
|
||||||
<image v-else class="{{!audioState || playAudioIndex != index ? 'ui-audio-icon' : 'ui-audio-icon-r-play'}}" src="https://image.fulllinkai.com/202308/09/5514071f2d388102b5672e46ea1922f4.png" mode="aspectFit" lazy-load="false"></image>
|
<image v-else class="{{!audioState || playAudioIndex != index ? 'ui-audio-icon' : 'ui-audio-icon-r-play'}}" src="https://image.fulllinkai.com/202308/09/5514071f2d388102b5672e46ea1922f4.png" mode="aspectFit" lazy-load="false"></image>
|
||||||
<view v-if="!audioState || playAudioIndex != index">{{item.audioDur+ '"'}}</view>
|
<view v-if="!audioState || playAudioIndex != index">{{item.audioDur+ '"'}}</view>
|
||||||
<view v-else>{{audioTime + '"'}}</view>
|
<view v-else>{{audioTime + '"'}}</view>
|
||||||
</view>
|
</view>
|
||||||
<!--视频信息-->
|
<!--视频信息-->
|
||||||
<view v-if="item.msgType == 'video'" :style="{width: item.attach.w + 'rpx', height: item.attach.h + 'rpx', display: videoIndex == index ? 'none' : 'block'}" class="liveImg" mode="widthFix" @tap.stop="playVideo(index, item.id)">
|
<view v-if="item.msgType == '3'" :style="{width: item.attach.w + 'rpx', height: item.attach.h + 'rpx', display: videoIndex == index ? 'none' : 'block'}" class="liveImg" mode="widthFix" @tap.stop="playVideo(index, item.id)">
|
||||||
<image v-if="videoIndex != index" class="ui-video-box" :src="item.attach.poster" :style="{width: item.attach.w + 'rpx', height: item.attach.h + 'rpx'}">
|
<image v-if="videoIndex != index" class="ui-video-box" :src="item.attach.poster" :style="{width: item.attach.w + 'rpx', height: item.attach.h + 'rpx'}">
|
||||||
<view class="ui-vide-poster">
|
<view class="ui-vide-poster">
|
||||||
<image class="ui-video_play_icon" src="https://image.fulllinkai.com/202308/17/42c88bf039bb56f85cfcb9af0392ffb6.png"></image>
|
<image class="ui-video_play_icon" src="https://image.fulllinkai.com/202308/17/42c88bf039bb56f85cfcb9af0392ffb6.png"></image>
|
||||||
@ -673,6 +673,7 @@ wepy.page({
|
|||||||
|
|
||||||
recorderManager: wx.getRecorderManager(),
|
recorderManager: wx.getRecorderManager(),
|
||||||
startPoint: 0,
|
startPoint: 0,
|
||||||
|
scrollY: true,
|
||||||
sendLock: true, // audio发送锁
|
sendLock: true, // audio发送锁
|
||||||
microphoneShow: false,
|
microphoneShow: false,
|
||||||
microphoneType: false, // 按住或松开
|
microphoneType: false, // 按住或松开
|
||||||
@ -707,6 +708,7 @@ wepy.page({
|
|||||||
toView: '',
|
toView: '',
|
||||||
uploadState: false,
|
uploadState: false,
|
||||||
progressValue: 0, // 上传进度
|
progressValue: 0, // 上传进度
|
||||||
|
lastId: '', // 历史记录分页数据最后一条id
|
||||||
lastTime: '', // 历史记录分页数据最后一条的时间戳
|
lastTime: '', // 历史记录分页数据最后一条的时间戳
|
||||||
lastMsgId: '', // 历史记录分页数据最后一条的id
|
lastMsgId: '', // 历史记录分页数据最后一条的id
|
||||||
beginTime: '', // 历史记录分页数据最后一条的时间
|
beginTime: '', // 历史记录分页数据最后一条的时间
|
||||||
@ -724,10 +726,10 @@ wepy.page({
|
|||||||
// 获取群成员信息
|
// 获取群成员信息
|
||||||
getMembers() {
|
getMembers() {
|
||||||
let vm = this
|
let vm = this
|
||||||
vm.$post({url: `${service.host}/chat/group/detail?team_id=${vm.otherUserId}`}).then(({code, data}) => {
|
vm.$get({url: `${service.host}/team/${vm.otherUserId}/detail`}).then(({code, data}) => {
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
// 第一次进入页面的时候才请求历史消息
|
// 第一次进入页面的时候才请求历史消息
|
||||||
if (!vm.membersData.id) {
|
if (!vm.membersData.user_team) {
|
||||||
vm.$nextTick(() => {
|
vm.$nextTick(() => {
|
||||||
// 获取历史消息
|
// 获取历史消息
|
||||||
vm.getHistoryMsg()
|
vm.getHistoryMsg()
|
||||||
@ -771,11 +773,6 @@ wepy.page({
|
|||||||
send() {
|
send() {
|
||||||
let vm = this
|
let vm = this
|
||||||
let timeData = new Date().getTime()
|
let timeData = new Date().getTime()
|
||||||
let data = {
|
|
||||||
to_user_id: vm.otherUserId,
|
|
||||||
content: vm.msg,
|
|
||||||
type: 'text'
|
|
||||||
}
|
|
||||||
if (!vm.msg) {
|
if (!vm.msg) {
|
||||||
vm.$showToast('请输入聊天内容')
|
vm.$showToast('请输入聊天内容')
|
||||||
return
|
return
|
||||||
@ -792,21 +789,16 @@ wepy.page({
|
|||||||
name: vm.myName,
|
name: vm.myName,
|
||||||
userId: vm.myUserId,
|
userId: vm.myUserId,
|
||||||
isSend: 0,
|
isSend: 0,
|
||||||
msgType: 'text'
|
msgType: '0'
|
||||||
})
|
})
|
||||||
vm.emojiShow = false
|
|
||||||
vm.msg = ''
|
|
||||||
vm.replyContent = ''
|
|
||||||
vm.toView = `id_${timeData}`
|
vm.toView = `id_${timeData}`
|
||||||
let msgIndex = 0
|
let msgIndex = 0
|
||||||
let msgNewObj = {}
|
let msgNewObj = {}
|
||||||
msgIndex = vm.msgList.findIndex((e) => e.timestamp == timeData)
|
msgIndex = vm.msgList.findIndex((e) => e.timestamp == timeData)
|
||||||
vm.$post({url: `${service.host}/chat/message/send`, data}).then(({code, data}) => {
|
|
||||||
if (code == 0) {
|
|
||||||
app.globalData.nim.msg.sendTextMsg({
|
app.globalData.nim.msg.sendTextMsg({
|
||||||
scene: 'team',
|
scene: 'team',
|
||||||
to: vm.otherUserId,
|
to: vm.otherUserId,
|
||||||
body: data.content,
|
body: vm.msg,
|
||||||
isSend: 0,
|
isSend: 0,
|
||||||
onSendBefore: function (msg) {
|
onSendBefore: function (msg) {
|
||||||
console.log('get msg before', msg)
|
console.log('get msg before', msg)
|
||||||
@ -814,7 +806,7 @@ wepy.page({
|
|||||||
data.content = vm.transitionMsg(data.content)
|
data.content = vm.transitionMsg(data.content)
|
||||||
}
|
}
|
||||||
msgNewObj = {
|
msgNewObj = {
|
||||||
text: data.content,
|
text: vm.msg,
|
||||||
attach: '',
|
attach: '',
|
||||||
id: `id_${msg.time}`,
|
id: `id_${msg.time}`,
|
||||||
isSelf: true,
|
isSelf: true,
|
||||||
@ -824,34 +816,20 @@ wepy.page({
|
|||||||
name: vm.myName,
|
name: vm.myName,
|
||||||
userId: msg.from,
|
userId: msg.from,
|
||||||
isSend: 1,
|
isSend: 1,
|
||||||
msgType: 'text'
|
msgType: '0'
|
||||||
}
|
}
|
||||||
vm.msgList.splice(msgIndex, 1, msgNewObj)
|
vm.msgList.splice(msgIndex, 1, msgNewObj)
|
||||||
vm.lastTime = format(msg.time)
|
vm.lastTime = format(msg.time)
|
||||||
|
vm.callbackSend('text')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
vm.msgList[msgIndex].isSend = 2
|
|
||||||
}
|
|
||||||
wx.hideLoading()
|
|
||||||
}).catch(() => {
|
|
||||||
vm.msgList[msgIndex].isSend = 2
|
|
||||||
wx.hideLoading()
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
// 发送图片消息
|
// 发送图片消息
|
||||||
sendPictures(file) {
|
sendPictures(file) {
|
||||||
let vm = this
|
let vm = this
|
||||||
let data = {
|
|
||||||
to_user_id: vm.otherUserId,
|
|
||||||
content: vm.msg,
|
|
||||||
type: 'picture'
|
|
||||||
}
|
|
||||||
vm.openShow = false
|
vm.openShow = false
|
||||||
vm.uploadState = true
|
vm.uploadState = true
|
||||||
vm.progressValue = 5
|
vm.progressValue = 5
|
||||||
vm.$post({url: `${service.host}/chat/message/send`, data}).then(({code, data}) => {
|
|
||||||
if (code == 0) {
|
|
||||||
app.globalData.nim.msg.sendImageMsg({
|
app.globalData.nim.msg.sendImageMsg({
|
||||||
scene: 'team',
|
scene: 'team',
|
||||||
to: vm.otherUserId,
|
to: vm.otherUserId,
|
||||||
@ -874,9 +852,10 @@ wepy.page({
|
|||||||
name: msg.fromNick,
|
name: msg.fromNick,
|
||||||
userId: msg.from,
|
userId: msg.from,
|
||||||
isSend: 1,
|
isSend: 1,
|
||||||
msgType: 'image'
|
msgType: '1'
|
||||||
})
|
})
|
||||||
vm.lastTime = format(msg.time)
|
vm.lastTime = format(msg.time)
|
||||||
|
vm.callbackSend('picture')
|
||||||
vm.$nextTick(() => {
|
vm.$nextTick(() => {
|
||||||
vm.toView = `id_${msg.time}`
|
vm.toView = `id_${msg.time}`
|
||||||
})
|
})
|
||||||
@ -888,11 +867,6 @@ wepy.page({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
wx.hideLoading()
|
|
||||||
}).catch(() => {
|
|
||||||
wx.hideLoading()
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
// 发送视频
|
// 发送视频
|
||||||
sendVideos(file) {
|
sendVideos(file) {
|
||||||
@ -924,9 +898,10 @@ wepy.page({
|
|||||||
name: msg.fromNick,
|
name: msg.fromNick,
|
||||||
userId: msg.from,
|
userId: msg.from,
|
||||||
isSend: 1,
|
isSend: 1,
|
||||||
msgType: 'video'
|
msgType: '3'
|
||||||
})
|
})
|
||||||
vm.lastTime = format(msg.time)
|
vm.lastTime = format(msg.time)
|
||||||
|
vm.callbackSend('video')
|
||||||
vm.$nextTick(() => {
|
vm.$nextTick(() => {
|
||||||
vm.toView = `id_${msg.time}`
|
vm.toView = `id_${msg.time}`
|
||||||
})
|
})
|
||||||
@ -969,9 +944,10 @@ wepy.page({
|
|||||||
name: msg.fromNick,
|
name: msg.fromNick,
|
||||||
userId: msg.from,
|
userId: msg.from,
|
||||||
isSend: 1,
|
isSend: 1,
|
||||||
msgType: 'audio'
|
msgType: '2'
|
||||||
})
|
})
|
||||||
vm.lastTime = format(msg.time)
|
vm.lastTime = format(msg.time)
|
||||||
|
vm.callbackSend('audio')
|
||||||
vm.$nextTick(() => {
|
vm.$nextTick(() => {
|
||||||
vm.toView = `id_${msg.time}`
|
vm.toView = `id_${msg.time}`
|
||||||
})
|
})
|
||||||
@ -984,6 +960,24 @@ wepy.page({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 发送信息后回调
|
||||||
|
callbackSend(type) {
|
||||||
|
let vm = this
|
||||||
|
let data = {
|
||||||
|
other_user_id: vm.otherUserId * 1,
|
||||||
|
field_7: vm.msg,
|
||||||
|
field_6: type
|
||||||
|
}
|
||||||
|
vm.$post({url: `${service.host}/chat/message/send`, data}).then(() => {
|
||||||
|
wx.hideLoading()
|
||||||
|
vm.msg = ''
|
||||||
|
vm.emojiShow = false
|
||||||
|
vm.replyContent = ''
|
||||||
|
}).catch(() => {
|
||||||
|
vm.uploadState = false
|
||||||
|
wx.hideLoading()
|
||||||
|
})
|
||||||
|
},
|
||||||
// 标记IM信息已读
|
// 标记IM信息已读
|
||||||
sendMsgReceipt() {
|
sendMsgReceipt() {
|
||||||
let vm = this
|
let vm = this
|
||||||
@ -1027,7 +1021,6 @@ wepy.page({
|
|||||||
},
|
},
|
||||||
// 获取历史消息数据
|
// 获取历史消息数据
|
||||||
getHistoryMsg() {
|
getHistoryMsg() {
|
||||||
let vm = this
|
|
||||||
let vm = this
|
let vm = this
|
||||||
let data = {
|
let data = {
|
||||||
min_id: vm.lastId
|
min_id: vm.lastId
|
||||||
@ -1039,7 +1032,8 @@ wepy.page({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
vm.$showLoading('')
|
vm.$showLoading('')
|
||||||
vm.$get({url: `${service.host}/chat/user/${vm.otherUserId}/message/list`, data}).then(({code, data}) => {
|
|
||||||
|
vm.$get({url: `${service.host}/chat/team/${vm.otherUserId}/message/list`, data}).then(({code, data}) => {
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
console.log(data, '-------------------')
|
console.log(data, '-------------------')
|
||||||
if (data && data.length > 0) {
|
if (data && data.length > 0) {
|
||||||
@ -1048,58 +1042,70 @@ wepy.page({
|
|||||||
// }
|
// }
|
||||||
data.forEach((item, index) => {
|
data.forEach((item, index) => {
|
||||||
item.time = new Date(item.create_time.replace(/[-]/g, '/').replace(/[-]/, '')).getTime()
|
item.time = new Date(item.create_time.replace(/[-]/g, '/').replace(/[-]/, '')).getTime()
|
||||||
item.attach = item.attach ? JSON.parse(item.attach) : ''
|
item.avatar = 'https://image.fulllinkai.com/202307/18/449c3253ca2bbed9314d39977a486d0e.png'
|
||||||
item.showTime = timeContrast(format(item.time), vm.lastTime)
|
item.showTime = timeContrast(format(item.time), vm.lastTime)
|
||||||
item.timing = getTime(format(item.time))
|
item.timing = getTime(format(item.time))
|
||||||
if (item.showTime && index > 0) {
|
if (item.showTime && index > 0) {
|
||||||
data[index].showTime = false
|
data[index].showTime = false
|
||||||
data[index - 1].showTime = true
|
data[index - 1].showTime = true
|
||||||
}
|
}
|
||||||
if (item.content_type == 'text' && /\[[^\]]+\]/.test(item.content)) {
|
if (item.type == '0' && /\[[^\]]+\]/.test(item.body_arr.msg)) {
|
||||||
item.body = vm.transitionMsg(item.content)
|
item.body = vm.transitionMsg(item.body_arr.msg)
|
||||||
|
} else {
|
||||||
|
item.body = item.body_arr.msg
|
||||||
}
|
}
|
||||||
vm.lastTime = format(item.time)
|
vm.lastTime = format(item.time)
|
||||||
})
|
// 获取成员头像后再循环获取数据
|
||||||
|
app.globalData.nim.user.getUsersNameCardFromServer({
|
||||||
|
accounts: [item.from]
|
||||||
|
}).then((res) => {
|
||||||
|
item.avatar = res[0].avatar
|
||||||
|
if (index + 1 == data.length) {
|
||||||
vm.lastMsgId = data[data.length - 1].id
|
vm.lastMsgId = data[data.length - 1].id
|
||||||
vm.beginTime = data[data.length - 1].time
|
vm.beginTime = data[data.length - 1].time
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
data.forEach((item) => {
|
data.forEach((item) => {
|
||||||
vm.msgList.unshift({
|
vm.msgList.unshift({
|
||||||
text: item.content,
|
text: item.body,
|
||||||
attach: vm.calculatePic(item.attach, item.content_type),
|
attach: vm.calculatePic(item.body_arr, item.type),
|
||||||
id: `id_${item.time}`,
|
id: `id_${item.time}`,
|
||||||
timestamp: item.time,
|
timestamp: item.time,
|
||||||
isSelf: item.is_mine == 0 ? false : true,
|
isSelf: item.is_mine == 'in' ? false : true,
|
||||||
avatar: item.is_mine == 0 ? vm.otherAvatar : vm.myAvatar,
|
avatar: item.is_mine == 'in' ? item.photo : vm.myAvatar,
|
||||||
time: item.timing,
|
time: item.timing,
|
||||||
showTime: item.showTime,
|
showTime: item.showTime,
|
||||||
videoDur: item.content_type == 'video' ? getVideoTime(item.attach.dur) : '',
|
videoDur: item.type == '3' && item.body_arr.dur ? getVideoTime(item.body_arr.dur) : '',
|
||||||
audioDur: item.content_type == 'audio' ? (item.attach.dur / 1000).toFixed(0) : '',
|
audioDur: item.type == '2' && item.body_arr.dur ? (item.body_arr.dur / 1000).toFixed(0) : '',
|
||||||
name: item.fromNick,
|
name: item.fromNick,
|
||||||
isSend: 1,
|
|
||||||
userId: item.from,
|
userId: item.from,
|
||||||
msgType: item.content_type
|
msgType: item.type,
|
||||||
|
tips: vm.groupNotification(item)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
console.log(vm.msgList, data[0].time, '88888888888888888')
|
console.log(vm.msgList, '88888888888888888')
|
||||||
vm.$nextTick(() => {
|
vm.$nextTick(() => {
|
||||||
if (vm.msgList.length < 8) {
|
|
||||||
vm.toView = `id_${data[0].time}`
|
vm.toView = `id_${data[0].time}`
|
||||||
|
if (vm.msgList.length > 15) {
|
||||||
|
vm.scrollY = false
|
||||||
}
|
}
|
||||||
vm.lastId = `${data[data.length - 1].id}`
|
vm.lastId = `${data[data.length - 1].id}`
|
||||||
vm.loading = true
|
vm.loading = true
|
||||||
// 防止撑开触发加载历史数据
|
// 防止撑开触发加载历史数据
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
vm.uploadState = false
|
vm.uploadState = false
|
||||||
|
vm.scrollY = true
|
||||||
}, 500)
|
}, 500)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
vm.loading = true
|
vm.loading = true
|
||||||
|
vm.scrollY = true
|
||||||
}
|
}
|
||||||
if (data && data.length < 7) {
|
if (data && data.length < 15) {
|
||||||
vm.finished = true
|
vm.finished = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1107,91 +1113,6 @@ wepy.page({
|
|||||||
wx.hideLoading()
|
wx.hideLoading()
|
||||||
console.log(err)
|
console.log(err)
|
||||||
})
|
})
|
||||||
// let data = {}
|
|
||||||
// if (vm.uploadState || vm.videoState) {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// if (!vm.lastMsgId) {
|
|
||||||
// data = {
|
|
||||||
// scene: 'team',
|
|
||||||
// to: vm.otherUserId,
|
|
||||||
// limit: 15
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// data = {
|
|
||||||
// scene: 'team',
|
|
||||||
// to: vm.otherUserId,
|
|
||||||
// limit: 15,
|
|
||||||
// reverse: false,
|
|
||||||
// endTime: vm.beginTime,
|
|
||||||
// lastMsgId: vm.lastMsgId
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (vm.finished) {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// vm.$showLoading('')
|
|
||||||
// app.globalData.nim.msgLog.getHistoryMsgs(data).then((object) => {
|
|
||||||
// if (object && object.length > 0) {
|
|
||||||
// if (vm.msgList && vm.msgList.length == 0) {
|
|
||||||
// // 标记IM消息已读
|
|
||||||
// vm.sendMsgReceipt()
|
|
||||||
// }
|
|
||||||
// object.forEach((item, index) => {
|
|
||||||
// item.avatar = 'https://image.fulllinkai.com/202307/18/449c3253ca2bbed9314d39977a486d0e.png',
|
|
||||||
// item.showTime = timeContrast(format(item.time), vm.lastTime)
|
|
||||||
// item.timing = getTime(format(item.time))
|
|
||||||
// if (item.showTime && index > 0) {
|
|
||||||
// object[index].showTime = false
|
|
||||||
// object[index - 1].showTime = true
|
|
||||||
// }
|
|
||||||
// if (item.type == 'text' && /\[[^\]]+\]/.test(item.body)) {
|
|
||||||
// item.body = vm.transitionMsg(item.body)
|
|
||||||
// }
|
|
||||||
// vm.lastTime = format(item.time)
|
|
||||||
// // 获取成员头像后再循环获取数据
|
|
||||||
// app.globalData.nim.user.getUsersNameCardFromServer({
|
|
||||||
// accounts: [item.from]
|
|
||||||
// }).then((res) => {
|
|
||||||
// item.avatar = res[0].avatar
|
|
||||||
// if (index + 1 == object.length) {
|
|
||||||
// vm.lastMsgId = object[object.length - 1].idServer
|
|
||||||
// vm.beginTime = object[object.length - 1].time
|
|
||||||
//
|
|
||||||
// setTimeout(() => {
|
|
||||||
// object.forEach((item) => {
|
|
||||||
// vm.msgList.unshift({
|
|
||||||
// text: item.body,
|
|
||||||
// attach: vm.calculatePic(item.attach, item.type),
|
|
||||||
// id: `id_${item.time}`,
|
|
||||||
// timestamp: item.time,
|
|
||||||
// isSelf: item.flow == 'in' ? false : true,
|
|
||||||
// avatar: item.flow == 'in' ? item.avatar : vm.myAvatar,
|
|
||||||
// time: item.timing,
|
|
||||||
// showTime: item.showTime,
|
|
||||||
// videoDur: item.type == 'video' ? getVideoTime(item.attach.dur) : '',
|
|
||||||
// audioDur: item.type == 'audio' ? (item.attach.dur / 1000).toFixed(0) : '',
|
|
||||||
// name: item.fromNick,
|
|
||||||
// userId: item.from,
|
|
||||||
// msgType: item.type,
|
|
||||||
// tips: vm.groupNotification(item)
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// console.log(vm.msgList, '88888888888888888')
|
|
||||||
// vm.toView = `id_${object[0].time}`
|
|
||||||
// vm.loading = true
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// } else {
|
|
||||||
// vm.loading = true
|
|
||||||
// }
|
|
||||||
// if (object && object.length < 15) {
|
|
||||||
// vm.finished = true
|
|
||||||
// }
|
|
||||||
// wx.hideLoading()
|
|
||||||
// })
|
|
||||||
},
|
},
|
||||||
// 监听底部输入框的高度
|
// 监听底部输入框的高度
|
||||||
changeInputHeight(e) {
|
changeInputHeight(e) {
|
||||||
@ -1392,23 +1313,23 @@ wepy.page({
|
|||||||
// 群通知消息判断
|
// 群通知消息判断
|
||||||
groupNotification (e) {
|
groupNotification (e) {
|
||||||
let text = ``
|
let text = ``
|
||||||
if (e.type == 'notification' && e.attach.type == 'addTeamMembers') {
|
if (e.type == '7' && e.attach.type == 'addTeamMembers') {
|
||||||
text = `${e.attach.users[1].nick}邀请${e.attach.users[0].nick}加入群`
|
text = `${e.attach.users[1].nick}邀请${e.attach.users[0].nick}加入群`
|
||||||
}
|
}
|
||||||
if (e.type == 'notification' && e.attach.type == 'leaveTeam') {
|
if (e.type == '7' && e.attach.type == 'leaveTeam') {
|
||||||
text = `${e.attach.users[0].nick}离开群`
|
text = `${e.attach.users[0].nick}离开群`
|
||||||
}
|
}
|
||||||
return text
|
return text
|
||||||
},
|
},
|
||||||
// 图片大小计算
|
// 图片大小计算
|
||||||
calculatePic(e, type) {
|
calculatePic(e, type) {
|
||||||
if (!e) {
|
if (!e.url) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
let wRatio = 0
|
let wRatio = 0
|
||||||
if (type == 'video' && e.url && e.url.includes('?')) {
|
if (type == '3' && e.url && e.url.includes('?')) {
|
||||||
e.poster = `${e.url}&vframe`
|
e.poster = `${e.url}&vframe`
|
||||||
} else if (type == 'video' && e.url) {
|
} else if (type == '3' && e.url) {
|
||||||
e.poster = `${e.url}?vframe`
|
e.poster = `${e.url}?vframe`
|
||||||
}
|
}
|
||||||
if (e.w > e.h) {
|
if (e.w > e.h) {
|
||||||
@ -1523,7 +1444,7 @@ wepy.page({
|
|||||||
let vm = this
|
let vm = this
|
||||||
let imageArr = []
|
let imageArr = []
|
||||||
vm.msgList.forEach((item) => {
|
vm.msgList.forEach((item) => {
|
||||||
if (item.msgType == 'image') {
|
if (item.msgType == '1') {
|
||||||
imageArr.push(item.attach.url)
|
imageArr.push(item.attach.url)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user