解决从搜索聊天记录跳转聊天时,下拉刷新上拉加载数据错误问题;解决图片、视频、文件上传后会变成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_,
// bottom: 0,
// })
// console.log(webview)
console.log("webview", webview)
token.value = webview.token
}
const init = () => {

View File

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

View File

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

View File

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

View File

@ -863,8 +863,8 @@ const editorOption = {
placeholder: '',
}
const handleSelectImg = (data) => {
onSendMessage({ ...data })
const handleSelectImg = (data, file_num) => {
onSendMessage({ ...data, file_num })
}
const virtualListChange = (vList) => {
@ -1094,7 +1094,7 @@ const onScrollToLower = () => {
} else {
if (tempVirtualList[0].sequence > dialogueList.records[0].sequence) {
virtualList.value = dialogueList.records
.slice(0, recordIndex)
.slice(Math.max(0, recordIndex - 10), recordIndex)
.concat(tempVirtualList)
.reverse()
// zpagingRef.value.setLocalPaging(
@ -1131,27 +1131,22 @@ const onScrollToUpper = () => {
tempVirtualList[tempVirtualList.length - 1].sequence <
dialogueList.records[dialogueList.records.length - 1].sequence
) {
// ID
const currentMsgId = tempVirtualList[tempVirtualList.length - 1].msg_id
virtualList.value = tempVirtualList
.concat(
dialogueList.records.slice(
recordIndex + 1,
Math.min(recordIndex + 11, dialogueList.records.length),
dialogueList.records.length,
),
)
.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;
border: 2rpx solid #000;
border-radius: 6rpx;
flex-shrink: 0;
span {
line-height: 34rpx;
}
@ -299,6 +300,7 @@ const resultDetail = computed(() => {
.info-detail-searchRecordDetail {
span {
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 pointerIconSrc from '@/static/image/search/search-item-pointer.png'
import lodash from 'lodash'
import { useUserStore } from '@/store'
const userStore = useUserStore()
const zPaging = ref()
useZPaging(zPaging)
@ -131,6 +135,7 @@ const state = reactive({
searchResultList: [], //
searchResult: null, //
pageNum: 1, //
uid: computed(() => userStore.uid), //id
})
const props = defineProps({
@ -197,10 +202,29 @@ const queryAllSearch = (pageNum, searchResultPageSize) => {
})
}
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,
data.talk_record_infos[0],
receiverInfo,
)
;(data.talk_record_infos || []).forEach((item) => {
item.group_type = 0

View File

@ -17,6 +17,10 @@ import { ServeSeachQueryAll } from '@/api/search/index'
import { onMounted } from 'vue'
import { handleSetWebviewStyle } from '@/utils/common'
import { useDialogueStore } from '@/store'
const dialogueStore = useDialogueStore()
onMounted(() => {
handleSetWebviewStyle()
})
@ -38,9 +42,24 @@ const clickSearchItem = (
searchResultKey,
talk_type,
receiver_id,
res,
) => {
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({
url:
'/pages/search/moreResult/moreResultDetail?searchText=' +

View File

@ -24,6 +24,10 @@ import {
} from '@/api/search/index'
import { reactive } from 'vue'
import { useDialogueStore } from '@/store'
const dialogueStore = useDialogueStore()
const state = reactive({
apiRequest: Function,
apiParams: String,
@ -86,8 +90,27 @@ const lastIdChange = (last_id, last_group_id, last_member_id) => {
}
//
const clickSearchItem = (searchText) => {
if (state.searchResultKey === 'general_infos') {
const clickSearchItem = (
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({
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 { ServeTalkRecord } from '@/api/search/index'
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({
apiParams: String,
searchText: String,
uid: computed(() => userStore.uid), //id
})
onLoad((options) => {
@ -80,15 +83,42 @@ const clickSearchItem = (
receiver_id,
res,
) => {
console.log(searchResultKey)
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({
name: result.receiver_name,
name: receiverInfo.receiver_name,
talk_type: talk_type,
receiver_id: receiver_id,
})
uni.navigateTo({
url: '/pages/dialog/index?msgInfo=' + res,
receiver_id: receiverInfo.receiver_id,
})
if (searchResultKey === 'talk_record_infos_receiver') {
uni.navigateTo({
url: '/pages/dialog/index',
})
} else {
uni.navigateTo({
url: '/pages/dialog/index?msgInfo=' + res,
})
}
}
</script>
<style scoped lang="scss"></style>

View File

@ -107,7 +107,18 @@ export const useDialogueListStore = createGlobalState(() => {
const addChatRecord = (indexName, item) => {
const dialogue = lodash.cloneDeep(useDialogueStore())
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');
updateUploadProgress(msgId,100)
this.sendUploadMessage(item)
this.sendUploadMessage(item, msgId)
} else {
const percentage = (item.uploadIndex / item.files.length) * 100
item.percentage = percentage.toFixed(1)
@ -124,11 +124,12 @@ export const useUploadsStore = defineStore('uploads', {
},
// 发送上传消息
sendUploadMessage(item: any) {
sendUploadMessage(item: any, file_num: String) {
ServeSendTalkFile({
upload_id: item.upload_id,
receiver_id: item.receiver_id,
talk_type: item.talk_type
talk_type: item.talk_type,
file_num: file_num
})
}
}