解决从搜索聊天记录跳转聊天时,下拉刷新上拉加载数据错误问题;解决图片、视频、文件上传后会变成2条问题;
Some checks failed
Check / lint (push) Has been cancelled
Check / typecheck (push) Has been cancelled
Check / build (build, 18.x, ubuntu-latest) (push) Has been cancelled
Check / build (build, 18.x, windows-latest) (push) Has been cancelled
Check / build (build:app, 18.x, ubuntu-latest) (push) Has been cancelled
Check / build (build:app, 18.x, windows-latest) (push) Has been cancelled
Check / build (build:mp-weixin, 18.x, ubuntu-latest) (push) Has been cancelled
Check / build (build:mp-weixin, 18.x, windows-latest) (push) Has been cancelled

This commit is contained in:
wangyifeng 2025-03-15 16:44:40 +08:00
parent 894bb9bf28
commit 380b0120bc
12 changed files with 163 additions and 38 deletions

View File

@ -17,7 +17,7 @@ const handleWebview = () => {
// top: statusBarHeight_, // top: statusBarHeight_,
// bottom: 0, // bottom: 0,
// }) // })
// console.log(webview) console.log("webview", webview)
token.value = webview.token token.value = webview.token
} }
const init = () => { const init = () => {

View File

@ -32,6 +32,11 @@ class Talk extends Base {
*/ */
talk_type = 0 talk_type = 0
/**
* 文件上传唯一随机值
*/
fileNum = ''
/** /**
* 初始化构造方法 * 初始化构造方法
* *
@ -43,6 +48,10 @@ class Talk extends Base {
this.sender_id = resource.sender_id this.sender_id = resource.sender_id
this.receiver_id = resource.receiver_id this.receiver_id = resource.receiver_id
this.talk_type = resource.talk_type this.talk_type = resource.talk_type
// this.fileNum = resource.file_num
if(resource.file_num){
resource.data.file_num = resource.file_num
}
this.resource = resource.data this.resource = resource.data
this.handle() this.handle()

View File

@ -74,7 +74,7 @@ const photoActionsSelect = (index) => {
console.log(res,'res'); console.log(res,'res');
res.tempFiles.forEach(async (file) => { res.tempFiles.forEach(async (file) => {
let data = await onUploadImageVideo(file, 'image') let data = await onUploadImageVideo(file, 'image')
emit('selectImg', data) emit('selectImg', data, data.file_num)
}) })
} }
}) })
@ -84,7 +84,7 @@ const photoActionsSelect = (index) => {
success: async (res) => { success: async (res) => {
console.log(res,'res'); console.log(res,'res');
let data = await onUploadImageVideo(res.tempFile, 'video',res.tempFilePath) let data = await onUploadImageVideo(res.tempFile, 'video',res.tempFilePath)
emit('selectImg', data) emit('selectImg', data, data.file_num)
} }
}) })
} }
@ -119,6 +119,7 @@ const onUploadImageVideo = async (file, type = 'image',fileUrl) => {
is_read: 0, is_read: 0,
is_revoke: 0, is_revoke: 0,
msg_id: randomId, msg_id: randomId,
file_num: randomId,
msg_type: 3, msg_type: 3,
nickname: userStore.nickname, nickname: userStore.nickname,
receiver_id: dialogueStore.talk.receiver_id, receiver_id: dialogueStore.talk.receiver_id,
@ -137,7 +138,8 @@ const onUploadImageVideo = async (file, type = 'image',fileUrl) => {
url: data.ori_url, url: data.ori_url,
size: file.size, size: file.size,
width: image.width, width: image.width,
height: image.height height: image.height,
file_num: randomId,
}) })
} else { } else {
resolve('') resolve('')
@ -171,6 +173,7 @@ const onUploadImageVideo = async (file, type = 'image',fileUrl) => {
is_read: 0, is_read: 0,
is_revoke: 0, is_revoke: 0,
msg_id: randomId, msg_id: randomId,
file_num: randomId,
msg_type: 5, msg_type: 5,
nickname: userStore.nickname, nickname: userStore.nickname,
receiver_id: dialogueStore.talk.receiver_id, receiver_id: dialogueStore.talk.receiver_id,
@ -189,7 +192,8 @@ const onUploadImageVideo = async (file, type = 'image',fileUrl) => {
url: data.ori_url, url: data.ori_url,
cover: data.cover_url, cover: data.cover_url,
duration: parseInt(resp.duration), duration: parseInt(resp.duration),
size: file.size size: file.size,
file_num: randomId,
}) })
} else { } else {
// resolve('') // resolve('')
@ -313,6 +317,7 @@ const chooseFile = () => {
is_read: 0, is_read: 0,
is_revoke: 0, is_revoke: 0,
msg_id: randomId, msg_id: randomId,
file_num: randomId,
msg_type: 6, msg_type: 6,
nickname: userStore.nickname, nickname: userStore.nickname,
receiver_id: dialogueStore.talk.receiver_id, receiver_id: dialogueStore.talk.receiver_id,

View File

@ -62,7 +62,11 @@
<customBtn <customBtn
:isBottom="true" :isBottom="true"
:btnText="$t('user.detail.sendMsg')" :btnText="$t('user.detail.sendMsg')"
:subBtnText="$t('user.detail.ringBell')" :subBtnText="
state.userInfo.sys_id === state.uid
? ''
: $t('user.detail.ringBell')
"
@clickBtn="toTalkUser" @clickBtn="toTalkUser"
@clickSubBtn="handleCall" @clickSubBtn="handleCall"
></customBtn> ></customBtn>
@ -103,8 +107,9 @@ import ZPaging from '@/uni_modules/z-paging/components/z-paging/z-paging.vue'
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import { reactive } from 'vue' import { reactive } from 'vue'
import { useTalkStore } from '@/store' import { useTalkStore, useUserStore } from '@/store'
const talkStore = useTalkStore() const talkStore = useTalkStore()
const userStore = useUserStore()
import { getUserInfoByClickAvatar } from '@/api/user/index' import { getUserInfoByClickAvatar } from '@/api/user/index'
@ -117,6 +122,7 @@ const state = reactive({
userBasicInfos: [], // userBasicInfos: [], //
isShowPhoneCall: false, // isShowPhoneCall: false, //
phoneNumber: '', // phoneNumber: '', //
uid: computed(() => userStore.uid), //id
}) })
onLoad((options) => { onLoad((options) => {

View File

@ -863,8 +863,8 @@ const editorOption = {
placeholder: '', placeholder: '',
} }
const handleSelectImg = (data) => { const handleSelectImg = (data, file_num) => {
onSendMessage({ ...data }) onSendMessage({ ...data, file_num })
} }
const virtualListChange = (vList) => { const virtualListChange = (vList) => {
@ -1094,7 +1094,7 @@ const onScrollToLower = () => {
} else { } else {
if (tempVirtualList[0].sequence > dialogueList.records[0].sequence) { if (tempVirtualList[0].sequence > dialogueList.records[0].sequence) {
virtualList.value = dialogueList.records virtualList.value = dialogueList.records
.slice(0, recordIndex) .slice(Math.max(0, recordIndex - 10), recordIndex)
.concat(tempVirtualList) .concat(tempVirtualList)
.reverse() .reverse()
// zpagingRef.value.setLocalPaging( // zpagingRef.value.setLocalPaging(
@ -1131,27 +1131,22 @@ const onScrollToUpper = () => {
tempVirtualList[tempVirtualList.length - 1].sequence < tempVirtualList[tempVirtualList.length - 1].sequence <
dialogueList.records[dialogueList.records.length - 1].sequence dialogueList.records[dialogueList.records.length - 1].sequence
) { ) {
// ID
const currentMsgId = tempVirtualList[tempVirtualList.length - 1].msg_id
virtualList.value = tempVirtualList virtualList.value = tempVirtualList
.concat( .concat(
dialogueList.records.slice( dialogueList.records.slice(
recordIndex + 1, Math.min(recordIndex + 11, dialogueList.records.length),
dialogueList.records.length, dialogueList.records.length,
), ),
) )
.reverse() .reverse()
// zpagingRef.value.setLocalPaging(
// tempVirtualList
// .concat(
// dialogueList.records.slice(
// recordIndex + 1,
// dialogueList.records.length,
// ),
// )
// .reverse(),
// // zpagingRef.value.scrollIntoViewById('zp-id-' + virtualList.value[virtualList.value.length - 1].msg_id)
// )
console.log(virtualList.value) //
nextTick(() => {
zpagingRef.value?.scrollIntoViewById('zp-id-' + currentMsgId)
})
} }
} }
} }

View File

@ -275,6 +275,7 @@ const resultDetail = computed(() => {
padding: 2rpx 14rpx; padding: 2rpx 14rpx;
border: 2rpx solid #000; border: 2rpx solid #000;
border-radius: 6rpx; border-radius: 6rpx;
flex-shrink: 0;
span { span {
line-height: 34rpx; line-height: 34rpx;
} }
@ -299,6 +300,7 @@ const resultDetail = computed(() => {
.info-detail-searchRecordDetail { .info-detail-searchRecordDetail {
span { span {
color: $theme-text; color: $theme-text;
word-break: break-all;
} }
} }
} }

View File

@ -117,6 +117,10 @@ import { useI18n } from 'vue-i18n'
import { ref, reactive, defineEmits, defineProps, onMounted } from 'vue' import { ref, reactive, defineEmits, defineProps, onMounted } from 'vue'
import pointerIconSrc from '@/static/image/search/search-item-pointer.png' import pointerIconSrc from '@/static/image/search/search-item-pointer.png'
import lodash from 'lodash'
import { useUserStore } from '@/store'
const userStore = useUserStore()
const zPaging = ref() const zPaging = ref()
useZPaging(zPaging) useZPaging(zPaging)
@ -131,6 +135,7 @@ const state = reactive({
searchResultList: [], // searchResultList: [], //
searchResult: null, // searchResult: null, //
pageNum: 1, // pageNum: 1, //
uid: computed(() => userStore.uid), //id
}) })
const props = defineProps({ const props = defineProps({
@ -197,10 +202,29 @@ const queryAllSearch = (pageNum, searchResultPageSize) => {
}) })
} }
if ((data.talk_record_infos || []).length > 0) { if ((data.talk_record_infos || []).length > 0) {
let receiverInfo = lodash.cloneDeep(data.talk_record_infos[0])
if (receiverInfo.talk_type === 1) {
//
if (receiverInfo.user_id === state.uid) {
//
}
if (receiverInfo.receiver_id === state.uid) {
//
let temp_id = receiverInfo.receiver_id
let temp_name = receiverInfo.receiver_name
let temp_avatar = receiverInfo.receiver_avatar
receiverInfo.receiver_id = receiverInfo.user_id
receiverInfo.receiver_name = receiverInfo.user_name
receiverInfo.receiver_avatar = receiverInfo.user_avatar
receiverInfo.user_id = temp_id
receiverInfo.user_name = temp_name
receiverInfo.user_avatar = temp_avatar
}
}
state.first_talk_record_infos = Object.assign( state.first_talk_record_infos = Object.assign(
{}, {},
state.first_talk_record_infos, state.first_talk_record_infos,
data.talk_record_infos[0], receiverInfo,
) )
;(data.talk_record_infos || []).forEach((item) => { ;(data.talk_record_infos || []).forEach((item) => {
item.group_type = 0 item.group_type = 0

View File

@ -17,6 +17,10 @@ import { ServeSeachQueryAll } from '@/api/search/index'
import { onMounted } from 'vue' import { onMounted } from 'vue'
import { handleSetWebviewStyle } from '@/utils/common' import { handleSetWebviewStyle } from '@/utils/common'
import { useDialogueStore } from '@/store'
const dialogueStore = useDialogueStore()
onMounted(() => { onMounted(() => {
handleSetWebviewStyle() handleSetWebviewStyle()
}) })
@ -38,9 +42,24 @@ const clickSearchItem = (
searchResultKey, searchResultKey,
talk_type, talk_type,
receiver_id, receiver_id,
res,
) => { ) => {
console.log(searchResultKey) console.log(searchResultKey)
if (searchResultKey === 'general_infos') { const result = JSON.parse(decodeURIComponent(res))
console.log(result)
if (searchResultKey === 'user_infos') {
} else if (searchResultKey === 'combinedGroup') {
dialogueStore.setDialogue({
name: result.name || result.group_name,
talk_type: result.type || 2,
receiver_id: result.id || result.group_id,
})
uni.navigateTo({
url: '/pages/dialog/index',
})
} else if (searchResultKey === 'general_infos') {
uni.navigateTo({ uni.navigateTo({
url: url:
'/pages/search/moreResult/moreResultDetail?searchText=' + '/pages/search/moreResult/moreResultDetail?searchText=' +

View File

@ -24,6 +24,10 @@ import {
} from '@/api/search/index' } from '@/api/search/index'
import { reactive } from 'vue' import { reactive } from 'vue'
import { useDialogueStore } from '@/store'
const dialogueStore = useDialogueStore()
const state = reactive({ const state = reactive({
apiRequest: Function, apiRequest: Function,
apiParams: String, apiParams: String,
@ -86,8 +90,27 @@ const lastIdChange = (last_id, last_group_id, last_member_id) => {
} }
// //
const clickSearchItem = (searchText) => { const clickSearchItem = (
if (state.searchResultKey === 'general_infos') { searchText,
searchResultKey,
talk_type,
receiver_id,
res,
) => {
console.log(state.searchResultKey)
const result = JSON.parse(decodeURIComponent(res))
console.log(result)
if (state.searchResultKey === 'user_infos') {
} else if (state.searchResultKey === 'combinedGroup') {
dialogueStore.setDialogue({
name: result.name || result.group_name,
talk_type: result.type || 2,
receiver_id: result.id || result.group_id,
})
uni.navigateTo({
url: '/pages/dialog/index',
})
} else if (state.searchResultKey === 'general_infos') {
uni.navigateTo({ uni.navigateTo({
url: '/pages/search/moreResult/moreResultDetail?searchText=' + searchText, url: '/pages/search/moreResult/moreResultDetail?searchText=' + searchText,
}) })

View File

@ -20,13 +20,16 @@ import searchList from '../components/searchList.vue'
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import { ServeTalkRecord } from '@/api/search/index' import { ServeTalkRecord } from '@/api/search/index'
import { reactive } from 'vue' import { reactive } from 'vue'
import { useDialogueStore } from "@/store"; import { useDialogueStore, useUserStore } from '@/store'
import lodash from 'lodash'
const dialogueStore = useDialogueStore(); const dialogueStore = useDialogueStore()
const userStore = useUserStore()
const state = reactive({ const state = reactive({
apiParams: String, apiParams: String,
searchText: String, searchText: String,
uid: computed(() => userStore.uid), //id
}) })
onLoad((options) => { onLoad((options) => {
@ -80,15 +83,42 @@ const clickSearchItem = (
receiver_id, receiver_id,
res, res,
) => { ) => {
console.log(searchResultKey)
let result = JSON.parse(decodeURIComponent(res)) let result = JSON.parse(decodeURIComponent(res))
console.log(result)
let receiverInfo = lodash.cloneDeep(result)
if (receiverInfo.talk_type === 1) {
//
if (receiverInfo.user_id === state.uid) {
//
}
if (receiverInfo.receiver_id === state.uid) {
//
let temp_id = receiverInfo.receiver_id
let temp_name = receiverInfo.receiver_name
let temp_avatar = receiverInfo.receiver_avatar
receiverInfo.receiver_id = receiverInfo.user_id
receiverInfo.receiver_name = receiverInfo.user_name
receiverInfo.receiver_avatar = receiverInfo.user_avatar
receiverInfo.user_id = temp_id
receiverInfo.user_name = temp_name
receiverInfo.user_avatar = temp_avatar
}
}
dialogueStore.setDialogue({ dialogueStore.setDialogue({
name: result.receiver_name, name: receiverInfo.receiver_name,
talk_type: talk_type, talk_type: talk_type,
receiver_id: receiver_id, receiver_id: receiverInfo.receiver_id,
})
uni.navigateTo({
url: '/pages/dialog/index?msgInfo=' + res,
}) })
if (searchResultKey === 'talk_record_infos_receiver') {
uni.navigateTo({
url: '/pages/dialog/index',
})
} else {
uni.navigateTo({
url: '/pages/dialog/index?msgInfo=' + res,
})
}
} }
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>

View File

@ -107,7 +107,18 @@ export const useDialogueListStore = createGlobalState(() => {
const addChatRecord = (indexName, item) => { const addChatRecord = (indexName, item) => {
const dialogue = lodash.cloneDeep(useDialogueStore()) const dialogue = lodash.cloneDeep(useDialogueStore())
if (dialogue?.index_name === indexName) { if (dialogue?.index_name === indexName) {
zpagingRef.value?.addChatRecordData(item, false, false) const index = virtualList.value.findIndex(
(v) => v?.file_num === item?.file_num,
)
if (index > -1) {
// 保持响应性的同时替换整个对象
virtualList.value.splice(index, 1, {
...virtualList.value[index], // 保留原有不需要修改的字段
...item, // 覆盖需要更新的字段
})
} else {
zpagingRef.value?.addChatRecordData(item, false, false)
}
} }
} }

View File

@ -104,7 +104,7 @@ export const useUploadsStore = defineStore('uploads', {
console.log(msgId,'msgId'); console.log(msgId,'msgId');
updateUploadProgress(msgId,100) updateUploadProgress(msgId,100)
this.sendUploadMessage(item) this.sendUploadMessage(item, msgId)
} else { } else {
const percentage = (item.uploadIndex / item.files.length) * 100 const percentage = (item.uploadIndex / item.files.length) * 100
item.percentage = percentage.toFixed(1) item.percentage = percentage.toFixed(1)
@ -124,11 +124,12 @@ export const useUploadsStore = defineStore('uploads', {
}, },
// 发送上传消息 // 发送上传消息
sendUploadMessage(item: any) { sendUploadMessage(item: any, file_num: String) {
ServeSendTalkFile({ ServeSendTalkFile({
upload_id: item.upload_id, upload_id: item.upload_id,
receiver_id: item.receiver_id, receiver_id: item.receiver_id,
talk_type: item.talk_type talk_type: item.talk_type,
file_num: file_num
}) })
} }
} }