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

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']
Message: typeof import('./src/components/x-message/message/index.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']
RevokeMessage: typeof import('./src/components/talk/message/RevokeMessage.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']

View File

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

View File

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

View File

@ -1,43 +1,50 @@
<template>
<div>
<wd-swipe-action class="swipe_action">
<div
@click="cellClick"
:class="['chatItem', props.data.is_top === 1 ? 'isTop' : '']"
>
<div class="avatarImg">
<tm-badge
:count="props.data.is_disturb === 1 ? props.data.unread_num : ''"
:dot="props.data.is_disturb === 0 && props.data.unread_num"
:maxCount="99"
class="badge"
color="#D03050"
>
<avatarModule
:mode="props?.data?.group_type === 0 ? 1 : 2"
:avatar="props?.data?.avatar"
:groupType="props?.data?.group_type"
:userName="props?.data?.name"
:customStyle="{
width: '96rpx',
height: '96rpx',
}"
:customTextStyle="{
fontSize: '32rpx',
fontWeight: 'bold',
color: '#fff',
lineHeight: '44rpx',
}"
></avatarModule>
</tm-badge>
</div>
<div class="chatInfo">
<div class="chatInfo_1">
<div class="name_center">
<div class="text-[#000000] text-[32rpx]
font-bold opacity-90 name_text">
<div>
<wd-swipe-action class="swipe_action">
<div
@click="cellClick"
:class="['chatItem', props.data.is_top === 1 ? 'isTop' : '']"
>
<div class="avatarImg">
<tm-badge
:count="props.data.is_disturb === 1 ? props.data.unread_num : ''"
:dot="
props.data.is_disturb === 0 && props.data.unread_num
? true
: false
"
:maxCount="99"
class="badge"
color="#D03050"
>
<avatarModule
:mode="props?.data?.group_type === 0 ? 1 : 2"
:avatar="props?.data?.avatar"
:groupType="props?.data?.group_type"
:userName="props?.data?.name"
:customStyle="{
width: '96rpx',
height: '96rpx',
}"
:customTextStyle="{
fontSize: '32rpx',
fontWeight: 'bold',
color: '#fff',
lineHeight: '44rpx',
}"
></avatarModule>
</tm-badge>
</div>
<div class="chatInfo">
<div class="chatInfo_1">
<div class="name_center">
<div
class="text-[#000000] text-[32rpx] font-bold opacity-90 name_text"
>
{{ 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>
@ -48,153 +55,153 @@
公司
</span>
</div>
</div>
<div style="flex-shrink: 0;"
class="text-[#000000] text-[28rpx] font-medium opacity-26 ml-[24rpx] time_right"
>
{{ beautifyTime(props.data.updated_at) }}
</div>
</div>
<div class="chatInfo_2 w-full mr-[6rpx]">
<div class="w-full chatInfo_2_1 textEllipsis">
{{ props.data.msg_text }}
</div>
</div>
</div>
</div>
<template #right>
<div class="flex flex-row flex-row-center-end">
<!-- 样式占位 -->
<div style="width: 1px"></div>
<div
@click="handleTop"
class="w-[156rpx] h-[154rpx] text-[#ffffff] bg-[#F09F1F] flex items-center justify-center"
>
{{ props.data.is_top === 1 ? "取消置顶" : "置顶" }}
</div>
<div
@click="handleDelete"
class="w-[156rpx] h-[154rpx] text-[#ffffff] bg-[#CF3050] flex items-center justify-center"
>
删除
</div>
</div>
</template>
</wd-swipe-action>
<div
v-if="props.index !== talkStore.talkItems.length - 1"
class="divider"
></div>
</div>
</div>
<div
style="flex-shrink: 0;"
class="text-[#000000] text-[28rpx] font-medium opacity-26 ml-[24rpx] time_right"
>
{{ beautifyTime(props.data.updated_at) }}
</div>
</div>
<div class="chatInfo_2 w-full mr-[6rpx]">
<div class="w-full chatInfo_2_1 textEllipsis">
{{ props.data.msg_text }}
</div>
</div>
</div>
</div>
<template #right>
<div class="flex flex-row flex-row-center-end">
<!-- 样式占位 -->
<div style="width: 1px;"></div>
<div
@click="handleTop"
class="w-[156rpx] h-[154rpx] text-[#ffffff] bg-[#F09F1F] flex items-center justify-center"
>
{{ props.data.is_top === 1 ? '取消置顶' : '置顶' }}
</div>
<div
@click="handleDelete"
class="w-[156rpx] h-[154rpx] text-[#ffffff] bg-[#CF3050] flex items-center justify-center"
>
删除
</div>
</div>
</template>
</wd-swipe-action>
<div
v-if="props.index !== talkStore.talkItems.length - 1"
class="divider"
></div>
</div>
</template>
<script setup>
import avatarModule from "@/components/avatar-module/index.vue";
import { ref, reactive, defineProps, computed } from "vue";
import dayjs from "dayjs";
import { beautifyTime } from "@/utils/datetime";
import { ServeClearTalkUnreadNum } from "@/api/chat";
import { useTalkStore, useDialogueStore } from "@/store";
import { useSessionMenu } from "@/hooks";
import avatarModule from '@/components/avatar-module/index.vue'
import { ref, reactive, defineProps, computed } from 'vue'
import dayjs from 'dayjs'
import { beautifyTime } from '@/utils/datetime'
import { ServeClearTalkUnreadNum } from '@/api/chat'
import { useTalkStore, useDialogueStore } from '@/store'
import { useSessionMenu } from '@/hooks'
const talkStore = useTalkStore();
const { onToTopTalk, onRemoveTalk } = useSessionMenu();
const dialogueStore = useDialogueStore();
const talkStore = useTalkStore()
const { onToTopTalk, onRemoveTalk } = useSessionMenu()
const dialogueStore = useDialogueStore()
const props = defineProps({
data: {
type: Object,
default: {},
required: true,
},
index: {
type: Number,
default: -1,
required: true,
},
});
data: {
type: Object,
default: {},
required: true,
},
index: {
type: Number,
default: -1,
required: true,
},
})
//
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 = () => {
console.log(props.data);
//
dialogueStore.setDialogue(props.data);
console.log(props.data)
//
dialogueStore.setDialogue(props.data)
//
if (props.data.unread_num > 0) {
ServeClearTalkUnreadNum({
talk_type: props.data.talk_type,
receiver_id: props.data.receiver_id,
}).then(() => {
talkStore.updateItem({
index_name: props.data.index_name,
unread_num: 0,
});
});
}
uni.navigateTo({
url: `/pages/dialog/index?sessionId=${props.data.id}`,
});
};
//
if (props.data.unread_num > 0) {
ServeClearTalkUnreadNum({
talk_type: props.data.talk_type,
receiver_id: props.data.receiver_id,
}).then(() => {
talkStore.updateItem({
index_name: props.data.index_name,
unread_num: 0,
})
})
}
uni.navigateTo({
url: `/pages/dialog/index?sessionId=${props.data.id}`,
})
}
const handleTop = () => {
console.log(props.data, 1);
onToTopTalk(props.data);
};
console.log(props.data, 1)
onToTopTalk(props.data)
}
//
const handleDelete = () => {
console.log(props.data);
onRemoveTalk(props.data);
};
console.log(props.data)
onRemoveTalk(props.data)
}
</script>
<style lang="scss" scoped>
::v-deep .swipe_action {
// border: 1px solid #fff;
// transform: translate3d(1px, 0px, 0px) !important;
// border: 1px solid #fff;
// transform: translate3d(1px, 0px, 0px) !important;
}
::v-deep .badge .round-6{
::v-deep .badge .round-6 {
min-width: 22rpx;
min-height: 22rpx;
}
.chatItem {
width: 100%;
height: 154rpx;
padding: 30rpx 16rpx;
display: flex;
align-items: center;
width: 100%;
height: 154rpx;
padding: 30rpx 16rpx;
display: flex;
align-items: center;
&.isTop {
background-color: #f3f3f3;
}
&.isTop {
background-color: #f3f3f3;
}
}
.chatInfo {
flex: 1;
margin-left: 20rpx;
flex: 1;
margin-left: 20rpx;
}
.chatInfo_1 {
display: flex;
align-items: center;
justify-content: space-between;
display: flex;
align-items: center;
justify-content: space-between;
}
.chatInfo_2 {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 6rpx;
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 6rpx;
}
.chatInfo_2_1 {
font-size: 28rpx;
color: rgba($color: #000000, $alpha: 0.4);
font-size: 28rpx;
color: rgba($color: #000000, $alpha: 0.4);
}
.tag{
.tag {
display: inline-flex;
align-items: center;
text-align: center;
@ -209,22 +216,22 @@ const handleDelete = () => {
font-weight: bold;
}
.companyTag {
border: 1px solid #7a58de;
color: #7a58de;
border: 1px solid #7a58de;
color: #7a58de;
}
.depTag {
border: 1px solid #377ec6;
color: #377ec6;
border: 1px solid #377ec6;
color: #377ec6;
}
.projectTag {
border: 1px solid #c1681c;
color: #c1681c;
border: 1px solid #c1681c;
color: #c1681c;
}
.name_center{
.name_center {
flex: 1;
min-width: 0;
}
.name_text{
.name_text {
display: inline-block;
max-height: 88rpx; //
line-height: 44rpx;
@ -236,23 +243,23 @@ const handleDelete = () => {
word-break: break-all;
}
.time_right {
/* white-space: nowrap;
/* white-space: nowrap;
max-width: 146rpx; */
flex: 0 0 auto; /* 不伸缩,保持内容宽度 */
white-space: nowrap;
}
.textEllipsis {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
}
.divider {
background-color: rgba(243, 243, 243, 1);
height: 1rpx;
margin: 0 18rpx;
background-color: rgba(243, 243, 243, 1);
height: 1rpx;
margin: 0 18rpx;
}
</style>

View File

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

View File

@ -36,7 +36,10 @@
</span>
</div>
</template>
<div class="search-record-detail" v-if="props.searchRecordDetail">
<div
class="search-record-detail"
v-if="props.searchRecordDetail && !props?.hideFirstRecord"
>
<searchItem
@click="
clickSearchItem(
@ -171,6 +174,10 @@ const props = defineProps({
return {}
},
}, //
hideFirstRecord: {
type: Boolean,
default: false,
}, ///
})
const { t } = useI18n()
@ -300,9 +307,9 @@ const queryAllSearch = (pageNum, searchResultPageSize) => {
)
let total = data.count
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
} 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
}
}
@ -394,7 +401,7 @@ const getHasMoreResult = (searchResultKey) => {
}
break
case 'general_infos':
if (
if (
state.searchResult['record_count'] &&
state.searchResult['record_count'] > 3
) {

View File

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