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