chooseCallee.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view class="callee-selector">
  3. <view class="callee-selector-header">
  4. <view class="close" @click="goBack()">取消</view>
  5. <text>选择成员</text>
  6. <view class="confirm" @click="groupCall()">确定</view>
  7. </view>
  8. <view class="callee-avatar">
  9. <view class="avatar-list">
  10. <image class="avatar-item" :src="currentUser.avatar"></image>
  11. <image class="avatar-item" v-for="(callee, index) in callees" :key="index" :src="callee.avatar"></image>
  12. </view>
  13. </view>
  14. <checkbox-group @change="selectCallees" class="member-list">
  15. <view v-for="(member, index) in groupMembers" :key="index" class="member-item">
  16. <image class="member-avatar" :src="member.avatar"></image>
  17. <view class="member-name">{{member.name}}</view>
  18. <checkbox class="member-check" :value="member.id" :checked="callees.includes(member)"/>
  19. </view>
  20. </checkbox-group>
  21. </view>
  22. </template>
  23. <script>
  24. import restApi from '../../../lib/restapi';
  25. const GRTC = uni.$GRTC;
  26. export default {
  27. data() {
  28. return {
  29. groupId: null,
  30. currentUser: null,
  31. groupMembers: null,
  32. callees: []
  33. }
  34. },
  35. onLoad(options) {
  36. this.mediaType = Number(options.mediaType);
  37. this.groupId = options.groupId;
  38. this.currentUser = uni.$currentUser;
  39. this.groupMembers = restApi.findGroupMembers(this.groupId);
  40. this.groupMembers = this.groupMembers.filter(user => user.id !== this.currentUser.id)
  41. },
  42. methods: {
  43. selectCallees(e) {
  44. const selectedCalleeIds = e.detail.value;
  45. this.callees = this.groupMembers.filter(member => selectedCalleeIds.includes(member.id));
  46. },
  47. goBack () {
  48. uni.navigateBack();
  49. },
  50. groupCall() {
  51. const calleeIds = this.callees.map((user) => user.id);
  52. if(calleeIds.length < 1) {
  53. uni.showToast({
  54. icon: "error",
  55. title: "请先选择成员!",
  56. duration: 2000
  57. })
  58. return;
  59. }
  60. const notificationBody = this.mediaType === 0 ? '邀请你加入多人视频':'邀请你加入多人通话';
  61. GRTC.groupCall({
  62. groupId: this.groupId,
  63. calleeIds: calleeIds,
  64. mediaType: this.mediaType,
  65. notification: {
  66. title: this.currentUser.name,
  67. body: notificationBody,
  68. sound: 'ring',
  69. badge: '+1'
  70. },
  71. }).then(() => {
  72. uni.redirectTo({
  73. url: `./dial`,
  74. })
  75. }).catch((error)=>{
  76. console.log("error:",error)
  77. uni.showToast({
  78. icon: "error",
  79. title: "呼叫失败:" + error,
  80. duration: 2000
  81. })
  82. })
  83. }
  84. }
  85. }
  86. </script>
  87. <style>
  88. .callee-selector {
  89. width: 100%;
  90. height: 100%;
  91. display: flex;
  92. flex-direction: column;
  93. background-color: #29282B;
  94. }
  95. .callee-selector-header {
  96. padding: 100rpx 40rpx;
  97. display: flex;
  98. flex-direction: row;
  99. justify-content: space-between;
  100. align-items: center;
  101. color: #ffffff;
  102. }
  103. .callee-selector-header .confirm {
  104. width: 110rpx;
  105. height: 60rpx;
  106. border-radius: 10rpx;
  107. background: #D02129;
  108. text-align: center;
  109. line-height: 60rpx;
  110. display: flex;
  111. flex-direction: row;
  112. justify-content: center;
  113. }
  114. .callee-avatar {
  115. padding: 20rpx;
  116. display: flex;
  117. justify-content: center;
  118. }
  119. .avatar-list {
  120. display: flex;
  121. overflow: scroll;
  122. flex-wrap: nowrap;
  123. }
  124. .avatar-item {
  125. flex-basis: 120rpx;
  126. flex-shrink: 0;
  127. width: 120rpx;
  128. height: 120rpx;
  129. border-radius: 10rpx;
  130. background-color: #4D4D4D;
  131. margin: 0 10rpx;
  132. }
  133. .member-list {
  134. flex: 1;
  135. display: flex;
  136. flex-direction: column;
  137. }
  138. .member-item {
  139. display: flex;
  140. align-items: center;
  141. border-bottom: 2rpx solid #393538;
  142. padding: 20rpx 40rpx;
  143. }
  144. .member-check {
  145. height: 80rpx;
  146. display: flex;
  147. align-items: center;
  148. }
  149. uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
  150. border-color: #d1d1d1 !important;
  151. }
  152. uni-checkbox .uni-checkbox-input {
  153. border-radius: 50% !important;
  154. }
  155. uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked {
  156. color: #D02129;
  157. }
  158. uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked::before {
  159. color: #D02129;
  160. }
  161. .member-avatar {
  162. width: 80rpx;
  163. height: 80rpx;
  164. border-radius: 10rpx;
  165. background-color: #4D4D4D;
  166. }
  167. .member-name {
  168. flex: 1;
  169. margin-left: 20rpx;
  170. color: #D0D2D4;
  171. font-size: 30rpx
  172. }
  173. </style>