2024-12-31 09:01:18 +00:00
|
|
|
|
<template>
|
|
|
|
|
<div class="outer-layer search-page">
|
|
|
|
|
<div class="root">
|
|
|
|
|
<searchList
|
|
|
|
|
:searchResultPageSize="10"
|
|
|
|
|
:listLimit="false"
|
|
|
|
|
:apiRequest="ServeTalkRecord"
|
|
|
|
|
:apiParams="state.apiParams"
|
|
|
|
|
:searchText="state.searchText"
|
|
|
|
|
:isPagination="true"
|
|
|
|
|
:searchRecordDetail="true"
|
2025-01-02 08:01:36 +00:00
|
|
|
|
@lastIdChange="lastIdChange"
|
2025-03-13 11:54:29 +00:00
|
|
|
|
@clickSearchItem="clickSearchItem"
|
2024-12-31 09:01:18 +00:00
|
|
|
|
></searchList>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup>
|
|
|
|
|
import searchList from '../components/searchList.vue'
|
|
|
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
|
|
|
import { ServeTalkRecord } from '@/api/search/index'
|
|
|
|
|
import { reactive } from 'vue'
|
2025-03-15 08:44:40 +00:00
|
|
|
|
import { useDialogueStore, useUserStore } from '@/store'
|
|
|
|
|
import lodash from 'lodash'
|
2025-03-13 11:54:29 +00:00
|
|
|
|
|
2025-03-15 08:44:40 +00:00
|
|
|
|
const dialogueStore = useDialogueStore()
|
|
|
|
|
const userStore = useUserStore()
|
2024-12-31 09:01:18 +00:00
|
|
|
|
|
|
|
|
|
const state = reactive({
|
|
|
|
|
apiParams: String,
|
|
|
|
|
searchText: String,
|
2025-03-15 08:44:40 +00:00
|
|
|
|
uid: computed(() => userStore.uid), //当前用户id
|
2024-12-31 09:01:18 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onLoad((options) => {
|
|
|
|
|
console.log(options)
|
|
|
|
|
let talk_type = 0
|
|
|
|
|
if (options.talk_type) {
|
|
|
|
|
talk_type = Number(options.talk_type)
|
|
|
|
|
}
|
|
|
|
|
let receiver_id = 0
|
|
|
|
|
if (options.receiver_id) {
|
|
|
|
|
receiver_id = Number(options.receiver_id)
|
|
|
|
|
}
|
|
|
|
|
state.apiParams = encodeURIComponent(
|
|
|
|
|
JSON.stringify({
|
|
|
|
|
talk_type: talk_type, //1私聊2群聊
|
|
|
|
|
receiver_id: receiver_id, //查详情的时候需传入
|
|
|
|
|
last_group_id: 0, //最后一条群id
|
|
|
|
|
last_member_id: 0, //最后一条用户id
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
if (options.searchText) {
|
|
|
|
|
state.searchText = options.searchText
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(JSON.parse(decodeURIComponent(state.apiParams)))
|
|
|
|
|
})
|
2025-01-02 08:01:36 +00:00
|
|
|
|
|
|
|
|
|
//分页查询时,最后一条id变化
|
|
|
|
|
const lastIdChange = (last_id, last_group_id, last_member_id) => {
|
|
|
|
|
let idChanges = {
|
|
|
|
|
last_id,
|
|
|
|
|
last_group_id,
|
|
|
|
|
last_member_id,
|
|
|
|
|
}
|
|
|
|
|
state.apiParams = encodeURIComponent(
|
|
|
|
|
JSON.stringify(
|
|
|
|
|
Object.assign(
|
|
|
|
|
{},
|
|
|
|
|
JSON.parse(decodeURIComponent(state.apiParams)),
|
|
|
|
|
idChanges,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
2025-03-13 11:54:29 +00:00
|
|
|
|
|
|
|
|
|
//点击了搜索结果项
|
|
|
|
|
const clickSearchItem = (
|
|
|
|
|
searchText,
|
|
|
|
|
searchResultKey,
|
|
|
|
|
talk_type,
|
|
|
|
|
receiver_id,
|
|
|
|
|
res,
|
|
|
|
|
) => {
|
2025-03-15 08:44:40 +00:00
|
|
|
|
console.log(searchResultKey)
|
2025-03-13 11:54:29 +00:00
|
|
|
|
let result = JSON.parse(decodeURIComponent(res))
|
2025-03-15 08:44:40 +00:00
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-13 11:54:29 +00:00
|
|
|
|
dialogueStore.setDialogue({
|
2025-03-15 08:44:40 +00:00
|
|
|
|
name: receiverInfo.receiver_name,
|
2025-03-13 11:54:29 +00:00
|
|
|
|
talk_type: talk_type,
|
2025-03-15 08:44:40 +00:00
|
|
|
|
receiver_id: receiverInfo.receiver_id,
|
2025-03-13 11:54:29 +00:00
|
|
|
|
})
|
2025-03-15 08:44:40 +00:00
|
|
|
|
if (searchResultKey === 'talk_record_infos_receiver') {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/dialog/index',
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/dialog/index?msgInfo=' + res,
|
|
|
|
|
})
|
|
|
|
|
}
|
2025-03-13 11:54:29 +00:00
|
|
|
|
}
|
2024-12-31 09:01:18 +00:00
|
|
|
|
</script>
|
|
|
|
|
<style scoped lang="scss"></style>
|