解决推送消息点击后,跳转页面读不出数据的问题

This commit is contained in:
wangyifeng 2025-03-20 14:35:40 +08:00
parent 92a7d74c6c
commit 8034a303e7
7 changed files with 212 additions and 186 deletions

2
components.d.ts vendored
View File

@ -30,6 +30,8 @@ declare module 'vue' {
LoginMessage: typeof import('./src/components/talk/message/LoginMessage.vue')['default'] LoginMessage: typeof import('./src/components/talk/message/LoginMessage.vue')['default']
Message: typeof import('./src/components/x-message/message/index.vue')['default'] Message: typeof import('./src/components/x-message/message/index.vue')['default']
MixedMessage: typeof import('./src/components/talk/message/MixedMessage.vue')['default'] MixedMessage: typeof import('./src/components/talk/message/MixedMessage.vue')['default']
NButton: typeof import('naive-ui')['NButton']
NIcon: typeof import('naive-ui')['NIcon']
PageAnimation: typeof import('./src/components/page-animation/index.vue')['default'] PageAnimation: typeof import('./src/components/page-animation/index.vue')['default']
RevokeMessage: typeof import('./src/components/talk/message/RevokeMessage.vue')['default'] RevokeMessage: typeof import('./src/components/talk/message/RevokeMessage.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink'] RouterLink: typeof import('vue-router')['RouterLink']

View File

@ -69,6 +69,7 @@ export function createApp() {
window.openUniPushMsg = (msg) => { window.openUniPushMsg = (msg) => {
console.log("=====点击通知栏消息") console.log("=====点击通知栏消息")
let pushMsg = JSON.parse(decodeURIComponent(msg)) let pushMsg = JSON.parse(decodeURIComponent(msg))
console.log("=====pushMsg",pushMsg)
//由于弹窗前处理了不该弹窗的场景,因此这里弹窗可以一并处理 //由于弹窗前处理了不该弹窗的场景,因此这里弹窗可以一并处理
//也就是都跳转到聊天页面 //也就是都跳转到聊天页面
const talkStore = useTalkStore() const talkStore = useTalkStore()

View File

@ -504,8 +504,7 @@ const toSearchByConditionPage = (flag) => {
condition = 'link' condition = 'link'
} }
uni.navigateTo({ uni.navigateTo({
url: url: '/pages/search/searchByCondition/index?condition=' + condition,
'/pages/search/searchByCondition/index?condition=' + condition
}) })
} }
} }
@ -644,7 +643,8 @@ const toSearchPage = () => {
'/pages/search/moreResult/moreResultDetail?talk_type=' + '/pages/search/moreResult/moreResultDetail?talk_type=' +
dialogueParams.type + dialogueParams.type +
'&receiver_id=' + '&receiver_id=' +
dialogueParams.receiver_id, dialogueParams.receiver_id +
'&hideFirstRecord=1',
}) })
} }
</script> </script>

View File

