index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="page_container">
  3. <custom-nav-bar :title="isUpdate ? '修改会议信息' : '预约会议'" />
  4. <view class="field_row field_row_input">
  5. <u--input placeholder="请输入会议主题" border="none" v-model="meetingData.meetingName"></u--input>
  6. </view>
  7. <view class="field_row" @click="showDatePicker = true">
  8. <view>开始时间</view>
  9. <view class="right_value">{{ showDate }}</view>
  10. <u-icon name="arrow-right" />
  11. </view>
  12. <view class="field_row" @click="showDurationPicker = true">
  13. <view>会议时长</view>
  14. <view class="right_value">{{ showDuration }}</view>
  15. <u-icon name="arrow-right" />
  16. </view>
  17. <view class="action_row">
  18. <u-button type="primary" :text="isUpdate ? '确认修改' : '预约会议'" @click="confirmReserve"></u-button>
  19. </view>
  20. <u-datetime-picker :minDate="Date.now()" :show="showDatePicker" v-model="meetingData.startTime" mode="datetime"
  21. @cancel="showDatePicker = false" @confirm="confirmDate" />
  22. <u-action-sheet safeAreaInsetBottom :actions="durationList" cancelText="取消" closeOnClickOverlay
  23. :closeOnClickAction="true" :show="showDurationPicker" @select="confirmDuration"
  24. @close="showDurationPicker = false" />
  25. </view>
  26. </template>
  27. <script>
  28. import { mapGetters } from "vuex";
  29. import CustomNavBar from "../../../components/CustomNavBar/index.vue";
  30. import dayjs from "dayjs";
  31. import { toastWithCallback } from "../../../util/common";
  32. import { updateMeeting, bookMeeting } from '../../../api/meeting'
  33. const secondsToTime = {
  34. 1800: "30分钟",
  35. 3600: "1小时",
  36. 5400: "1.5小时",
  37. 7200: "2小时",
  38. };
  39. export default {
  40. components: {
  41. CustomNavBar,
  42. },
  43. data() {
  44. return {
  45. meetingData: {
  46. meetingName: "",
  47. startTime: 0,
  48. duration: 0,
  49. },
  50. isUpdate: false,
  51. showDatePicker: false,
  52. showDurationPicker: false,
  53. durationList: [
  54. {
  55. name: "30分钟",
  56. value: 1800,
  57. },
  58. {
  59. name: "1小时",
  60. value: 3600,
  61. },
  62. {
  63. name: "1.5小时",
  64. value: 5400,
  65. },
  66. {
  67. name: "2小时",
  68. value: 7200,
  69. },
  70. ],
  71. };
  72. },
  73. computed: {
  74. ...mapGetters(["storeSelfInfo"]),
  75. showDate() {
  76. if (this.meetingData.startTime) {
  77. return dayjs(this.meetingData.startTime).format("M月D日 HH:mm");
  78. }
  79. return "";
  80. },
  81. showDuration() {
  82. if (this.meetingData.duration) {
  83. return secondsToTime[this.meetingData.duration];
  84. }
  85. return "";
  86. },
  87. },
  88. onLoad(options) {
  89. this.isUpdate = JSON.parse(options.isUpdate);
  90. if (options.meetingData) {
  91. const meetingInfo = JSON.parse(options.meetingData);
  92. this.meetingData = {
  93. meetingID: meetingInfo?.info?.systemGenerated?.meetingID,
  94. meetingName: meetingInfo?.info?.creatorDefinedMeeting?.title,
  95. startTime: meetingInfo?.info?.creatorDefinedMeeting?.scheduledTime * 1000,
  96. duration: meetingInfo?.info?.creatorDefinedMeeting?.meetingDuration,
  97. };
  98. }
  99. },
  100. methods: {
  101. confirmDate(value) {
  102. console.log(value);
  103. this.showDatePicker = false;
  104. },
  105. confirmDuration({ value }) {
  106. this.meetingData.duration = value;
  107. this.showDurationPicker = false;
  108. },
  109. confirmReserve() {
  110. const notEmpty =
  111. Object.values(this.meetingData).find((field) => !field) === undefined;
  112. if (!notEmpty && !this.isUpdate) {
  113. return;
  114. }
  115. if (this.isUpdate) {
  116. const params = {
  117. meetingID: this.meetingData.meetingID,
  118. updatingUserID: this.storeSelfInfo.userID,
  119. title: this.meetingData.meetingName,
  120. scheduledTime: Math.round(this.meetingData.startTime / 1000),
  121. meetingDuration: this.meetingData.duration,
  122. password: "",
  123. timeZone: "Asia/Shanghai",
  124. repeatInfo: {
  125. endDate: 1735664461,
  126. repeatType: "None",
  127. uintType: "Week",
  128. interval: 0,
  129. },
  130. canParticipantsEnableCamera: true,
  131. canParticipantsUnmuteMicrophone: true,
  132. canParticipantsShareScreen: true,
  133. disableCameraOnJoin: false,
  134. disableMicrophoneOnJoin: false,
  135. canParticipantJoinMeetingEarly: true,
  136. lockMeeting: false,
  137. audioEncouragement: true,
  138. videoMirroring: true,
  139. };
  140. console.log('params', params);
  141. updateMeeting(params)
  142. .then(() => {
  143. toastWithCallback("修改成功!", () => uni.$u.route("/pages_im/pages/common/meetingCenter/index"))
  144. })
  145. .catch(() => uni.$u.toast("修改失败!"));
  146. return;
  147. }
  148. const params = {
  149. creatorUserID: this.storeSelfInfo.userID,
  150. creatorDefinedMeetingInfo: {
  151. title: this.meetingData.meetingName,
  152. scheduledTime: Math.round(this.meetingData.startTime / 1000),
  153. meetingDuration: this.meetingData.duration,
  154. password: "",
  155. timeZone: "Asia/Shanghai",
  156. },
  157. repeatInfo: {
  158. endDate: 1735664461,
  159. repeatType: "None",
  160. uintType: "Week",
  161. interval: 0,
  162. },
  163. setting: {
  164. canParticipantsEnableCamera: true,
  165. canParticipantsUnmuteMicrophone: true,
  166. canParticipantsShareScreen: true,
  167. disableCameraOnJoin: false,
  168. disableMicrophoneOnJoin: false,
  169. canParticipantJoinMeetingEarly: true,
  170. lockMeeting: false,
  171. audioEncouragement: true,
  172. videoMirroring: true,
  173. },
  174. };
  175. console.log('params', params);
  176. bookMeeting(params)
  177. .then(() => {
  178. toastWithCallback("预约成功!", () => uni.$u.route("/pages_im/pages/common/meetingCenter/index"))
  179. })
  180. .catch(() => uni.$u.toast("预约失败!"));
  181. // IMSDK.asyncApi("signalingCreateMeeting", IMSDK.uuid(), {
  182. // meetingName: this.meetingData.meetingName,
  183. // meetingHostUserID: this.$store.getters.storeSelfInfo.userID,
  184. // startTime: (this.meetingData.startTime / 1000).toFixed() * 1,
  185. // meetingDuration: this.meetingData.duration,
  186. // inviteeUserIDList: [],
  187. // })
  188. // .then(({ data }) => {
  189. // IMSDK.asyncApi("signalingUpdateMeetingInfo", IMSDK.uuid(), {
  190. // roomID: data.roomID,
  191. // participantCanUnmuteSelf: true,
  192. // });
  193. // uni.$u.route("/pages/common/meetingDetails/index", {
  194. // meetingData: JSON.stringify({
  195. // roomID: data.roomID,
  196. // meetingName: this.meetingData.meetingName,
  197. // hostUserID: this.$store.getters.storeSelfInfo.userID,
  198. // startTime: (this.meetingData.startTime / 1000).toFixed() * 1,
  199. // endTime:
  200. // (this.meetingData.startTime / 1000).toFixed() * 1 +
  201. // this.meetingData.duration,
  202. // launcher: `发起人:${this.$store.getters.storeSelfInfo.nickname}`,
  203. // }),
  204. // });
  205. // })
  206. // .catch((err) => {
  207. // console.log(err);
  208. // uni.$u.toast("预约失败!");
  209. // });
  210. },
  211. },
  212. };
  213. </script>
  214. <style lang="scss">
  215. .page_container {
  216. background-color: #f6f6f6;
  217. .field_row {
  218. display: flex;
  219. align-items: center;
  220. justify-content: space-between;
  221. padding: 32rpx;
  222. background-color: #fff;
  223. position: relative;
  224. .right_value {
  225. color: #737577;
  226. margin-right: 48rpx;
  227. }
  228. .u-icon--right {
  229. position: absolute;
  230. right: 32rpx;
  231. }
  232. &_input {
  233. margin-top: 24rpx;
  234. }
  235. }
  236. .action_row {
  237. margin-top: 10vh;
  238. padding: 0 24%;
  239. }
  240. }
  241. </style>