index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="group_settings_container">
  3. <custom-nav-bar title="群管理" />
  4. <view class="setting_row">
  5. <setting-item
  6. v-if="isOwner || isAdmin"
  7. title="全体禁言"
  8. :loading="switchLoading.mute"
  9. @switch="changeMute"
  10. :switchValue="isAllMuted"
  11. :is_switch="true"
  12. :border="false"
  13. />
  14. </view>
  15. <view class="setting_row">
  16. <setting-item @click="showActionSheet" title="进群验证" :border="false">
  17. <text class="sub_title">{{ getGroupVerStr() }}</text>
  18. </setting-item>
  19. <setting-item title="不允许查看群成员资料" :loading="switchLoading.look" @switch="changeLook" :switchValue="!canLookOther" :is_switch="true" :border="false" />
  20. <setting-item title="不允许添加群成员为好友" :loading="switchLoading.add" @switch="changeAdd" :switchValue="!canAddOther" :is_switch="true" :border="false" />
  21. </view>
  22. <view class="setting_row">
  23. <setting-item v-if="isOwner" @click="toTransfer" title="群主管理权转让" :border="false" />
  24. </view>
  25. <action-sheet :groupID="storeCurrentConversation.groupID" :visible.sync="actionSheetVisible" />
  26. </view>
  27. </template>
  28. <script>
  29. import { mapGetters } from 'vuex';
  30. import { GroupMemberListTypes } from '../../../constant';
  31. import IMSDK, { IMMethods } from 'openim-uniapp-polyfill';
  32. import { GroupMemberRole, GroupStatus, GroupVerificationType, MessageReceiveOptType, AllowType } from '@/pages_im/constant/imConstants';
  33. import CustomNavBar from '../../../components/CustomNavBar/index.vue';
  34. import SettingItem from '../../../components/SettingItem/index.vue';
  35. import ActionSheet from './components/ActionSheet.vue';
  36. export default {
  37. components: {
  38. CustomNavBar,
  39. SettingItem,
  40. ActionSheet
  41. },
  42. data() {
  43. return {
  44. actionSheetVisible: false,
  45. confirmType: null,
  46. switchLoading: {
  47. pin: false,
  48. opt: false,
  49. mute: false,
  50. look: false,
  51. add: false
  52. }
  53. };
  54. },
  55. computed: {
  56. ...mapGetters(['storeCurrentConversation', 'storeCurrentMemberInGroup', 'storeCurrentGroup']),
  57. isOwner() {
  58. return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Owner;
  59. },
  60. isAdmin() {
  61. return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Admin;
  62. },
  63. isAllMuted() {
  64. return this.storeCurrentGroup.status === GroupStatus.Muted;
  65. },
  66. canLookOther() {
  67. return this.$store.getters.storeCurrentGroup.lookMemberInfo === AllowType.Allowed;
  68. },
  69. canAddOther() {
  70. return this.$store.getters.storeCurrentGroup.applyMemberFriend === AllowType.Allowed;
  71. }
  72. },
  73. methods: {
  74. changeLook(flag) {
  75. this.switchLoading.look = true;
  76. IMSDK.asyncApi(IMSDK.IMMethods.SetGroupLookMemberInfo, IMSDK.uuid(), {
  77. groupID: this.$store.getters.storeCurrentGroup.groupID,
  78. rule: flag ? AllowType.NotAllowed : AllowType.Allowed
  79. })
  80. .catch(() => uni.$u.toast('设置失败'))
  81. .finally(() => (this.switchLoading.look = false));
  82. },
  83. changeAdd(flag) {
  84. this.switchLoading.add = true;
  85. IMSDK.asyncApi(IMSDK.IMMethods.SetGroupApplyMemberFriend, IMSDK.uuid(), {
  86. groupID: this.$store.getters.storeCurrentGroup.groupID,
  87. rule: flag ? AllowType.NotAllowed : AllowType.Allowed
  88. })
  89. .catch(() => uni.$u.toast('设置失败'))
  90. .finally(() => (this.switchLoading.add = false));
  91. },
  92. changeMute(isMute) {
  93. this.switchLoading.mute = true;
  94. IMSDK.asyncApi(IMSDK.IMMethods.ChangeGroupMute, IMSDK.uuid(), {
  95. groupID: this.storeCurrentGroup.groupID,
  96. isMute
  97. })
  98. .then(() => uni.$u.toast('禁言成功'))
  99. .catch(() => uni.$u.toast('禁言失败'))
  100. .finally(() => (this.switchLoading.mute = false));
  101. },
  102. getGroupVerStr() {
  103. if (this.storeCurrentGroup.needVerification === GroupVerificationType.ApplyNeedInviteNot) {
  104. return '群成员邀请无需验证';
  105. }
  106. if (this.storeCurrentGroup.needVerification === GroupVerificationType.AllNot) {
  107. return '允许所有人加群';
  108. }
  109. return '需要发送验证消息';
  110. },
  111. toTransfer() {
  112. uni.navigateTo({
  113. url: `/pages_im/pages/conversation/groupMemberList/index?type=${GroupMemberListTypes.Transfer}&groupID=${this.storeCurrentGroup.groupID}`
  114. });
  115. },
  116. showActionSheet() {
  117. if (!this.isAdmin && !this.isOwner) {
  118. return;
  119. }
  120. this.actionSheetVisible = true;
  121. }
  122. }
  123. };
  124. </script>
  125. <style lang="scss" scoped>
  126. .group_settings_container {
  127. @include colBox(false);
  128. height: 100vh;
  129. background-color: #f6f6f6;
  130. .setting_row {
  131. background-color: #fff;
  132. margin: 24rpx 24rpx 0;
  133. border-radius: 6px;
  134. overflow: hidden;
  135. }
  136. }
  137. </style>