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

238 lines
6.4 KiB
Vue
Raw Normal View History

2024-11-19 05:57:36 +00:00
<template>
<div class="outer-layer">
<div>
<tm-navbar class="index_top_navbar" :hideBack="false" hideHome title="" :leftWidth="420">
2024-11-22 01:06:37 +00:00
<template v-slot:left>
2024-12-24 08:28:44 +00:00
<div class="flex items-center ml-[48rpx]">
<image
class="w-[72rpx] h-[72rpx]"
style="border-radius: 50%;"
2024-12-24 08:28:44 +00:00
:src="userStore.avatar"
mode="scaleToFill"
/>
2024-12-24 08:28:44 +00:00
<div class="ml-[24rpx] text-[36rpx] font-bold">
{{ userStore.nickname }}
</div>
2024-11-22 01:06:37 +00:00
</div>
</template>
<template v-slot:right>
2024-12-30 06:47:02 +00:00
<div class="mr-[48rpx] popoverBox">
2024-12-24 08:28:44 +00:00
<tm-popover position="br" color="#333333" :width="260">
<image
class="w-[48rpx] h-[48rpx]"
style="border-radius: 50%;"
2024-12-24 08:28:44 +00:00
:src="addCircle"
mode="scaleToFill"
/>
2024-12-24 08:28:44 +00:00
<template v-slot:label>
<div
class="w-full h-[208rpx] pt-[22rpx] pb-[32rpx] pl-[14rpx] pr-[12rpx]"
>
<div
@click="creatGroupChat"
class="flex items-center pl-[22rpx] mb-[32rpx]"
>
2024-12-24 08:28:44 +00:00
<div class="mr-[26rpx] flex items-center">
<tm-image
:width="40"
:height="39"
2024-12-24 08:28:44 +00:00
:src="cahtPopover"
></tm-image>
</div>
<div
class="leading-[54rpx] text-[32rpx] text-[#FFFFFF] font-bold"
>
发起群聊
</div>
2024-12-24 08:28:44 +00:00
</div>
<div class="divider"></div>
<div
@click="toAddressBookPage"
class="flex items-center pl-[22rpx] mt-[32rpx]"
>
2024-12-24 08:28:44 +00:00
<div class="mr-[26rpx] flex items-center">
<tm-image
:width="40"
:height="43"
2024-12-24 08:28:44 +00:00
:src="zu3289"
></tm-image>
</div>
<div
class="leading-[54rpx] text-[32rpx] text-[#FFFFFF] font-bold"
>
2024-12-24 08:28:44 +00:00
通讯录
</div>
</div>
</div>
</template>
</tm-popover>
2024-11-22 01:06:37 +00:00
</div>
2024-12-24 08:28:44 +00:00
</template>
2024-11-22 01:06:37 +00:00
</tm-navbar>
2024-11-19 05:57:36 +00:00
</div>
<div class="root">
<div class="searchRoot" @click="toSearchPage">
2024-12-24 08:28:44 +00:00
<tm-input
placeholder="请输入…"
color="#F9F9FD"
:round="1"
prefix="tmicon-search"
prefixColor="#46299D"
placeholderStyle="color:#BABABA"
class="input_search"
2024-12-24 08:28:44 +00:00
></tm-input>
2024-11-19 05:57:36 +00:00
</div>
<div class="contentRoot">
2024-11-22 01:06:37 +00:00
<chatItem
2024-12-24 08:28:44 +00:00
v-for="(item, index) in items"
2024-11-22 01:06:37 +00:00
:key="item.index_name"
:index="index"
:data="item"
/>
2024-11-19 05:57:36 +00:00
</div>
</div>
</div>
</template>
2024-11-11 06:46:14 +00:00
<script setup>
import { ref, watch, computed } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app'
import { useChatList } from '@/store/chatList/index.js'
import { useAuth } from '@/store/auth'
import { useTalkStore, useUserStore, useDialogueStore } from '@/store'
import chatItem from './components/chatItem.vue'
import addCircle from '@/static/image/chatList/addCircle.png'
import cahtPopover from '@/static/image/chatList/cahtPopover.png'
import zu3289 from '@/static/image/chatList/zu3289@2x.png'
2024-11-11 06:46:14 +00:00
const talkStore = useTalkStore()
const userStore = useUserStore()
const dialogueStore = useDialogueStore()
const { userInfo } = useAuth()
2024-11-11 06:46:14 +00:00
const topItems = computed(() => talkStore.topItems)
2024-11-22 01:06:37 +00:00
const items = computed(() => {
// if (searchKeyword.value.length === 0) {
return talkStore.talkItems
2024-11-22 01:06:37 +00:00
// }
// return talkStore.talkItems.filter((item) => {
// let keyword = item.remark || item.name
// return keyword.toLowerCase().indexOf(searchKeyword.value.toLowerCase()) != -1
// })
})
2024-11-22 01:06:37 +00:00
2024-12-24 08:28:44 +00:00
const creatGroupChat = () => {
uni.navigateTo({
url: '/pages/creatGroupChat/index',
})
}
2024-11-22 01:06:37 +00:00
const toSearchPage = () => {
uni.navigateTo({
url: '/pages/search/index',
})
}
//点击跳转到通讯录页面
const toAddressBookPage = () => {
uni.navigateTo({
url: '/pages/chooseByDeps/index?chooseMode=3',
})
}
2024-12-24 08:28:44 +00:00
watch(
() => talkStore,
(newValue, oldValue) => {
// console.log(talkStore)
2024-12-24 08:28:44 +00:00
},
{ deep: true, immediate: true },
)
2024-11-22 01:06:37 +00:00
2024-12-24 08:28:44 +00:00
onShow(() => {
talkStore.loadTalkList()
})
onLoad((options) => {
if (options?.openSessionIndexName) {
if (items?.value?.length > 0) {
items.value.forEach((openSession) => {
if (openSession.index_name === options?.openSessionIndexName) {
dialogueStore.setDialogue(openSession)
if (openSession.unread_num > 0) {
ServeClearTalkUnreadNum({
talk_type: openSession.talk_type,
receiver_id: openSession.receiver_id,
}).then(() => {
talkStore.updateItem({
index_name: openSession.index_name,
unread_num: 0,
})
})
}
uni.navigateTo({
url: '/pages/dialog/index?sessionId=' + openSession.id,
})
}
})
}
}
})
2024-11-11 06:46:14 +00:00
</script>
<style scoped lang="scss">
2024-12-24 08:28:44 +00:00
uni-page-body,
page {
height: 100%;
2024-11-26 08:51:36 +00:00
}
2024-11-19 05:57:36 +00:00
.outer-layer {
overflow-y: auto;
flex: 1;
background-image: url('@/static/image/clockIn/z3280@3x.png');
2024-11-19 05:57:36 +00:00
background-size: cover;
padding: 0 32rpx 20rpx 32rpx;
display: flex;
flex-direction: column;
}
::v-deep .index_top_navbar > .statusHeight:first-child{
height: 70px !important;
}
::v-deep .index_top_navbar .statusHeightTop{
height: 70px !important;
}
::v-deep .index_top_navbar .statusHeightTop > .noNvueBorder:first-child{
height: 70px !important;
}
2024-11-19 05:57:36 +00:00
.root {
flex: 1;
padding: 20rpx 0;
}
.searchRoot {
background-color: #fff;
padding: 22rpx 18rpx;
/* ::v-deep .input_search{
background: #F9F9FD !important;
} */
::v-deep .noNvueBorder > .noNvueBorder > .noNvueBorder{
// border: 1px solid red !important;
background: #F9F9FD !important;
}
2024-11-19 05:57:36 +00:00
}
.contentRoot {
margin-top: 20rpx;
background-color: #fff;
}
.divider {
2024-12-24 08:28:44 +00:00
height: 1rpx;
background-color: #7c7c7c;
2024-12-24 08:28:44 +00:00
opacity: 0.6;
}
2024-12-30 06:47:02 +00:00
.popoverBox {
:deep(.popover-bcc) {
transform: translateX(16rpx) translateY(48rpx);
2024-12-30 06:47:02 +00:00
}
}
2024-11-11 06:46:14 +00:00
</style>