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

169 lines
4.5 KiB
Vue
Raw Normal View History

2024-11-19 05:57:36 +00:00
<template>
<div class="outer-layer">
<div>
2024-12-24 08:28:44 +00:00
<tm-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]">
<tm-image
:width="72"
:height="72"
:round="12"
:src="userStore.avatar"
></tm-image>
<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">
<tm-image
:width="41"
:height="41"
:round="12"
:src="addCircle"
></tm-image>
<template v-slot:label>
<div class="w-full h-[208rpx] pt-[22rpx] pb-[22rpx] pl-[34rpx] pr-[32rpx]" >
<div @click="creatGroupChat" class="flex items-center mb-[30rpx]" >
<div class="mr-[26rpx] flex items-center">
<tm-image
:width="40"
:height="40"
:src="cahtPopover"
></tm-image>
</div>
<div class="leading-[54rpx] text-[32rpx] text-[#FFFFFF] font-bold" >发起群聊</div>
</div>
<div class="divider" ></div>
<div class="flex items-center mt-[28rpx]" >
<div class="mr-[26rpx] flex items-center">
<tm-image
:width="40"
:height="40"
:src="zu3289"
></tm-image>
</div>
<div class="leading-[54rpx] text-[32rpx] text-[#FFFFFF] font-bold" >
通讯录
</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"
></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>
2024-12-24 08:28:44 +00:00
import { ref, watch, computed } from "vue";
2024-12-13 05:09:38 +00:00
import { onShow, onLoad } from "@dcloudio/uni-app";
2024-11-19 05:57:36 +00:00
import { useChatList } from "@/store/chatList/index.js";
2024-12-24 08:28:44 +00:00
import { useAuth } from "@/store/auth";
import { useTalkStore, useUserStore } from "@/store";
import chatItem from "./components/chatItem.vue";
2024-11-22 01:06:37 +00:00
import addCircle from "@/static/image/chatList/addCircle.png";
2024-12-24 08:28:44 +00:00
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
2024-12-24 08:28:44 +00:00
const talkStore = useTalkStore();
const userStore = useUserStore();
const { userInfo } = useAuth();
2024-11-11 06:46:14 +00:00
2024-12-24 08:28:44 +00:00
const topItems = computed(() => talkStore.topItems);
2024-11-22 01:06:37 +00:00
const items = computed(() => {
// if (searchKeyword.value.length === 0) {
2024-12-24 08:28:44 +00:00
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-12-24 08:28:44 +00:00
});
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",
});
};
2024-12-24 08:28:44 +00:00
watch(
() => talkStore,
(newValue, oldValue) => {
console.log(talkStore);
},
{ deep: true, immediate: true }
);
2024-11-22 01:06:37 +00:00
2024-12-24 08:28:44 +00:00
onShow(() => {
talkStore.loadTalkList();
});
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");
background-size: cover;
padding: 0 32rpx 20rpx 32rpx;
display: flex;
flex-direction: column;
}
.root {
flex: 1;
padding: 20rpx 0;
}
.searchRoot {
background-color: #fff;
padding: 22rpx 18rpx;
}
.contentRoot {
margin-top: 20rpx;
background-color: #fff;
}
2024-12-24 08:28:44 +00:00
.divider{
height: 1rpx;
background-color: #7C7C7C;
opacity: 0.6;
}
2024-12-30 06:47:02 +00:00
.popoverBox {
:deep(.popover-bcc){
transform:translateX(20rpx) translateY(40rpx);
}
}
2024-11-11 06:46:14 +00:00
</style>