index.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. import { defineComponent, onMounted, onUnmounted, reactive, ref, nextTick } from 'vue';
  2. import styles from './index.module.less';
  3. // import signinTips from './images/signin-tips.png';
  4. import {
  5. Button,
  6. CellGroup,
  7. Field,
  8. Picker,
  9. Popup,
  10. closeToast,
  11. showToast,
  12. Loading
  13. } from 'vant';
  14. import { useRoute, useRouter } from 'vue-router';
  15. import threeMan from './images/update/three-man.png'
  16. import OWxTip from '@/components/m-wx-tip';
  17. import { browser, getHttpOrigin, getUrlCode } from '@/helpers/utils';
  18. import qs from 'query-string';
  19. import request from '@/helpers/request';
  20. import { goWechatAuth } from '@/state';
  21. import { useInterval, useIntervalFn } from '@vueuse/core';
  22. import MMessageTip from '@/components/m-message-tip';
  23. import TCPlayer from 'tcplayer.js';
  24. import 'tcplayer.js/dist/tcplayer.css';
  25. import { _initVideo } from './initVideo'
  26. import nextBtn from './images/next_btn.png'
  27. export default defineComponent({
  28. name: 'intention-questionnaire',
  29. setup() {
  30. // 页面定时
  31. const pageTimer = useInterval(1000, { controls: true });
  32. pageTimer.pause();
  33. const router = useRouter();
  34. const route = useRoute();
  35. const forms = reactive({
  36. loading: true,
  37. code: null,
  38. openId: '' as any,
  39. isPageHide: false,
  40. contentA: "<p><span style=\"color: rgb(0, 0, 0);\">一、请所有家长进行</span><span style=\"color: rgb(207, 19, 34);\">签到</span></p><p><span style=\"color: rgb(0, 0, 0);\">二、</span><span style=\"color: rgb(207, 19, 34);\">观看</span><span style=\"color: rgb(0, 0, 0);\">管乐团家长会议</span></p><p><span style=\"color: rgb(0, 0, 0);\"> 1、学校领导讲话(5分钟)</span></p><p><span style=\"color: rgb(0, 0, 0);\"> 2、基金会老师介绍乐团事项(20分钟)</span></p><p><span style=\"color: rgb(0, 0, 0);\"> *乐团组建背景及政策</span></p><p><span style=\"color: rgb(0, 0, 0);\"> *乐团发展规划与乐器知识讲解</span></p><p><span style=\"color: rgb(0, 0, 0);\"> *学校/基金会/家长各方职责与投入</span></p><p><span style=\"color: rgb(0, 0, 0);\"> *入团流程讲解</span></p><p><span style=\"color: rgb(0, 0, 0);\">三、请</span><span style=\"color: rgb(207, 19, 34);\">“有意向”</span><span style=\"color: rgb(0, 0, 0);\">让孩子加入乐团的家长点击</span><span style=\"color: rgb(207, 19, 34);\">“乐团报名”</span><span style=\"color: rgb(0, 0, 0);\">完成信息填报</span></p>", // 第一段
  41. contentB: "<p><span style=\"color: rgb(0, 0, 0);\">一、请所有家长进行</span><span style=\"color: rgb(207, 19, 34);\">签到</span></p><p><span style=\"color: rgb(0, 0, 0);\">二、</span><span style=\"color: rgb(207, 19, 34);\">观看</span><span style=\"color: rgb(0, 0, 0);\">管乐团家长会议</span></p><p><span style=\"color: rgb(0, 0, 0);\"> 1、学校领导讲话(5分钟)</span></p><p><span style=\"color: rgb(0, 0, 0);\"> 2、基金会老师介绍乐团事项(20分钟)</span></p><p><span style=\"color: rgb(0, 0, 0);\"> *乐团组建背景及政策</span></p><p><span style=\"color: rgb(0, 0, 0);\"> *乐团发展规划与乐器知识讲解</span></p><p><span style=\"color: rgb(0, 0, 0);\"> *学校/基金会/家长各方职责与投入</span></p><p><span style=\"color: rgb(0, 0, 0);\"> *入团流程讲解</span></p><p><span style=\"color: rgb(0, 0, 0);\">三、请</span><span style=\"color: rgb(207, 19, 34);\">“有意向”</span><span style=\"color: rgb(0, 0, 0);\">让孩子加入乐团的家长点击</span><span style=\"color: rgb(207, 19, 34);\">“乐团报名”</span><span style=\"color: rgb(0, 0, 0);\">完成信息填报</span></p>", // 第二段
  42. contentC: "<p><span style=\"color: rgb(0, 0, 0);\">一、请所有家长进行</span><span style=\"color: rgb(207, 19, 34);\">签到</span></p><p><span style=\"color: rgb(0, 0, 0);\">二、</span><span style=\"color: rgb(207, 19, 34);\">观看</span><span style=\"color: rgb(0, 0, 0);\">管乐团家长会议</span></p><p><span style=\"color: rgb(0, 0, 0);\"> 1、学校领导讲话(5分钟)</span></p><p><span style=\"color: rgb(0, 0, 0);\"> 2、基金会老师介绍乐团事项(20分钟)</span></p><p><span style=\"color: rgb(0, 0, 0);\"> *乐团组建背景及政策</span></p><p><span style=\"color: rgb(0, 0, 0);\"> *乐团发展规划与乐器知识讲解</span></p><p><span style=\"color: rgb(0, 0, 0);\"> *学校/基金会/家长各方职责与投入</span></p><p><span style=\"color: rgb(0, 0, 0);\"> *入团流程讲解</span></p><p><span style=\"color: rgb(0, 0, 0);\">三、请</span><span style=\"color: rgb(207, 19, 34);\">“有意向”</span><span style=\"color: rgb(0, 0, 0);\">让孩子加入乐团的家长点击</span><span style=\"color: rgb(207, 19, 34);\">“乐团报名”</span><span style=\"color: rgb(0, 0, 0);\">完成信息填报</span></p>", // 第三段
  43. contentD: "",
  44. introductionVideo: "https://oss.dayaedu.com/ktyq/02/1739324017357.mp4",
  45. introductionVideoTime: 117,
  46. coverImg: "https://oss.dayaedu.com/ktyq/02/1739324197269.png",
  47. introductionVideo2: "https://oss.dayaedu.com/ktyq/02/1739324017357.mp4",
  48. introductionVideoTime2: 117,
  49. coverImg2: "https://oss.dayaedu.com/ktyq/02/1739324215341.png",
  50. player1: null as any,
  51. player2: null as any,
  52. player1Speed: 1,
  53. player2Speed: 1,
  54. videoLoading1: true,
  55. videoLoading2: true,
  56. meetingType: 'primarySchoolNo' as 'primarySchoolNo' | 'primarySchoolYes' | 'juniorSchoolNo' | 'juniorSchool' | any,
  57. intentionInfo: null as any,
  58. });
  59. const showPopup = ref(false);
  60. const showPopupMessage = ref('');
  61. // 播放视频总时长
  62. const videoIntervalRef = useInterval(1000, { controls: true });
  63. videoIntervalRef.pause();
  64. const videoIntervalRef2 = useInterval(1000, { controls: true });
  65. videoIntervalRef2.pause();
  66. onMounted(async () => {
  67. forms.meetingType = route.query.type || forms.meetingType;
  68. nextTick(() => {
  69. const videoRef: any = document.querySelector('#register-video')
  70. const videoRef2: any = document.querySelector('#register-video2')
  71. if(videoRef) {
  72. const rect = videoRef?.getBoundingClientRect()
  73. console.log(rect)
  74. videoRef.style.height = rect.width / 16 * 9 + 'px'
  75. }
  76. if(videoRef2) {
  77. const rect = videoRef2?.getBoundingClientRect()
  78. console.log(rect)
  79. videoRef2.style.height = rect.width / 16 * 9 + 'px'
  80. }
  81. })
  82. try {
  83. // 判断是否获取微信code码
  84. // if (!forms.code) return;
  85. const { data } = await request.get(
  86. '/edu-app/open/meetingQuestionSetting/detail?type=' + forms.meetingType + '&weChatCode=' + forms.code
  87. );
  88. if (data) {
  89. forms.contentA = data.contentA || forms.contentA
  90. forms.contentB = data.contentB || forms.contentB
  91. forms.contentC = data.contentC || forms.contentC
  92. forms.contentD = data.contentD || forms.contentD
  93. forms.openId = data.openId
  94. sessionStorage.setItem('active-open-id', data.openId);
  95. }
  96. } catch {
  97. //
  98. }
  99. _initVideo('one', forms, videoIntervalRef)
  100. _initVideo('two', forms, videoIntervalRef2)
  101. });
  102. const getAppIdAndCode = async (url?: string) => {
  103. try {
  104. const { data } = await request.get(
  105. '/edu-app/open/paramConfig/wechatAppId'
  106. );
  107. // 判断是否有微信appId
  108. if (data) {
  109. closeToast();
  110. goWechatAuth(data, url);
  111. }
  112. } catch(e) {
  113. //
  114. console.log(e)
  115. }
  116. };
  117. if (browser().weixin) {
  118. //授权
  119. const openId = sessionStorage.getItem('active-open-id');
  120. forms.openId = openId;
  121. const code = getUrlCode();
  122. console.log(code, 'code')
  123. if (!code) {
  124. const newUrl =
  125. getHttpOrigin() +
  126. window.location.pathname +
  127. '#' +
  128. route.path +
  129. '?' +
  130. qs.stringify({
  131. ...route.query
  132. });
  133. getAppIdAndCode(newUrl);
  134. return '';
  135. } else {
  136. forms.code = code;
  137. }
  138. }
  139. const nextSkip = () => {
  140. router.push({
  141. path: '/fill-questionnaire',
  142. query: {
  143. openId: forms.openId, //
  144. meetingType: forms.meetingType
  145. }
  146. });
  147. };
  148. const onPageShow = () => {
  149. console.log(forms.isPageHide, 'showInfo');
  150. if (forms.isPageHide) {
  151. window.location.reload();
  152. }
  153. };
  154. // 处理监听页面返回不刷新的问题
  155. window.addEventListener('pageshow', onPageShow);
  156. const onPageHide = () => {
  157. console.log(forms.isPageHide, 'showInfo');
  158. forms.isPageHide = true;
  159. };
  160. window.addEventListener('pagehide', onPageHide);
  161. onUnmounted(() => {
  162. window.removeEventListener('pageshow', onPageShow);
  163. window.removeEventListener('pagehide', onPageHide);
  164. });
  165. return () => (
  166. <div class={styles['intention-page']}>
  167. <div class={styles['content-box']}>
  168. <div class={styles.contentBody} v-html={forms.contentA}></div>
  169. <div class={styles.contentBody}>
  170. <div class={styles.cbTitle}>一、什么是音乐(器乐)课堂数字化转型<span>(详见视频介绍)</span></div>
  171. <div class={[styles['video-content']]}>
  172. <video
  173. id="register-video"
  174. class={styles['video']}
  175. src={forms.introductionVideo}
  176. playsinline={true}
  177. poster={forms.coverImg}
  178. preload="auto"></video>
  179. </div>
  180. </div>
  181. <div class={styles.contentBody} v-html={forms.contentB}></div>
  182. <div class={styles.contentBody} v-html={forms.contentC}></div>
  183. <div class={styles.contentBody}>
  184. <div class={styles.cbTitle}>四、什么是器乐数字 Ai<span>(详见视频介绍)</span></div>
  185. <div class={[styles['video-content']]}>
  186. <video
  187. id="register-video2"
  188. class={styles['video']}
  189. src={forms.introductionVideo2}
  190. playsinline={true}
  191. poster={forms.coverImg2}
  192. preload="auto"></video>
  193. </div>
  194. </div>
  195. <div class={styles.contentBody} v-html={forms.contentD}></div>
  196. </div>
  197. {/* 是否在微信中打开 */}
  198. <OWxTip />
  199. <div class={styles.bottomBtn}>
  200. <p>在您了解上述内容后,<i>请点击下一步进行意见</i></p>
  201. <img class={styles.nextBtn} src={nextBtn} onClick={nextSkip} />
  202. </div>
  203. </div>
  204. );
  205. }
  206. });