transference.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <page-meta :page-font-size="fontValue+'px'" :root-font-size="fontValue+'px'"></page-meta>
  3. <view>
  4. <cu-custom bgImage="/static/bg.png" :isBack="true">
  5. <template v-slot:content>
  6. <text class="text-black">转让群</text>
  7. </template>
  8. </cu-custom>
  9. <index-bar :indexMap="map">
  10. <radio-group class="block" @change="radioChange">
  11. <view v-for="(item,key) in map.keys()" :key="key" :class="'indexItem-' + item" :id="'indexes-' + item"
  12. :data-index="item">
  13. <view class="padding">{{ item }}</view>
  14. <view class="cu-list menu-avatar no-padding">
  15. <view class="cu-item" v-for="(user,sub) in map.get(item)" :key="sub">
  16. <radio class="checkbox" :value="user.id" />
  17. <image class="cu-avatar radius lg" :src="user.avatar"></image>
  18. <view class="content">
  19. <view class="text-black text-bold">{{ user.name }}</view>
  20. <view class="text-black text-sm">
  21. {{ user.name }}
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view style="height: 140rpx;"></view>
  28. </radio-group>
  29. </index-bar>
  30. <view class="cu-form-group margin-top text-center" style="bottom: 0.5rem;position: fixed;width: 100%;">
  31. <button class="cu-btn bg-cyan lg margin-top" style="width: 100%;margin-bottom: 30rpx;" @tap="transference">确认转让</button>
  32. </view>
  33. </view>
  34. </template>
  35. <script setup lang="ts">
  36. import {getCurrentInstance, ref} from "vue";
  37. import FriendApi from "@/api/FriendApi";
  38. import Tools from "@/utils/Tools";
  39. import CuCustom from '@/colorui/components/cu-custom.vue'
  40. import GroupApi from "@/api/GroupApi";
  41. import MessageUtils from "@/utils/MessageUtils";
  42. import {onLoad} from '@dcloudio/uni-app';
  43. import type User from "@/mode/User";
  44. import IndexBar from '@/components/IndexBar.vue'
  45. import ChatType from "@/utils/ChatType";
  46. import MessageType from "@/utils/MessageType";
  47. import SendCode from "@/utils/SendCode";
  48. import {useWsStore} from "@/store/WsStore";
  49. import {useUserStore} from "@/store/userStore";
  50. import VimAvatar from "@/components/VimAvatar.vue";
  51. import Auth from "@/api/Auth";
  52. const fontValue=ref(Auth.getfontSize());
  53. //@ts-ignore
  54. const {proxy} = getCurrentInstance();
  55. const userStore = useUserStore();
  56. const map = ref(new Map());
  57. //群id
  58. const groupId = ref('');
  59. //群主
  60. const master = ref('');
  61. //选中的用户id
  62. const id = ref<string>();
  63. const user = userStore.getUser()
  64. const radioChange = (e: any) => {
  65. id.value = e.detail.value;
  66. }
  67. onLoad((opt) => {
  68. groupId.value = opt?.id;
  69. if (groupId.value) {
  70. GroupApi.get(groupId.value)
  71. .then((res) => {
  72. master.value = res.data.master;
  73. return GroupApi.users(groupId.value)
  74. })
  75. .then((res) => {
  76. const list = res.data.filter((item: User) => item.id !== master.value);
  77. map.value = Tools.listToMap(list);
  78. })
  79. }
  80. })
  81. /**
  82. * 转让群
  83. */
  84. const transference = () => {
  85. if (id.value) {
  86. GroupApi.transference(groupId.value,id.value).then(() => {
  87. uni.navigateBack()
  88. })
  89. }
  90. }
  91. /**
  92. * 通知群主
  93. * @param masterId 群主id
  94. * @param fromId 发送人
  95. */
  96. const notifyMaster = (masterId: string, fromId: string) => {
  97. if (masterId) {
  98. const sendInfo = {
  99. code: SendCode.GROUP_VALIDATE,
  100. message: {
  101. mine: true,
  102. fromId: fromId,
  103. chatId: masterId,
  104. type: ChatType.FRIEND,
  105. messageType: MessageType.text,
  106. content: '',
  107. timestamp: new Date().getTime()
  108. }
  109. }
  110. useWsStore().send(JSON.stringify(sendInfo))
  111. }
  112. }
  113. </script>
  114. <style scoped>
  115. .cu-list.menu-avatar > .cu-item > .cu-avatar {
  116. left: 3.9375rem;
  117. }
  118. .cu-list.menu-avatar > .cu-item .content {
  119. left: 7.5625rem;
  120. }
  121. .cu-list.menu-avatar > .cu-item .checkbox {
  122. left: 1rem;
  123. position: absolute;
  124. }
  125. </style>