处理搜索不同条件、不同类型跳转对应聊天记录
This commit is contained in:
parent
a6810d4f12
commit
026e4fa3e6
@ -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,
|
||||
})
|
||||
}
|
@ -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: '', //搜索内容
|
||||
|
@ -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]
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -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)),
|
||||
)
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -27,8 +27,8 @@ const dialogueStore = useDialogueStore()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const state = reactive({
|
||||
apiParams: String,
|
||||
searchText: String,
|
||||
apiParams: '',
|
||||
searchText: '',
|
||||
uid: computed(() => userStore.uid), //当前用户id
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user