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

291 lines
8.0 KiB
Vue
Raw Normal View History

2024-12-24 08:28:44 +00:00
<template>
<div class="outer-layer">
<div>
<tm-navbar :hideBack="false" hideHome title="发起群聊" :leftWidth="320">
</tm-navbar>
</div>
<div class="root">
2025-01-08 01:18:41 +00:00
<div class="w-full pl-[32rpx] pr-[32rpx] mb-[20rpx]" >
2024-12-24 08:28:44 +00:00
<div class="w-full mt-[60rpx] flex justify-center" >
2025-01-08 01:18:41 +00:00
<div v-if="groupActiveIndex === -1" class="avatar-placeholder">
2024-12-24 08:28:44 +00:00
</div>
<div class="mb-[40rpx]" v-else>
<tm-image
:width="192"
:height="192"
:round="12"
:src="avatarImg"
></tm-image>
</div>
</div>
2025-01-08 01:18:41 +00:00
<div class="input-group flex items-center justify-between" >
2024-12-24 08:28:44 +00:00
<div class="input-item">
群名称
</div>
<div class="input-box" >
<tm-input
2025-01-08 01:18:41 +00:00
v-model="groupName"
2024-12-24 08:28:44 +00:00
:followTheme="false"
2025-01-08 01:18:41 +00:00
fontColor="#747474"
2024-12-24 08:28:44 +00:00
placeholderStyle="color: #B4B4B4"
focusColor="#FFF"
:fontSize="28"
:maxlength="20"
2025-01-08 01:18:41 +00:00
:height="40"
2024-12-24 08:28:44 +00:00
:transprent="true"
placeholder="请输入群名称1~20个字"
2025-01-08 01:18:41 +00:00
:padding="[0,0]"
align="right"
2024-12-24 08:28:44 +00:00
>
</tm-input>
</div>
</div>
2025-01-08 01:18:41 +00:00
<div class="input-group w-full flex flex-col mt-[20rpx] leading-[40rpx]" >
<div class="flex items-center justify-between" >
<div class="input-item">
群类型
</div>
<div @click="chooseGroupType" class="left-box" >
<div class="text-[#B4B4B4] text-[28rpx]" >
<span v-if="groupActiveIndex ===-1">请选择群类型</span>
<span v-else-if="groupActiveIndex ===0">普通群</span>
<span v-else-if="groupActiveIndex ===1">部门群</span>
<span v-else-if="groupActiveIndex ===2">项目群</span>
</div>
<div class="ml-[32rpx]" >
<tm-icon :font-size="22" color="#747474" name="tmicon-angle-right"></tm-icon>
</div>
</div>
2024-12-24 08:28:44 +00:00
</div>
2025-01-08 01:18:41 +00:00
<div v-if="depCheckedKeys.length" class="mt-[32rpx]" >
<div
v-for="(item,index) in depCheckedKeys"
class="text-[#747474] text-[28rpx] leading-[40rpx] font-bold"
:class="[
index !==0 ? 'mt-[10rpx]':'',
depsNoExpanded&&index>4 ? 'hidden':''
]"
>
{{ item.name }}
2024-12-24 08:28:44 +00:00
</div>
2025-01-08 01:18:41 +00:00
<div class="text-[#46299D] text-[28rpx] mt-[20rpx] font-bold flex justify-center" >
<div v-if="depCheckedKeys.length>5" @click="depsNoExpanded = !depsNoExpanded" class="w-[100rpx]">
{{ depsNoExpanded? '展开':'收起' }}
</div>
2024-12-24 08:28:44 +00:00
</div>
</div>
</div>
2025-01-08 01:18:41 +00:00
<div v-if="groupActiveIndex===1" class="input-group w-full flex flex-col mt-[20rpx] leading-[40rpx]" >
<div class="flex items-center justify-between" >
<div class="input-item">
群管理员
</div>
<div @click="chooseGroupAdmin" class="left-box" >
<div class="ml-[32rpx] flex items-center" >
<div v-if="!groupAdmins.length" class="text-[#B4B4B4] text-[28rpx] font-bold mr-[32rpx]">请选择群管理员</div>
<tm-icon :font-size="22" color="#747474" name="tmicon-angle-right"></tm-icon>
</div>
</div>
</div>
<div v-if="groupAdmins.length" class="mt-[32rpx]" >
<div
v-for="(item,index) in groupAdmins"
class="text-[#747474] text-[28rpx] leading-[40rpx] font-bold"
:class="[
index !==0 ? 'mt-[10rpx]':'',
depsNoExpanded&&index>4 ? 'hidden':''
]"
>
{{ item.name }}
</div>
<div class="text-[#46299D] text-[28rpx] mt-[20rpx] font-bold flex justify-center" >
<div v-if="groupAdmins.length>5" @click="depsNoExpanded = !depsNoExpanded" class="w-[100rpx]">
{{ depsNoExpanded? '展开':'收起' }}
</div>
</div>
</div>
</div>
2024-12-24 08:28:44 +00:00
</div>
<div class="h-[162rpx] flex justify-center bg-[#FFFFFF]">
2025-01-08 01:18:41 +00:00
<div class="mt-[14rpx] btnBox" >
2024-12-24 08:28:44 +00:00
<tm-button
2025-01-08 01:18:41 +00:00
@click="handleConfirm"
2024-12-24 08:28:44 +00:00
color="#46299D"
2025-01-08 01:18:41 +00:00
:disabled="confirmBtnStatus"
2024-12-24 08:28:44 +00:00
disabledColor="#E6E6E6"
:margin="[0]"
:shadow="0"
:width="426"
:height="76"
size="large"
2025-01-08 01:18:41 +00:00
label="发起群聊"
2024-12-24 08:28:44 +00:00
>
</tm-button>
</div>
</div>
</div>
</div>
</template>
<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 } from "@/store";
import addCircle from "@/static/image/chatList/addCircle.png";
import cahtPopover from "@/static/image/chatList/cahtPopover.png";
import zu4992 from "@/static/image/chatList/zu4992@2x.png";
import zu4991 from "@/static/image/chatList/zu4991@2x.png";
import zu4989 from "@/static/image/chatList/zu4989@2x.png";
2025-01-08 01:18:41 +00:00
import { useGroupTypeStore } from "@/store/groupType";
2024-12-24 08:28:44 +00:00
2025-01-08 01:18:41 +00:00
const { groupName,groupActiveIndex,depCheckedKeys,groupAdmins,createDepGroup,resetGroupInfo } = useGroupTypeStore();
2024-12-24 08:28:44 +00:00
const talkStore = useTalkStore();
const userStore = useUserStore();
const { userInfo } = useAuth();
const groupChatType = ref('');
2025-01-08 01:18:41 +00:00
const depsNoExpanded = ref(true);
2024-12-24 08:28:44 +00:00
const avatarImg = computed(() => {
let srcT = "";
2025-01-08 01:18:41 +00:00
switch (groupActiveIndex.value) {
case 0:
2024-12-24 08:28:44 +00:00
srcT = zu4992;
break;
2025-01-08 01:18:41 +00:00
case 1:
2024-12-24 08:28:44 +00:00
srcT = zu4989;
break;
2025-01-08 01:18:41 +00:00
case 2:
srcT = zu4991;
break;
2024-12-24 08:28:44 +00:00
default:
srcT = zu4992;
}
return srcT;
})
const chooseGroupType = () => {
uni.navigateTo({
url: '/pages/chooseGroupType/index'
})
}
2025-01-08 01:18:41 +00:00
const chooseGroupAdmin = () => {
uni.navigateTo({
url: '/pages/chooseGroupAdmin/index'
})
}
const handleConfirm = async () => {
if (groupActiveIndex.value === 0) {
}else if(groupActiveIndex.value === 1){
const res = await createDepGroup()
if (res.code === 200) {
resetGroupInfo()
uni.navigateBack()
}
}else {
}
}
const confirmBtnStatus = computed(() => {
let disabledT = false;
if (groupName.value === "" || !groupActiveIndex.value) {
return true;
}
switch (groupActiveIndex.value) {
case 0:
break;
case 1:
if (!depCheckedKeys.value.length) {
disabledT = true;
}
if (!groupAdmins.value.length) {
disabledT = true;
}
break;
case 2:
break;
default:
break;
}
return disabledT
})
onShow(() => {
depsNoExpanded.value = true;
})
2024-12-24 08:28:44 +00:00
</script>
<style scoped lang="scss">
uni-page-body,
page {
height: 100%;
}
.outer-layer {
overflow-y: auto;
flex: 1;
background-image: url("@/static/image/clockIn/z3280@3x.png");
background-size: cover;
padding-bottom: 0;
display: flex;
flex-direction: column;
}
.root {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.divider{
height: 1rpx;
background-color: #7C7C7C;
opacity: 0.6;
}
.avatar-placeholder {
width: 192rpx;
height: 192rpx;
background-color: #e0e0e0;
border-radius: 50%;
margin-bottom: 40rpx;
}
.input-group {
background-color: #fff;
2025-01-08 01:18:41 +00:00
padding-top: 38rpx;
padding-bottom: 32rpx;
2024-12-24 08:28:44 +00:00
padding-left: 32rpx;
padding-right: 40rpx;
2025-01-08 01:18:41 +00:00
// display: flex;
// align-items: center;
// justify-content: space-between;
2024-12-24 08:28:44 +00:00
}
.input-item {
2025-01-08 01:18:41 +00:00
line-height: 40rpx;
2024-12-24 08:28:44 +00:00
font-size: 28rpx;
color: #000;
font-weight: bold;
}
.input-box {
margin-left: 84rpx;
2025-01-08 01:18:41 +00:00
line-height: 40rpx;
2024-12-24 08:28:44 +00:00
width: 404rpx;
}
.left-box {
display: flex;
align-items: center;
}
2025-01-08 01:18:41 +00:00
.btnBox {
:deep(uni-button[disabled="true"]) {
color: #bebebe !important;
}
}
2024-12-24 08:28:44 +00:00
</style>