create.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view>
  3. <view class="container">
  4. <view class="item" @tap.stop="showtype">
  5. <view class="group-type">
  6. <view class="icon-box">
  7. <text class="icon">*</text>
  8. <text class="aside-left">群类型</text>
  9. <text class="aside-right" @tap="popupToggle = true">{{ groupType }}</text>
  10. </view>
  11. <image class=" listimage" src="/static/static/assets/detail.svg"></image>
  12. </view>
  13. </view>
  14. <view class="item">
  15. <view class="group-ID">
  16. <text class="aside-left">群ID</text>
  17. <input class="input" type="number" placeholder="请输入群ID" @input="bindgroupIDInput" placeholder-style="color:#BBBBBB;" />
  18. </view>
  19. </view>
  20. <view class="item">
  21. <view class="group-name">
  22. <view class="icon-box">
  23. <text class="icon">*</text>
  24. <text class="aside-left">群名称</text>
  25. </view>
  26. <input class="inputname" placeholder="请输入群名称" @input="bindgroupnameInput" placeholder-style="color:#BBBBBB;" />
  27. </view>
  28. </view>
  29. <view class="group-create" @tap="bindConfirmCreate">发起群聊</view>
  30. </view>
  31. <view class="pop-mask" v-if="popupToggle" @tap.stop="handleChooseToggle">
  32. <view class="popup-main" @tap.stop="handleCatchTap">
  33. <view
  34. v-for="(item, index) in groupTypeList"
  35. :key="index"
  36. :class="'type ' + (item.groupType === groupType && 'type-active')"
  37. :data-value="item"
  38. @tap="selectType"
  39. >
  40. <view class="group-type-list" :data-item="item">
  41. <view class="list-type">
  42. <view>{{ item.groupType }}</view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. // miniprogram/pages/TUI-Group/create-group/create.js
  52. import logger from '../../../utils/logger';
  53. export default {
  54. data() {
  55. return {
  56. groupTypeList: [
  57. {
  58. groupType: '品牌客户群(Work)',
  59. Type: uni.$TUIKitTIM.TYPES.GRP_WORK
  60. },
  61. {
  62. groupType: 'VIP专属群(Public)',
  63. Type: uni.$TUIKitTIM.TYPES.GRP_PUBLIC
  64. },
  65. {
  66. groupType: '临时会议群 (Meeting)',
  67. Type: uni.$TUIKitTIM.TYPES.GRP_MEETING
  68. },
  69. {
  70. groupType: '直播群(AVChatRoom)',
  71. Type: uni.$TUIKitTIM.TYPES.GRP_AVCHATROOM
  72. }
  73. ],
  74. groupType: '',
  75. Type: '',
  76. name: '',
  77. groupID: '',
  78. popupToggle: false
  79. };
  80. },
  81. components: {},
  82. props: {},
  83. methods: {
  84. showtype() {
  85. this.setData({
  86. popupToggle: true
  87. });
  88. },
  89. bindgroupIDInput(e) {
  90. const id = e.detail.value;
  91. this.setData({
  92. groupID: id
  93. });
  94. },
  95. bindgroupnameInput(e) {
  96. const groupname = e.detail.value;
  97. this.setData({
  98. name: groupname
  99. });
  100. },
  101. selectType(e) {
  102. console.error(e.currentTarget.dataset.value, 'lll');
  103. this.setData({
  104. groupType: e.currentTarget.dataset.value.groupType,
  105. Type: e.currentTarget.dataset.value.Type,
  106. name: e.currentTarget.dataset.value.name,
  107. popupToggle: false
  108. });
  109. },
  110. bindConfirmCreate() {
  111. logger.log(`TUI-Group | create-group | bindConfirmCreate | groupID: ${this.groupID}`);
  112. const promise = uni.$TUIKit.createGroup({
  113. type: this.Type,
  114. name: this.name,
  115. groupID: this.groupID
  116. });
  117. promise
  118. .then(imResponse => {
  119. // 创建成功
  120. // 创建的群的资料
  121. const { groupID } = imResponse.data.group;
  122. uni.navigateTo({
  123. url: `../../TUI-Chat/chat?conversationID=GROUP${groupID}`
  124. });
  125. })
  126. .catch(() => {
  127. uni.showToast({
  128. title: '该群组ID被使用,请更换群ID',
  129. icon: 'none'
  130. });
  131. });
  132. },
  133. handleChooseToggle() {
  134. this.setData({
  135. popupToggle: false
  136. });
  137. },
  138. handleCatchTap() {
  139. console.log('占位:函数 handleCatchTap 未声明');
  140. }
  141. }
  142. };
  143. </script>
  144. <style>
  145. @import './create.css';
  146. </style>