处理搜索不同条件、不同类型跳转对应聊天记录

This commit is contained in:
wangyifeng 2025-03-17 19:54:43 +08:00
parent a6810d4f12
commit 026e4fa3e6
8 changed files with 189 additions and 37 deletions

View File

@ -45,3 +45,12 @@ export const ServeTalkDate = (data) => {
data,
})
}
//获取会话Id
export const ServeGetSessionId = (data) => {
return request({
url: '/api/v1/talk/session/getId',
method: 'POST',
data,
})
}

View File

@ -21,9 +21,20 @@
<script setup>
import { defineProps, defineEmits, reactive, watch } from 'vue'
const props = defineProps({
searchText: String,
first_talk_record_infos: Object,
disabled: Boolean,
searchText: {
type: String,
default: ''
},
first_talk_record_infos: {
type: Object,
default(){
return {}
}
},
disabled: {
type: Boolean,
default: false
},
})
const state = reactive({
searchText: '', //

View File

@ -804,7 +804,7 @@ const onEditorChange = () => {
// emit('editor-event', emitCall('input_event', text))
// 5
const now = new Date().getTime()
Object.keys(state.value.revokedMessages).forEach((msgId) => {
Object.keys(state.value.revokedMessages || {}).forEach((msgId) => {
if (now - state.value.revokedMessages[msgId].revokeTime > 5 * 60 * 1000) {
delete state.value.revokedMessages[msgId]
}

View File

@ -99,11 +99,26 @@ import { beautifyTime } from '@/utils/datetime'
const { t } = useI18n()
const props = defineProps({
searchItem: Object | Number,
searchResultKey: String,
searchText: String, //
searchRecordDetail: Boolean, //
pointerIconSrc: String, //
conditionType: Number, //
searchResultKey: {
type: String,
default: '',
},
searchText: {
type: String,
default: '',
}, //
searchRecordDetail: {
type: Boolean,
default: false,
}, //
pointerIconSrc: {
type: String,
default: '',
}, //
conditionType: {
type: Number,
default: 0,
}, //
})
// -
const keyMapping = {
@ -193,10 +208,8 @@ const imgText = computed(() => {
})
// -groupType
const groupTypeMapping = {
0: {
},
1: {
},
0: {},
1: {},
2: {
result_type: t('index.mine.department'),
result_type_color: '#377EC6',

View File

@ -139,14 +139,37 @@ const state = reactive({
})
const props = defineProps({
searchResultPageSize: Number, //
listLimit: Boolean, //
apiParams: String, //
searchResultPageSize: {
type: Number,
default: 0,
}, //
listLimit: {
type: Boolean,
default: false,
}, //
apiParams: {
type: String,
default: '',
}, //
apiRequest: Function, //
searchText: String, //
isPagination: Boolean, //
searchRecordDetail: Boolean, //
first_talk_record_infos: Object, //
searchText: {
type: String,
default: '',
}, //
isPagination: {
type: Boolean,
default: false,
}, //
searchRecordDetail: {
type: Boolean,
default: false,
}, //
first_talk_record_infos: {
type: Object,
default() {
return {}
},
}, //
})
const { t } = useI18n()
@ -366,6 +389,9 @@ const getHasMoreResult = (searchResultKey) => {
}
break
case 'general_infos':
// if (state?.searchResult['general_infos']?.length >= 3) {
// has_more_result = t('has_more') + t('chat.type.record')
// }
break
default:
}
@ -379,12 +405,40 @@ const toMoreResultPage = (searchResultKey) => {
//
const clickSearchItem = (searchResultKey, searchItem) => {
console.log(searchResultKey, searchItem)
let talk_type = searchItem.talk_type
let receiver_id = searchItem.receiver_id
if (searchResultKey === 'user_infos') {
talk_type = 1
receiver_id = searchItem.id
} else if (searchResultKey === 'combinedGroup') {
talk_type = searchItem.type || 2
receiver_id = searchItem.group_id || searchItem.id
} else if (searchResultKey === 'general_infos') {
if (searchItem.talk_type === 1) {
if (searchItem.user_id === state.uid) {
//
}
if (searchItem.receiver_id === state.uid) {
//
let temp_id = searchItem.receiver_id
let temp_name = searchItem.receiver_name
let temp_avatar = searchItem.receiver_avatar
searchItem.receiver_id = searchItem.user_id
searchItem.receiver_name = searchItem.user_name
searchItem.receiver_avatar = searchItem.user_avatar
searchItem.user_id = temp_id
searchItem.user_name = temp_name
searchItem.user_avatar = temp_avatar
}
}
}
emits(
'clickSearchItem',
state.searchText,
searchResultKey,
searchItem.talk_type,
searchItem.receiver_id,
talk_type,
receiver_id,
encodeURIComponent(JSON.stringify(searchItem)),
)
}

View File

@ -13,7 +13,7 @@
</template>
<script setup>
import searchList from './components/searchList.vue'
import { ServeSeachQueryAll } from '@/api/search/index'
import { ServeSeachQueryAll, ServeGetSessionId } from '@/api/search/index'
import { onMounted } from 'vue'
import { handleSetWebviewStyle } from '@/utils/common'
@ -37,7 +37,7 @@ const toMoreResultPage = (searchResultKey, searchText) => {
}
//
const clickSearchItem = (
const clickSearchItem = async (
searchText,
searchResultKey,
talk_type,
@ -47,17 +47,25 @@ const clickSearchItem = (
console.log(searchResultKey)
const result = JSON.parse(decodeURIComponent(res))
console.log(result)
console.log(talk_type, receiver_id)
const sessionId = await getSessionId(talk_type, receiver_id)
if (searchResultKey === 'user_infos') {
dialogueStore.setDialogue({
name: result.nickname,
talk_type: 1,
receiver_id: receiver_id,
})
uni.navigateTo({
url: '/pages/dialog/index?sessionId=' + sessionId,
})
} else if (searchResultKey === 'combinedGroup') {
dialogueStore.setDialogue({
name: result.name || result.group_name,
talk_type: result.type || 2,
receiver_id: result.id || result.group_id,
receiver_id: result.group_id || result.id,
})
uni.navigateTo({
url: '/pages/dialog/index',
url: '/pages/dialog/index?sessionId=' + sessionId
})
} else if (searchResultKey === 'general_infos') {
uni.navigateTo({
@ -71,5 +79,25 @@ const clickSearchItem = (
})
}
}
//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(() => {})
})
}
</script>
<style scoped lang="scss"></style>

View File

@ -21,6 +21,7 @@ import {
ServeQueryUser,
ServeQueryGroup,
ServeTalkRecord,
ServeGetSessionId,
} from '@/api/search/index'
import { reactive } from 'vue'
@ -30,9 +31,9 @@ const dialogueStore = useDialogueStore()
const state = reactive({
apiRequest: Function,
apiParams: String,
searchText: String,
searchResultKey: String,
apiParams: '',
searchText: '',
searchResultKey: '',
})
onLoad((options) => {
@ -90,7 +91,7 @@ const lastIdChange = (last_id, last_group_id, last_member_id) => {
}
//
const clickSearchItem = (
const clickSearchItem = async (
searchText,
searchResultKey,
talk_type,
@ -100,21 +101,57 @@ const clickSearchItem = (
console.log(state.searchResultKey)
const result = JSON.parse(decodeURIComponent(res))
console.log(result)
console.log(talk_type, receiver_id)
const sessionId = await getSessionId(talk_type, receiver_id)
if (state.searchResultKey === 'user_infos') {
dialogueStore.setDialogue({
name: result.nickname,
talk_type: 1,
receiver_id: receiver_id,
})
uni.navigateTo({
url: '/pages/dialog/index?sessionId=' + sessionId,
})
} 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,
receiver_id: result.group_id || result.id,
})
uni.navigateTo({
url: '/pages/dialog/index',
url: '/pages/dialog/index?sessionId=' + sessionId,
})
} else if (state.searchResultKey === 'general_infos') {
uni.navigateTo({
url: '/pages/search/moreResult/moreResultDetail?searchText=' + searchText,
url:
'/pages/search/moreResult/moreResultDetail?searchText=' +
searchText +
'&talk_type=' +
talk_type +
'&receiver_id=' +
receiver_id,
})
}
}
//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(() => {})
})
}
</script>
<style scoped lang="scss"></style>

View File

@ -27,8 +27,8 @@ const dialogueStore = useDialogueStore()
const userStore = useUserStore()
const state = reactive({
apiParams: String,
searchText: String,
apiParams: '',
searchText: '',
uid: computed(() => userStore.uid), //id
})