处理搜索不同条件、不同类型跳转对应聊天记录
This commit is contained in:
parent
a6810d4f12
commit
026e4fa3e6
@ -45,3 +45,12 @@ export const ServeTalkDate = (data) => {
|
|||||||
data,
|
data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取会话Id
|
||||||
|
export const ServeGetSessionId = (data) => {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/talk/session/getId',
|
||||||
|
method: 'POST',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
@ -21,9 +21,20 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { defineProps, defineEmits, reactive, watch } from 'vue'
|
import { defineProps, defineEmits, reactive, watch } from 'vue'
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
searchText: String,
|
searchText: {
|
||||||
first_talk_record_infos: Object,
|
type: String,
|
||||||
disabled: Boolean,
|
default: ''
|
||||||
|
},
|
||||||
|
first_talk_record_infos: {
|
||||||
|
type: Object,
|
||||||
|
default(){
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
})
|
})
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
searchText: '', //搜索内容
|
searchText: '', //搜索内容
|
||||||
|
@ -804,7 +804,7 @@ const onEditorChange = () => {
|
|||||||
// emit('editor-event', emitCall('input_event', text))
|
// emit('editor-event', emitCall('input_event', text))
|
||||||
// 清理过期的撤回消息(超过5分钟)
|
// 清理过期的撤回消息(超过5分钟)
|
||||||
const now = new Date().getTime()
|
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) {
|
if (now - state.value.revokedMessages[msgId].revokeTime > 5 * 60 * 1000) {
|
||||||
delete state.value.revokedMessages[msgId]
|
delete state.value.revokedMessages[msgId]
|
||||||
}
|
}
|
||||||
|
@ -99,11 +99,26 @@ import { beautifyTime } from '@/utils/datetime'
|
|||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
searchItem: Object | Number,
|
searchItem: Object | Number,
|
||||||
searchResultKey: String,
|
searchResultKey: {
|
||||||
searchText: String, //搜索内容
|
type: String,
|
||||||
searchRecordDetail: Boolean, //是否是搜索聊天记录详情
|
default: '',
|
||||||
pointerIconSrc: String, //箭头图标
|
},
|
||||||
conditionType: Number, //搜索类型
|
searchText: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
}, //搜索内容
|
||||||
|
searchRecordDetail: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
}, //是否是搜索聊天记录详情
|
||||||
|
pointerIconSrc: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
}, //箭头图标
|
||||||
|
conditionType: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
}, //搜索类型
|
||||||
})
|
})
|
||||||
// 映射表-查找对应结构下的属性名
|
// 映射表-查找对应结构下的属性名
|
||||||
const keyMapping = {
|
const keyMapping = {
|
||||||
@ -193,10 +208,8 @@ const imgText = computed(() => {
|
|||||||
})
|
})
|
||||||
// 映射表-根据groupType设置对应值
|
// 映射表-根据groupType设置对应值
|
||||||
const groupTypeMapping = {
|
const groupTypeMapping = {
|
||||||
0: {
|
0: {},
|
||||||
},
|
1: {},
|
||||||
1: {
|
|
||||||
},
|
|
||||||
2: {
|
2: {
|
||||||
result_type: t('index.mine.department'),
|
result_type: t('index.mine.department'),
|
||||||
result_type_color: '#377EC6',
|
result_type_color: '#377EC6',
|
||||||
|
@ -139,14 +139,37 @@ const state = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
searchResultPageSize: Number, //搜索结果每页数据量
|
searchResultPageSize: {
|
||||||
listLimit: Boolean, //是否限制列表内数据数量
|
type: Number,
|
||||||
apiParams: String, //请求参数
|
default: 0,
|
||||||
|
}, //搜索结果每页数据量
|
||||||
|
listLimit: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
}, //是否限制列表内数据数量
|
||||||
|
apiParams: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
}, //请求参数
|
||||||
apiRequest: Function, //请求
|
apiRequest: Function, //请求
|
||||||
searchText: String, //搜索内容
|
searchText: {
|
||||||
isPagination: Boolean, //是否分页
|
type: String,
|
||||||
searchRecordDetail: Boolean, //是否是搜索聊天记录的详情
|
default: '',
|
||||||
first_talk_record_infos: Object, //接受者信息
|
}, //搜索内容
|
||||||
|
isPagination: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
}, //是否分页
|
||||||
|
searchRecordDetail: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
}, //是否是搜索聊天记录的详情
|
||||||
|
first_talk_record_infos: {
|
||||||
|
type: Object,
|
||||||
|
default() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
}, //接受者信息
|
||||||
})
|
})
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
@ -366,6 +389,9 @@ const getHasMoreResult = (searchResultKey) => {
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'general_infos':
|
case 'general_infos':
|
||||||
|
// if (state?.searchResult['general_infos']?.length >= 3) {
|
||||||
|
// has_more_result = t('has_more') + t('chat.type.record')
|
||||||
|
// }
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
@ -379,12 +405,40 @@ const toMoreResultPage = (searchResultKey) => {
|
|||||||
|
|
||||||
//点击了搜索结果项
|
//点击了搜索结果项
|
||||||
const clickSearchItem = (searchResultKey, searchItem) => {
|
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(
|
emits(
|
||||||
'clickSearchItem',
|
'clickSearchItem',
|
||||||
state.searchText,
|
state.searchText,
|
||||||
searchResultKey,
|
searchResultKey,
|
||||||
searchItem.talk_type,
|
talk_type,
|
||||||
searchItem.receiver_id,
|
receiver_id,
|
||||||
encodeURIComponent(JSON.stringify(searchItem)),
|
encodeURIComponent(JSON.stringify(searchItem)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import searchList from './components/searchList.vue'
|
import searchList from './components/searchList.vue'
|
||||||
import { ServeSeachQueryAll } from '@/api/search/index'
|
import { ServeSeachQueryAll, ServeGetSessionId } from '@/api/search/index'
|
||||||
import { onMounted } from 'vue'
|
import { onMounted } from 'vue'
|
||||||
import { handleSetWebviewStyle } from '@/utils/common'
|
import { handleSetWebviewStyle } from '@/utils/common'
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ const toMoreResultPage = (searchResultKey, searchText) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//点击了搜索结果项
|
//点击了搜索结果项
|
||||||
const clickSearchItem = (
|
const clickSearchItem = async (
|
||||||
searchText,
|
searchText,
|
||||||
searchResultKey,
|
searchResultKey,
|
||||||
talk_type,
|
talk_type,
|
||||||
@ -47,17 +47,25 @@ const clickSearchItem = (
|
|||||||
console.log(searchResultKey)
|
console.log(searchResultKey)
|
||||||
const result = JSON.parse(decodeURIComponent(res))
|
const result = JSON.parse(decodeURIComponent(res))
|
||||||
console.log(result)
|
console.log(result)
|
||||||
|
console.log(talk_type, receiver_id)
|
||||||
|
const sessionId = await getSessionId(talk_type, receiver_id)
|
||||||
if (searchResultKey === 'user_infos') {
|
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') {
|
} else if (searchResultKey === 'combinedGroup') {
|
||||||
dialogueStore.setDialogue({
|
dialogueStore.setDialogue({
|
||||||
name: result.name || result.group_name,
|
name: result.name || result.group_name,
|
||||||
talk_type: result.type || 2,
|
talk_type: result.type || 2,
|
||||||
receiver_id: result.id || result.group_id,
|
receiver_id: result.group_id || result.id,
|
||||||
})
|
})
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/dialog/index',
|
url: '/pages/dialog/index?sessionId=' + sessionId
|
||||||
})
|
})
|
||||||
} else if (searchResultKey === 'general_infos') {
|
} else if (searchResultKey === 'general_infos') {
|
||||||
uni.navigateTo({
|
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>
|
</script>
|
||||||
<style scoped lang="scss"></style>
|
<style scoped lang="scss"></style>
|
||||||
|
@ -21,6 +21,7 @@ import {
|
|||||||
ServeQueryUser,
|
ServeQueryUser,
|
||||||
ServeQueryGroup,
|
ServeQueryGroup,
|
||||||
ServeTalkRecord,
|
ServeTalkRecord,
|
||||||
|
ServeGetSessionId,
|
||||||
} from '@/api/search/index'
|
} from '@/api/search/index'
|
||||||
import { reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
|
|
||||||
@ -30,9 +31,9 @@ const dialogueStore = useDialogueStore()
|
|||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
apiRequest: Function,
|
apiRequest: Function,
|
||||||
apiParams: String,
|
apiParams: '',
|
||||||
searchText: String,
|
searchText: '',
|
||||||
searchResultKey: String,
|
searchResultKey: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
@ -90,7 +91,7 @@ const lastIdChange = (last_id, last_group_id, last_member_id) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//点击了搜索结果项
|
//点击了搜索结果项
|
||||||
const clickSearchItem = (
|
const clickSearchItem = async (
|
||||||
searchText,
|
searchText,
|
||||||
searchResultKey,
|
searchResultKey,
|
||||||
talk_type,
|
talk_type,
|
||||||
@ -100,21 +101,57 @@ const clickSearchItem = (
|
|||||||
console.log(state.searchResultKey)
|
console.log(state.searchResultKey)
|
||||||
const result = JSON.parse(decodeURIComponent(res))
|
const result = JSON.parse(decodeURIComponent(res))
|
||||||
console.log(result)
|
console.log(result)
|
||||||
|
console.log(talk_type, receiver_id)
|
||||||
|
const sessionId = await getSessionId(talk_type, receiver_id)
|
||||||
if (state.searchResultKey === 'user_infos') {
|
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') {
|
} else if (state.searchResultKey === 'combinedGroup') {
|
||||||
dialogueStore.setDialogue({
|
dialogueStore.setDialogue({
|
||||||
name: result.name || result.group_name,
|
name: result.name || result.group_name,
|
||||||
talk_type: result.type || 2,
|
talk_type: result.type || 2,
|
||||||
receiver_id: result.id || result.group_id,
|
receiver_id: result.group_id || result.id,
|
||||||
})
|
})
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/dialog/index',
|
url: '/pages/dialog/index?sessionId=' + sessionId,
|
||||||
})
|
})
|
||||||
} else if (state.searchResultKey === 'general_infos') {
|
} else if (state.searchResultKey === 'general_infos') {
|
||||||
uni.navigateTo({
|
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>
|
</script>
|
||||||
<style scoped lang="scss"></style>
|
<style scoped lang="scss"></style>
|
||||||
|
@ -27,8 +27,8 @@ const dialogueStore = useDialogueStore()
|
|||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
apiParams: String,
|
apiParams: '',
|
||||||
searchText: String,
|
searchText: '',
|
||||||
uid: computed(() => userStore.uid), //当前用户id
|
uid: computed(() => userStore.uid), //当前用户id
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user