chat-app/src/pages/chooseChat/index.vue

319 lines
8.4 KiB
Vue
Raw Normal View History

2024-12-19 03:02:47 +00:00
<template>
2025-02-08 09:09:57 +00:00
<div class="choose-chat-page">
<ZPaging ref="zPaging" :show-scrollbar="false">
<template #top>
<customNavbar
:title="$t('pageTitle.select.shareChat')"
:hideBack="true"
>
<template #left>
<div
@click="handleClose"
class="ml-[42rpx] text-[34rpx] leading-[48rpx] font-regular"
>
{{ $t('button.text.close') }}
</div>
</template>
<template #right>
<div
v-if="!isMultiSelect"
@click="isMultiSelect = true"
class="mr-[36rpx] text-[34rpx] leading-[48rpx] font-regular"
>
{{ $t('button.multiple.choice') }}
</div>
<div v-else class="mr-[36rpx] btnBox">
<customBtn
:btnText="
selectItems.length
? $t('button.text.done') + `(${selectItems.length})`
: $t('button.text.done')
"
:disabled="!selectItems.length"
@clickBtn="handleFinish"
></customBtn>
</div>
</template>
</customNavbar>
</template>
<div class="choose-chat">
<div class="searchRoot">
<customInput></customInput>
</div>
<div class="contentRoot">
<chatItem
v-for="(item, index) in items"
:key="item.index_name"
:index="index"
:data="item"
:isMultiSelect="isMultiSelect"
@itemClick="itemClick"
/>
</div>
</div>
<tm-modal
v-model:show="showWin"
:height="forwardModalHeight"
:round="4"
okColor="#FFFFFF"
@ok="handleOk"
@cancel="handleCancel"
:okText="'发送'"
2025-02-08 09:09:57 +00:00
>
<template v-slot:title>
<div
class="w-full pl-[30rpx] leading-[48rpx] mt-[30rpx] font-bold text-[32rpx]"
>
发送给:
2024-12-19 03:02:47 +00:00
</div>
</template>
<template v-slot:default>
2025-02-08 09:09:57 +00:00
<div
class="pl-[22rpx] pr-[32rpx] pt-[10rpx] flex items-center justify-start flex-wrap"
>
<div
v-if="selectItemsModal.length > 1"
v-for="item in selectItemsModal"
class="w-1/4 mt-[20rpx] flex flex-col items-center justify-center"
>
<div class="w-[96rpx] h-[96rpx] rounded-[60rpx] flex-center">
<tm-image
:width="96"
:height="96"
:round="12"
:src="item.avatar"
></tm-image>
</div>
<div
class="mt-[8rpx] text-[#666666] text-[24rpx] w-[94rpx] truncate"
>
<span>{{ item.name }}</span>
2025-02-08 09:09:57 +00:00
</div>
2024-12-19 03:02:47 +00:00
</div>
2025-02-08 09:09:57 +00:00
<div v-else class="w-full flex items-center justify-start">
<avatarModule
:mode="2"
:avatar="selectItemsModal[0].avatar"
:groupType="selectItemsModal[0].group_type"
:customStyle="{ width: '96rpx', height: '96rpx' }"
></avatarModule>
<div class="ml-[16rpx] text-[#161616] text-[32rpx] font-bold">
{{ selectItemsModal[0].name }}
<span v-if="selectItemsModal[0].talk_type === 2">{{ selectItemsModal[0].group_member_num }}</span>
<span v-if="selectItemsModal[0].group_type === 2" class="depTag tag">
部门
</span>
<span v-if="selectItemsModal[0].group_type === 3" class="projectTag tag">
项目
</span>
<span v-if="selectItemsModal[0].group_type === 4" class="companyTag tag">
公司
</span>
2025-02-08 09:09:57 +00:00
</div>
2024-12-19 03:02:47 +00:00
</div>
</div>
2025-02-08 09:09:57 +00:00
</template>
</tm-modal>
</ZPaging>
2024-12-19 03:02:47 +00:00
</div>
</template>
<script setup>
2025-02-08 09:09:57 +00:00
import customInput from '@/components/custom-input/custom-input.vue'
import avatarModule from '@/components/avatar-module/index.vue'
import ZPaging from '@/uni_modules/z-paging/components/z-paging/z-paging.vue'
import customBtn from '@/components/custom-btn/custom-btn.vue'
import { ref, watch, computed, onMounted, onUnmounted } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app'
import { useChatList } from '@/store/chatList/index.js'
import { useAuth } from '@/store/auth'
2024-12-19 03:02:47 +00:00
import { useTalkStore, useUserStore, useDialogueStore } from '@/store'
2025-02-08 09:09:57 +00:00
import chatItem from './components/chatItem.vue'
import addCircle from '@/static/image/chatList/addCircle.png'
2024-12-19 03:02:47 +00:00
import lodash from 'lodash'
const talkStore = useTalkStore()
const userStore = useUserStore()
const { userInfo } = useAuth()
const dialogueStore = useDialogueStore()
const isMultiSelect = ref(false)
const showWin = ref(false)
const forwardModalHeight = ref(402)
const topItems = computed(() => talkStore.topItems)
const items = ref([])
// const items = computed(() => {
// return lodash.cloneDeep(talkStore.talkItems)
// })
const selectItems = computed(() => {
2025-02-08 09:09:57 +00:00
return items.value.filter((item) => item.isCheck)
2024-12-19 03:02:47 +00:00
})
const selectItemsModal = ref([])
const itemClick = (item) => {
2025-02-08 09:09:57 +00:00
console.log(item)
2024-12-19 03:02:47 +00:00
if (isMultiSelect.value) {
item.isCheck = !item.isCheck
return false
}
selectItemsModal.value = [item]
forwardModalHeight.value = 402
showWin.value = true
}
const handleFinish = () => {
2025-02-08 09:09:57 +00:00
console.log(selectItems.value)
2024-12-19 03:02:47 +00:00
selectItemsModal.value = selectItems.value
if (selectItemsModal.value.length > 4) {
forwardModalHeight.value = 560
} else {
forwardModalHeight.value = 402
}
showWin.value = true
}
const handleClose = () => {
dialogueStore.setForwardType('')
dialogueStore.setForwardMessages([])
uni.navigateBack()
}
const handleOk = () => {
let msg_ids = dialogueStore.forwardMessages.map((item) => item.msg_id)
let user_ids = []
let group_ids = []
2024-12-20 08:59:58 +00:00
for (let o of selectItemsModal.value) {
2024-12-19 03:02:47 +00:00
if (o.talk_type == 1) {
user_ids.push(o.receiver_id)
} else {
group_ids.push(o.receiver_id)
}
}
dialogueStore.ApiForwardRecord({
mode: dialogueStore.forwardType,
message_ids: msg_ids,
uids: user_ids,
2025-02-08 09:09:57 +00:00
gids: group_ids,
2024-12-19 03:02:47 +00:00
})
2024-12-20 08:59:58 +00:00
2024-12-19 03:02:47 +00:00
uni.navigateBack()
}
const handleCancel = () => {
2025-02-08 09:09:57 +00:00
console.log('cancel')
2024-12-19 03:02:47 +00:00
}
2025-02-08 09:09:57 +00:00
watch(
() => talkStore,
(newValue, oldValue) => {
console.log(talkStore)
},
{ deep: true, immediate: true },
)
2024-12-19 03:02:47 +00:00
onMounted(() => {
talkStore.loadTalkList()
2025-02-08 09:09:57 +00:00
console.log(talkStore.talkItems)
2024-12-19 03:02:47 +00:00
items.value = lodash.cloneDeep(talkStore.talkItems)
})
onUnmounted(() => {
dialogueStore.setForwardType('')
dialogueStore.setForwardMessages([])
})
</script>
<style scoped lang="scss">
2025-02-08 09:09:57 +00:00
::v-deep .zp-paging-container-content {
2024-12-19 03:02:47 +00:00
height: 100%;
2025-02-08 09:09:57 +00:00
display: flex;
2024-12-19 03:02:47 +00:00
}
2025-02-08 09:09:57 +00:00
.choose-chat {
2024-12-19 03:02:47 +00:00
flex: 1;
2025-02-08 09:09:57 +00:00
padding: 20rpx 32rpx;
2024-12-19 03:02:47 +00:00
display: flex;
flex-direction: column;
2025-02-08 09:09:57 +00:00
background-image: url('@/static/image/clockIn/z3280@3x.png');
background-size: cover;
background-position: bottom center;
background-attachment: fixed;
2024-12-19 03:02:47 +00:00
}
.searchRoot {
background-color: #fff;
padding: 22rpx 18rpx;
}
.contentRoot {
margin-top: 20rpx;
background-color: #fff;
}
.tag{
display: inline-flex;
align-items: center;
text-align: center;
// margin-left: 10rpx;
margin-top: 4rpx;
vertical-align: top;
height: 38rpx;
line-height: 38rpx;
padding: 0 10rpx;
font-size: 24rpx;
border-radius: 6rpx;
font-weight: bold;
}
.companyTag {
border: 1px solid #7a58de;
color: #7a58de;
}
.depTag {
border: 1px solid #377ec6;
color: #377ec6;
}
.projectTag {
border: 1px solid #c1681c;
color: #c1681c;
}
2024-12-19 03:02:47 +00:00
.btnBox {
2025-02-08 09:09:57 +00:00
::v-deep .custom-btn-class {
padding: 6rpx 24rpx !important;
width: unset !important;
min-width: unset !important;
height: unset !important;
}
::v-deep .wd-button__text {
font-size: 34rpx !important;
font-weight: 400 !important;
line-height: 48rpx !important;
2024-12-19 03:02:47 +00:00
}
}
:deep(.noNvueBorder.round-bl-4) {
2025-02-08 09:09:57 +00:00
border-top: 1rpx solid #e7e7e7 !important;
background-color: #ffffff !important;
2024-12-19 03:02:47 +00:00
uni-text {
2025-02-08 09:09:57 +00:00
color: #1a1a1a !important;
2024-12-19 03:02:47 +00:00
font-size: 32rpx !important;
line-height: 48rpx !important;
}
}
:deep(.noNvueBorder.round-br-4) {
2025-02-08 09:09:57 +00:00
border-top: 1rpx solid #e7e7e7 !important;
border-left: 1rpx solid #e7e7e7 !important;
background-color: #ffffff !important;
2024-12-19 03:02:47 +00:00
uni-text {
font-weight: bold;
2025-02-08 09:09:57 +00:00
color: #46299d !important;
2024-12-19 03:02:47 +00:00
font-size: 32rpx !important;
line-height: 48rpx !important;
}
}
</style>