处理本地缓存没有时,聊天记录的跳转,并处理直接调起相机、文件查看等问题

This commit is contained in:
wangyifeng 2025-03-18 20:00:41 +08:00
parent 026e4fa3e6
commit 2642a885f0
9 changed files with 672 additions and 317 deletions

View File

@ -25,33 +25,33 @@ const getFileTypeIMG = computed(() => {
let objT = {
finishedImg: '',
blankImg: '',
progressColor: ''
};
progressColor: '',
}
switch (suffix) {
case 'pdf':
objT.finishedImg = filePaperPDF
objT.blankImg = filePaperPDFBlank
objT.progressColor = '#DE4E4E'
break;
break
case 'doc':
case 'docx':
objT.finishedImg = filePaperWord
objT.blankImg = filePaperWordBlank
objT.progressColor = '#2750B2'
break;
break
case 'xls':
case 'xlsx':
objT.finishedImg = filePaperExcel
objT.blankImg = filePaperExcelBlank
objT.progressColor = '#3C7F4B'
break;
break
case 'ppt':
case 'pptx':
objT.finishedImg = filePaperPPT
objT.blankImg = filePaperPPTBlank
objT.progressColor = '#B74B2B'
break;
break
default:
objT.finishedImg = filePaperOther
objT.blankImg = filePaperOtherBlank
@ -60,34 +60,92 @@ const getFileTypeIMG = computed(() => {
return objT
})
const previewPDF = () => {
if (typeof plus !== 'undefined') {
downloadAndOpenFile()
} else {
document.addEventListener('plusready', () => {
downloadAndOpenFile()
})
}
}
const downloadAndOpenFile = () => {
uni.showLoading({ title: '加载中...', mask: true })
const downloadUrl = props?.extra?.path
if (!downloadUrl) {
uni.hideLoading()
uni.showToast({ title: '文件路径无效', icon: 'none' })
return
}
const options = {
filename: '_doc/downloads/', //
}
const dtask = plus.downloader.createDownload(downloadUrl, options, function (
d,
status,
) {
if (status === 200) {
uni.hideLoading()
const filePath = d.filename
if (filePath) {
plus.runtime.openFile(filePath, {}, function () {})
} else {
uni.showToast({ title: '文件路径无效', icon: 'none' })
}
} else {
uni.hideLoading()
}
})
dtask.start()
}
</script>
<template>
<section
class="file-message"
@click="previewPDF"
:class="{ left: data.float === 'left', right: data.float === 'right' }"
>
<div class="flex justify-between">
<div class="w-[228rpx] text-[32rpx] text-[#1A1A1A] h-[88rpx] leading-[44rpx] textEllipsis file_name">
<div
class="w-[228rpx] text-[32rpx] text-[#1A1A1A] h-[88rpx] leading-[44rpx] textEllipsis file_name"
>
{{ extra.name }}
</div>
<div v-if="data.uploadStatus === 2 || !data.uploadStatus" class="w-[95rpx]">
<tm-image :width="95" :height="95" :src="getFileTypeIMG.finishedImg"></tm-image>
<div
v-if="data.uploadStatus === 2 || !data.uploadStatus"
class="w-[95rpx]"
>
<tm-image
:width="95"
:height="95"
:src="getFileTypeIMG.finishedImg"
></tm-image>
</div>
<div v-if="data.uploadStatus === 1 || data.uploadStatus === 3" class="w-[95rpx]">
<tm-image :width="95" :height="95" :src="getFileTypeIMG.blankImg"></tm-image>
<wd-circle
customClass="circleProgress"
:modelValue="data.uploadCurrent"
layerColor="#E3E3E3"
:color="getFileTypeIMG.progressColor"
:strokeWidth="3"
:size="20"
></wd-circle>
<div
v-if="data.uploadStatus === 1 || data.uploadStatus === 3"
class="w-[95rpx]"
>
<tm-image
:width="95"
:height="95"
:src="getFileTypeIMG.blankImg"
></tm-image>
<wd-circle
customClass="circleProgress"
:modelValue="data.uploadCurrent"
layerColor="#E3E3E3"
:color="getFileTypeIMG.progressColor"
:strokeWidth="3"
:size="20"
></wd-circle>
</div>
</div>
<div class="divider mt-[28rpx]"></div>
<div class="text-[24rpx] text-[#747474] mt-[10rpx]">{{ fileFormatSize(extra.size) }}</div>
<div class="text-[24rpx] text-[#747474] mt-[10rpx]">
{{ fileFormatSize(extra.size) }}
</div>
<!-- <div class="main">
<div class="ext">{{ getFileNameSuffix(extra.name) }}</div>
<div class="file-box">
@ -124,7 +182,7 @@ const getFileTypeIMG = computed(() => {
border-radius: 16rpx 0 16rpx 16rpx;
}
.file_name{
.file_name {
word-break: break-all; /* 在任意字符间断行 */
word-wrap: break-word; /* 允许长单词换行到下一行 */
}
@ -217,7 +275,7 @@ const getFileTypeIMG = computed(() => {
}
.divider {
background-color: #E7E7E7;
background-color: #e7e7e7;
height: 1rpx;
}

View File

@ -379,6 +379,12 @@ const handleClickItem = (item) => {
}
return
}
if(props?.manageType === 'searchRecord'){
uni.navigateTo({
url: '/pages/search/searchByCondition/index?condition=member'
})
return
}
let itemList = dialogueParams.memberList
if (
props?.manageType === 'admin' &&

View File

@ -96,7 +96,9 @@
</div>
</div>
<div class="chat-records-search chat-settings-card">
<customInput :disabled="true"></customInput>
<div @click="toSearchPage">
<customInput :disabled="true"></customInput>
</div>
<div class="record-search-types">
<div
class="record-search-types-each"
@ -151,8 +153,10 @@
@click="showConfirmPrompt(2)"
class="clear-chat-record-btn-each"
v-if="
groupParams?.groupInfo?.is_manager && dialogueParams.type === 2
&& (groupParams?.groupInfo?.group_type === 1 || groupParams?.groupInfo?.group_type === 3)
groupParams?.groupInfo?.is_manager &&
dialogueParams.type === 2 &&
(groupParams?.groupInfo?.group_type === 1 ||
groupParams?.groupInfo?.group_type === 3)
"
>
<span class="text-[32rpx] font-regular">
@ -163,8 +167,10 @@
@click="showConfirmPrompt(3)"
class="clear-chat-record-btn-each"
v-if="
groupParams?.groupInfo?.is_manager && dialogueParams.type === 2
&& (groupParams?.groupInfo?.group_type === 1 || groupParams?.groupInfo?.group_type === 3)
groupParams?.groupInfo?.is_manager &&
dialogueParams.type === 2 &&
(groupParams?.groupInfo?.group_type === 1 ||
groupParams?.groupInfo?.group_type === 3)
"
>
<span class="text-[32rpx] font-regular">
@ -499,10 +505,7 @@ const toSearchByConditionPage = (flag) => {
}
uni.navigateTo({
url:
'/pages/search/searchByCondition/index?condition=' +
condition +
'&receiver_id=' +
state.groupId,
'/pages/search/searchByCondition/index?condition=' + condition
})
}
}
@ -629,6 +632,21 @@ const inviteMembersInGroup = async (memberList) => {
}
}
}
//
const toSearchPage = () => {
// uni.navigateTo({
// url:
// '/pages/search/searchByCondition/index?condition=text'
// })
uni.navigateTo({
url:
'/pages/search/moreResult/moreResultDetail?talk_type=' +
dialogueParams.type +
'&receiver_id=' +
dialogueParams.receiver_id,
})
}
</script>
<style scoped lang="scss">
.outer-layer {

View File

@ -1,25 +1,39 @@
<template>
<div class="emojiRoot">
<div @click="()=>photoActionsSelect(0)" class="flex flex-col items-center">
<div class="w-[106rpx] h-[106rpx] bg-[#F9F9F9] rounded-[60rpx] flex-center">
<div
@click="() => photoActionsSelect(0)"
class="flex flex-col items-center"
>
<div
class="w-[106rpx] h-[106rpx] bg-[#F9F9F9] rounded-[60rpx] flex-center"
>
<tm-image :width="53" :height="44" :src="photoAlbum"></tm-image>
</div>
<div class="mt-[6rpx] text-[#666666] text-[24rpx]">照片</div>
</div>
<div @click="()=>photoActionsSelect(1)" class="flex flex-col items-center">
<div class="w-[106rpx] h-[106rpx] bg-[#F9F9F9] rounded-[60rpx] flex-center">
<div
@click="() => photoActionsSelect(1)"
class="flex flex-col items-center"
>
<div
class="w-[106rpx] h-[106rpx] bg-[#F9F9F9] rounded-[60rpx] flex-center"
>
<tm-image :width="53" :height="44" :src="videoImg"></tm-image>
</div>
<div class="mt-[6rpx] text-[#666666] text-[24rpx]">视频</div>
</div>
<div @click="takePhoto" class="flex flex-col items-center">
<div class="w-[106rpx] h-[106rpx] bg-[#F9F9F9] rounded-[60rpx] flex-center">
<div
class="w-[106rpx] h-[106rpx] bg-[#F9F9F9] rounded-[60rpx] flex-center"
>
<tm-image :width="53" :height="44" :src="photoGraph"></tm-image>
</div>
<div class="mt-[6rpx] text-[#666666] text-[24rpx]">拍摄</div>
</div>
<div @click="chooseFile" class="flex flex-col items-center">
<div class="w-[106rpx] h-[106rpx] bg-[#F9F9F9] rounded-[60rpx] flex-center">
<div
class="w-[106rpx] h-[106rpx] bg-[#F9F9F9] rounded-[60rpx] flex-center"
>
<tm-image :width="53" :height="44" :src="folder"></tm-image>
</div>
<div class="mt-[6rpx] text-[#666666] text-[24rpx]">文件</div>
@ -27,10 +41,15 @@
</div>
</template>
<script setup>
import { ref, reactive, defineProps, defineEmits } from "vue"
import dayjs from "dayjs";
import { ref, reactive, defineProps, defineEmits } from 'vue'
import dayjs from 'dayjs'
import { beautifyTime } from '@/utils/datetime'
import { useDialogueListStore, useDialogueStore, useUserStore,useUploadsStore } from '@/store'
import {
useDialogueListStore,
useDialogueStore,
useUserStore,
useUploadsStore,
} from '@/store'
import { useSessionMenu } from '@/hooks'
import photoAlbum from '@/static/image/chatList/photoAlbum.png'
import photoGraph from '@/static/image/chatList/photoGraph.png'
@ -43,26 +62,34 @@ const props = defineProps({
sendUserInfo: {
type: Object,
default: {},
required: true
required: true,
},
talkParams: {
type: Object,
default: {},
required: true
}
});
required: true,
},
})
const state = reactive({
base64Url: ''
})
const uploadsStore = useUploadsStore()
const { addDialogueRecord, virtualList, updateUploadProgress } = useDialogueListStore()
const {
addDialogueRecord,
virtualList,
updateUploadProgress,
} = useDialogueListStore()
const dialogueStore = useDialogueStore()
const userStore = useUserStore()
const emit = defineEmits(['selectImg'])
const onProgressFn = (progress, id) => {
console.log(progress.loaded / progress.total * 100, 'progress');
console.log((progress.loaded / progress.total) * 100, 'progress')
updateUploadProgress(id, progress.loaded / progress.total * 100)
updateUploadProgress(id, (progress.loaded / progress.total) * 100)
}
const photoActionsSelect = (index) => {
@ -71,28 +98,31 @@ const photoActionsSelect = (index) => {
sourceType: ['album'],
count: 9,
success: async (res) => {
console.log(res,'res');
console.log(res, 'res')
res.tempFiles.forEach(async (file) => {
let data = await onUploadImageVideo(file, 'image')
emit('selectImg', data, data.file_num)
})
}
},
})
}else{
} else {
uni.chooseVideo({
sourceType: ['album'],
success: async (res) => {
console.log(res,'res');
let data = await onUploadImageVideo(res.tempFile, 'video',res.tempFilePath)
console.log(res, 'res')
let data = await onUploadImageVideo(
res.tempFile,
'video',
res.tempFilePath,
)
emit('selectImg', data, data.file_num)
}
},
})
}
}
const onUploadImageVideo = async (file, type = 'image',fileUrl) => {
console.log(file, 'file');
const onUploadImageVideo = async (file, type = 'image', fileUrl) => {
console.log(file, 'file')
return new Promise(async (resolve) => {
if (type === 'image') {
let image = new Image()
@ -100,20 +130,20 @@ const onUploadImageVideo = async (file, type = 'image',fileUrl) => {
image.onload = () => {
const form = new FormData()
form.append('file', file)
form.append("source", "fonchain-chat");
form.append("urlParam", `width=${image.width}&height=${image.height}`);
form.append('source', 'fonchain-chat')
form.append('urlParam', `width=${image.width}&height=${image.height}`)
let randomId = uniqueId()
let newItem = {
avatar: userStore.avatar,
created_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
extra: {
height: image.height,
name: "",
name: '',
size: 0,
url: image.src,
width: image.width
width: image.width,
},
float: "right",
float: 'right',
isCheck: false,
is_mark: 0,
is_read: 0,
@ -127,80 +157,84 @@ const onUploadImageVideo = async (file, type = 'image',fileUrl) => {
talk_type: dialogueStore.talk.talk_type,
user_id: userStore.uid,
uploadCurrent: 0,
uploadStatus: 1, // 1 2 3
uploadStatus: 1, // 1 2 3
}
virtualList.value.unshift(newItem)
uploadImg(form, (e) => onProgressFn(e, randomId)).then(({ status, data, msg }) => {
if (status == 0) {
resolve({
type: 'image',
url: data.ori_url,
size: file.size,
width: image.width,
height: image.height,
file_num: randomId,
})
} else {
resolve('')
message.error(msg)
}
})
uploadImg(form, (e) => onProgressFn(e, randomId)).then(
({ status, data, msg }) => {
if (status == 0) {
resolve({
type: 'image',
url: data.ori_url,
size: file.size,
width: image.width,
height: image.height,
file_num: randomId,
})
} else {
resolve('')
message.error(msg)
}
},
)
}
} else {
uni.getVideoInfo({
src:fileUrl,
success:(resp)=>{
console.log(resp);
form.append('file', file)
form.append("source", "fonchain-chat");
form.append("type", "video");
form.append("urlParam", `width=${resp.width}&height=${resp.height}`);
let randomId = uniqueId()
let newItem = {
avatar: userStore.avatar,
created_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
extra: {
duration: parseInt(resp.duration),
height: resp.height,
name: "",
url: fileUrl,
width: resp.width
},
float: "right",
isCheck: false,
is_mark: 0,
is_read: 0,
is_revoke: 0,
msg_id: randomId,
file_num: randomId,
msg_type: 5,
nickname: userStore.nickname,
receiver_id: dialogueStore.talk.receiver_id,
sequence: -1,
talk_type: dialogueStore.talk.talk_type,
user_id: userStore.uid,
uploadCurrent: 0,
uploadStatus: 1, // 1 2 3
}
virtualList.value.unshift(newItem)
uploadImg(form, (e) => onProgressFn(e, randomId)).then(({ status, data, msg }) => {
if (status == 0) {
console.log(data);
resolve({
type: 'video',
url: data.ori_url,
cover: data.cover_url,
src: fileUrl,
success: (resp) => {
console.log(resp)
form.append('file', file)
form.append('source', 'fonchain-chat')
form.append('type', 'video')
form.append('urlParam', `width=${resp.width}&height=${resp.height}`)
let randomId = uniqueId()
let newItem = {
avatar: userStore.avatar,
created_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
extra: {
duration: parseInt(resp.duration),
size: file.size,
file_num: randomId,
})
} else {
// resolve('')
// message.error(msg)
height: resp.height,
name: '',
url: fileUrl,
width: resp.width,
},
float: 'right',
isCheck: false,
is_mark: 0,
is_read: 0,
is_revoke: 0,
msg_id: randomId,
file_num: randomId,
msg_type: 5,
nickname: userStore.nickname,
receiver_id: dialogueStore.talk.receiver_id,
sequence: -1,
talk_type: dialogueStore.talk.talk_type,
user_id: userStore.uid,
uploadCurrent: 0,
uploadStatus: 1, // 1 2 3
}
})
}
virtualList.value.unshift(newItem)
uploadImg(form, (e) => onProgressFn(e, randomId)).then(
({ status, data, msg }) => {
if (status == 0) {
console.log(data)
resolve({
type: 'video',
url: data.ori_url,
cover: data.cover_url,
duration: parseInt(resp.duration),
size: file.size,
file_num: randomId,
})
} else {
// resolve('')
// message.error(msg)
}
},
)
},
})
const form = new FormData()
}
@ -209,132 +243,181 @@ const onUploadImageVideo = async (file, type = 'image',fileUrl) => {
const base64ToFile = (base64) => {
// base64file
const [header, base64String] = base64.split(";base64,");
const imageType = header.split(":")[1];
const byteCharacters = atob(base64String);
const [header, base64String] = base64.split(';base64,')
const imageType = header.split(':')[1]
const byteCharacters = atob(base64String)
const byteArray = new Uint8Array(
Array.from(byteCharacters, (char) => char.charCodeAt(0))
);
return new File(
[new Blob([byteArray], { type: imageType })],
"example.png",
{ type: imageType }
);
Array.from(byteCharacters, (char) => char.charCodeAt(0)),
)
return new File([new Blob([byteArray], { type: imageType })], 'example.png', {
type: imageType,
})
}
const choosePhoto = (filter = 'none', maximum = 9, multiple = true) => {
window.plus?.gallery.pick((res) => {
console.log(res);
res.files.reverse()
res.files.forEach(async (filePath) => {
const suffix = filePath.split('.').pop()?.toLowerCase() || ''
if (['jpg', 'png'].includes(suffix)) {
console.log("进入图片")
window.plus?.io?.resolveLocalFileSystemURL(filePath, async (entry) => {
entry.file((file) => {
const fileReader = new plus.io.FileReader();
fileReader.readAsDataURL(file);
fileReader.onloadend = async (e) => {
const base64Url = e.target.result;
const fileObj = base64ToFile(base64Url);
let data = await onUploadImageVideo(fileObj, 'image')
emit('selectImg', data)
};
})
},
(err) => {
console.log(err);
}
)
}
if (['mp4', 'flv'].includes(suffix)) {
console.log(filePath,"进入视频")
// const localUrl = plus.io.convertLocalFileSystemURL(filePath)
// console.log(localUrl);
plus.io.getVideoInfo({
filePath:filePath,
success:(event)=>{
console.log(event);
},
fail:(err)=>{
console.log(err);
window.plus?.gallery.pick(
(res) => {
console.log(res)
res.files.reverse()
res.files.forEach(async (filePath) => {
const suffix = filePath.split('.').pop()?.toLowerCase() || ''
if (['jpg', 'png'].includes(suffix)) {
console.log('进入图片')
window.plus?.io?.resolveLocalFileSystemURL(
filePath,
async (entry) => {
entry.file((file) => {
const fileReader = new plus.io.FileReader()
fileReader.readAsDataURL(file)
fileReader.onloadend = async (e) => {
const base64Url = e.target.result
const fileObj = base64ToFile(base64Url)
let data = await onUploadImageVideo(fileObj, 'image')
emit('selectImg', data)
}
})
},
(err) => {
console.log(err)
},
)
}
});
// window.plus?.io?.resolveLocalFileSystemURL(localUrl, async (entry) => {
// entry.file((file) => {
// console.log(file,'file');
// const fileReader = new plus.io.FileReader();
// fileReader.readAsDataURL(file);
// fileReader.onloadend = async (e) => {
// const base64Url = e.target.result;
// const fileObj = base64ToFile(base64Url);
// let data = await onUploadImageVideo(fileObj, 'video')
// emit('selectImg', data)
// };
// })
// },
// (err) => {
// console.log(err);
// }
// )
}
})
}, (err) => {
console.log(err);
},
if (['mp4', 'flv'].includes(suffix)) {
console.log(filePath, '进入视频')
// const localUrl = plus.io.convertLocalFileSystemURL(filePath)
// console.log(localUrl);
plus.io.getVideoInfo({
filePath: filePath,
success: (event) => {
console.log(event)
},
fail: (err) => {
console.log(err)
},
})
// window.plus?.io?.resolveLocalFileSystemURL(localUrl, async (entry) => {
// entry.file((file) => {
// console.log(file,'file');
// const fileReader = new plus.io.FileReader();
// fileReader.readAsDataURL(file);
// fileReader.onloadend = async (e) => {
// const base64Url = e.target.result;
// const fileObj = base64ToFile(base64Url);
// let data = await onUploadImageVideo(fileObj, 'video')
// emit('selectImg', data)
// };
// })
// },
// (err) => {
// console.log(err);
// }
// )
}
})
},
(err) => {
console.log(err)
},
{
filter: filter,
maximum: maximum,
multiple: multiple,
}
},
)
}
const takePhoto = () => {
if (typeof plus !== 'undefined') {
getCamera()
} else {
document.addEventListener('plusready', () => {
getCamera()
})
}
}
const chooseFile = () => {
uni.chooseFile({
count: 1,
extension:[''],
success: (res) => {
let randomId = uniqueId()
let newItem = {
avatar: userStore.avatar,
created_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
extra: {
drive: 3,
name: res.tempFiles[0].name,
size: res.tempFiles[0].size,
path: res.tempFilePaths[0],
},
float: "right",
isCheck: false,
is_mark: 0,
is_read: 0,
is_revoke: 0,
msg_id: randomId,
file_num: randomId,
msg_type: 6,
nickname: userStore.nickname,
receiver_id: dialogueStore.talk.receiver_id,
sequence: -1,
talk_type: dialogueStore.talk.talk_type,
user_id: userStore.uid,
uploadCurrent: 0,
uploadStatus: 1, // 1 2 3
}
virtualList.value.unshift(newItem)
uploadsStore.initUploadFile(res.tempFiles[0], props.talkParams,randomId)
}
const getCamera = () => {
const cmr = plus.camera.getCamera()
cmr.captureImage(
(p) => {
plus.io.resolveLocalFileSystemURL(
p,
(entry) => {
compressAndShowImage(entry.toLocalURL(), entry.name)
},
(err) => {
console.log(err)
},
)
},
() => {},
{ index: '2' },
)
}
const compressAndShowImage = (url, filename) => {
const dst = `_doc/upload/${filename}`
plus.zip.compressImage(
{ src: url, dst, quality: 10, overwrite: true },
(zip) => displayImage(zip.target),
(err) => {
console.log(err)
},
)
}
const displayImage = (url) => {
plus.io.resolveLocalFileSystemURL(url, (entry) => {
entry.file((file) => {
const fileReader = new plus.io.FileReader()
fileReader.readAsDataURL(file)
fileReader.onloadend = async (e) => {
state.base64Url = e.target.result
const imageFile = base64ToFile(state.base64Url)
let data = await onUploadImageVideo(imageFile, 'image')
emit('selectImg', data, data.file_num)
}
})
})
}
const chooseFile = () => {
uni.chooseFile({
count: 1,
extension: [''],
success: (res) => {
let randomId = uniqueId()
let newItem = {
avatar: userStore.avatar,
created_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
extra: {
drive: 3,
name: res.tempFiles[0].name,
size: res.tempFiles[0].size,
path: res.tempFilePaths[0],
},
float: 'right',
isCheck: false,
is_mark: 0,
is_read: 0,
is_revoke: 0,
msg_id: randomId,
file_num: randomId,
msg_type: 6,
nickname: userStore.nickname,
receiver_id: dialogueStore.talk.receiver_id,
sequence: -1,
talk_type: dialogueStore.talk.talk_type,
user_id: userStore.uid,
uploadCurrent: 0,
uploadStatus: 1, // 1 2 3
}
virtualList.value.unshift(newItem)
uploadsStore.initUploadFile(res.tempFiles[0], props.talkParams, randomId)
},
})
}
</script>
<style lang="scss" scoped>
.emojiRoot {

View File

@ -493,7 +493,12 @@ import useZPaging from '@/uni_modules/z-paging/components/z-paging/js/hooks/useZ
import emojiPanel from './components/emojiPanel.vue'
import filePanel from './components/filePanel.vue'
import lodash from 'lodash'
import { ServePublishMessage,detailGetRecordsContext,ServeClearTalkUnreadNum } from '@/api/chat'
import {
ServePublishMessage,
detailGetRecordsContext,
ServeClearTalkUnreadNum,
ServeTalkRecords,
} from '@/api/chat'
import copy07 from '@/static/image/chatList/copy07@2x.png'
import multipleChoices from '@/static/image/chatList/multipleChoices@2x.png'
import cite from '@/static/image/chatList/cite@2x.png'
@ -545,10 +550,7 @@ const state = ref({
isOpenFilePanel: false,
showWin: false,
onfocusItem: null,
sessionId: '',
talkType: '',
receiverId: '',
indexName: '',
sessionId: '', //Id
localPageLoadDone: true, //
quoteInfo: null, //
mentionIsMulSelect: false, //
@ -557,15 +559,14 @@ const state = ref({
selectAreaHeight: 0, //
isShowMentionSelect: false, //
useCustomLoadMore: false, //使
recordDate: '', //
serveFindRecord: [], //
})
uniOnload((options) => {
console.log('onLoad'+ options)
uniOnload(async (options) => {
console.log('onLoad' + options)
if (options.sessionId) {
state.value.sessionId = options.sessionId
state.value.talkType = options.talkType
state.value.receiverId = options.receiverId
state.value.indexName = options.indexName
}
if (options.msgInfo) {
const msgInfo = JSON.parse(decodeURIComponent(options.msgInfo))
@ -573,18 +574,23 @@ uniOnload((options) => {
state.value.useCustomLoadMore = true
return
}
if (options.recordDate) {
state.value.recordDate = options.recordDate
const msgInfo = await findTalkRecords(options.recordDate, true)
queryRecordsByMsgInfo(msgInfo)
state.value.useCustomLoadMore = true
return
}
initData()
})
uniOnUnload(() => {
console.log('onUnload')
console.log(state.value.talkType)
console.log(state.value.receiverId)
ServeClearTalkUnreadNum({
talk_type: Number(state.value.talkType),
receiver_id: Number(state.value.receiverId)
talk_type: Number(talkParams.type),
receiver_id: Number(talkParams.receiver_id),
}).then(() => {
talkStore.updateItem({
index_name: state.value.indexNamee,
index_name: talkParams.index_name,
unread_num: 0,
})
})
@ -1089,9 +1095,13 @@ watch(
if (newValue) {
const dialogueList = getDialogueList(talkParams.index_name)
// console.log(newValue[newValue.length - 1]?.sequence, dialogueList?.records?.[0]?.sequence)
if (!dialogueList || dialogueList?.length === 0) {
state.value.localPageLoadDone = true
return
}
if (
newValue[newValue.length - 1]?.sequence ===
dialogueList.records?.[0]?.sequence
dialogueList?.records?.[0]?.sequence
) {
//
state.value.localPageLoadDone = true
@ -1105,14 +1115,28 @@ watch(
},
)
const onScrollToLower = () => {
const onScrollToLower = async () => {
if (state.value.useCustomLoadMore) {
const tempVirtualList = lodash.cloneDeep(virtualList.value).reverse()
const dialogueList = getDialogueList(talkParams.index_name)
const recordIndex = dialogueList.records.findIndex(
const recordIndex = dialogueList?.records?.findIndex(
(record) => record.msg_id === tempVirtualList[0].msg_id,
)
if (recordIndex === -1) {
if (!recordIndex || recordIndex === -1) {
const moreRecords = await findTalkRecords(
'',
false,
tempVirtualList[0].sequence,
{
direction: 'up',
sort_sequence: '',
},
)
console.log(moreRecords)
virtualList.value = moreRecords.concat(tempVirtualList).reverse()
console.log(virtualList.value)
} else {
if (tempVirtualList[0].sequence > dialogueList.records[0].sequence) {
virtualList.value = dialogueList.records
@ -1139,15 +1163,32 @@ const onScrollToLower = () => {
}
//
const onScrollToUpper = () => {
const onScrollToUpper = async () => {
if (state.value.useCustomLoadMore) {
const tempVirtualList = lodash.cloneDeep(virtualList.value).reverse()
const dialogueList = getDialogueList(talkParams.index_name)
const recordIndex = dialogueList.records.findIndex(
const recordIndex = dialogueList?.records?.findIndex(
(record) =>
record.msg_id === tempVirtualList[tempVirtualList.length - 1].msg_id,
)
if (recordIndex === -1) {
console.log(recordIndex)
if (!recordIndex || recordIndex === -1) {
// ID
const currentMsgId = tempVirtualList[tempVirtualList.length - 1].msg_id
const moreRecords = await findTalkRecords(
'',
false,
tempVirtualList[tempVirtualList.length - 1].sequence,
)
console.log(moreRecords)
virtualList.value = tempVirtualList.concat(moreRecords.reverse()).reverse()
console.log(virtualList.value)
//
nextTick(() => {
zpagingRef.value?.scrollIntoViewById('zp-id-' + currentMsgId)
})
} else {
if (
tempVirtualList[tempVirtualList.length - 1].sequence <
@ -1266,57 +1307,122 @@ const getMentionSelectLists = (mentionSelectList) => {
}
//msgsequence
const queryRecordsByMsgInfo = (msgInfo) => {
const queryRecordsByMsgInfo = async (msgInfo) => {
console.log(msgInfo)
const dialogueList = getDialogueList(talkParams.index_name)
const recordIndex = dialogueList.records.findIndex(
const recordIndex = dialogueList?.records?.findIndex(
(record) => record.msg_id === msgInfo.msg_id,
)
if (recordIndex === -1) {
let recordsList = []
console.log(recordIndex)
if (!recordIndex || recordIndex === -1) {
recordsList = await findTalkRecords('', true, msgInfo.sequence)
} else {
// console.log(recordIndex)
const startRecordIndex = Math.max(0, recordIndex - 10)
const endRecordIndex = Math.max(0, recordIndex + 10)
// console.log(dialogueList.records.slice(startRecordIndex, endRecordIndex))
// console.log(recordIndex-startRecordIndex)
const recordsList = dialogueList.records.slice(
startRecordIndex,
endRecordIndex,
)
nextTick(() => {
zpagingRef.value.complete(recordsList.reverse())
loadConfig.status = dialogueList.records?.[0]?.sequence > 1 ? 1 : 2
nextTick(() => {
let offset = uni.getSystemInfoSync().windowHeight
const navBarAreaQuery = uni.createSelectorQuery()
navBarAreaQuery
.select('#navBarArea')
.boundingClientRect((res) => {
if (res) {
// console.log(':', res.height)
offset = offset - res.height
}
})
.exec()
const footBoxAreaQuery = uni.createSelectorQuery()
footBoxAreaQuery
.select('#footBoxArea')
.boundingClientRect((res) => {
if (res) {
// console.log(':', res.height)
offset = offset - res.height
}
})
.exec()
setTimeout(() => {
zpagingRef.value.scrollIntoViewById(
'zp-id-' + msgInfo.msg_id,
offset - 60,
)
}, 1000)
})
})
recordsList = dialogueList.records.slice(startRecordIndex, endRecordIndex)
}
nextTick(() => {
zpagingRef.value.complete(recordsList.reverse())
loadConfig.status = dialogueList?.records?.[0]?.sequence > 1 ? 1 : 2
nextTick(() => {
let offset = uni.getSystemInfoSync().windowHeight
const navBarAreaQuery = uni.createSelectorQuery()
navBarAreaQuery
.select('#navBarArea')
.boundingClientRect((res) => {
if (res) {
// console.log(':', res.height)
offset = offset - res.height
}
})
.exec()
const footBoxAreaQuery = uni.createSelectorQuery()
footBoxAreaQuery
.select('#footBoxArea')
.boundingClientRect((res) => {
if (res) {
// console.log(':', res.height)
offset = offset - res.height
}
})
.exec()
setTimeout(() => {
zpagingRef.value.scrollIntoViewById(
'zp-id-' + msgInfo.msg_id,
offset - 60,
)
}, 1000)
})
})
}
//
const findTalkRecords = (record, isMiddle, sequence, appointParams) => {
return new Promise((resolve, reject) => {
let params = {
talk_type: talkParams.type, //12
receiver_id: talkParams.receiver_id, //idid
no_limit: '', //1
file_name: '',
msg_type: 0, //0:;2:;3:;4:;5:;6:;7:;9:;11;12
cursor: sequence || 0, //
limit: 10, //
direction: 'down', //downup
start_time: '',
end_time: '',
group_member_user_id: 0, //id
sort_sequence: 'asc',
}
if (record) {
params = Object.assign({}, params, {
start_time: record,
end_time: record,
limit: 1,
direction: '',
})
}
if (appointParams) {
params = Object.assign({}, params, appointParams)
}
console.log(params)
const resp = ServeTalkRecords(params)
console.log(resp)
resp.then(({ code, data }) => {
console.log(data)
if (code == 200) {
if (data?.items.length > 0) {
if (record) {
resolve(data?.items[0])
return
}
if (isMiddle) {
state.value.serveFindRecord = JSON.parse(
JSON.stringify(data?.items),
)
return findTalkRecords('', false, sequence + 1, {
direction: 'up',
sort_sequence: '',
}).then((finalResult) => {
console.log(finalResult)
resolve(finalResult)
})
} else {
state.value.serveFindRecord = data?.items
.reverse()
.concat(state.value.serveFindRecord)
resolve(JSON.parse(JSON.stringify(state.value.serveFindRecord)))
state.value.serveFindRecord = []
}
}
} else {
}
})
resp.catch(() => {})
})
}
//
@ -1368,7 +1474,9 @@ const rpxToPx = (rpx) => {
}
onUnmounted(() => {
dialogueStore.setDialogue({})
if (!state.value.recordDate) {
dialogueStore.setDialogue({})
}
clearMultiSelect()
})
</script>

View File

@ -136,7 +136,7 @@ const cellClick = () => {
});
}
uni.navigateTo({
url: `/pages/dialog/index?sessionId=${props.data.id}&talkType=${props.data.talk_type}&receiverId=${props.data.receiver_id}&indexName=${props.data.index_name}`,
url: `/pages/dialog/index?sessionId=${props.data.id}`,
});
};

View File

@ -250,7 +250,7 @@ onLoad((options) => {
})
}
uni.navigateTo({
url: `/pages/dialog/index?sessionId=${openSession.id}&talkType=${openSession.talk_type}&receiverId=${openSession.receiver_id}&indexName=${openSession.index_name}`,
url: `/pages/dialog/index?sessionId=${openSession.id}`,
})
}
})

View File

@ -19,6 +19,7 @@
'font-size': '28rpx',
'font-weight': 400,
}"
:refresher-enabled="false"
>
<template #top>
<div class="searchRoot">
@ -299,7 +300,11 @@ const queryAllSearch = (pageNum, searchResultPageSize) => {
)
let total = data.count
if (props.searchRecordDetail) {
total = data.group_record_count
if(state?.first_talk_record_infos?.talk_type === 1){
total = data.user_record_count
} else if (state?.first_talk_record_infos?.talk_type === 2){
total = data.group_record_count
}
}
zPaging.value?.completeByTotal([data], total)
} else {
@ -389,9 +394,12 @@ const getHasMoreResult = (searchResultKey) => {
}
break
case 'general_infos':
// if (state?.searchResult['general_infos']?.length >= 3) {
// has_more_result = t('has_more') + t('chat.type.record')
// }
if (
state.searchResult['record_count'] &&
state.searchResult['record_count'] > 3
) {
has_more_result = t('has_more') + t('chat.type.record')
}
break
default:
}

View File

@ -64,7 +64,8 @@
v-if="
state.condition === 'imgAndVideo' ||
state.condition === 'file' ||
state.condition === 'link'
state.condition === 'link' ||
state.condition === 'member'
"
:style="{
padding: state.condition === 'imgAndVideo' ? '0 27rpx' : '',
@ -72,7 +73,11 @@
>
<div
class="search-by-condition-input"
v-if="state.condition === 'file' || state.condition === 'link'"
v-if="
state.condition === 'file' ||
state.condition === 'link' ||
state.condition === 'member'
"
>
<customInput
:searchText="state.searchText"
@ -173,6 +178,7 @@
</div>
<div
class="condition-each-result-attachments"
@click="previewPDF(item)"
v-if="
state.condition === 'file' || state.condition === 'link'
"
@ -255,7 +261,7 @@ import useZPaging from '@/uni_modules/z-paging/components/z-paging/js/hooks/useZ
import { parseTime } from '@/utils/datetime'
import { onMounted, reactive, computed, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { ServeTalkDate } from '@/api/search/index'
import { ServeTalkDate, ServeGetSessionId } from '@/api/search/index'
import { ServeFindTalkRecords } from '@/api/chat/index'
import { useDialogueStore } from '@/store'
import { useI18n } from 'vue-i18n'
@ -273,7 +279,6 @@ const dialogueParams = reactive({
let nowDay = new Date().setHours(0, 0, 0, 0)
const state = reactive({
receiver_id: '', //id
pageTitle: '', //
dateStyle: [], //
nowDate: new Date(nowDay), //
@ -289,16 +294,16 @@ const state = reactive({
searchResultList: [], //
cursor: 0, //
msg_type: 0, //
group_member_id: 0, //id
})
onLoad((options) => {
console.log(options)
if (options.receiver_id) {
state.receiver_id = Number(options.receiver_id)
}
if (options.condition) {
state.condition = options.condition
if (options.condition === 'date') {
if (options.condition === 'member') {
// queryAllSearch()
} else if (options.condition === 'date') {
state.showPageTitle = true
state.pageTitle = t('search.condition.date')
ServeQueryTalkDate(parseTime(state.nowDate, '{y}{m}'))
@ -352,7 +357,7 @@ const ServeQueryTalkDate = (month) => {
let params = {
month: month,
talk_type: dialogueParams.talk_type, //12
receiver_id: state.receiver_id, //id
receiver_id: dialogueParams.receiver_id, //id
}
const resp = ServeTalkDate(params)
console.log(resp)
@ -387,7 +392,7 @@ const ServeQueryTalkDate = (month) => {
}
//
const selectDate = (e) => {
const selectDate = async (e) => {
if (e == parseTime(state.nowDate, '{y}/{m}/{d}')) {
console.log('==今日')
state.dateStyle = [
@ -413,6 +418,37 @@ const selectDate = (e) => {
},
]
}
const sessionId = await getSessionId(
dialogueParams.talk_type,
dialogueParams.receiver_id,
)
uni.navigateTo({
url:
'/pages/dialog/index?sessionId=' +
sessionId +
'&recordDate=' +
parseTime(e, '{y}-{m}-{d}'),
})
}
//Id
const getSessionId = (talk_type, receiver_id) => {
return new Promise((resolve, reject) => {
let params = {
talkType: talk_type,
receiverId: receiver_id,
}
const resp = ServeGetSessionId(params)
console.log(resp)
resp.then(({ code, data }) => {
console.log(data)
if (code == 200) {
resolve(data?.sessionId)
} else {
}
})
resp.catch(() => {})
})
}
//
@ -466,7 +502,7 @@ const queryAllSearch = () => {
direction: 'up', //downup
start_time: '',
end_time: '',
group_member_user_id: 0, //id
group_member_user_id: state.group_member_id, //id
file_name: state.msg_type === 6 ? state.searchText : '',
}
console.log(params)
@ -564,6 +600,43 @@ const fileTypeAvatar = (fileType) => {
}
return file_type_avatar
}
const previewPDF = (item) => {
console.log(item)
if (typeof plus !== 'undefined') {
downloadAndOpenFile(item)
} else {
document.addEventListener('plusready', () => {
downloadAndOpenFile(item)
})
}
}
const downloadAndOpenFile = (item) => {
uni.showLoading({ title: '加载中...', mask: true })
const downloadUrl = item?.extra?.path
const options = {
filename: '_doc/downloads/', //
}
const dtask = plus.downloader.createDownload(downloadUrl, options, function (
d,
status,
) {
if (status === 200) {
uni.hideLoading()
const filePath = d.filename
plus.runtime.openFile(
filePath,
{},
function () {},
function (error) {},
)
} else {
uni.hideLoading()
}
})
dtask.start()
}
</script>
<style scoped lang="scss">
.search-by-date {
@ -670,6 +743,7 @@ body::v-deep .round-3 {
span {
line-height: 40rpx;
color: $theme-text;
word-break: break-all;
}
}
.attachment-sub-info {