modeView.tsx 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. import { defineComponent, onMounted, watch, reactive, ref, nextTick } from "vue";
  2. import styles from "./index.module.less";
  3. import backImg from "./image/icon-back.png";
  4. import nameImg from "./image/zt.png";
  5. import lxMode from "./image/lxMode.json";
  6. import glMode from "./image/glMode.json";
  7. import pcMode from "./image/pcMode.json";
  8. import lxImg from "./image/lxImg.png";
  9. import glImg from "./image/glImg.png";
  10. import pcImg from "./image/pcImg.png";
  11. import { headTopData } from "./index";
  12. import TheVip from "../custom-plugins/the-vip";
  13. import { getQuery } from "/src/utils/queryString";
  14. import { storeData } from "/src/store";
  15. import state from "/src/state";
  16. import { studentQueryUserInfo } from "../api";
  17. import { usePageVisibility } from "@vant/use";
  18. import { Vue3Lottie } from "vue3-lottie";
  19. import { popImgs, hanldeConfirmPop, hanldeClosePop, evaluatingData } from "/src/view/evaluating"
  20. import { Popup } from "vant";
  21. import AbnormalPop from "/src/view/abnormal-pop";
  22. import { smoothAnimationState } from "../view-detail/smoothAnimation";
  23. import { browser } from "/src/utils";
  24. export default defineComponent({
  25. name: "modeView",
  26. setup() {
  27. const query = getQuery();
  28. const data = reactive({
  29. showVip: false,
  30. });
  31. // const modeImgDom1 = ref();
  32. // const modeImgDom2 = ref();
  33. // const modeImgDom3 = ref();
  34. const openGuid = () => {
  35. // 加载后 判断 端口号 加载对应的引导
  36. if (storeData.platformType !== "STUDENT" || storeData.user.clientType !== "STUDENT") {
  37. } else {
  38. // 从课堂乐器学生端课件预览默认不显示会员
  39. if (storeData.user.vipMember || state.paymentType === "FREE" || query.showCourseMember === "true") {
  40. } else {
  41. // 不是vip
  42. data.showVip = true;
  43. state.isVip = true;
  44. }
  45. }
  46. };
  47. const getUserInfo = async () => {
  48. const res = await studentQueryUserInfo();
  49. const student = res?.data || {};
  50. storeData.user.vipMember = student.vipMember;
  51. // console.log("🚀 ~ student:", student);
  52. if (storeData.user.vipMember) {
  53. data.showVip = false;
  54. state.isVip = false;
  55. openGuid();
  56. }
  57. };
  58. const pageVisible = usePageVisibility();
  59. watch(
  60. () => pageVisible.value,
  61. (val) => {
  62. if (val === "visible") {
  63. if (storeData.user.vipMember) return;
  64. console.log("页面显示");
  65. getUserInfo();
  66. }
  67. }
  68. );
  69. // watch(
  70. // () => headTopData.modeType,
  71. // (value, oldValue) => {
  72. // // headTopData.modeType 值 刚开始是 "" 所以 第一次切换时候不触发播放动画
  73. // if (!oldValue) return;
  74. // nextTick(() => {
  75. // if (value === "show") {
  76. // modeImgDom1.value?.pause();
  77. // modeImgDom2.value?.pause();
  78. // modeImgDom3.value?.pause();
  79. // } else if (value === "init") {
  80. // modeImgDom1.value?.play();
  81. // modeImgDom2.value?.play();
  82. // modeImgDom3.value?.play();
  83. // }
  84. // });
  85. // }
  86. // );
  87. onMounted(() => {
  88. openGuid();
  89. });
  90. watch(
  91. () => evaluatingData.socketErrorStatus,
  92. () => {
  93. if (evaluatingData.socketErrorStatus === 2) {
  94. setTimeout(() => {
  95. evaluatingData.socketErrorPop = false;
  96. }, 1000);
  97. }
  98. }
  99. );
  100. const browserInfo = browser();
  101. const isPad = navigator?.userAgent?.includes("UAWEIVRD-W09") || browserInfo?.iPad || browserInfo.isTablet;
  102. return () => (
  103. <div class={[styles.modeView, isPad && styles.isiPad, headTopData.modeType !== "init" && styles.hidden]}>
  104. <img
  105. src={backImg}
  106. class={styles.back}
  107. onClick={() => {
  108. if(state.isSingleLine){
  109. smoothAnimationState.isShow.value = state.melodyLine;
  110. }
  111. // 返回的时候 跳转到之前记录的模式
  112. if(headTopData.oldModeType !== "practise"){
  113. // 点击评测模式进入评测模块的需要检测耳机状态,通过返回按钮进入评测模块的,不检测耳机状态
  114. evaluatingData.needCheckErjiStatus = false;
  115. headTopData.handleChangeModeType(headTopData.oldModeType)
  116. }
  117. headTopData.modeType = "show";
  118. }}
  119. />
  120. <div class={[styles.modeBox, ((!state.isPercussion && !state.enableEvaluation) || (state.isPercussion && state.enableEvaluation) || (state.isPercussion && !state.enableEvaluation)) && styles.twoModeBox]}>
  121. {/* <Vue3Lottie ref={modeImgDom1} class={styles.modeImg} animationData={lxMode} autoPlay={false} loop={true} onClick={() => {
  122. if(state.isSingleLine){
  123. smoothAnimationState.isShow.value = state.melodyLine;
  124. }
  125. headTopData.handleChangeModeType("practise")
  126. }}></Vue3Lottie> */}
  127. <img class={styles.modeImg} src={lxImg}
  128. onClick={() => {
  129. if(state.isSingleLine){
  130. smoothAnimationState.isShow.value = state.melodyLine;
  131. }
  132. headTopData.handleChangeModeType("practise")
  133. }} />
  134. {!state.isPercussion &&
  135. // <Vue3Lottie ref={modeImgDom2} class={styles.modeImg} animationData={glMode} autoPlay={false} loop={true} onClick={() => headTopData.handleChangeModeType("follow")}></Vue3Lottie>
  136. <img class={styles.modeImg} src={glImg}
  137. onClick={() => headTopData.handleChangeModeType("follow")} />
  138. }
  139. {state.enableEvaluation &&
  140. // <Vue3Lottie ref={modeImgDom3} class={styles.modeImg} animationData={pcMode} autoPlay={false} loop={true} onClick={() => {
  141. // // 点击评测模式进入评测模块的需要检测耳机状态,通过返回按钮进入评测模块的,不检测耳机状态
  142. // evaluatingData.needCheckErjiStatus = true;
  143. // headTopData.handleChangeModeType("evaluating")
  144. // }}></Vue3Lottie>
  145. <img class={styles.modeImg} src={pcImg}
  146. onClick={() => {
  147. // 点击评测模式进入评测模块的需要检测耳机状态,通过返回按钮进入评测模块的,不检测耳机状态
  148. evaluatingData.needCheckErjiStatus = true;
  149. headTopData.handleChangeModeType("evaluating")
  150. }} />
  151. }
  152. </div>
  153. {data.showVip && <TheVip />}
  154. {/** 延迟检测中途,socket出错,网络提示弹窗 */}
  155. {/* {
  156. state.modeType !== 'evaluating' &&
  157. <div>
  158. <Popup teleport="body" closeOnClickOverlay={false} class={["popup-custom", "van-scale", evaluatingData.socketErrorStatus === 2 && styles.socketErrorStatus]} transition="van-scale" v-model:show={evaluatingData.socketErrorPop} overlay-style={evaluatingData.socketErrorStatus === 2?{ background: "initial" }:{}}>
  159. <AbnormalPop onConfirm={hanldeConfirmPop} onClose={hanldeClosePop} />
  160. </Popup>
  161. </div>
  162. } */}
  163. </div>
  164. );
  165. },
  166. });