|
@@ -20,10 +20,16 @@
|
|
</template>
|
|
</template>
|
|
<div class="member-li" @click="addMember" v-if="status == 2">
|
|
<div class="member-li" @click="addMember" v-if="status == 2">
|
|
<div class="add">
|
|
<div class="add">
|
|
- <svg-icon class="add-icon" name="add3" />
|
|
|
|
|
|
+ <van-icon class="add-icon" name="plus" />
|
|
</div>
|
|
</div>
|
|
<div>邀请</div>
|
|
<div>邀请</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div class="member-li" @click="deleteMember" v-if="status == 2 && isAdmin">
|
|
|
|
+ <div class="add">
|
|
|
|
+ <van-icon class="add-icon" name="minus" />
|
|
|
|
+ </div>
|
|
|
|
+ <div>移出</div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<van-cell-group class="user-bar-list" v-if="status == 2">
|
|
<van-cell-group class="user-bar-list" v-if="status == 2">
|
|
@@ -60,10 +66,10 @@
|
|
</template>
|
|
</template>
|
|
</van-cell>
|
|
</van-cell>
|
|
</van-cell-group> -->
|
|
</van-cell-group> -->
|
|
- <van-cell-group class="user-bar-list" style="display: none;">
|
|
|
|
|
|
+ <van-cell-group class="user-bar-list">
|
|
<van-cell class="user-bar-list-last" title="查看聊天记录" is-link @click="goChatDetail"></van-cell>
|
|
<van-cell class="user-bar-list-last" title="查看聊天记录" is-link @click="goChatDetail"></van-cell>
|
|
</van-cell-group>
|
|
</van-cell-group>
|
|
- <div class="exit" @click="showExit = true" v-if="status == 2">退出群聊</div>
|
|
|
|
|
|
+ <div class="exit" @click="showExit = true" v-if="status == 2">{{isAdmin?'解散':'退出'}}群聊</div>
|
|
<!-- 修改信息弹框 -->
|
|
<!-- 修改信息弹框 -->
|
|
<van-popup v-model:show="showUpdateName" :style="{ borderRadius:'25px' }">
|
|
<van-popup v-model:show="showUpdateName" :style="{ borderRadius:'25px' }">
|
|
<div class="pop-content-password">
|
|
<div class="pop-content-password">
|
|
@@ -95,10 +101,10 @@
|
|
<!-- 退出群聊弹框 -->
|
|
<!-- 退出群聊弹框 -->
|
|
<van-popup v-model:show="showExit" :style="{ borderRadius:'25px' }">
|
|
<van-popup v-model:show="showExit" :style="{ borderRadius:'25px' }">
|
|
<div class="pop-content-password">
|
|
<div class="pop-content-password">
|
|
- <div class="pop-title-password">确定要退出群聊吗?</div>
|
|
|
|
|
|
+ <div class="pop-title-password">确定要{{isAdmin?'解散':'退出'}}群聊吗?</div>
|
|
<div class="pop-btn-password" style="margin-top: 50px;">
|
|
<div class="pop-btn-password" style="margin-top: 50px;">
|
|
<van-button type="default" class="btn-password cancel" @click="showExit = false">{{ $t('wallet.Cancel') }}</van-button>
|
|
<van-button type="default" class="btn-password cancel" @click="showExit = false">{{ $t('wallet.Cancel') }}</van-button>
|
|
- <van-button type="default" class="btn-password confirm" @click="popConfirm">{{ $t('wallet.Sure') }}</van-button>
|
|
|
|
|
|
+ <van-button type="default" class="btn-password confirm" @click="popExit">{{ $t('wallet.Sure') }}</van-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</van-popup>
|
|
</van-popup>
|
|
@@ -108,7 +114,7 @@
|
|
<script setup>
|
|
<script setup>
|
|
import { useWebSocketStore } from "@/stores/modules/webSocketStore.js";
|
|
import { useWebSocketStore } from "@/stores/modules/webSocketStore.js";
|
|
import { useWalletStore } from "@/stores/modules/walletStore";
|
|
import { useWalletStore } from "@/stores/modules/walletStore";
|
|
-import { groupList,selectGroupName } from "@/api/path/im.api";
|
|
|
|
|
|
+import { groupList,selectGroupName,selectEditnickname,quitGroup,dissolveGroup } from "@/api/path/im.api";
|
|
import { useRouter,useRoute } from 'vue-router'
|
|
import { useRouter,useRoute } from 'vue-router'
|
|
import { reactive } from 'vue'
|
|
import { reactive } from 'vue'
|
|
import { showNotify,showToast } from 'vant';
|
|
import { showNotify,showToast } from 'vant';
|
|
@@ -119,13 +125,12 @@ const wsStore = useWebSocketStore();
|
|
const IM_PATH = import.meta.env.VITE_IM_PATH_FIlE;
|
|
const IM_PATH = import.meta.env.VITE_IM_PATH_FIlE;
|
|
const walletStore = useWalletStore();
|
|
const walletStore = useWalletStore();
|
|
|
|
|
|
-const newNickname = ref('');
|
|
|
|
const groupMembers = ref([]);//显示部分成员
|
|
const groupMembers = ref([]);//显示部分成员
|
|
const groupMembersNum= ref([]);//全部成员
|
|
const groupMembersNum= ref([]);//全部成员
|
|
const information = reactive({
|
|
const information = reactive({
|
|
name:wsStore.toUserInfo.nickname,
|
|
name:wsStore.toUserInfo.nickname,
|
|
notice:wsStore.toUserInfo.notice,
|
|
notice:wsStore.toUserInfo.notice,
|
|
- nickname:newNickname.value? newNickname.value : walletStore.username
|
|
|
|
|
|
+ nickname:''
|
|
})
|
|
})
|
|
const type = ref(1);//1:修改群聊名称 2:修改我的群昵称
|
|
const type = ref(1);//1:修改群聊名称 2:修改我的群昵称
|
|
const disturb = ref(true);
|
|
const disturb = ref(true);
|
|
@@ -141,18 +146,24 @@ const fetchGroupMembers = async () => {
|
|
try {
|
|
try {
|
|
const res = await groupList(wsStore.toUserInfo.uuid);
|
|
const res = await groupList(wsStore.toUserInfo.uuid);
|
|
groupMembers.value = (res.data || []).slice(0, 8);
|
|
groupMembers.value = (res.data || []).slice(0, 8);
|
|
- groupMembersNum.value = res.data || []
|
|
|
|
|
|
+ groupMembersNum.value = res.data || [];
|
|
|
|
+ const dataInfo = groupMembersNum.value.find(
|
|
|
|
+ m => m.uuid === walletStore.account
|
|
|
|
+ );
|
|
|
|
+ if (dataInfo) {
|
|
|
|
+ information.nickname = dataInfo.nickname || ''; // 群个人昵称
|
|
|
|
+ }
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.error("获取群成员失败", e);
|
|
console.error("获取群成员失败", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+const isAdmin = computed(() => {
|
|
|
|
+ const self = groupMembersNum.value.find(m => m.uuid === walletStore.account);
|
|
|
|
+ return self?.userId === self?.guserId;
|
|
|
|
+});
|
|
const changeUpdateName = (val) => {
|
|
const changeUpdateName = (val) => {
|
|
type.value = val;
|
|
type.value = val;
|
|
newName.value = val == 1?information.name:information.nickname;
|
|
newName.value = val == 1?information.name:information.nickname;
|
|
- if(val == 2){
|
|
|
|
- showToast('无法修改!')
|
|
|
|
- return;
|
|
|
|
- };
|
|
|
|
showUpdateName.value = true;
|
|
showUpdateName.value = true;
|
|
}
|
|
}
|
|
// 群聊名称取消
|
|
// 群聊名称取消
|
|
@@ -175,7 +186,20 @@ const popConfirm = () => {
|
|
// 修改群聊名称接口
|
|
// 修改群聊名称接口
|
|
funSelectGroupName({name:newName.value,uuid:wsStore.toUserInfo.uuid});
|
|
funSelectGroupName({name:newName.value,uuid:wsStore.toUserInfo.uuid});
|
|
}else{
|
|
}else{
|
|
|
|
+ // 修改群个人昵称接口
|
|
|
|
+ funSelectEditnickname({nickname:newName.value,groupId:wsStore.toUserInfo.id})
|
|
information.nickname = newName.value;
|
|
information.nickname = newName.value;
|
|
|
|
+ // 同步更新 groupMembers 和 groupMembersNum(因为你两个地方用到)
|
|
|
|
+ const selfData = groupMembersNum.value.find(m => m.uuid === walletStore.account);
|
|
|
|
+ if (selfData) {
|
|
|
|
+ selfData.nickname = newName.value;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果 groupMembers 是前 8 个成员的子集,也要更新
|
|
|
|
+ const selfInMembers = groupMembers.value.find(m => m.uuid === walletStore.account);
|
|
|
|
+ if (selfInMembers) {
|
|
|
|
+ selfInMembers.nickname = newName.value;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}, 1000);
|
|
}, 1000);
|
|
}
|
|
}
|
|
@@ -192,6 +216,20 @@ const funSelectGroupName = async (params) => {
|
|
showToast('修改失败')
|
|
showToast('修改失败')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+// 修改群个人昵称接口
|
|
|
|
+const funSelectEditnickname = async (params) => {
|
|
|
|
+ try {
|
|
|
|
+ const res = await selectEditnickname(wsStore.uuid,params);
|
|
|
|
+ if(res.code == 200){
|
|
|
|
+ showToast('修改成功');
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ showToast('修改失败')
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ showToast('修改失败')
|
|
|
|
+ }
|
|
|
|
+}
|
|
// 群公告
|
|
// 群公告
|
|
const changeUpdateNotice = () => {
|
|
const changeUpdateNotice = () => {
|
|
if(!newNotice.value){
|
|
if(!newNotice.value){
|
|
@@ -206,6 +244,25 @@ const changeUpdateNotice = () => {
|
|
wsStore.toUserInfo.notice = newNotice.value;
|
|
wsStore.toUserInfo.notice = newNotice.value;
|
|
}, 500);
|
|
}, 500);
|
|
}
|
|
}
|
|
|
|
+//退出或者解散
|
|
|
|
+const popExit = async () => {
|
|
|
|
+ const action = isAdmin.value ? dissolveGroup : quitGroup;
|
|
|
|
+ const successMsg = isAdmin.value ? '解散成功' : '退出成功';
|
|
|
|
+ const failMsg = isAdmin.value ? '解散失败' : '退出失败';
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ const res = await action(walletStore.account, wsStore.toUserInfo.id);
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ showToast(successMsg);
|
|
|
|
+ router.push('im');
|
|
|
|
+ } else {
|
|
|
|
+ showToast(failMsg);
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ showToast(failMsg);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
// 跳转群二维码页面
|
|
// 跳转群二维码页面
|
|
const goQrcode = () => {
|
|
const goQrcode = () => {
|
|
router.push('qrcode')
|
|
router.push('qrcode')
|
|
@@ -223,6 +280,12 @@ const addMember = () => {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+// 跳转移出成员页面
|
|
|
|
+const deleteMember = () => {
|
|
|
|
+ router.push({
|
|
|
|
+ path: 'deleteMember'
|
|
|
|
+ })
|
|
|
|
+}
|
|
// 跳转查看成员页面
|
|
// 跳转查看成员页面
|
|
const checkMember = () => {
|
|
const checkMember = () => {
|
|
router.push('checkMember')
|
|
router.push('checkMember')
|
|
@@ -304,11 +367,11 @@ onMounted(() => {
|
|
background: #F2F2F2;
|
|
background: #F2F2F2;
|
|
position: relative;
|
|
position: relative;
|
|
.add-icon{
|
|
.add-icon{
|
|
- width: 20px;
|
|
|
|
- height: 20px;
|
|
|
|
|
|
+ font-size: 20px;
|
|
position: absolute;
|
|
position: absolute;
|
|
top:50%;
|
|
top:50%;
|
|
left: 50%;
|
|
left: 50%;
|
|
|
|
+ color: #8D8D8D;
|
|
transform: translate(-50%,-50%);
|
|
transform: translate(-50%,-50%);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -365,7 +428,6 @@ onMounted(() => {
|
|
color: #FF0000;
|
|
color: #FF0000;
|
|
text-align: center;
|
|
text-align: center;
|
|
line-height: 44px;
|
|
line-height: 44px;
|
|
- display: none;
|
|
|
|
}
|
|
}
|
|
.pop-content-password{
|
|
.pop-content-password{
|
|
padding: 27px 35px 25px 34px;
|
|
padding: 27px 35px 25px 34px;
|