@ -8,7 +8,11 @@
<div class="avatarImg"> <div class="avatarImg">
<tm-badge <tm-badge
:count="props.data.is_disturb === 1 ? props.data.unread_num : ''" :count="props.data.is_disturb === 1 ? props.data.unread_num : ''"
:dot="props.data.is_disturb === 0 && props.data.unread_num" :dot="
props.data.is_disturb === 0 && props.data.unread_num
? true
: false
"
:maxCount="99" :maxCount="99"
class="badge" class="badge"
color="#D03050" color="#D03050"
@ -34,10 +38,13 @@
<div class="chatInfo"> <div class="chatInfo">
<div class="chatInfo_1"> <div class="chatInfo_1">
<div class="name_center"> <div class="name_center">
<div class="text-[#000000] text-[32rpx] <div
font-bold opacity-90 name_text"> class="text-[#000000] text-[32rpx] font-bold opacity-90 name_text"
>
{{ formatNameText(props.data.name) }} {{ formatNameText(props.data.name) }}
<span v-if="props.data.talk_type === 2">{{props.data.group_member_num}}</span> <span v-if="props.data.talk_type === 2">
{{ props.data.group_member_num }}
</span>
<span v-if="props.data.group_type === 2" class="depTag tag"> <span v-if="props.data.group_type === 2" class="depTag tag">
部门 部门
</span> </span>
@ -48,9 +55,9 @@
公司 公司
</span> </span>
</div> </div>
</div> </div>
<div style="flex-shrink: 0;" <div
style="flex-shrink: 0;"
class="text-[#000000] text-[28rpx] font-medium opacity-26 ml-[24rpx] time_right" class="text-[#000000] text-[28rpx] font-medium opacity-26 ml-[24rpx] time_right"
> >
{{ beautifyTime(props.data.updated_at) }} {{ beautifyTime(props.data.updated_at) }}
@ -66,12 +73,12 @@
<template #right> <template #right>
<div class="flex flex-row flex-row-center-end"> <div class="flex flex-row flex-row-center-end">
<!-- 样式占位 --> <!-- 样式占位 -->
<div style="width: 1px"></div> <div style="width: 1px;"></div>
<div <div
@click="handleTop" @click="handleTop"
class="w-[156rpx] h-[154rpx] text-[#ffffff] bg-[#F09F1F] flex items-center justify-center" class="w-[156rpx] h-[154rpx] text-[#ffffff] bg-[#F09F1F] flex items-center justify-center"
> >
{{ props.data.is_top === 1 ? "取消置顶" : "置顶" }} {{ props.data.is_top === 1 ? '取消置顶' : '置顶' }}
</div> </div>
<div <div
@click="handleDelete" @click="handleDelete"
@ -89,17 +96,17 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import avatarModule from "@/components/avatar-module/index.vue"; import avatarModule from '@/components/avatar-module/index.vue'
import { ref, reactive, defineProps, computed } from "vue"; import { ref, reactive, defineProps, computed } from 'vue'
import dayjs from "dayjs"; import dayjs from 'dayjs'
import { beautifyTime } from "@/utils/datetime"; import { beautifyTime } from '@/utils/datetime'
import { ServeClearTalkUnreadNum } from "@/api/chat"; import { ServeClearTalkUnreadNum } from '@/api/chat'
import { useTalkStore, useDialogueStore } from "@/store"; import { useTalkStore, useDialogueStore } from '@/store'
import { useSessionMenu } from "@/hooks"; import { useSessionMenu } from '@/hooks'
const talkStore = useTalkStore(); const talkStore = useTalkStore()
const { onToTopTalk, onRemoveTalk } = useSessionMenu(); const { onToTopTalk, onRemoveTalk } = useSessionMenu()
const dialogueStore = useDialogueStore(); const dialogueStore = useDialogueStore()
const props = defineProps({ const props = defineProps({
data: { data: {
type: Object, type: Object,
@ -111,17 +118,17 @@ const props = defineProps({
default: -1, default: -1,
required: true, required: true,
}, },
}); })
// //
const formatNameText = (text, maxLength = 16) => { const formatNameText = (text, maxLength = 16) => {
return text.length > maxLength ? `${text.slice(0, maxLength - 1)}...` : text; return text.length > maxLength ? `${text.slice(0, maxLength - 1)}...` : text
}; }
const cellClick = () => { const cellClick = () => {
console.log(props.data); console.log(props.data)
// //
dialogueStore.setDialogue(props.data); dialogueStore.setDialogue(props.data)
// //
if (props.data.unread_num > 0) { if (props.data.unread_num > 0) {
@ -132,31 +139,31 @@ const cellClick = () => {
talkStore.updateItem({ talkStore.updateItem({
index_name: props.data.index_name, index_name: props.data.index_name,
unread_num: 0, unread_num: 0,
}); })
}); })
} }
uni.navigateTo({ uni.navigateTo({
url: `/pages/dialog/index?sessionId=${props.data.id}`, url: `/pages/dialog/index?sessionId=${props.data.id}`,
}); })
}; }
const handleTop = () => { const handleTop = () => {
console.log(props.data, 1); console.log(props.data, 1)
onToTopTalk(props.data); onToTopTalk(props.data)
}; }
// //
const handleDelete = () => { const handleDelete = () => {
console.log(props.data); console.log(props.data)
onRemoveTalk(props.data); onRemoveTalk(props.data)
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
::v-deep .swipe_action { ::v-deep .swipe_action {
// border: 1px solid #fff; // border: 1px solid #fff;
// transform: translate3d(1px, 0px, 0px) !important; // transform: translate3d(1px, 0px, 0px) !important;
} }
::v-deep .badge .round-6{ ::v-deep .badge .round-6 {
min-width: 22rpx; min-width: 22rpx;
min-height: 22rpx; min-height: 22rpx;
} }
@ -194,7 +201,7 @@ const handleDelete = () => {
font-size: 28rpx; font-size: 28rpx;
color: rgba($color: #000000, $alpha: 0.4); color: rgba($color: #000000, $alpha: 0.4);
} }
.tag{ .tag {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
text-align: center; text-align: center;
@ -220,11 +227,11 @@ const handleDelete = () => {
border: 1px solid #c1681c; border: 1px solid #c1681c;
color: #c1681c; color: #c1681c;
} }
.name_center{ .name_center {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
} }
.name_text{ .name_text {
display: inline-block; display: inline-block;
max-height: 88rpx; // max-height: 88rpx; //
line-height: 44rpx; line-height: 44rpx;

View File

@ -125,6 +125,7 @@ import { ref, watch, computed } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app' import { onShow, onLoad } from '@dcloudio/uni-app'
import { useChatList } from '@/store/chatList/index.js' import { useChatList } from '@/store/chatList/index.js'
import { useAuth } from '@/store/auth' import { useAuth } from '@/store/auth'
import { ServeClearTalkUnreadNum } from '@/api/chat'
import { useTalkStore, useUserStore, useDialogueStore } from '@/store' import { useTalkStore, useUserStore, useDialogueStore } from '@/store'
import chatItem from './components/chatItem.vue' import chatItem from './components/chatItem.vue'
import addCircle from '@/static/image/chatList/addCircle.png' import addCircle from '@/static/image/chatList/addCircle.png'
@ -237,6 +238,7 @@ onLoad((options) => {
if (items?.value?.length > 0) { if (items?.value?.length > 0) {
items.value.forEach((openSession) => { items.value.forEach((openSession) => {
if (openSession.index_name === options?.openSessionIndexName) { if (openSession.index_name === options?.openSessionIndexName) {
setTimeout(() => {
dialogueStore.setDialogue(openSession) dialogueStore.setDialogue(openSession)
if (openSession.unread_num > 0) { if (openSession.unread_num > 0) {
ServeClearTalkUnreadNum({ ServeClearTalkUnreadNum({
@ -252,6 +254,7 @@ onLoad((options) => {
uni.navigateTo({ uni.navigateTo({
url: `/pages/dialog/index?sessionId=${openSession.id}`, url: `/pages/dialog/index?sessionId=${openSession.id}`,
}) })
}, 500)
} }
}) })
} }

View File

@ -36,7 +36,10 @@
</span> </span>
</div> </div>
</template> </template>
<div class="search-record-detail" v-if="props.searchRecordDetail"> <div
class="search-record-detail"
v-if="props.searchRecordDetail && !props?.hideFirstRecord"
>
<searchItem <searchItem
@click=" @click="
clickSearchItem( clickSearchItem(
@ -171,6 +174,10 @@ const props = defineProps({
return {} return {}
}, },
}, // }, //
hideFirstRecord: {
type: Boolean,
default: false,
}, ///
}) })
const { t } = useI18n() const { t } = useI18n()
@ -300,9 +307,9 @@ const queryAllSearch = (pageNum, searchResultPageSize) => {
) )
let total = data.count let total = data.count
if (props.searchRecordDetail) { if (props.searchRecordDetail) {
if(state?.first_talk_record_infos?.talk_type === 1){ if (state?.first_talk_record_infos?.talk_type === 1) {
total = data.user_record_count total = data.user_record_count
} else if (state?.first_talk_record_infos?.talk_type === 2){ } else if (state?.first_talk_record_infos?.talk_type === 2) {
total = data.group_record_count total = data.group_record_count
} }
} }

View File

@ -7,6 +7,7 @@
:apiRequest="ServeTalkRecord" :apiRequest="ServeTalkRecord"
:apiParams="state.apiParams" :apiParams="state.apiParams"
:searchText="state.searchText" :searchText="state.searchText"
:hideFirstRecord="state.hideFirstRecord"
:isPagination="true" :isPagination="true"
:searchRecordDetail="true" :searchRecordDetail="true"
@lastIdChange="lastIdChange" @lastIdChange="lastIdChange"
@ -30,6 +31,7 @@ const state = reactive({
apiParams: '', apiParams: '',
searchText: '', searchText: '',
uid: computed(() => userStore.uid), //id uid: computed(() => userStore.uid), //id
hideFirstRecord: false, ///
}) })
onLoad((options) => { onLoad((options) => {
@ -55,6 +57,10 @@ onLoad((options) => {
} }
console.log(JSON.parse(decodeURIComponent(state.apiParams))) console.log(JSON.parse(decodeURIComponent(state.apiParams)))
if (options.hideFirstRecord) {
state.hideFirstRecord = options.hideFirstRecord === '1' ? true : false
}
}) })
//id //id
@ -116,7 +122,7 @@ const clickSearchItem = (
}) })
} else { } else {
uni.navigateTo({ uni.navigateTo({
url: '/pages/dialog/index?msgInfo=' + res, url: '/pages/dialog/index?msgInfo=' + res + '&keepDialogInfo=1',
}) })
} }
} }