Initial commit
This commit is contained in:
57
pages/conversation/groupSettings/components/ActionSheet.vue
Normal file
57
pages/conversation/groupSettings/components/ActionSheet.vue
Normal file
@@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<u-action-sheet
|
||||
safeAreaInsetBottom
|
||||
closeOnClickOverlay
|
||||
@close="onClose"
|
||||
@select="onSelect"
|
||||
round="24"
|
||||
:actions="joinGroupActions"
|
||||
:show="visible"
|
||||
cancelText="取消"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import IMSDK, { GroupVerificationType } from "openim-uniapp-polyfill";
|
||||
export default {
|
||||
name: "",
|
||||
components: {},
|
||||
props: {
|
||||
visible: Boolean,
|
||||
groupID: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
joinGroupActions: [
|
||||
{
|
||||
name: "允许任何人加群",
|
||||
type: GroupVerificationType.AllNot,
|
||||
},
|
||||
{
|
||||
name: "群成员邀请无需验证",
|
||||
type: GroupVerificationType.ApplyNeedInviteNot,
|
||||
},
|
||||
{
|
||||
name: "需要发送验证消息",
|
||||
type: GroupVerificationType.AllNeed,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onClose() {
|
||||
this.$emit("update:visible", false);
|
||||
},
|
||||
onSelect({ type }) {
|
||||
IMSDK.asyncApi(IMSDK.IMMethods.SetGroupVerification, IMSDK.uuid(), {
|
||||
groupID: this.groupID,
|
||||
verification: type,
|
||||
})
|
||||
.then(() => uni.$u.toast("操作成功"))
|
||||
.catch(() => uni.$u.toast("操作失败"));
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss"></style>
|
||||
171
pages/conversation/groupSettings/components/GroupMemberRow.vue
Normal file
171
pages/conversation/groupSettings/components/GroupMemberRow.vue
Normal file
@@ -0,0 +1,171 @@
|
||||
<template>
|
||||
<view @click="toMemberList" class="member_row">
|
||||
<!-- <view class="member_title">
|
||||
<text>群成员</text>
|
||||
<view class="member_desc">
|
||||
<text>{{ `${memberCount}人` }}</text>
|
||||
<u-icon name="arrow-right" color="#999" size="16" />
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="member_list">
|
||||
<view class="member_item" v-for="(member, index) in groupMemberList">
|
||||
<my-avatar
|
||||
:src="member.faceURL"
|
||||
:desc="member.nickname"
|
||||
:key="member.userID"
|
||||
size="48"
|
||||
/>
|
||||
<view class="ower" v-if="member.roleLevel === 100">群主</view>
|
||||
<text class="member_item_name">{{ member.nickname }}</text>
|
||||
</view>
|
||||
<view class="member_item">
|
||||
<image
|
||||
style="width: 48px; height: 48px; min-width: 48px"
|
||||
@click.stop="inviteMember"
|
||||
src="@/static/images/group_setting_invite.png"
|
||||
alt=""
|
||||
/>
|
||||
<text class="member_item_name">增加</text>
|
||||
</view>
|
||||
<view class="member_item" v-if="isAdmin || isOwner">
|
||||
<image
|
||||
style="width: 48px; height: 48px; min-width: 48px"
|
||||
@click.stop="kickMember"
|
||||
src="@/static/images/group_setting_remove.png"
|
||||
alt=""
|
||||
/>
|
||||
<text class="member_item_name">移出</text>
|
||||
</view>
|
||||
</view>
|
||||
<view @click="toMemberList" class="more">
|
||||
<text>查看全部群成员({{ memberCount }})</text>
|
||||
<view class="more_right">
|
||||
<u-icon name="arrow-right" color="#999" size="18" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from "vuex";
|
||||
import IMSDK, { GroupMemberRole } from "openim-uniapp-polyfill";
|
||||
import MyAvatar from "@/components/MyAvatar/index.vue";
|
||||
import SettingItem from "@/components/SettingItem/index.vue";
|
||||
import { ContactChooseTypes, GroupMemberListTypes } from "@/constant";
|
||||
export default {
|
||||
name: "",
|
||||
components: {
|
||||
MyAvatar,
|
||||
SettingItem,
|
||||
},
|
||||
props: {
|
||||
isNomal: Boolean,
|
||||
memberCount: Number,
|
||||
groupID: String,
|
||||
groupMemberList: Array,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
"storeCurrentConversation",
|
||||
"storeCurrentMemberInGroup",
|
||||
"storeCurrentGroup",
|
||||
]),
|
||||
isOwner() {
|
||||
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Owner;
|
||||
},
|
||||
isAdmin() {
|
||||
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Admin;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
toMemberList() {
|
||||
uni.navigateTo({
|
||||
url: `/pages/conversation/groupMemberList/index?type=${GroupMemberListTypes.Preview}&groupID=${this.groupID}`,
|
||||
});
|
||||
},
|
||||
inviteMember() {
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/contactChoose/index?type=${ContactChooseTypes.Invite}&groupID=${this.groupID}`,
|
||||
});
|
||||
},
|
||||
kickMember() {
|
||||
uni.navigateTo({
|
||||
url: `/pages/conversation/groupMemberList/index?type=${GroupMemberListTypes.Kickout}&groupID=${this.groupID}`,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.member_row {
|
||||
@include colBox(false);
|
||||
padding: 36rpx 36rpx 0;
|
||||
margin: 24rpx;
|
||||
background-color: #fff;
|
||||
color: $uni-text-color;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
|
||||
.member_title {
|
||||
@include btwBox();
|
||||
|
||||
.member_desc {
|
||||
@include vCenterBox();
|
||||
font-size: 26rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.member_list {
|
||||
@include vCenterBox();
|
||||
flex-wrap: wrap;
|
||||
|
||||
.member_item {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 8rpx 14rpx;
|
||||
|
||||
&_name {
|
||||
margin-top: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: #8e9ab0;
|
||||
max-width: 48px;
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ower{
|
||||
width: 48px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
bottom: 34rpx;
|
||||
font-size: 24rpx;
|
||||
position: absolute;
|
||||
color: #0089FF;
|
||||
background: #E8EAEF;
|
||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||
}
|
||||
|
||||
.more {
|
||||
@include btwBox();
|
||||
margin-top: 20rpx;
|
||||
padding: 20rpx 0rpx 20rpx;
|
||||
border-top: 1px solid rgba(153, 153, 153, 0.2);
|
||||
|
||||
.more_right {
|
||||
@include vCenterBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
361
pages/conversation/groupSettings/index.vue
Normal file
361
pages/conversation/groupSettings/index.vue
Normal file
@@ -0,0 +1,361 @@
|
||||
<template>
|
||||
<view class="group_settings_container">
|
||||
<custom-nav-bar title="群聊设置" />
|
||||
<view class="group_settings_content">
|
||||
<view class="setting_row info_row">
|
||||
<view class="group_avatar" @click="updateGroupAvatar">
|
||||
<my-avatar
|
||||
:src="storeCurrentConversation.faceURL"
|
||||
:isGroup="true"
|
||||
size="46"
|
||||
/>
|
||||
<image
|
||||
v-if="isOwner"
|
||||
class="edit_icon"
|
||||
src="@/static/images/group_setting_edit.png"
|
||||
alt=""
|
||||
/>
|
||||
</view>
|
||||
<view class="group_info">
|
||||
<view class="group_info_name">
|
||||
<text class="group_name"
|
||||
>{{ storeCurrentConversation.showName }}({{
|
||||
storeCurrentGroup.memberCount
|
||||
}})</text
|
||||
>
|
||||
<image
|
||||
v-if="isOwner || isAdmin"
|
||||
@click="toUpdateGroupName"
|
||||
style="width: 24rpx; height: 24rpx"
|
||||
src="@/static/images/group_edit.png"
|
||||
alt=""
|
||||
/>
|
||||
</view>
|
||||
|
||||
<text @click="copyGroupID" class="sub_title">{{
|
||||
storeCurrentConversation.groupID
|
||||
}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<group-member-row
|
||||
v-if="isJoinGroup"
|
||||
:isNomal="!isAdmin && !isOwner"
|
||||
:groupID="storeCurrentConversation.groupID"
|
||||
:memberCount="storeCurrentGroup.memberCount"
|
||||
:groupMemberList="groupMemberList"
|
||||
/>
|
||||
<view v-if="isJoinGroup" class="setting_row">
|
||||
<setting-item
|
||||
v-if="isOwner || isAdmin"
|
||||
@click="toGroupManage"
|
||||
title="群管理"
|
||||
:border="false"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="setting_row">
|
||||
<setting-item
|
||||
v-if="isJoinGroup"
|
||||
danger
|
||||
@click="() => (confirmType = isOwner ? 'Dismiss' : 'Quit')"
|
||||
:title="isOwner ? '解散群聊' : '退出群聊'"
|
||||
:border="false"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<u-modal
|
||||
:content="getConfirmContent"
|
||||
asyncClose
|
||||
:show="confirmType !== null"
|
||||
showCancelButton
|
||||
@confirm="confirm"
|
||||
@cancel="() => (confirmType = null)"
|
||||
></u-modal>
|
||||
</view>
|
||||
|
||||
<u-toast ref="uToast"></u-toast>
|
||||
<action-sheet
|
||||
:groupID="storeCurrentConversation.groupID"
|
||||
:visible.sync="actionSheetVisible"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from "vuex";
|
||||
import { GroupMemberListTypes } from "@/constant";
|
||||
import IMSDK, {
|
||||
GroupMemberRole,
|
||||
GroupStatus,
|
||||
GroupVerificationType,
|
||||
IMMethods,
|
||||
MessageReceiveOptType,
|
||||
} from "openim-uniapp-polyfill";
|
||||
import CustomNavBar from "@/components/CustomNavBar/index.vue";
|
||||
import MyAvatar from "@/components/MyAvatar/index.vue";
|
||||
import SettingItem from "@/components/SettingItem/index.vue";
|
||||
import GroupMemberRow from "./components/GroupMemberRow.vue";
|
||||
import ActionSheet from "./components/ActionSheet.vue";
|
||||
import { getPurePath } from "@/util/common";
|
||||
|
||||
const ConfirmTypes = {
|
||||
Dismiss: "Dismiss",
|
||||
Quit: "Quit",
|
||||
};
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CustomNavBar,
|
||||
MyAvatar,
|
||||
SettingItem,
|
||||
GroupMemberRow,
|
||||
ActionSheet,
|
||||
},
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
actionSheetVisible: false,
|
||||
confirmType: null,
|
||||
switchLoading: {
|
||||
pin: false,
|
||||
opt: false,
|
||||
mute: false,
|
||||
},
|
||||
groupMemberList: [],
|
||||
isJoinGroup: true
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
this.getGroupMemberList();
|
||||
if (this.storeCurrentConversation.groupID) {
|
||||
IMSDK.asyncApi(
|
||||
IMMethods.IsJoinGroup,
|
||||
IMSDK.uuid(),
|
||||
this.storeCurrentConversation.groupID
|
||||
).then((res) => {
|
||||
this.isJoinGroup = res.data
|
||||
});
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"storeCurrentGroup.memberCount"() {
|
||||
this.getGroupMemberList();
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
"storeCurrentConversation",
|
||||
"storeCurrentMemberInGroup",
|
||||
"storeCurrentGroup",
|
||||
]),
|
||||
getConfirmContent() {
|
||||
if (this.confirmType === ConfirmTypes.Quit) {
|
||||
return "确定要退出当前群聊吗?";
|
||||
}
|
||||
if (this.confirmType === ConfirmTypes.Dismiss) {
|
||||
return "确定要解散当前群聊吗?";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
isOwner() {
|
||||
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Owner;
|
||||
},
|
||||
isAdmin() {
|
||||
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Admin;
|
||||
},
|
||||
getGroupVerStr() {
|
||||
if (
|
||||
this.storeCurrentGroup.needVerification ===
|
||||
GroupVerificationType.ApplyNeedInviteNot
|
||||
) {
|
||||
return "群成员邀请无需验证";
|
||||
}
|
||||
if (
|
||||
this.storeCurrentGroup.needVerification === GroupVerificationType.AllNot
|
||||
) {
|
||||
return "允许所有人加群";
|
||||
}
|
||||
return "需要发送验证消息";
|
||||
},
|
||||
isAllMuted() {
|
||||
return this.storeCurrentGroup.status === GroupStatus.Muted;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getGroupMemberList() {
|
||||
IMSDK.asyncApi(IMSDK.IMMethods.GetGroupMemberList, IMSDK.uuid(), {
|
||||
groupID: this.storeCurrentConversation.groupID,
|
||||
filter: 0,
|
||||
offset: 0,
|
||||
count: !this.isAdmin && !this.isOwner ? 9 : 8,
|
||||
})
|
||||
.then(({ data }) => {
|
||||
console.log(data);
|
||||
this.groupMemberList = [...data];
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
},
|
||||
toGroupManage() {
|
||||
uni.navigateTo({
|
||||
url: "/pages/conversation/groupManage/index",
|
||||
});
|
||||
},
|
||||
toUpdateGroupName() {
|
||||
if (!this.isAdmin && !this.isOwner) {
|
||||
return;
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url: `/pages/conversation/updateGroupOrNickname/index?sourceInfo=${JSON.stringify(
|
||||
this.storeCurrentGroup,
|
||||
)}`,
|
||||
});
|
||||
},
|
||||
copyGroupID() {
|
||||
uni.setClipboardData({
|
||||
data: this.storeCurrentGroup.groupID,
|
||||
success: () => {
|
||||
uni.hideToast();
|
||||
this.$nextTick(() => {
|
||||
uni.$u.toast("复制成功");
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
showActionSheet() {
|
||||
if (!this.isAdmin && !this.isOwner) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.actionSheetVisible = true;
|
||||
},
|
||||
updateGroupAvatar() {
|
||||
if (!this.isAdmin && !this.isOwner) {
|
||||
return;
|
||||
}
|
||||
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ["compressed"],
|
||||
success: async ({ tempFilePaths }) => {
|
||||
const path = tempFilePaths[0];
|
||||
const nameIdx = path.lastIndexOf("/") + 1;
|
||||
const typeIdx = path.lastIndexOf(".") + 1;
|
||||
const fileName = path.slice(nameIdx);
|
||||
const fileType = path.slice(typeIdx);
|
||||
try {
|
||||
const {
|
||||
data: { url },
|
||||
} = await IMSDK.asyncApi(IMMethods.UploadFile, IMSDK.uuid(), {
|
||||
filepath: getPurePath(tempFilePaths[0]),
|
||||
name: fileName,
|
||||
contentType: fileType,
|
||||
uuid: IMSDK.uuid(),
|
||||
});
|
||||
await IMSDK.asyncApi(IMSDK.IMMethods.SetGroupInfo, IMSDK.uuid(), {
|
||||
groupID: this.storeCurrentConversation.groupID,
|
||||
faceURL: url,
|
||||
});
|
||||
uni.$u.toast("修改成功");
|
||||
} catch (error) {
|
||||
uni.$u.toast("修改失败");
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
confirm() {
|
||||
let funcName = "";
|
||||
let sourceID = this.storeCurrentConversation.groupID;
|
||||
if (this.confirmType === ConfirmTypes.Quit) {
|
||||
funcName = IMSDK.IMMethods.QuitGroup;
|
||||
}
|
||||
if (this.confirmType === ConfirmTypes.Dismiss) {
|
||||
funcName = IMSDK.IMMethods.DismissGroup;
|
||||
}
|
||||
IMSDK.asyncApi(funcName, IMSDK.uuid(), sourceID)
|
||||
.then(() => {
|
||||
uni.$u.toast("操作成功");
|
||||
setTimeout(
|
||||
() =>
|
||||
uni.switchTab({
|
||||
url: "/pages/conversation/conversationList/index",
|
||||
}),
|
||||
250,
|
||||
);
|
||||
})
|
||||
.catch(() => uni.$u.toast("操作失败"))
|
||||
.finally(() => (this.confirmType = null));
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.group_settings_container {
|
||||
@include colBox(false);
|
||||
height: 100vh;
|
||||
background-color: #f6f6f6;
|
||||
|
||||
.group_settings_content {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.setting_row {
|
||||
background-color: #fff;
|
||||
margin: 24rpx;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.info_row {
|
||||
@include vCenterBox();
|
||||
padding: 36rpx 44rpx;
|
||||
|
||||
.group_avatar {
|
||||
margin-right: 16rpx;
|
||||
position: relative;
|
||||
|
||||
.edit_icon {
|
||||
position: absolute;
|
||||
right: -6rpx;
|
||||
bottom: -6rpx;
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
.group_info {
|
||||
min-height: 46px;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
|
||||
&_name {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.group_name {
|
||||
// @include nomalEllipsis();
|
||||
font-size: 34rpx;
|
||||
max-width: 380rpx;
|
||||
margin-right: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.sub_title {
|
||||
@include nomalEllipsis();
|
||||
margin-bottom: 0;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user