modeView.tsx 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import { defineComponent, onMounted, watch, reactive, ref, nextTick, computed } from "vue";
  2. import styles from "./index.module.less";
  3. import backImg from "./image/icon-back.png";
  4. import titmeImg from "./image/modeTitle.png";
  5. import nameImg from "./image/zt.png";
  6. import lxMode from "./image/lxMode.json";
  7. import glMode from "./image/glMode.json";
  8. import pcMode from "./image/pcMode.json";
  9. import modeTitle from "./image/modeTitle.json";
  10. import modeVip from "./image/mode_vip.png";
  11. import modesVip from "./image/mode_svip.png";
  12. import { headTopData, checkMusicBuy } from "./index";
  13. import { getQuery } from "/src/utils/queryString";
  14. import state from "/src/state";
  15. import { studentQueryUserInfo } from "../api";
  16. import { usePageVisibility } from "@vant/use";
  17. import { Vue3Lottie } from "vue3-lottie";
  18. import { popImgs, hanldeConfirmPop, hanldeClosePop, evaluatingData } from "/src/view/evaluating"
  19. import { Popup } from "vant";
  20. import AbnormalPop from "/src/view/abnormal-pop";
  21. import { smoothAnimationState } from "../view-detail/smoothAnimation";
  22. import { browser } from "/src/utils";
  23. import { stat } from "fs";
  24. export default defineComponent({
  25. name: "modeView",
  26. setup() {
  27. const modeImgDom1 = ref();
  28. const modeImgDom2 = ref();
  29. const modeImgDom3 = ref();
  30. const modeImgDom4 = ref();
  31. watch(
  32. () => headTopData.modeType,
  33. (value, oldValue) => {
  34. // headTopData.modeType 值 刚开始是 "" 所以 第一次切换时候不触发播放动画
  35. if (!oldValue) return;
  36. nextTick(() => {
  37. if (value === "show") {
  38. modeImgDom1.value?.pause();
  39. modeImgDom2.value?.pause();
  40. modeImgDom3.value?.pause();
  41. modeImgDom4.value?.stop();
  42. } else if (value === "init") {
  43. modeImgDom1.value?.play();
  44. modeImgDom2.value?.play();
  45. modeImgDom3.value?.play();
  46. modeImgDom4.value?.goToAndPlay(0);
  47. }
  48. });
  49. }
  50. );
  51. watch(
  52. () => evaluatingData.socketErrorStatus,
  53. () => {
  54. if (evaluatingData.socketErrorStatus === 2) {
  55. setTimeout(() => {
  56. evaluatingData.socketErrorPop = false;
  57. }, 1000);
  58. }
  59. }
  60. );
  61. const browserInfo = browser();
  62. const isPad = navigator?.userAgent?.includes("UAWEIVRD-W09") || browserInfo?.iPad || browserInfo.isTablet;
  63. // vip图标
  64. const showVip = computed(() => {
  65. return state.vipType === "NOT_VIP" && state.paymentType !== "FREE" && !state.musicBuyInfo.buyed
  66. });
  67. // svip图标
  68. const showsVip = computed(() => {
  69. return !state.vipType?.includes("SVIP") && state.paymentType !== "FREE" && !state.musicBuyInfo.buyed
  70. });
  71. return () => (
  72. <div class={[styles.modeView, isPad && styles.isiPad, headTopData.modeType !== "init" && styles.hidden]}>
  73. <img
  74. src={backImg}
  75. class={styles.back}
  76. onClick={() => {
  77. if(state.isSingleLine){
  78. smoothAnimationState.isShow.value = state.melodyLine;
  79. }
  80. // 返回的时候 跳转到之前记录的模式
  81. if(headTopData.oldModeType !== "practise"){
  82. // 点击评测模式进入评测模块的需要检测耳机状态,通过返回按钮进入评测模块的,不检测耳机状态
  83. evaluatingData.needCheckErjiStatus = false;
  84. headTopData.handleChangeModeType(headTopData.oldModeType)
  85. }
  86. headTopData.modeType = "show";
  87. }}
  88. />
  89. {/* <img src={titmeImg} class={styles.modeTitle} /> */}
  90. {
  91. <Vue3Lottie ref={modeImgDom4} class={styles.modeTitle} animationData={modeTitle} autoPlay={false} loop={false} delay={2000}></Vue3Lottie>
  92. }
  93. <div class={[styles.modeBox, ((!state.isPercussion && !state.enableEvaluation) || (state.isPercussion && state.enableEvaluation) || (state.isPercussion && !state.enableEvaluation)) && styles.twoModeBox]}>
  94. <div class={styles.modeItem}>
  95. <Vue3Lottie ref={modeImgDom1} class={styles.modeImg} animationData={lxMode} autoPlay={false} loop={true} onClick={() => {
  96. if (checkMusicBuy(state.musicBuyInfo)) {
  97. if(state.isSingleLine){
  98. smoothAnimationState.isShow.value = state.melodyLine;
  99. }
  100. headTopData.handleChangeModeType("practise")
  101. }
  102. }}></Vue3Lottie>
  103. {
  104. showVip.value && <img class={styles.vipIcon} src={modeVip} />
  105. }
  106. </div>
  107. {/* <img class={styles.modeImg} src={lxImg}
  108. onClick={() => {
  109. if(state.isSingleLine){
  110. smoothAnimationState.isShow.value = state.melodyLine;
  111. }
  112. headTopData.handleChangeModeType("practise")
  113. }} /> */}
  114. {!state.isPercussion &&
  115. <div class={styles.modeItem}>
  116. <Vue3Lottie ref={modeImgDom2} class={styles.modeImg} animationData={glMode} autoPlay={false} loop={true} onClick={() => {
  117. if (checkMusicBuy(state.musicBuyInfo)) {
  118. headTopData.handleChangeModeType("follow")
  119. }
  120. }}></Vue3Lottie>
  121. { showsVip.value && <img class={styles.svipIcon} src={modesVip} /> }
  122. </div>
  123. // <img class={styles.modeImg} src={glImg}
  124. // onClick={() => headTopData.handleChangeModeType("follow")} />
  125. }
  126. {state.enableEvaluation &&
  127. <div class={styles.modeItem}>
  128. <Vue3Lottie ref={modeImgDom3} class={styles.modeImg} animationData={pcMode} autoPlay={false} loop={true} onClick={() => {
  129. if (checkMusicBuy(state.musicBuyInfo)) {
  130. // 点击评测模式进入评测模块的需要检测耳机状态,通过返回按钮进入评测模块的,不检测耳机状态
  131. evaluatingData.needCheckErjiStatus = true;
  132. headTopData.handleChangeModeType("evaluating")
  133. }
  134. }}></Vue3Lottie>
  135. { showsVip.value && <img class={styles.svipIcon} src={modesVip} /> }
  136. </div>
  137. // <img class={styles.modeImg} src={pcImg}
  138. // onClick={() => {
  139. // // 点击评测模式进入评测模块的需要检测耳机状态,通过返回按钮进入评测模块的,不检测耳机状态
  140. // evaluatingData.needCheckErjiStatus = true;
  141. // headTopData.handleChangeModeType("evaluating")
  142. // }} />
  143. }
  144. </div>
  145. {/** 延迟检测中途,socket出错,网络提示弹窗 */}
  146. {/* {
  147. state.modeType !== 'evaluating' &&
  148. <div>
  149. <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" }:{}}>
  150. <AbnormalPop onConfirm={hanldeConfirmPop} onClose={hanldeClosePop} />
  151. </Popup>
  152. </div>
  153. } */}
  154. </div>
  155. );
  156. },
  157. });