index.tsx 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154
  1. import { PropType, computed, defineComponent, nextTick, onBeforeMount, onMounted, onUnmounted, reactive, ref, toRef } from "vue";
  2. import styles from "./index.module.less";
  3. import icons from "./image/icons.json";
  4. import { FIGNER_INSTRUMENT_DATA, FIGNER_INSTRUMENT_REALKEY, IFIGNER_INSTRUMENT_Note } from "/src/view/figner-preview";
  5. import { ITypeFingering, IVocals, getFingeringConfig, mappingVoicePart, subjectFingering } from "/src/view/fingering/fingering-config";
  6. import { Howl } from "howler";
  7. import { storeData } from "/src/store";
  8. import { api_back, api_cloudLoading, api_setRequestedOrientation, api_setStatusBarVisibility, isSpecialShapedScreen } from "/src/helpers/communication";
  9. import Hammer from "hammerjs";
  10. import { Button, Icon, Loading, Popover, Popup, Progress, Space, showToast } from "vant";
  11. import GuideIndex from "./guide/guide-index";
  12. import { getQuery } from "/src/utils/queryString";
  13. import { browser } from "/src/utils";
  14. import { usePageVisibility } from "@vant/use";
  15. import { watch } from "vue";
  16. import icon_loading_img from "./image/icon_loading_img.png";
  17. import noteImg from "./image/noteImg.png";
  18. import state, { IPlatform } from "/src/state";
  19. import { api_musicalInstrumentList, api_subjectList, getSubjectList } from "../api";
  20. import ChangeSubject from "./change-subject";
  21. import { Tabs, Tab } from "vant";
  22. import useDrag from "/src/hooks/useDrag";
  23. import Dragbom from "/src/hooks/useDrag/dragbom";
  24. import useDragGuidance from "/src/hooks/useDrag/useDragGuidance";
  25. import { FINER_INSTRUMENT_POINT } from "./fingeringPoint";
  26. export default defineComponent({
  27. name: "viewFigner",
  28. emits: ["close"],
  29. props: {
  30. show: {
  31. type: Boolean,
  32. default: true,
  33. },
  34. isComponent: {
  35. type: Boolean,
  36. default: false,
  37. },
  38. subject: {
  39. type: String as PropType<IVocals>,
  40. default: "",
  41. },
  42. },
  43. setup(props, { emit }) {
  44. const query = getQuery();
  45. const browsInfo = browser();
  46. const tempCode = query.code ? query.code.split(",")[0] : "";
  47. const code = mappingVoicePart(tempCode, "INSTRUMENT");
  48. const subject = props.isComponent ? props.subject || "pan-flute" : code || "pan-flute";
  49. const data = reactive({
  50. linkSource: query.linkSource, // 来源,目前只有课件里使用
  51. loading: true,
  52. subject: subject as any,
  53. realKey: 0,
  54. notes: [] as IFIGNER_INSTRUMENT_Note[],
  55. notePoints: [] as any, // 显示的点
  56. tones: [] as IFIGNER_INSTRUMENT_Note[],
  57. activeTone: {} as IFIGNER_INSTRUMENT_Note,
  58. popupActiveTone: {} as IFIGNER_INSTRUMENT_Note,
  59. activeToneName: "",
  60. soundFonts: {} as any,
  61. viewIndex: 0,
  62. viewTotal: 1,
  63. noteAudio: null as unknown as Howl,
  64. transform: {
  65. scale: 1,
  66. x: 0,
  67. y: 0,
  68. startScale: 1,
  69. startX: 0,
  70. startY: 0,
  71. transition: "",
  72. },
  73. tipShow: false,
  74. tips: [] as IFIGNER_INSTRUMENT_Note[],
  75. tnoteShow: false,
  76. loadingSoundFonts: true,
  77. loadingSoundProgress: 0,
  78. changeSubjectShow: false,
  79. huaweiPad: navigator?.userAgent?.includes("UAWEIVRD-W09") ? true : false,
  80. paddingTop: "",
  81. paddingLeft: "",
  82. subjects: [] as any,
  83. fingeringModeList: [
  84. {
  85. text: "指法模式",
  86. value: "fingeringMode",
  87. icon: icons.icon_click,
  88. },
  89. {
  90. text: "听音模式",
  91. value: "listenMode",
  92. icon: icons.icon_listen,
  93. },
  94. {
  95. text: "音阶模式",
  96. value: "scaleMode",
  97. icon: icons.icon_mode,
  98. },
  99. ],
  100. fingeringMode: query.type || ("scaleMode" as "fingeringMode" | "listenMode" | "scaleMode"), // 模式
  101. noteType: "all" as "#c" | "all", // 音调
  102. loadingDom: false, // 切换乐器时需要重置
  103. loadingImg: false, // 切换模式,加载图片
  104. domOverlapping: false, // 元素是否被遮住
  105. domOverImgPropery: {
  106. width: "100%",
  107. height: "100%",
  108. } as any,
  109. });
  110. const fingerData = reactive({
  111. relationshipIndex: 0,
  112. subject: null as unknown as ITypeFingering,
  113. fingeringInfo: subjectFingering(data.subject),
  114. });
  115. if (!props.isComponent) {
  116. state.fingeringInfo = fingerData.fingeringInfo;
  117. }
  118. const getAPPData = async (type: "top" | "left") => {
  119. const screenData = await isSpecialShapedScreen();
  120. if (screenData?.content) {
  121. console.log("🚀 ~ screenData:", screenData.content);
  122. const { isSpecialShapedScreen, notchHeight } = screenData.content;
  123. if (isSpecialShapedScreen) {
  124. if (type === "top") {
  125. data.paddingTop = 25 + "px";
  126. }
  127. if (type === "left") {
  128. data.paddingLeft = 25 + "px";
  129. }
  130. }
  131. }
  132. };
  133. const getHeadTop = () => {
  134. if (fingerData.fingeringInfo.orientation === 1) {
  135. getAPPData("top");
  136. }
  137. if (fingerData.fingeringInfo.orientation === 0) {
  138. getAPPData("left");
  139. }
  140. };
  141. const getNotes = () => {
  142. const fignerData = FIGNER_INSTRUMENT_DATA[data.subject as keyof typeof FIGNER_INSTRUMENT_DATA];
  143. if (fignerData) {
  144. data.tones = fignerData.tones || [];
  145. if (data.tones.length) {
  146. data.activeTone = data.tones[0];
  147. data.popupActiveTone = data.tones[0];
  148. }
  149. data.tips = fignerData.tips || [];
  150. setNotes();
  151. setTimeout(() => {
  152. data.loading = false;
  153. }, 600);
  154. }
  155. };
  156. const setNotes = () => {
  157. const fignerData = FIGNER_INSTRUMENT_DATA[data.subject as keyof typeof FIGNER_INSTRUMENT_DATA];
  158. if (fignerData) {
  159. const tempNotes = fignerData[`list${data.activeTone.realName || ""}`];
  160. const appendNote: any = [];
  161. tempNotes.forEach((note: any) => {
  162. note.steps = new Array(Math.abs(note.step)).fill(1);
  163. if (FIGNER_INSTRUMENT_REALKEY.includes(note.realKey)) {
  164. appendNote.push(note);
  165. }
  166. });
  167. // 判断是音符状态
  168. data.notes = data.noteType === "#c" ? appendNote : tempNotes;
  169. // data.notes = fignerData[`list${data.activeTone.realName || ""}`];
  170. data.notePoints = FINER_INSTRUMENT_POINT[data.subject];
  171. }
  172. };
  173. const getFingeringData = async () => {
  174. const subject: any = data.subject + (data.viewIndex === 0 ? "" : data.viewIndex);
  175. console.log("🚀 ~ subject:模式", subject, data.viewIndex, data.fingeringMode);
  176. fingerData.subject = await getFingeringConfig(subject);
  177. };
  178. const createAudio = (url: string) => {
  179. return new Promise((resolve, reject) => {
  180. const noteAudio = new Howl({
  181. src: url,
  182. loop: true,
  183. onload: () => {
  184. resolve(noteAudio);
  185. },
  186. onloaderror: () => {
  187. reject(new Error(`加载音频失败`));
  188. },
  189. });
  190. });
  191. };
  192. const getSounFonts = async () => {
  193. const pathname = /(192|localhost)/.test(location.origin) ? "/" : location.pathname;
  194. data.loadingSoundFonts = true;
  195. try {
  196. data.loadingSoundProgress = 0;
  197. for (let i = 0; i < data.notes.length; i++) {
  198. const note = data.notes[i];
  199. // console.log("🚀 ~ note:", i);
  200. let url = `${pathname}soundfonts/${data.subject}/`;
  201. url += note.realName;
  202. url += ".mp3";
  203. data.soundFonts[note.realKey] = await createAudio(url);
  204. data.loadingSoundProgress = Math.floor(((i + 1) / data.notes.length) * 100);
  205. }
  206. data.loadingSoundProgress = 100;
  207. } catch (e: any) {
  208. //
  209. showToast(e.message);
  210. }
  211. api_cloudLoading();
  212. data.loadingSoundFonts = false;
  213. };
  214. // const selectSubjectType = (subject: string) => {
  215. // data.subjects.forEach((item: any) => {
  216. // if (item.value === subject) {
  217. // item.className = styles.selected;
  218. // } else {
  219. // item.className = "";
  220. // }
  221. // });
  222. // };
  223. // 切换当前模式
  224. const onChangeFingeringModel = (e: any) => {
  225. e.stopPropagation();
  226. //
  227. if (playAction.listenLock) return;
  228. if (playAction.showAnswerLoading) return;
  229. data.loadingImg = true;
  230. if (data.fingeringMode === "scaleMode") {
  231. if (["pan-flute", "ocarina", "whistling"].includes(data.subject)) {
  232. data.viewIndex = 1;
  233. } else {
  234. data.viewIndex = 0;
  235. }
  236. const o: any = {
  237. "pan-flute": 2,
  238. ocarina: 2,
  239. whistling: 2,
  240. piccolo: 2,
  241. "hulusi-flute": 2,
  242. "baroque-recorder": 2,
  243. };
  244. data.viewTotal = o[data.subject] || 1;
  245. data.fingeringMode = "listenMode";
  246. } else if (data.fingeringMode === "listenMode") {
  247. data.fingeringMode = "fingeringMode";
  248. } else if (data.fingeringMode === "fingeringMode") {
  249. data.fingeringMode = "scaleMode";
  250. data.viewIndex = 0;
  251. data.noteType = "all";
  252. }
  253. data.tipShow = false;
  254. resetElement();
  255. resetMode(true, 0);
  256. setTimeout(() => {
  257. __init(false);
  258. }, 100);
  259. };
  260. const __init = async (loadSong = true) => {
  261. data.loadingDom = true;
  262. getNotes();
  263. // selectSubjectType(data.subject);
  264. if (data.fingeringMode === "fingeringMode") {
  265. if (data.subject === "pan-flute") {
  266. data.viewIndex = 3;
  267. } else if (["pan-flute", "ocarina", "melodica", "whistling"].includes(data.subject)) {
  268. data.viewIndex = 1;
  269. }
  270. } else {
  271. if (["pan-flute", "ocarina", "whistling"].includes(data.subject)) {
  272. data.viewIndex = 1;
  273. }
  274. }
  275. const o: any = {
  276. "pan-flute": 2,
  277. ocarina: 2,
  278. whistling: 2,
  279. piccolo: 2,
  280. "hulusi-flute": 2,
  281. "baroque-recorder": 2,
  282. };
  283. data.viewTotal = o[data.subject] || 1;
  284. getFingeringData();
  285. getHeadTop();
  286. if (loadSong) {
  287. await getSounFonts();
  288. }
  289. data.loadingDom = false;
  290. data.loadingImg = false;
  291. // 初始化获取元素宽高
  292. onResize();
  293. };
  294. // 获取声部
  295. const getSubjects = async () => {
  296. try {
  297. // api_subjectList
  298. // const subjects = await api_musicalInstrumentList({
  299. // enableFlag: true,
  300. // });
  301. // const rows = subjects.data || [];
  302. // rows.forEach((row: any) => {
  303. // const tempList: any = {
  304. // text: row.name,
  305. // value: mappingVoicePart(row.code, "INSTRUMENT"), // mappingVoicePart(row.code, "INSTRUMENT"),
  306. // id: row.id,
  307. // };
  308. // data.subjects.push(tempList);
  309. // });
  310. const subjects = await api_subjectList({
  311. enableFlag: true,
  312. delFlag: 0,
  313. page: 1,
  314. rows: 999,
  315. });
  316. const rows = subjects.data || [];
  317. const tempSubjects: any[] = [];
  318. rows.forEach((row: any) => {
  319. const tempList: any = {
  320. text: row.name,
  321. value: "", // mappingVoicePart(row.code, "INSTRUMENT"),
  322. id: row.id,
  323. children: [] as any,
  324. };
  325. if (Array.isArray(row.instruments)) {
  326. row.instruments.forEach((i: any) => {
  327. const code = i.code ? i.code.split(",") : [];
  328. tempList.children.push({
  329. text: i.name,
  330. id: i.id,
  331. value: mappingVoicePart(code[0] || "", "INSTRUMENT"),
  332. });
  333. });
  334. }
  335. tempSubjects.push(tempList);
  336. });
  337. console.log(data.subject, "data.subject");
  338. data.subjects = tempSubjects;
  339. } catch (e) {
  340. //
  341. console.log(e, "e");
  342. }
  343. };
  344. onBeforeMount(async () => {
  345. if (browser().isApp) {
  346. state.platform = "APP" as IPlatform;
  347. } else {
  348. state.platform = query.platform?.toLocaleUpperCase() || "";
  349. }
  350. if (state.platform === IPlatform.PC) {
  351. document.title = "听音练习";
  352. }
  353. await getSubjects();
  354. __init();
  355. });
  356. // 播放时间
  357. let noteTimer: any = null;
  358. /**
  359. * 播放音频
  360. * @param item 音频节点
  361. * @param showNote 是否显示对应的指法
  362. * @param isScrollShowNote 是否滚动到对应播放的位置
  363. * @param autoStop 是否自动停止
  364. * @returns
  365. */
  366. const noteClick = (item: IFIGNER_INSTRUMENT_Note, showNote = true, isScrollShowNote = false, autoStop = false, callBack?: any) => {
  367. // console.log('音高', item.realKey)
  368. if (data.noteAudio) {
  369. data.noteAudio.stop();
  370. if (data.realKey === item.realKey) {
  371. data.realKey = 0;
  372. data.noteAudio = null as unknown as Howl;
  373. return;
  374. }
  375. clearTimeout(noteTimer);
  376. }
  377. if (showNote) {
  378. data.realKey = item.realKey;
  379. }
  380. // console.log("key:", item.realKey, data.soundFonts);
  381. data.noteAudio = data.soundFonts[item.realKey];
  382. if (data.noteAudio) {
  383. clearTimeout(noteTimer);
  384. data.noteAudio.play();
  385. if (isScrollShowNote) scrollAnswer(item.realKey);
  386. // 判断是否自动停止播放停止
  387. if (autoStop) return;
  388. noteTimer = setTimeout(() => {
  389. handleStop();
  390. if (callBack && typeof callBack === "function") {
  391. callBack(item);
  392. }
  393. }, 300);
  394. }
  395. };
  396. const handleStop = () => {
  397. if (data.noteAudio) {
  398. data.noteAudio.stop();
  399. data.realKey = 0;
  400. data.noteAudio = null as unknown as Howl;
  401. }
  402. };
  403. const isLongPress = ref(false); // 是否长按
  404. const isTouchStart = ref(false); // 是否长按
  405. let isTouch = false;
  406. let timerNoteId: any;
  407. const longPressDuration = 200;
  408. const onLongPress = () => {
  409. console.log("长按检测成功!");
  410. isLongPress.value = true;
  411. clearTimeout(noteTimer);
  412. };
  413. // 开始长按检测
  414. const startNotePress = async (note: any, isScrollShowNote = true) => {
  415. if (playStatus.gamut) return;
  416. if (playAction.listenLock) return;
  417. if (playAction.showAnswerLoading) return;
  418. timerNoteId = setTimeout(onLongPress, longPressDuration);
  419. // 为了处理希沃白板垃圾事件
  420. if (isTouchStart.value) return;
  421. isTouchStart.value = true;
  422. if (playStatus.action) {
  423. playAction.userAnswer = note;
  424. // 判断用户答题
  425. const userResult = note.realKey === playAction.standardAnswer.realKey ? 1 : 2;
  426. playAction.userAnswerStatus = userResult;
  427. playAction.listenLock = true;
  428. data.realKey = note.realKey;
  429. noteClick(note, true, isScrollShowNote, false, playCallBack);
  430. } else {
  431. handleStop();
  432. noteClick(note, true, isScrollShowNote);
  433. }
  434. };
  435. // 取消长按检测
  436. const cancelNotePress = async (note: any, isScrollShowNote = true) => {
  437. if (timerNoteId !== null) {
  438. clearTimeout(timerNoteId);
  439. timerNoteId = null;
  440. }
  441. if (isLongPress.value) {
  442. handleStop();
  443. playCallBack(note);
  444. }
  445. if (isLongPress.value) {
  446. isLongPress.value = false;
  447. }
  448. isTouchStart.value = false;
  449. console.log(isLongPress.value, timerNoteId, note.realName);
  450. };
  451. const playCallBack = (note: any) => {
  452. if (playAction.listenLock) {
  453. const userResult = note.realKey === playAction.standardAnswer.realKey ? 1 : 2;
  454. resetMode(userResult === 1 ? true : false, 0);
  455. data.realKey = 0;
  456. // 如果是指法模式显示完之后要还原
  457. if (data.fingeringMode === "fingeringMode" && userResult === 2) {
  458. // 延迟显示,因为重置的时候有一个异步操作
  459. setTimeout(() => {
  460. data.realKey = playAction.standardAnswer.realKey;
  461. }, 10);
  462. }
  463. playAction.listenLock = false;
  464. }
  465. };
  466. /** 点击音符播放 */
  467. const noteInstrumentPlay = async (note: any, isScroll = false) => {
  468. // 判断是否在播放音阶
  469. if (playStatus.gamut) return;
  470. if (playAction.listenLock) return;
  471. if (playAction.showAnswerLoading) return;
  472. if (playStatus.action) {
  473. playAction.userAnswer = note;
  474. // 判断用户答题
  475. const userResult = note.realKey === playAction.standardAnswer.realKey ? 1 : 2;
  476. playAction.userAnswerStatus = userResult;
  477. playAction.listenLock = true;
  478. data.realKey = note.realKey;
  479. await fingeringPlay(note, 1000);
  480. resetMode(userResult === 1 ? true : false, 0);
  481. data.realKey = 0;
  482. // 如果是指法模式显示完之后要还原
  483. if (data.fingeringMode === "fingeringMode" && userResult === 2) {
  484. // 延迟显示,因为重置的时候有一个异步操作
  485. setTimeout(() => {
  486. data.realKey = playAction.standardAnswer.realKey;
  487. }, 10);
  488. }
  489. playAction.listenLock = false;
  490. } else {
  491. noteClick(note, true, isScroll);
  492. }
  493. };
  494. /** 返回 */
  495. const handleBack = () => {
  496. // platform: query.platform,
  497. handleStop();
  498. if (props.isComponent) {
  499. // 返回的时候默认横屏
  500. // api_setRequestedOrientation(0);
  501. emit("close");
  502. return;
  503. } else if (state.platform === IPlatform.PC) {
  504. console.log(1, query);
  505. if (query.matchMedia == 1) {
  506. // 老师端,首页
  507. window.parent.postMessage(
  508. {
  509. api: "iframe_exit",
  510. },
  511. "*"
  512. );
  513. return;
  514. } else {
  515. window.close();
  516. return;
  517. }
  518. // if (fingerData.fingeringInfo.orientation === 0) {
  519. // api_setRequestedOrientation(1);
  520. // }
  521. }
  522. // 不在APP中,
  523. if (!storeData.isApp) {
  524. window.close();
  525. return;
  526. }
  527. api_back();
  528. };
  529. // 排箫,默认0.9显示
  530. const setDefaultScale = () => {
  531. if (data.subject === "pan-flute") {
  532. data.transform.scale = 0.9;
  533. data.transform.startScale = 0.9;
  534. }
  535. };
  536. onMounted(() => {
  537. loadElement();
  538. api_setStatusBarVisibility();
  539. });
  540. // 判断两个元素是否重叠
  541. const isElementOverlapping = (el1: any, el2: any) => {
  542. const rect1 = el1?.getBoundingClientRect();
  543. const rect2 = el2?.getBoundingClientRect();
  544. return !(rect1.right < rect2.left || rect1.left > rect2.right || rect1.bottom < rect2.top || rect1.top > rect2.bottom);
  545. };
  546. // 是否在拖拽
  547. const isDragging = ref(false);
  548. const loadElement = () => {
  549. const fingeringContainer = document.getElementById("fingeringContainer");
  550. setDefaultScale();
  551. // console.log("🚀 ~ fingeringContainer:", fingeringContainer);
  552. const mc = new Hammer.Manager(fingeringContainer as HTMLElement);
  553. mc.add(new Hammer.Pan({ threshold: 0, pointers: 0 }));
  554. mc.add(new Hammer.Pinch({ threshold: 0 })).recognizeWith([mc.get("pan")]);
  555. let dragTimeout: any;
  556. mc.on("panstart pinchstart", function (ev) {
  557. isDragging.value = true;
  558. clearTimeout(dragTimeout);
  559. data.transform.transition = "";
  560. });
  561. mc.on("panmove pinchmove", function (ev) {
  562. if (ev.type === "pinchmove") {
  563. // console.log("🚀 ~ ev:", ev.type, ev.scale, ev.deltaX, ev.deltaY);
  564. data.transform.scale = ev.scale * data.transform.startScale;
  565. data.transform.x = data.transform.startX + ev.deltaX;
  566. data.transform.y = data.transform.startY + ev.deltaY;
  567. // 使用示例
  568. const element1 = document.getElementById("fullInstrumentImg");
  569. const element2 = document.getElementById("fullInstrumentUserTab");
  570. data.domOverlapping = isElementOverlapping(element1, element2);
  571. }
  572. if (ev.type === "panmove") {
  573. // console.log("🚀 ~ ev:", ev.type, ev.deltaX, ev.deltaY);
  574. data.transform.x = data.transform.startX + ev.deltaX;
  575. data.transform.y = data.transform.startY + ev.deltaY;
  576. // 使用示例
  577. const element1 = document.getElementById("fullInstrumentImg");
  578. const element2 = document.getElementById("fullInstrumentUserTab");
  579. data.domOverlapping = isElementOverlapping(element1, element2);
  580. }
  581. });
  582. mc.on("panend pinchend", function (ev) {
  583. dragTimeout = setTimeout(() => {
  584. isDragging.value = false;
  585. }, 100); // 设置一个短暂的延迟以确保拖拽操作结束
  586. });
  587. //
  588. mc.on("hammer.input", function (ev) {
  589. if (ev.isFinal) {
  590. // isDragging.value = false;
  591. data.transform.startScale = data.transform.scale;
  592. data.transform.startX = data.transform.x;
  593. data.transform.startY = data.transform.y;
  594. // 使用示例
  595. const element1 = document.getElementById("fullInstrumentImg");
  596. const element2 = document.getElementById("fullInstrumentUserTab");
  597. data.domOverlapping = isElementOverlapping(element1, element2);
  598. }
  599. });
  600. };
  601. const resetElement = () => {
  602. data.transform.transition = "all 0.3s";
  603. nextTick(() => {
  604. data.transform.scale = data.subject === "pan-flute" ? 0.9 : 1;
  605. data.transform.x = 0;
  606. data.transform.y = 0;
  607. data.transform.startScale = data.subject === "pan-flute" ? 0.9 : 1;
  608. data.transform.startX = 0;
  609. data.transform.startY = 0;
  610. data.domOverlapping = false;
  611. });
  612. };
  613. // 判断乐器是否移动
  614. const instrumentTranstion = computed(() => {
  615. const transform = data.transform;
  616. let scale = 1;
  617. if (data.subject === "pan-flute") {
  618. scale = 0.9;
  619. }
  620. if (transform.scale !== scale || transform.x !== 0 || transform.y !== 0 || transform.startScale !== scale || transform.startX !== 0 || transform.startY !== 0) {
  621. return true;
  622. } else {
  623. return false;
  624. }
  625. });
  626. const pageVisible = usePageVisibility();
  627. watch(
  628. () => pageVisible.value,
  629. (val) => {
  630. if (val === "hidden") {
  631. clearTimeout(playAction.timer);
  632. playAction.listenLock = false;
  633. playAction.listenTipsStatus = false;
  634. playAction.exampleAnser = {};
  635. resetMode(true, 0);
  636. handleStop();
  637. gaumntPause();
  638. }
  639. }
  640. );
  641. watch(
  642. () => data.tipShow,
  643. (val: any) => {
  644. if (!val) {
  645. onResize();
  646. }
  647. }
  648. );
  649. /** 课件播放 */
  650. const changePlay = (res: any) => {
  651. if (res?.data?.api === "setPlayState") {
  652. clearTimeout(playAction.timer);
  653. playAction.listenLock = false;
  654. playAction.listenTipsStatus = false;
  655. playAction.exampleAnser = {};
  656. resetMode(true, 0);
  657. handleStop();
  658. gaumntPause();
  659. // 重置乐器
  660. if (res?.data?.data?.code) {
  661. data.subject = code;
  662. data.viewIndex = 0;
  663. data.tipShow = false;
  664. data.loadingDom = true;
  665. fingerData.fingeringInfo = subjectFingering(data.subject);
  666. data.activeTone = {} as any;
  667. data.popupActiveTone = {} as any;
  668. resetElement();
  669. // 设置屏幕方向
  670. setTimeout(() => {
  671. __init();
  672. }, 100);
  673. }
  674. } else if (res.data.api === "startPlayState") {
  675. onStartPlayState();
  676. }
  677. };
  678. const onStartPlayState = () => {
  679. if (!localStorage.getItem("fingerGuideKey")) return;
  680. if (!(props.show && !data.loading && !data.loadingSoundFonts)) return;
  681. if (data.changeSubjectShow) return;
  682. if (data.fingeringMode === "fingeringMode" || data.fingeringMode === "listenMode") {
  683. onActionPlay();
  684. }
  685. };
  686. const noteBoxRef = ref();
  687. const scrollNoteBox = (type: "left" | "right") => {
  688. const domOffsetWidth = noteBoxRef.value.offsetWidth;
  689. const width = domOffsetWidth / 2;
  690. const scrollLeft: any = noteBoxRef.value.scrollLeft;
  691. // 判断是否移动到最左边
  692. if (width >= scrollLeft && type === "left") {
  693. // 不管当前显示在哪个音老师滚动到开始位置
  694. (noteBoxRef.value as unknown as HTMLElement).scroll({
  695. left: 0,
  696. top: 0,
  697. behavior: "smooth",
  698. });
  699. return;
  700. }
  701. // 处理在部分手机点击左右会超出范围
  702. if (type === "right") {
  703. // 遍历子元素并累加它们的宽度
  704. let childElementsWidth = 0;
  705. for (let i = 0; i < noteBoxRef.value.children.length; i++) {
  706. childElementsWidth += noteBoxRef.value.children[i].offsetWidth;
  707. }
  708. // 判断是否移动到最右边
  709. if (width > childElementsWidth - scrollLeft - domOffsetWidth) {
  710. // 不管当前显示在哪个音老师滚动到开始位置
  711. (noteBoxRef.value as unknown as HTMLElement).scroll({
  712. left: noteBoxRef.value.scrollWidth,
  713. top: 0,
  714. behavior: "smooth",
  715. });
  716. return;
  717. }
  718. }
  719. (noteBoxRef.value as unknown as HTMLElement).scrollBy({
  720. left: type === "left" ? -width : width,
  721. behavior: "smooth",
  722. });
  723. };
  724. const playStatus = reactive({
  725. gamut: false, // 是否播放音阶
  726. gamutTimer: null as any, // 播放音阶定时器
  727. answer: false, // 是否显示答案
  728. action: false, // 是否开始播放
  729. });
  730. /** 音符切换 */
  731. const noteChangeShow = () => {
  732. if (playStatus.action) {
  733. if (playAction.listenLock) return;
  734. playAction.resetAction = true;
  735. resetMode(true, 0);
  736. }
  737. // // 播放音阶时不能切换
  738. // if (playStatus.gamut) return;
  739. // // 开始答题不能切换
  740. // if (playStatus.action) return;
  741. playStatus.gamut = false;
  742. gaumntPause();
  743. if (data.noteType === "all") {
  744. data.noteType = "#c";
  745. } else {
  746. data.noteType = "all";
  747. }
  748. getNotes();
  749. setTimeout(() => {
  750. (noteBoxRef.value as unknown as HTMLElement).scroll({
  751. left: 0,
  752. top: 0,
  753. behavior: "smooth",
  754. });
  755. }, 0);
  756. setTimeout(() => {
  757. playAction.resetAction = false;
  758. }, 2000);
  759. };
  760. // 开始播放音阶
  761. const onGamutPlayOrPause = async () => {
  762. playAction.resetAction = false;
  763. if (playStatus.gamut) {
  764. playStatus.gamut = false;
  765. gaumntPause();
  766. } else {
  767. // 不管当前显示在哪个音老师滚动到开始位置
  768. (noteBoxRef.value as unknown as HTMLElement).scroll({
  769. left: 0,
  770. top: 0,
  771. behavior: "smooth",
  772. });
  773. playStatus.gamut = true;
  774. const notes = data.notes;
  775. let scrollCount = 0;
  776. for (let i = 0; i < notes.length; i++) {
  777. if (!playStatus.gamut) return false;
  778. const activeDom = document.querySelectorAll(".note-class")[i] as any;
  779. if (activeDom.offsetLeft >= noteBoxRef.value.offsetWidth + (noteBoxRef.value.offsetWidth / 2) * scrollCount - activeDom.offsetWidth) {
  780. scrollNoteBox("right");
  781. scrollCount++;
  782. }
  783. await gaumtPlay(notes[i]);
  784. }
  785. // // 处理播放到最后一个
  786. setTimeout(() => {
  787. playStatus.gamut = false;
  788. gaumntPause();
  789. }, 667);
  790. }
  791. };
  792. const gaumtPlay = (note: any, status?: boolean) => {
  793. return new Promise((resolve) => {
  794. playStatus.gamutTimer = setTimeout(() => {
  795. if (playStatus.gamut || status) {
  796. noteClick(note);
  797. }
  798. resolve(note);
  799. }, 667);
  800. });
  801. };
  802. const gaumntPause = () => {
  803. clearTimeout(playStatus.gamutTimer);
  804. if (data.noteAudio) {
  805. data.noteAudio.stop();
  806. data.realKey = 0;
  807. data.noteAudio = null as unknown as Howl;
  808. }
  809. };
  810. /** 开始播放 */
  811. const playAction = reactive({
  812. exampleAnser: {} as any, // 示例声音
  813. standardAnswer: {} as any, // 标准答案key
  814. showAnswerLoading: false, // 显示按答案中
  815. listenModeStatus: false, // 是否开始了模式
  816. listenLock: false,
  817. listenTipsStatus: false, // 开始播放状态
  818. resetAction: false, // 是否重置
  819. /** 0: 未答,1: 答对,2: 答错 */
  820. userAnswerStatus: 0 as 0 | 1 | 2, // 用户回答状态
  821. userAnswer: {} as any, // 用户答的数据
  822. timer: null as any,
  823. });
  824. const onActionPlay = async () => {
  825. playAction.resetAction = false;
  826. if (playAction.listenLock) return;
  827. if (playAction.showAnswerLoading) return;
  828. playStatus.action = true;
  829. playStatus.answer = true;
  830. // 先暂停播放声音
  831. gaumntPause();
  832. if (data.fingeringMode === "fingeringMode") {
  833. onFingeringMode();
  834. } else if (data.fingeringMode === "listenMode") {
  835. if (playAction.listenModeStatus) {
  836. playAction.listenLock = true;
  837. await fingeringPlay(playAction.standardAnswer, 1500, false);
  838. gaumntPause();
  839. playAction.listenLock = false;
  840. } else {
  841. onListenMode();
  842. }
  843. }
  844. };
  845. // 指法模式
  846. const fingeringPlay = (note: any, timer = 1500, showNote = true) => {
  847. return new Promise((resolve) => {
  848. noteClick(note, showNote);
  849. playAction.timer = setTimeout(() => {
  850. resolve(note);
  851. }, timer);
  852. });
  853. };
  854. const onFingeringMode = () => {
  855. const randomIndex = Math.floor(Math.random() * data.notes.length);
  856. playAction.standardAnswer = data.notes[randomIndex];
  857. data.realKey = data.notes[randomIndex].realKey;
  858. if (playAction.listenModeStatus) {
  859. return;
  860. }
  861. playAction.listenModeStatus = true; // 是否开始听音
  862. playAction.listenLock = true; // 锁
  863. playAction.listenTipsStatus = true;
  864. playAction.timer = setTimeout(() => {
  865. playAction.listenTipsStatus = false;
  866. playAction.listenLock = false; // 锁
  867. }, 2000);
  868. };
  869. // 听音模式
  870. const onListenMode = async () => {
  871. playAction.listenModeStatus = true; // 是否开始听音
  872. playAction.listenLock = true; // 锁
  873. playAction.listenTipsStatus = true;
  874. // 设置并保存示例数据
  875. let randomIndex = data.notes.findIndex((item: any) => item.realKey === 69); // Math.floor(Math.random() * data.notes.length);
  876. playAction.exampleAnser = data.notes[randomIndex];
  877. data.realKey = playAction.exampleAnser.realKey;
  878. scrollAnswer(playAction.exampleAnser.realKey);
  879. await fingeringPlay(playAction.exampleAnser);
  880. data.realKey = 0;
  881. playAction.exampleAnser = {};
  882. gaumntPause();
  883. playAction.timer = setTimeout(async () => {
  884. // 设置答题数据
  885. randomIndex = Math.floor(Math.random() * data.notes.length);
  886. playAction.standardAnswer = data.notes[randomIndex];
  887. await fingeringPlay(data.notes[randomIndex], 1500, false);
  888. gaumntPause();
  889. playAction.listenLock = false;
  890. playAction.listenTipsStatus = false;
  891. }, 1000);
  892. };
  893. // 显示答案
  894. const onShowAnswer = async () => {
  895. if (playAction.listenLock) return;
  896. playAction.showAnswerLoading = true;
  897. scrollAnswer(playAction.standardAnswer.realKey);
  898. await fingeringPlay(playAction.standardAnswer);
  899. resetMode(true, 0);
  900. // }
  901. };
  902. // 滚动到对应答案位置
  903. const scrollAnswer = (realKey?: any) => {
  904. const tempRealKey = realKey || data.realKey;
  905. const index = data.notes.findIndex((item: any) => item.realKey === tempRealKey);
  906. const activeDom = document.querySelectorAll(".note-class")[index] as any;
  907. if (activeDom) {
  908. const aWidth = activeDom.offsetWidth;
  909. const width = noteBoxRef.value.offsetWidth;
  910. const aLeft = Math.max(activeDom?.offsetLeft - aWidth, 0);
  911. (noteBoxRef.value as unknown as HTMLElement).scroll({
  912. left: Math.max(aLeft - width / 2, 0),
  913. top: 0,
  914. behavior: "smooth",
  915. });
  916. }
  917. };
  918. /**
  919. * 重置播放状态
  920. * @param status 是否全部重置
  921. * @param timer 延时时长(默认2s)
  922. */
  923. const resetMode = (status = true, timer = 2000) => {
  924. // 2秒钟后重置
  925. setTimeout(() => {
  926. gaumntPause();
  927. if (status) {
  928. playAction.standardAnswer = {};
  929. playAction.showAnswerLoading = false;
  930. playAction.userAnswerStatus = 0;
  931. playAction.userAnswer = {};
  932. playAction.listenModeStatus = false;
  933. playStatus.action = false;
  934. playStatus.answer = false;
  935. playStatus.gamut = false;
  936. data.realKey = 0;
  937. } else {
  938. playAction.userAnswerStatus = 0;
  939. playAction.userAnswer = {};
  940. }
  941. }, timer);
  942. };
  943. /** 滚轮缩放 */
  944. const handleWheel = (e: WheelEvent) => {
  945. e.preventDefault();
  946. if (e.deltaY > 0) {
  947. data.transform.scale -= 0.1;
  948. if (data.transform.scale <= 0.5) {
  949. data.transform.scale = 0.5;
  950. }
  951. } else {
  952. data.transform.scale += 0.1;
  953. if (data.transform.scale >= 2) {
  954. data.transform.scale = 2;
  955. }
  956. }
  957. // 使用示例
  958. setTimeout(() => {
  959. const element1 = document.getElementById("fullInstrumentImg");
  960. const element2 = document.getElementById("fullInstrumentUserTab");
  961. data.domOverlapping = isElementOverlapping(element1, element2);
  962. }, 0);
  963. };
  964. const onResize = () => {
  965. nextTick(() => {
  966. setTimeout(() => {
  967. const element1: any = document.querySelector("#fullInstrumentImg");
  968. // console.log(element1, "element1");
  969. const rect = element1?.getBoundingClientRect();
  970. data.domOverImgPropery = {
  971. ...rect,
  972. width: rect.width * (1 / data.transform.scale) + "px",
  973. height: rect.height * (1 / data.transform.scale) + "px",
  974. };
  975. }, 330);
  976. });
  977. };
  978. onMounted(() => {
  979. window.addEventListener("message", changePlay);
  980. window.addEventListener("resize", onResize);
  981. const fingeringContainer = document.getElementById("fingeringContainer");
  982. fingeringContainer?.addEventListener("wheel", handleWheel);
  983. document.addEventListener("keydown", (e: KeyboardEvent) => {
  984. if (e.code === "Tab") {
  985. e.stopPropagation();
  986. e.preventDefault();
  987. // onStartPlayState();
  988. // 判断是否在应用中
  989. window.parent.postMessage(
  990. {
  991. api: "documentBodyKeyup",
  992. code: "Tab",
  993. },
  994. "*"
  995. );
  996. }
  997. });
  998. });
  999. onUnmounted(() => {
  1000. window.removeEventListener("message", changePlay);
  1001. window.removeEventListener("resize", onResize);
  1002. const fingeringContainer = document.getElementById("fingeringContainer");
  1003. fingeringContainer?.removeEventListener("wheel", handleWheel);
  1004. document.title = "Ai学练";
  1005. });
  1006. const containerBox = computed(() => {
  1007. if (state.platform === IPlatform.PC || query.modelType) {
  1008. return {
  1009. paddingTop: "1.3rem",
  1010. paddingBottom: "",
  1011. };
  1012. }
  1013. if (data.fingeringMode === "scaleMode") {
  1014. if (data.subject === "hulusi-flute") {
  1015. return {
  1016. paddingTop: "1.3rem",
  1017. paddingBottom: ".5rem",
  1018. };
  1019. } else if (data.subject === "piccolo" || data.subject === "baroque-recorder") {
  1020. return {
  1021. paddingTop: "1.3rem",
  1022. paddingBottom: ".5rem",
  1023. };
  1024. } else if (data.subject === "pan-flute") {
  1025. return {
  1026. paddingTop: "1.3rem",
  1027. paddingBottom: "0",
  1028. };
  1029. } else if (data.subject === "ocarina" || data.subject === "whistling") {
  1030. return {
  1031. paddingTop: "1.3rem",
  1032. paddingBottom: "0",
  1033. };
  1034. } else if (data.subject === "melodica") {
  1035. return {
  1036. paddingTop: "1.8rem",
  1037. paddingBottom: "0.2rem",
  1038. };
  1039. } else {
  1040. return {
  1041. paddingTop: "",
  1042. paddingBottom: "",
  1043. };
  1044. }
  1045. } else {
  1046. if (data.subject === "hulusi-flute") {
  1047. return {
  1048. paddingTop: "1.3rem",
  1049. paddingBottom: "0rem",
  1050. };
  1051. } else if (data.subject === "piccolo" || data.subject === "baroque-recorder") {
  1052. return {
  1053. paddingTop: "1.3rem",
  1054. paddingBottom: ".5rem",
  1055. };
  1056. } else if (data.subject === "pan-flute") {
  1057. return {
  1058. paddingTop: "1.3rem",
  1059. paddingBottom: "0",
  1060. };
  1061. } else if (data.subject === "ocarina" || data.subject === "whistling") {
  1062. return {
  1063. paddingTop: "1.3rem",
  1064. paddingBottom: "0",
  1065. };
  1066. } else if (data.subject === "melodica") {
  1067. return {
  1068. paddingTop: "1.8rem",
  1069. paddingBottom: "0.2rem",
  1070. };
  1071. } else {
  1072. return {
  1073. paddingTop: "",
  1074. paddingBottom: "",
  1075. };
  1076. }
  1077. }
  1078. });
  1079. const listenText = computed(() => {
  1080. if (data.fingeringMode === "fingeringMode") {
  1081. if (playStatus.action) {
  1082. return "换一换";
  1083. } else {
  1084. return "开始练习";
  1085. }
  1086. } else if (data.fingeringMode === "listenMode") {
  1087. if (playStatus.action) {
  1088. return "再听一遍";
  1089. } else {
  1090. return "开始听音";
  1091. }
  1092. }
  1093. return "开始听音";
  1094. });
  1095. const modeText = computed(() => {
  1096. let text = "";
  1097. let icon = icons.icon_mode;
  1098. data.fingeringModeList.forEach((item: any) => {
  1099. if (item.value === data.fingeringMode) {
  1100. text = item.text;
  1101. icon = item.icon;
  1102. }
  1103. });
  1104. return {
  1105. text,
  1106. icon,
  1107. };
  1108. });
  1109. // 屏幕方向 0 竖,1 横
  1110. const orientationDirection = computed(() => {
  1111. return ["hulusi-flute", "piccolo", "baroque-recorder"].includes(data.subject) ? 1 : 0;
  1112. });
  1113. const resultImg = (note: any) => {
  1114. if (data.realKey === note.realKey && !playStatus.action) {
  1115. return {
  1116. icon: icons.icon_btn_ylow,
  1117. status: false,
  1118. };
  1119. } else if (playAction.exampleAnser.realKey === note.realKey) {
  1120. return {
  1121. icon: icons.icon_btn_ylow,
  1122. status: false,
  1123. };
  1124. } else if (playAction.standardAnswer.realKey === note.realKey) {
  1125. // 没有开始答题
  1126. if (!playStatus.action) {
  1127. return {
  1128. icon: icons.icon_btn_ylow,
  1129. status: false,
  1130. };
  1131. }
  1132. // 显示答案中
  1133. if (playAction.showAnswerLoading) {
  1134. return {
  1135. icon: icons.icon_btn_green,
  1136. status: true,
  1137. };
  1138. }
  1139. // 用户答对
  1140. if (playAction.userAnswerStatus === 1) {
  1141. return {
  1142. icon: icons.icon_btn_green,
  1143. status: true,
  1144. };
  1145. }
  1146. } else {
  1147. // 用户答错
  1148. if (playAction.userAnswerStatus === 2 && playAction.userAnswer.realKey === note.realKey) {
  1149. return {
  1150. icon: icons.icon_btn_red,
  1151. status: true,
  1152. };
  1153. }
  1154. }
  1155. return {
  1156. icon: icons.icon_btn_blue,
  1157. status: true,
  1158. };
  1159. };
  1160. const userTabActive = ref<"1" | "2">("1");
  1161. const userTabs = [
  1162. {
  1163. name: "音阶",
  1164. value: "1",
  1165. },
  1166. {
  1167. name: "功能",
  1168. value: "2",
  1169. },
  1170. ];
  1171. // 引导页
  1172. const { guidanceShow, setGuidanceShow } = useDragGuidance();
  1173. // 切换乐器弹窗
  1174. let changeSubjectShowBoxDragData: any;
  1175. let changeSubjectShowBoxClass: string;
  1176. if (query.platform === "pc") {
  1177. changeSubjectShowBoxClass = "changeSubjectShowBoxClass_drag";
  1178. changeSubjectShowBoxDragData = useDrag([`${changeSubjectShowBoxClass} .dragTopBox`, `${changeSubjectShowBoxClass} .dragbomBox`], changeSubjectShowBoxClass, toRef(data, "changeSubjectShow"), storeData.user.id as string);
  1179. }
  1180. // 移调弹窗
  1181. let tnoteShowBoxDragData: any;
  1182. let tnoteShowBoxClass: string;
  1183. if (query.platform === "pc") {
  1184. tnoteShowBoxClass = "tnoteShowBoxClass_drag";
  1185. tnoteShowBoxDragData = useDrag([`${tnoteShowBoxClass} .dragTopBox`, `${tnoteShowBoxClass} .dragbomBox`], tnoteShowBoxClass, toRef(data, "tnoteShow"), storeData.user.id as string);
  1186. }
  1187. return () => {
  1188. const relationship = fingerData.subject?.relationship?.[data.realKey] || [];
  1189. const rs: number[] = Array.isArray(relationship[1]) ? relationship[fingerData.relationshipIndex] : relationship;
  1190. const canTizhi = Array.isArray(relationship[1]);
  1191. return (
  1192. <div
  1193. class={[styles.fingerBox, state.platform !== IPlatform.PC && !query.modelType && fingerData.fingeringInfo.orientation === 1 ? styles.fingerBottom : styles.fingerRight, data.linkSource === "class" ? styles.linkSourceClass : ""]}
  1194. onClick={() => {
  1195. if (data.linkSource === "class") {
  1196. window.parent.postMessage(
  1197. {
  1198. api: "clickViewFigner",
  1199. },
  1200. "*"
  1201. );
  1202. }
  1203. }}
  1204. >
  1205. {/* 老师端过来隐藏 */}
  1206. {query.platform !== "pc" && (
  1207. <div
  1208. class={styles.head}
  1209. style={{
  1210. paddingTop: data.paddingTop && !browser().ios ? data.paddingTop : "",
  1211. paddingLeft: data.paddingLeft && !browser().ios ? data.paddingLeft : "",
  1212. }}
  1213. >
  1214. <div class={styles.left}>
  1215. <button class={[styles.backBtn]} onClick={() => handleBack()}>
  1216. <img src={icons.icon_back} />
  1217. </button>
  1218. <div
  1219. class={[styles.baseBtn, styles.changeInstrumentBtn]}
  1220. onClick={(e) => {
  1221. e.stopPropagation();
  1222. //
  1223. // 播放音阶时不能切换
  1224. if (playStatus.gamut) {
  1225. return;
  1226. }
  1227. // 开始答题不能切换
  1228. if (playAction.listenLock) {
  1229. return;
  1230. }
  1231. data.changeSubjectShow = true;
  1232. }}
  1233. >
  1234. <img src={icons.icon_change_instrument} />
  1235. <span>切换乐器</span>
  1236. </div>
  1237. <div class={styles.baseBtn} onClick={onChangeFingeringModel}>
  1238. <img src={modeText.value.icon} />
  1239. <span>{modeText.value.text}</span>
  1240. </div>
  1241. {/* */}
  1242. </div>
  1243. {/* */}
  1244. </div>
  1245. )}
  1246. <div
  1247. class={styles.fingerContent}
  1248. style={{
  1249. paddingTop: data.paddingTop ? data.paddingTop : "",
  1250. paddingLeft: data.paddingLeft ? data.paddingLeft : "",
  1251. }}
  1252. >
  1253. <div class={styles.wrapFinger}>
  1254. <div
  1255. id="fingeringContainer"
  1256. class={[styles.boxFinger, query.platform === "pc" ? styles.pcBoxFinger : "", data.domOverlapping && data.notePoints?.length > 0 && styles.boxFingerOverlapping]}
  1257. style={{
  1258. paddingTop: containerBox.value.paddingTop,
  1259. paddingBottom: containerBox.value.paddingBottom,
  1260. }}
  1261. >
  1262. <div
  1263. style={{
  1264. transform: `translate3d(${data.transform.x}px,${data.transform.y}px,0px) scale(${data.transform.scale})`,
  1265. transition: data.transform.transition,
  1266. }}
  1267. class={[styles.fingeringContainer]}
  1268. >
  1269. <div class={styles.imgs}>
  1270. {!data.loadingImg && <img id="fullInstrumentImg" src={data.fingeringMode === "scaleMode" ? fingerData.subject?.json?.full : fingerData.subject?.json?.full1} />}
  1271. {rs.map((key: number | string, index: number) => {
  1272. const nk: string = typeof key === "string" ? key.replace("active-", "") : String(key);
  1273. return <img class={styles.showImgNk} data-index={nk} src={fingerData.subject?.json?.[nk]} />;
  1274. })}
  1275. <div style={{ left: data.viewIndex == 2 ? "0" : "64%" }} class={[styles.tizhi, canTizhi && styles.canDisplay]} onClick={() => (fingerData.relationshipIndex = fingerData.relationshipIndex === 0 ? 1 : 0)}>
  1276. 替指
  1277. </div>
  1278. <div id="finger-note-2" style={{ left: "50%", transform: "translateX(-50%)" }} class={styles.tizhi} onClick={() => (fingerData.relationshipIndex = fingerData.relationshipIndex === 0 ? 1 : 0)}></div>
  1279. {data.notePoints?.length > 0 && (
  1280. <div
  1281. class={[styles.fingeringPointSection]}
  1282. style={{
  1283. width: data.domOverImgPropery.width,
  1284. height: data.domOverImgPropery.height,
  1285. }}
  1286. >
  1287. <div class={[styles[data.subject], data.viewIndex === 2 && data.subject === "pan-flute" && styles["pan-flute-back"]]}>
  1288. {data.notePoints.map((point: any) => (
  1289. <div
  1290. class={styles.p1}
  1291. style={point.style}
  1292. // onClick={(e: any) => {
  1293. // e.stopPropagation();
  1294. // if (isDragging.value) return;
  1295. // noteInstrumentPlay(point, true);
  1296. // }}
  1297. onMousedown={(e: any) => {
  1298. e.stopPropagation();
  1299. e.preventDefault();
  1300. console.log("onMousedown", e);
  1301. if (isTouch) return;
  1302. startNotePress(point);
  1303. }}
  1304. onMouseup={(e: any) => {
  1305. e.stopPropagation();
  1306. e.preventDefault();
  1307. // console.log("onMouseup", e);
  1308. if (isTouch) return;
  1309. cancelNotePress(point);
  1310. }}
  1311. onMouseleave={(e: any) => {
  1312. e.stopPropagation();
  1313. e.preventDefault();
  1314. // console.log("onMouseleave", e);
  1315. if (isTouch) return;
  1316. cancelNotePress(point);
  1317. }}
  1318. onTouchstart={(e: any) => {
  1319. e.stopPropagation();
  1320. e.preventDefault();
  1321. // console.log("onTouchstart", e);
  1322. isTouch = true;
  1323. startNotePress(point);
  1324. }}
  1325. onTouchend={(e: any) => {
  1326. e.stopPropagation();
  1327. e.preventDefault();
  1328. // console.log("onTouchend", e);
  1329. cancelNotePress(point);
  1330. }}
  1331. onTouchcancel={(e: any) => {
  1332. e.stopPropagation();
  1333. e.preventDefault();
  1334. // console.log("onTouchcancel", e);
  1335. cancelNotePress(point);
  1336. }}
  1337. >
  1338. {point.children && (
  1339. <div
  1340. class={styles.p2}
  1341. // onClick={(e: any) => {
  1342. // e.stopPropagation();
  1343. // if (isDragging.value) return;
  1344. // noteInstrumentPlay(point.children, true);
  1345. // }}
  1346. onMousedown={(e: any) => {
  1347. e.stopPropagation();
  1348. e.preventDefault();
  1349. if (isTouch) return;
  1350. startNotePress(point.children);
  1351. }}
  1352. onMouseup={(e: any) => {
  1353. e.stopPropagation();
  1354. e.preventDefault();
  1355. if (isTouch) return;
  1356. cancelNotePress(point.children);
  1357. }}
  1358. onMouseleave={(e: any) => {
  1359. e.stopPropagation();
  1360. e.preventDefault();
  1361. if (isTouch) return;
  1362. cancelNotePress(point.children);
  1363. }}
  1364. onTouchstart={(e: any) => {
  1365. e.stopPropagation();
  1366. e.preventDefault();
  1367. isTouch = true;
  1368. startNotePress(point.children);
  1369. }}
  1370. onTouchend={(e: any) => {
  1371. e.stopPropagation();
  1372. e.preventDefault();
  1373. cancelNotePress(point.children);
  1374. }}
  1375. onTouchcancel={(e: any) => {
  1376. e.stopPropagation();
  1377. e.preventDefault();
  1378. cancelNotePress(point.children);
  1379. }}
  1380. style={point.children.style}
  1381. ></div>
  1382. )}
  1383. </div>
  1384. ))}
  1385. </div>
  1386. </div>
  1387. )}
  1388. </div>
  1389. </div>
  1390. </div>
  1391. {/* 老师端过来隐藏 */}
  1392. {query.platform === "pc" ? (
  1393. <div class={[styles.userTab, data.domOverlapping && data.notePoints?.length > 0 && styles.usrTabOverlaping]} id="fullInstrumentUserTab">
  1394. <Tabs v-model:active={userTabActive.value} class={styles.userTabBox}>
  1395. {userTabs.map((item) => {
  1396. return (
  1397. <Tab title={item.name} name={item.value}>
  1398. {item.value === "1" ? (
  1399. <>
  1400. <div
  1401. class={styles.notes}
  1402. style={{
  1403. paddingLeft: data.paddingLeft ? data.paddingLeft : "",
  1404. }}
  1405. >
  1406. {playAction.listenTipsStatus && <div class={[styles.tipsT, data.fingeringMode === "fingeringMode" ? styles.playTips2 : styles.playTips]}></div>}
  1407. {playAction.userAnswerStatus === 1 && <div class={[styles.tipsT, styles.playSuccess]}></div>}
  1408. {playAction.userAnswerStatus === 2 && <div class={[styles.tipsT, styles.playError]}></div>}
  1409. {playAction.resetAction && <div class={[styles.tipsT, styles.playTips5]}></div>}
  1410. <div class={[styles.backBtn, styles.changeMusBtn]} onClick={() => handleBack()}>
  1411. <span>返回</span>
  1412. </div>
  1413. <div class={styles.changeMusBtn} onClick={onChangeFingeringModel}>
  1414. <span>{modeText.value.text}</span>
  1415. </div>
  1416. <div
  1417. class={[styles.noteContent, data.fingeringMode !== "scaleMode" && orientationDirection.value === 0 && styles.noteContentOther, browsInfo.ios ? "" : styles.noteContentWrap, data.huaweiPad && styles.huaweiPad]}
  1418. onClick={(e: any) => {
  1419. e.stopPropagation();
  1420. }}
  1421. >
  1422. {((data.noteType !== "#c" && (orientationDirection.value === 0 || (orientationDirection.value === 1 && state.platform === IPlatform.PC))) || (orientationDirection.value === 1 && state.platform === IPlatform.APP)) && (
  1423. <Button
  1424. class={styles.noteBtn}
  1425. onClick={(e: any) => {
  1426. e.stopPropagation();
  1427. scrollNoteBox("left");
  1428. }}
  1429. >
  1430. <Icon name="arrow-left" />
  1431. </Button>
  1432. )}
  1433. {/* 判断是否为音阶模式 */}
  1434. {data.fingeringMode !== "scaleMode" && (
  1435. <div draggable={false} class={styles.note} onClick={noteChangeShow}>
  1436. <img draggable={false} src={data.noteType === "all" ? icons.icon_btn_orange : icons.icon_btn_orange2} />
  1437. </div>
  1438. )}
  1439. {!!data.tones.length && data.fingeringMode === "scaleMode" && (
  1440. <>
  1441. {fingerData.fingeringInfo.name == "hulusi-flute" ? (
  1442. <div id="finger-note-1" class={[styles.note, styles.btnGrToggleBtn]} onClick={() => (data.tnoteShow = true)}>
  1443. <img draggable={false} src={noteImg} />
  1444. <div class={styles.nameBox}>
  1445. <div class={styles.name}>全按作</div>
  1446. <div class={[styles.noteKey, styles.noteKeyBtn]}>
  1447. {data.activeTone.step > 0 ? <span class={styles.dot}></span> : null}
  1448. <div class={styles.noteName}>
  1449. <sup>{data.activeTone.mark && (data.activeTone.mark === "rise" ? "#" : "b")}</sup>
  1450. {data.activeTone.key}
  1451. </div>
  1452. {data.activeTone.step < 0 ? <span class={[styles.dot, styles.botDot]}></span> : null}
  1453. </div>
  1454. </div>
  1455. </div>
  1456. ) : (
  1457. <div id="finger-note-1" class={[styles.note, styles.btnGrToggleBtn]} onClick={() => (data.tnoteShow = true)}>
  1458. <img draggable={false} src={noteImg} />
  1459. <div>
  1460. <div class={styles.name}>
  1461. <div>
  1462. <sup>{data.activeTone.mark && (data.activeTone.mark === "rise" ? "#" : "b")}</sup>
  1463. {data.activeTone.name}
  1464. </div>
  1465. </div>
  1466. </div>
  1467. </div>
  1468. )}
  1469. </>
  1470. )}
  1471. {/* [styles.noteContent, browsInfo.ios ? "" : styles.noteContentWrap, data.huaweiPad && styles.huaweiPad] */}
  1472. <div class={styles.lastNoteContent}>
  1473. <div ref={noteBoxRef} class={styles.noteBox}>
  1474. {data.notes.map((note: IFIGNER_INSTRUMENT_Note, index: number) => {
  1475. const steps = new Array(Math.abs(note.step)).fill(1);
  1476. return (
  1477. <div
  1478. id={index == 0 ? "finger-note-0" : ""}
  1479. draggable={false}
  1480. class={[styles.note, "note-class"]}
  1481. key={note.realKey}
  1482. // onClick={async () => {
  1483. // noteInstrumentPlay(note);
  1484. // }}
  1485. onMousedown={(e: any) => {
  1486. e.stopPropagation();
  1487. e.preventDefault();
  1488. if (isTouch) return;
  1489. startNotePress(note, false);
  1490. }}
  1491. onMouseup={(e: any) => {
  1492. e.stopPropagation();
  1493. e.preventDefault();
  1494. if (isTouch) return;
  1495. cancelNotePress(note, false);
  1496. }}
  1497. onMouseleave={(e: any) => {
  1498. e.stopPropagation();
  1499. e.preventDefault();
  1500. if (isTouch) return;
  1501. cancelNotePress(note, false);
  1502. }}
  1503. onTouchstart={(e: any) => {
  1504. e.stopPropagation();
  1505. e.preventDefault();
  1506. isTouch = true;
  1507. startNotePress(note, false);
  1508. }}
  1509. onTouchend={(e: any) => {
  1510. e.stopPropagation();
  1511. e.preventDefault();
  1512. cancelNotePress(note, false);
  1513. }}
  1514. onTouchcancel={(e: any) => {
  1515. e.stopPropagation();
  1516. e.preventDefault();
  1517. cancelNotePress(note, false);
  1518. }}
  1519. >
  1520. <img draggable={false} src={resultImg(note).icon} />
  1521. {playStatus.action && ((playAction.showAnswerLoading && playAction.standardAnswer.realKey === note.realKey) || (playAction.userAnswerStatus === 1 && playAction.userAnswer.realKey === note.realKey)) ? <span class={styles.showAnswer}></span> : ""}
  1522. {playStatus.action && playAction.userAnswerStatus === 2 && playAction.userAnswer.realKey === note.realKey ? <span class={[styles.showAnswer, styles.errorAnswer]}></span> : ""}
  1523. <div
  1524. class={[
  1525. styles.noteKey,
  1526. ((data.realKey === note.realKey && !playStatus.action) ||
  1527. (playStatus.action && playAction.exampleAnser.realKey === note.realKey) ||
  1528. (playStatus.action && ((playAction.showAnswerLoading && playAction.standardAnswer.realKey === note.realKey) || (playAction.userAnswerStatus === 1 && playAction.userAnswer.realKey === note.realKey))) ||
  1529. (playStatus.action && playAction.userAnswerStatus === 2 && playAction.userAnswer.realKey === note.realKey)) &&
  1530. styles.keyActive,
  1531. ]}
  1532. >
  1533. {/* 显示对应的点 */}
  1534. {note.step > 0 ? steps.map((n: any) => <span class={styles.dot}></span>) : null}
  1535. <div class={styles.noteName}>
  1536. <sup>{note.mark && (note.mark === "rise" ? "#" : "b")}</sup>
  1537. {note.key}
  1538. </div>
  1539. {/* 显示对应的点 */}
  1540. {note.step < 0 ? steps.map((n: any) => <span class={styles.dot}></span>) : null}
  1541. </div>
  1542. </div>
  1543. );
  1544. })}
  1545. </div>
  1546. </div>
  1547. {((data.noteType !== "#c" && (orientationDirection.value === 0 || (orientationDirection.value === 1 && state.platform === IPlatform.PC))) || (orientationDirection.value === 1 && state.platform === IPlatform.APP)) && (
  1548. <Button
  1549. class={styles.noteBtn}
  1550. onClick={(e: any) => {
  1551. e.stopPropagation();
  1552. scrollNoteBox("right");
  1553. }}
  1554. >
  1555. <Icon name="arrow" />
  1556. </Button>
  1557. )}
  1558. </div>
  1559. </div>
  1560. {data.fingeringMode !== "scaleMode" && (
  1561. <div
  1562. class={styles.optionBtns}
  1563. onClick={(e: any) => {
  1564. e.stopPropagation();
  1565. }}
  1566. >
  1567. <Button class={[styles.oBtn, styles.gamut, playStatus.action && styles.disabled]} round onClick={onGamutPlayOrPause}>
  1568. {playStatus.gamut ? "暂停" : "播放音阶"}
  1569. </Button>
  1570. <Button class={[styles.oBtn, styles.play, playStatus.gamut && styles.disabled]} round onClick={onActionPlay}>
  1571. {listenText.value}
  1572. </Button>
  1573. <Button class={[styles.oBtn, styles.success, !playStatus.answer && styles.disabled]} round onClick={onShowAnswer}>
  1574. 显示答案
  1575. </Button>
  1576. </div>
  1577. )}
  1578. </>
  1579. ) : (
  1580. <>
  1581. <div class={styles.btnBox}>
  1582. <div class={styles.btnCon}>
  1583. <div
  1584. class={[styles.btnGr]}
  1585. onClick={(e) => {
  1586. e.stopPropagation();
  1587. //
  1588. // 播放音阶时不能切换
  1589. if (playStatus.gamut) {
  1590. return;
  1591. }
  1592. // 开始答题不能切换
  1593. if (playAction.listenLock) {
  1594. return;
  1595. }
  1596. data.changeSubjectShow = true;
  1597. }}
  1598. >
  1599. <img src={icons.icon_change_instrument} />
  1600. <span>切换乐器</span>
  1601. </div>
  1602. {data.subject !== "melodica" && data.fingeringMode === "scaleMode" && (
  1603. <div
  1604. class={styles.btnGr}
  1605. onClick={() => {
  1606. data.viewIndex++;
  1607. if (data.viewIndex > data.viewTotal) {
  1608. if (["pan-flute", "ocarina", "whistling"].includes(data.subject)) {
  1609. data.viewIndex = 1;
  1610. } else {
  1611. data.viewIndex = 0;
  1612. }
  1613. }
  1614. getFingeringData();
  1615. }}
  1616. >
  1617. <img src={icons.icon_toggle} />
  1618. <span>视图</span>
  1619. </div>
  1620. )}
  1621. <div
  1622. class={styles.btnGr}
  1623. onClick={() => {
  1624. resetElement();
  1625. data.tipShow = !data.tipShow;
  1626. onResize();
  1627. }}
  1628. >
  1629. <img src={icons.icon_2_1} />
  1630. <span>说明</span>
  1631. </div>
  1632. {instrumentTranstion.value && (
  1633. <div class={[styles.btnGr]} onClick={() => resetElement()}>
  1634. <img src={icons.icon_2_0} />
  1635. <span>还原</span>
  1636. </div>
  1637. )}
  1638. </div>
  1639. </div>
  1640. </>
  1641. )}
  1642. </Tab>
  1643. );
  1644. })}
  1645. </Tabs>
  1646. </div>
  1647. ) : (
  1648. <div class={[data.domOverlapping && data.notePoints?.length > 0 && styles.usrTabOverlapingNotes]} id="fullInstrumentUserTab">
  1649. <div
  1650. class={[styles.notes]}
  1651. style={{
  1652. paddingLeft: data.paddingLeft ? data.paddingLeft : "",
  1653. }}
  1654. >
  1655. {playAction.listenTipsStatus && <div class={[styles.tipsT, data.fingeringMode === "fingeringMode" ? styles.playTips2 : styles.playTips]}></div>}
  1656. {playAction.userAnswerStatus === 1 && <div class={[styles.tipsT, styles.playSuccess]}></div>}
  1657. {playAction.userAnswerStatus === 2 && <div class={[styles.tipsT, styles.playError]}></div>}
  1658. {playAction.resetAction && <div class={[styles.tipsT, styles.playTips5]}></div>}
  1659. {((data.noteType !== "#c" && (orientationDirection.value === 0 || (orientationDirection.value === 1 && state.platform === IPlatform.PC))) || (orientationDirection.value === 1 && state.platform === IPlatform.APP)) && (
  1660. <Button
  1661. class={styles.noteBtn}
  1662. onClick={(e: any) => {
  1663. e.stopPropagation();
  1664. scrollNoteBox("left");
  1665. }}
  1666. >
  1667. <Icon name="arrow-left" />
  1668. </Button>
  1669. )}
  1670. <div
  1671. class={[styles.noteContent, data.fingeringMode !== "scaleMode" && orientationDirection.value === 0 && styles.noteContentOther, browsInfo.ios ? "" : styles.noteContentWrap, data.huaweiPad && styles.huaweiPad]}
  1672. onClick={(e: any) => {
  1673. e.stopPropagation();
  1674. }}
  1675. >
  1676. {/* 判断是否为音阶模式 */}
  1677. {data.fingeringMode !== "scaleMode" && (
  1678. <div draggable={false} class={styles.note} onClick={noteChangeShow}>
  1679. <img draggable={false} src={data.noteType === "all" ? icons.icon_btn_orange : icons.icon_btn_orange2} />
  1680. </div>
  1681. )}
  1682. {/* [styles.noteContent, browsInfo.ios ? "" : styles.noteContentWrap, data.huaweiPad && styles.huaweiPad] */}
  1683. <div class={styles.lastNoteContent}>
  1684. <div ref={noteBoxRef} class={styles.noteBox} id="noteBox">
  1685. {data.notes.map((note: IFIGNER_INSTRUMENT_Note, index: number) => {
  1686. const steps = new Array(Math.abs(note.step)).fill(1);
  1687. return (
  1688. <div
  1689. id={index == 0 ? "finger-note-0" : ""}
  1690. draggable={false}
  1691. class={[styles.note, "note-class"]}
  1692. key={note.realKey}
  1693. // onClick={async () => {
  1694. // noteInstrumentPlay(note);
  1695. // }}
  1696. onMousedown={(e: any) => {
  1697. e.stopPropagation();
  1698. e.preventDefault();
  1699. if (isTouch) return;
  1700. startNotePress(note, false);
  1701. }}
  1702. onMouseup={(e: any) => {
  1703. e.stopPropagation();
  1704. e.preventDefault();
  1705. if (isTouch) return;
  1706. cancelNotePress(note, false);
  1707. }}
  1708. onMouseleave={(e: any) => {
  1709. e.stopPropagation();
  1710. e.preventDefault();
  1711. if (isTouch) return;
  1712. cancelNotePress(note, false);
  1713. }}
  1714. onTouchstart={(e: any) => {
  1715. e.stopPropagation();
  1716. e.preventDefault();
  1717. isTouch = true;
  1718. startNotePress(note, false);
  1719. }}
  1720. onTouchend={(e: any) => {
  1721. e.stopPropagation();
  1722. e.preventDefault();
  1723. cancelNotePress(note, false);
  1724. }}
  1725. onTouchcancel={(e: any) => {
  1726. e.stopPropagation();
  1727. e.preventDefault();
  1728. cancelNotePress(note, false);
  1729. }}
  1730. >
  1731. <img draggable={false} src={resultImg(note).icon} />
  1732. {playStatus.action && ((playAction.showAnswerLoading && playAction.standardAnswer.realKey === note.realKey) || (playAction.userAnswerStatus === 1 && playAction.userAnswer.realKey === note.realKey)) ? <span class={styles.showAnswer}></span> : ""}
  1733. {playStatus.action && playAction.userAnswerStatus === 2 && playAction.userAnswer.realKey === note.realKey ? <span class={[styles.showAnswer, styles.errorAnswer]}></span> : ""}
  1734. <div
  1735. class={[
  1736. styles.noteKey,
  1737. ((data.realKey === note.realKey && !playStatus.action) ||
  1738. (playStatus.action && playAction.exampleAnser.realKey === note.realKey) ||
  1739. (playStatus.action && ((playAction.showAnswerLoading && playAction.standardAnswer.realKey === note.realKey) || (playAction.userAnswerStatus === 1 && playAction.userAnswer.realKey === note.realKey))) ||
  1740. (playStatus.action && playAction.userAnswerStatus === 2 && playAction.userAnswer.realKey === note.realKey)) &&
  1741. styles.keyActive,
  1742. ]}
  1743. >
  1744. {/* 显示对应的点 */}
  1745. {note.step > 0 ? steps.map((n: any) => <span class={styles.dot}></span>) : null}
  1746. <div class={styles.noteName}>
  1747. <sup>{note.mark && (note.mark === "rise" ? "#" : "b")}</sup>
  1748. {note.key}
  1749. </div>
  1750. {/* 显示对应的点 */}
  1751. {note.step < 0 ? steps.map((n: any) => <span class={styles.dot}></span>) : null}
  1752. </div>
  1753. </div>
  1754. );
  1755. })}
  1756. </div>
  1757. </div>
  1758. </div>
  1759. {((data.noteType !== "#c" && (orientationDirection.value === 0 || (orientationDirection.value === 1 && state.platform === IPlatform.PC))) || (orientationDirection.value === 1 && state.platform === IPlatform.APP)) && (
  1760. <Button
  1761. class={styles.noteBtn}
  1762. onClick={(e: any) => {
  1763. e.stopPropagation();
  1764. scrollNoteBox("right");
  1765. }}
  1766. >
  1767. <Icon name="arrow" />
  1768. </Button>
  1769. )}
  1770. </div>
  1771. {data.fingeringMode !== "scaleMode" && (
  1772. <div
  1773. class={styles.optionBtns}
  1774. onClick={(e: any) => {
  1775. e.stopPropagation();
  1776. }}
  1777. >
  1778. <Button class={[styles.oBtn, styles.gamut, playStatus.action && styles.disabled]} round onClick={onGamutPlayOrPause}>
  1779. {playStatus.gamut ? "暂停" : "播放音阶"}
  1780. </Button>
  1781. <Button class={[styles.oBtn, styles.play, playStatus.gamut && styles.disabled]} round onClick={onActionPlay}>
  1782. {listenText.value}
  1783. </Button>
  1784. <Button class={[styles.oBtn, styles.success, !playStatus.answer && styles.disabled]} round onClick={onShowAnswer}>
  1785. 显示答案
  1786. </Button>
  1787. </div>
  1788. )}
  1789. </div>
  1790. )}
  1791. </div>
  1792. {/* 老师端过来隐藏 */}
  1793. {query.platform !== "pc" && (
  1794. <div
  1795. class={styles.fixedRightBtns}
  1796. style={{
  1797. paddingTop: data.paddingTop ? data.paddingTop : "",
  1798. paddingLeft: data.paddingLeft ? data.paddingLeft : "",
  1799. }}
  1800. onClick={(e: any) => {
  1801. e.stopPropagation();
  1802. }}
  1803. >
  1804. <div class={styles.rightBtn}>
  1805. {data.subject !== "melodica" && data.fingeringMode === "scaleMode" && (
  1806. <div
  1807. class={styles.baseBtn}
  1808. onClick={() => {
  1809. data.viewIndex++;
  1810. if (data.viewIndex > data.viewTotal) {
  1811. if (["pan-flute", "ocarina", "whistling"].includes(data.subject)) {
  1812. data.viewIndex = 1;
  1813. } else {
  1814. data.viewIndex = 0;
  1815. }
  1816. }
  1817. getFingeringData();
  1818. }}
  1819. >
  1820. <img src={icons.icon_toggle} />
  1821. <span>视图</span>
  1822. </div>
  1823. )}
  1824. <div
  1825. class={styles.baseBtn}
  1826. onClick={() => {
  1827. resetElement();
  1828. data.tipShow = !data.tipShow;
  1829. onResize();
  1830. }}
  1831. >
  1832. <img src={icons.icon_2_1} />
  1833. <span>说明</span>
  1834. </div>
  1835. {!!data.tones.length && data.fingeringMode === "scaleMode" && (
  1836. <>
  1837. {fingerData.fingeringInfo.name == "hulusi-flute" ? (
  1838. <div id="finger-note-1" class={[styles.baseBtn, styles.toggleBtnhulusi, styles.active]} onClick={() => (data.tnoteShow = true)}>
  1839. <div>
  1840. 全按作
  1841. <div class={[styles.noteKey, styles.noteKeyBtn]}>
  1842. {data.activeTone.step > 0 ? <span class={[styles.topDot, styles.dot]}></span> : null}
  1843. <div class={styles.noteName}>
  1844. <sup>{data.activeTone.mark && (data.activeTone.mark === "rise" ? "#" : "b")}</sup>
  1845. {data.activeTone.key}
  1846. </div>
  1847. {data.activeTone.step < 0 ? <span class={[styles.bottomDot, styles.dot]}></span> : null}
  1848. </div>
  1849. </div>
  1850. <img src={icons.icon_arrow} />
  1851. </div>
  1852. ) : (
  1853. <div id="finger-note-1" class={[styles.baseBtn, styles.toggleBtnhulusi2, styles.active]} onClick={() => (data.tnoteShow = true)}>
  1854. <div class={styles.oterhD}>
  1855. <div>
  1856. <div style={{ marginTop: "-4px" }}>
  1857. <sup>{data.activeTone.mark && (data.activeTone.mark === "rise" ? "#" : "b")}</sup>
  1858. {data.activeTone.name}
  1859. </div>
  1860. </div>
  1861. <img src={icons.icon_arrow} />
  1862. </div>
  1863. </div>
  1864. )}
  1865. </>
  1866. )}
  1867. </div>
  1868. <div class={[styles.baseBtn, !instrumentTranstion.value && styles.resetBtn]} style={{ marginTop: "8px" }} onClick={() => resetElement()}>
  1869. <img src={icons.icon_2_0} />
  1870. <span>还原</span>
  1871. </div>
  1872. </div>
  1873. )}
  1874. {/* 老师端加上遮罩点击关闭 */}
  1875. {query.platform === "pc" && data.tipShow && (
  1876. <div
  1877. class={[styles.tipsOverlay, data.tipShow ? styles.tipsOverlayBg : ""]}
  1878. onClick={() => {
  1879. data.tipShow = false;
  1880. }}
  1881. ></div>
  1882. )}
  1883. <div class={[styles.tips, data.loadingDom ? styles.hiddens : "", data.tipShow ? "" : styles.tipHidden, query.platform === "pc" && data.tipShow ? styles.tipsPcBg : ""]}>
  1884. <div class={styles.tipTitle}>
  1885. <div class={styles.tipTitleName}>{fingerData.fingeringInfo.code}使用说明</div>
  1886. <Button
  1887. class={styles.tipClose}
  1888. onClick={(e: any) => {
  1889. e.stopPropagation();
  1890. data.tipShow = false;
  1891. }}
  1892. >
  1893. <Icon name="cross" size={19} color="#fff" />
  1894. </Button>
  1895. </div>
  1896. <div class={styles.iconBook}></div>
  1897. <div class={styles.tipContentbox}>
  1898. <div class={styles.tipContent}>
  1899. {data.tips.map((tip, tipIndex) => (
  1900. <div class={styles.tipItem}>
  1901. <div class={styles.iconWrap}>
  1902. <div class={styles.tipItemIcon}>{tipIndex + 1}</div>
  1903. </div>
  1904. <div>
  1905. {tip.name}: {tip.realName}
  1906. </div>
  1907. </div>
  1908. ))}
  1909. </div>
  1910. </div>
  1911. </div>
  1912. {data.loadingSoundFonts && (
  1913. <div class={styles.loading}>
  1914. <div class={styles.loadingWrap}>
  1915. <img class={styles.loadingIcon} src={icon_loading_img} />
  1916. <Progress percentage={data.loadingSoundProgress} />
  1917. <div class={styles.loadingTip}>加载中,请稍后…</div>
  1918. </div>
  1919. </div>
  1920. )}
  1921. </div>
  1922. <Popup
  1923. class={["tonePopup", tnoteShowBoxClass]}
  1924. style={query.platform === "pc" ? tnoteShowBoxDragData.styleDrag.value : {}}
  1925. v-model:show={data.tnoteShow}
  1926. position={state.platform === IPlatform.PC ? "center" : !query.modelType && fingerData.fingeringInfo.orientation === 1 ? "bottom" : "right"}
  1927. >
  1928. <div class={styles.tones}>
  1929. <div class={[styles.toneTitle, "toneTitle_pc"]}>
  1930. <div class={styles.tipTitleName}>移调</div>
  1931. <Button
  1932. class={styles.tipClose}
  1933. onClick={(e: any) => {
  1934. e.stopPropagation();
  1935. data.tnoteShow = false;
  1936. }}
  1937. >
  1938. <Icon name="cross" size={19} color="#fff" />
  1939. </Button>
  1940. </div>
  1941. <div class={[styles.tipContentbox, "tipContentbox_pc"]}>
  1942. <div class={[styles.tipContent, "tipContent_pc"]}>
  1943. <div class={[styles.tipWrap, "tipWrap_pc"]}>
  1944. <Space size={0} class={styles.toneContent}>
  1945. {data.tones.map((tone: IFIGNER_INSTRUMENT_Note) => {
  1946. const steps = new Array(Math.abs(tone.step)).fill(1);
  1947. return (
  1948. <Button
  1949. class={[fingerData.fingeringInfo.name == "hulusi-flute" && styles.hulusiBtn]}
  1950. round
  1951. plain
  1952. type={data.popupActiveTone.realName === tone.realName ? "primary" : "default"}
  1953. onClick={(e: any) => {
  1954. e.stopPropagation();
  1955. data.popupActiveTone = tone;
  1956. setNotes();
  1957. }}
  1958. >
  1959. {fingerData.fingeringInfo.name == "hulusi-flute" ? (
  1960. <div style={{ display: "flex", alignItems: "center" }}>
  1961. 全按作
  1962. <div class={[styles.noteKey, styles.hulusiNoteKey]}>
  1963. {tone.step > 0 ? <span class={styles.dot}></span> : null}
  1964. <div class={styles.noteName} style={{ fontSize: "0.25rem" }}>
  1965. <sup>{tone.mark && (tone.mark === "rise" ? "#" : "b")}</sup>
  1966. {tone.key}
  1967. </div>
  1968. {tone.step < 0 ? <span class={styles.dot}></span> : null}
  1969. </div>
  1970. </div>
  1971. ) : (
  1972. <div class={styles.noteName}>
  1973. <sup>{tone.mark && (tone.mark === "rise" ? "#" : "b")}</sup>
  1974. {tone.name}
  1975. </div>
  1976. )}
  1977. </Button>
  1978. );
  1979. })}
  1980. </Space>
  1981. </div>
  1982. <div class={[styles.toneAction, "toneAction_pc"]}>
  1983. <img
  1984. onClick={(e: any) => {
  1985. e.stopPropagation();
  1986. data.tnoteShow = false;
  1987. }}
  1988. src={icons.icon_action_cancel}
  1989. />
  1990. <img
  1991. onClick={(e: any) => {
  1992. e.stopPropagation();
  1993. data.activeTone = data.popupActiveTone;
  1994. setNotes();
  1995. data.tnoteShow = false;
  1996. }}
  1997. src={icons.icon_action_confirm}
  1998. />
  1999. </div>
  2000. </div>
  2001. </div>
  2002. </div>
  2003. {query.platform === "pc" && (
  2004. <>
  2005. <div class={[styles.dragTopBox, "dragTopBox"]}></div>
  2006. <Dragbom showGuide={guidanceShow.value} onGuideDone={setGuidanceShow}></Dragbom>
  2007. </>
  2008. )}
  2009. </Popup>
  2010. <Popup
  2011. style={query.platform === "pc" ? changeSubjectShowBoxDragData.styleDrag.value : {}}
  2012. v-model:show={data.changeSubjectShow}
  2013. class={[styles.changeSubjectPopup, query.platform === "pc" && styles.changeSubjectPopupPc, changeSubjectShowBoxClass]}
  2014. closeOnClickOverlay={query.platform === "pc" ? false : true}
  2015. onClick={(e: any) => {
  2016. e.stopPropagation();
  2017. }}
  2018. >
  2019. <ChangeSubject
  2020. changeSubjectShow={data.changeSubjectShow}
  2021. subjectList={data.subjects}
  2022. subject={data.subject}
  2023. onClose={() => (data.changeSubjectShow = false)}
  2024. onConfirm={(code: any) => {
  2025. if (data.subject === code) {
  2026. data.changeSubjectShow = false;
  2027. return;
  2028. }
  2029. const originalSubject = JSON.parse(JSON.stringify(data.subject));
  2030. data.subject = code;
  2031. data.viewIndex = 0;
  2032. data.tipShow = false;
  2033. data.loadingDom = true;
  2034. fingerData.fingeringInfo = subjectFingering(data.subject);
  2035. data.activeTone = {} as any;
  2036. data.noteType = "all";
  2037. resetElement();
  2038. resetMode(true, 0);
  2039. // api_setRequestedOrientation(orientationDirection.value);
  2040. data.changeSubjectShow = false;
  2041. // 设置屏幕方向
  2042. setTimeout(() => {
  2043. const before = ["hulusi-flute", "piccolo", "baroque-recorder"].includes(originalSubject) ? 0 : 0;
  2044. if (orientationDirection.value !== before) {
  2045. data.paddingTop = "";
  2046. data.paddingLeft = "";
  2047. }
  2048. __init();
  2049. }, 100);
  2050. }}
  2051. />
  2052. {query.platform === "pc" && (
  2053. <>
  2054. <div class={[styles.dragTopBox, "dragTopBox"]}></div>
  2055. <Dragbom showGuide={guidanceShow.value} onGuideDone={setGuidanceShow}></Dragbom>
  2056. </>
  2057. )}
  2058. </Popup>
  2059. {props.show && !data.loading && !data.loadingSoundFonts && <GuideIndex fingeringMode={data.fingeringMode} showGuide={false} list={["finger"]} />}
  2060. </div>
  2061. );
  2062. };
  2063. },
  2064. });