index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="page_container">
  3. <custom-nav-bar title="群成员权限" />
  4. <view class="setting_row">
  5. <setting-item
  6. title="不允许查看群成员资料"
  7. :loading="switchLoading.look"
  8. @switch="changeLook"
  9. :switchValue="!canLookOther"
  10. :is_switch="true"
  11. />
  12. <setting-item
  13. title="不允许添加群成员为好友"
  14. :loading="switchLoading.add"
  15. @switch="changeAdd"
  16. :switchValue="!canAddOther"
  17. :is_switch="true"
  18. />
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import IMSDK, { AllowType } from "openim-uniapp-polyfill";
  24. import CustomNavBar from "../../../components/CustomNavBar/index.vue";
  25. import SettingItem from "../../../components/SettingItem/index.vue";
  26. export default {
  27. components: {
  28. CustomNavBar,
  29. SettingItem,
  30. },
  31. data() {
  32. return {
  33. switchLoading: {
  34. look: false,
  35. add: false,
  36. },
  37. };
  38. },
  39. computed: {
  40. canLookOther() {
  41. return (
  42. this.$store.getters.storeCurrentGroup.lookMemberInfo ===
  43. AllowType.Allowed
  44. );
  45. },
  46. canAddOther() {
  47. return (
  48. this.$store.getters.storeCurrentGroup.applyMemberFriend ===
  49. AllowType.Allowed
  50. );
  51. },
  52. },
  53. methods: {
  54. changeLook(flag) {
  55. this.switchLoading.look = true;
  56. IMSDK.asyncApi(IMSDK.IMMethods.SetGroupLookMemberInfo, IMSDK.uuid(), {
  57. groupID: this.$store.getters.storeCurrentGroup.groupID,
  58. rule: flag ? AllowType.NotAllowed : AllowType.Allowed,
  59. })
  60. .catch(() => uni.$u.toast("设置失败"))
  61. .finally(() => (this.switchLoading.look = false));
  62. },
  63. changeAdd(flag) {
  64. this.switchLoading.add = true;
  65. IMSDK.asyncApi(IMSDK.IMMethods.SetGroupApplyMemberFriend, IMSDK.uuid(), {
  66. groupID: this.$store.getters.storeCurrentGroup.groupID,
  67. rule: flag ? AllowType.NotAllowed : AllowType.Allowed,
  68. })
  69. .catch(() => uni.$u.toast("设置失败"))
  70. .finally(() => (this.switchLoading.add = false));
  71. },
  72. },
  73. };
  74. </script>
  75. <style lang="scss">
  76. .page_container {
  77. background-color: #f8f8f8;
  78. .setting_row {
  79. background-color: #fff;
  80. margin: 24rpx 0;
  81. }
  82. }
  83. </style>