index.vue 5.0 KB

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