index.tsx 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127
  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. }
  675. };
  676. const noteBoxRef = ref();
  677. const scrollNoteBox = (type: "left" | "right") => {
  678. const domOffsetWidth = noteBoxRef.value.offsetWidth;
  679. const width = domOffsetWidth / 2;
  680. const scrollLeft: any = noteBoxRef.value.scrollLeft;
  681. // 判断是否移动到最左边
  682. if (width >= scrollLeft && type === "left") {
  683. // 不管当前显示在哪个音老师滚动到开始位置
  684. (noteBoxRef.value as unknown as HTMLElement).scroll({
  685. left: 0,
  686. top: 0,
  687. behavior: "smooth",
  688. });
  689. return;
  690. }
  691. // 处理在部分手机点击左右会超出范围
  692. if (type === "right") {
  693. // 遍历子元素并累加它们的宽度
  694. let childElementsWidth = 0;
  695. for (let i = 0; i < noteBoxRef.value.children.length; i++) {
  696. childElementsWidth += noteBoxRef.value.children[i].offsetWidth;
  697. }
  698. // 判断是否移动到最右边
  699. if (width > childElementsWidth - scrollLeft - domOffsetWidth) {
  700. // 不管当前显示在哪个音老师滚动到开始位置
  701. (noteBoxRef.value as unknown as HTMLElement).scroll({
  702. left: noteBoxRef.value.scrollWidth,
  703. top: 0,
  704. behavior: "smooth",
  705. });
  706. return;
  707. }
  708. }
  709. (noteBoxRef.value as unknown as HTMLElement).scrollBy({
  710. left: type === "left" ? -width : width,
  711. behavior: "smooth",
  712. });
  713. };
  714. const playStatus = reactive({
  715. gamut: false, // 是否播放音阶
  716. gamutTimer: null as any, // 播放音阶定时器
  717. answer: false, // 是否显示答案
  718. action: false, // 是否开始播放
  719. });
  720. /** 音符切换 */
  721. const noteChangeShow = () => {
  722. if (playStatus.action) {
  723. if (playAction.listenLock) return;
  724. playAction.resetAction = true;
  725. resetMode(true, 0);
  726. }
  727. // // 播放音阶时不能切换
  728. // if (playStatus.gamut) return;
  729. // // 开始答题不能切换
  730. // if (playStatus.action) return;
  731. playStatus.gamut = false;
  732. gaumntPause();
  733. if (data.noteType === "all") {
  734. data.noteType = "#c";
  735. } else {
  736. data.noteType = "all";
  737. }
  738. getNotes();
  739. setTimeout(() => {
  740. (noteBoxRef.value as unknown as HTMLElement).scroll({
  741. left: 0,
  742. top: 0,
  743. behavior: "smooth",
  744. });
  745. }, 0);
  746. setTimeout(() => {
  747. playAction.resetAction = false;
  748. }, 2000);
  749. };
  750. // 开始播放音阶
  751. const onGamutPlayOrPause = async () => {
  752. playAction.resetAction = false;
  753. if (playStatus.gamut) {
  754. playStatus.gamut = false;
  755. gaumntPause();
  756. } else {
  757. // 不管当前显示在哪个音老师滚动到开始位置
  758. (noteBoxRef.value as unknown as HTMLElement).scroll({
  759. left: 0,
  760. top: 0,
  761. behavior: "smooth",
  762. });
  763. playStatus.gamut = true;
  764. const notes = data.notes;
  765. let scrollCount = 0;
  766. for (let i = 0; i < notes.length; i++) {
  767. if (!playStatus.gamut) return false;
  768. const activeDom = document.querySelectorAll(".note-class")[i] as any;
  769. if (activeDom.offsetLeft >= noteBoxRef.value.offsetWidth + (noteBoxRef.value.offsetWidth / 2) * scrollCount - activeDom.offsetWidth) {
  770. scrollNoteBox("right");
  771. scrollCount++;
  772. }
  773. await gaumtPlay(notes[i]);
  774. }
  775. // // 处理播放到最后一个
  776. setTimeout(() => {
  777. playStatus.gamut = false;
  778. gaumntPause();
  779. }, 667);
  780. }
  781. };
  782. const gaumtPlay = (note: any, status?: boolean) => {
  783. return new Promise((resolve) => {
  784. playStatus.gamutTimer = setTimeout(() => {
  785. if (playStatus.gamut || status) {
  786. noteClick(note);
  787. }
  788. resolve(note);
  789. }, 667);
  790. });
  791. };
  792. const gaumntPause = () => {
  793. clearTimeout(playStatus.gamutTimer);
  794. if (data.noteAudio) {
  795. data.noteAudio.stop();
  796. data.realKey = 0;
  797. data.noteAudio = null as unknown as Howl;
  798. }
  799. };
  800. /** 开始播放 */
  801. const playAction = reactive({
  802. exampleAnser: {} as any, // 示例声音
  803. standardAnswer: {} as any, // 标准答案key
  804. showAnswerLoading: false, // 显示按答案中
  805. listenModeStatus: false, // 是否开始了模式
  806. listenLock: false,
  807. listenTipsStatus: false, // 开始播放状态
  808. resetAction: false, // 是否重置
  809. /** 0: 未答,1: 答对,2: 答错 */
  810. userAnswerStatus: 0 as 0 | 1 | 2, // 用户回答状态
  811. userAnswer: {} as any, // 用户答的数据
  812. timer: null as any,
  813. });
  814. const onActionPlay = async () => {
  815. playAction.resetAction = false;
  816. if (playAction.listenLock) return;
  817. if (playAction.showAnswerLoading) return;
  818. playStatus.action = true;
  819. playStatus.answer = true;
  820. // 先暂停播放声音
  821. gaumntPause();
  822. if (data.fingeringMode === "fingeringMode") {
  823. onFingeringMode();
  824. } else if (data.fingeringMode === "listenMode") {
  825. if (playAction.listenModeStatus) {
  826. playAction.listenLock = true;
  827. await fingeringPlay(playAction.standardAnswer, 1500, false);
  828. gaumntPause();
  829. playAction.listenLock = false;
  830. } else {
  831. onListenMode();
  832. }
  833. }
  834. };
  835. // 指法模式
  836. const fingeringPlay = (note: any, timer = 1500, showNote = true) => {
  837. return new Promise((resolve) => {
  838. noteClick(note, showNote);
  839. playAction.timer = setTimeout(() => {
  840. resolve(note);
  841. }, timer);
  842. });
  843. };
  844. const onFingeringMode = () => {
  845. const randomIndex = Math.floor(Math.random() * data.notes.length);
  846. playAction.standardAnswer = data.notes[randomIndex];
  847. data.realKey = data.notes[randomIndex].realKey;
  848. if (playAction.listenModeStatus) {
  849. return;
  850. }
  851. playAction.listenModeStatus = true; // 是否开始听音
  852. playAction.listenLock = true; // 锁
  853. playAction.listenTipsStatus = true;
  854. playAction.timer = setTimeout(() => {
  855. playAction.listenTipsStatus = false;
  856. playAction.listenLock = false; // 锁
  857. }, 2000);
  858. };
  859. // 听音模式
  860. const onListenMode = async () => {
  861. playAction.listenModeStatus = true; // 是否开始听音
  862. playAction.listenLock = true; // 锁
  863. playAction.listenTipsStatus = true;
  864. // 设置并保存示例数据
  865. let randomIndex = data.notes.findIndex((item: any) => item.realKey === 67); // Math.floor(Math.random() * data.notes.length);
  866. playAction.exampleAnser = data.notes[randomIndex];
  867. data.realKey = playAction.exampleAnser.realKey;
  868. scrollAnswer(playAction.exampleAnser.realKey);
  869. await fingeringPlay(playAction.exampleAnser);
  870. data.realKey = 0;
  871. playAction.exampleAnser = {};
  872. gaumntPause();
  873. playAction.timer = setTimeout(async () => {
  874. // 设置答题数据
  875. randomIndex = Math.floor(Math.random() * data.notes.length);
  876. playAction.standardAnswer = data.notes[randomIndex];
  877. await fingeringPlay(data.notes[randomIndex], 1500, false);
  878. gaumntPause();
  879. playAction.listenLock = false;
  880. playAction.listenTipsStatus = false;
  881. }, 1000);
  882. };
  883. // 显示答案
  884. const onShowAnswer = async () => {
  885. if (playAction.listenLock) return;
  886. playAction.showAnswerLoading = true;
  887. scrollAnswer(playAction.standardAnswer.realKey);
  888. await fingeringPlay(playAction.standardAnswer);
  889. resetMode(true, 0);
  890. // }
  891. };
  892. // 滚动到对应答案位置
  893. const scrollAnswer = (realKey?: any) => {
  894. const tempRealKey = realKey || data.realKey;
  895. const index = data.notes.findIndex((item: any) => item.realKey === tempRealKey);
  896. const activeDom = document.querySelectorAll(".note-class")[index] as any;
  897. if (activeDom) {
  898. const aWidth = activeDom.offsetWidth;
  899. const width = noteBoxRef.value.offsetWidth;
  900. const aLeft = Math.max(activeDom?.offsetLeft - aWidth, 0);
  901. (noteBoxRef.value as unknown as HTMLElement).scroll({
  902. left: Math.max(aLeft - width / 2, 0),
  903. top: 0,
  904. behavior: "smooth",
  905. });
  906. }
  907. };
  908. /**
  909. * 重置播放状态
  910. * @param status 是否全部重置
  911. * @param timer 延时时长(默认2s)
  912. */
  913. const resetMode = (status = true, timer = 2000) => {
  914. // 2秒钟后重置
  915. setTimeout(() => {
  916. gaumntPause();
  917. if (status) {
  918. playAction.standardAnswer = {};
  919. playAction.showAnswerLoading = false;
  920. playAction.userAnswerStatus = 0;
  921. playAction.userAnswer = {};
  922. playAction.listenModeStatus = false;
  923. playStatus.action = false;
  924. playStatus.answer = false;
  925. playStatus.gamut = false;
  926. data.realKey = 0;
  927. } else {
  928. playAction.userAnswerStatus = 0;
  929. playAction.userAnswer = {};
  930. }
  931. }, timer);
  932. };
  933. /** 滚轮缩放 */
  934. const handleWheel = (e: WheelEvent) => {
  935. e.preventDefault();
  936. if (e.deltaY > 0) {
  937. data.transform.scale -= 0.1;
  938. if (data.transform.scale <= 0.5) {
  939. data.transform.scale = 0.5;
  940. }
  941. } else {
  942. data.transform.scale += 0.1;
  943. if (data.transform.scale >= 2) {
  944. data.transform.scale = 2;
  945. }
  946. }
  947. // 使用示例
  948. setTimeout(() => {
  949. const element1 = document.getElementById("fullInstrumentImg");
  950. const element2 = document.getElementById("fullInstrumentUserTab");
  951. data.domOverlapping = isElementOverlapping(element1, element2);
  952. }, 0);
  953. };
  954. const onResize = () => {
  955. nextTick(() => {
  956. setTimeout(() => {
  957. const element1: any = document.querySelector("#fullInstrumentImg");
  958. // console.log(element1, "element1");
  959. const rect = element1?.getBoundingClientRect();
  960. data.domOverImgPropery = {
  961. ...rect,
  962. width: rect.width * (1 / data.transform.scale) + "px",
  963. height: rect.height * (1 / data.transform.scale) + "px",
  964. };
  965. }, 330);
  966. });
  967. };
  968. onMounted(() => {
  969. window.addEventListener("message", changePlay);
  970. window.addEventListener("resize", onResize);
  971. const fingeringContainer = document.getElementById("fingeringContainer");
  972. fingeringContainer?.addEventListener("wheel", handleWheel);
  973. });
  974. onUnmounted(() => {
  975. window.removeEventListener("message", changePlay);
  976. window.removeEventListener("resize", onResize);
  977. const fingeringContainer = document.getElementById("fingeringContainer");
  978. fingeringContainer?.removeEventListener("wheel", handleWheel);
  979. document.title = "Ai学练";
  980. });
  981. const containerBox = computed(() => {
  982. if (state.platform === IPlatform.PC || query.modelType) {
  983. return {
  984. paddingTop: "1.3rem",
  985. paddingBottom: "",
  986. };
  987. }
  988. if (data.fingeringMode === "scaleMode") {
  989. if (data.subject === "hulusi-flute") {
  990. return {
  991. paddingTop: "1.3rem",
  992. paddingBottom: ".5rem",
  993. };
  994. } else if (data.subject === "piccolo" || data.subject === "baroque-recorder") {
  995. return {
  996. paddingTop: "1.3rem",
  997. paddingBottom: ".5rem",
  998. };
  999. } else if (data.subject === "pan-flute") {
  1000. return {
  1001. paddingTop: "1.3rem",
  1002. paddingBottom: "0",
  1003. };
  1004. } else if (data.subject === "ocarina" || data.subject === "whistling") {
  1005. return {
  1006. paddingTop: "1.3rem",
  1007. paddingBottom: "0",
  1008. };
  1009. } else if (data.subject === "melodica") {
  1010. return {
  1011. paddingTop: "1.8rem",
  1012. paddingBottom: "0.2rem",
  1013. };
  1014. } else {
  1015. return {
  1016. paddingTop: "",
  1017. paddingBottom: "",
  1018. };
  1019. }
  1020. } else {
  1021. if (data.subject === "hulusi-flute") {
  1022. return {
  1023. paddingTop: "1.3rem",
  1024. paddingBottom: "0rem",
  1025. };
  1026. } else if (data.subject === "piccolo" || data.subject === "baroque-recorder") {
  1027. return {
  1028. paddingTop: "1.3rem",
  1029. paddingBottom: ".5rem",
  1030. };
  1031. } else if (data.subject === "pan-flute") {
  1032. return {
  1033. paddingTop: "1.3rem",
  1034. paddingBottom: "0",
  1035. };
  1036. } else if (data.subject === "ocarina" || data.subject === "whistling") {
  1037. return {
  1038. paddingTop: "1.3rem",
  1039. paddingBottom: "0",
  1040. };
  1041. } else if (data.subject === "melodica") {
  1042. return {
  1043. paddingTop: "1.8rem",
  1044. paddingBottom: "0.2rem",
  1045. };
  1046. } else {
  1047. return {
  1048. paddingTop: "",
  1049. paddingBottom: "",
  1050. };
  1051. }
  1052. }
  1053. });
  1054. const listenText = computed(() => {
  1055. if (data.fingeringMode === "fingeringMode") {
  1056. if (playStatus.action) {
  1057. return "换一换";
  1058. } else {
  1059. return "开始练习";
  1060. }
  1061. } else if (data.fingeringMode === "listenMode") {
  1062. if (playStatus.action) {
  1063. return "再听一遍";
  1064. } else {
  1065. return "开始听音";
  1066. }
  1067. }
  1068. return "开始听音";
  1069. });
  1070. const modeText = computed(() => {
  1071. let text = "";
  1072. let icon = icons.icon_mode;
  1073. data.fingeringModeList.forEach((item: any) => {
  1074. if (item.value === data.fingeringMode) {
  1075. text = item.text;
  1076. icon = item.icon;
  1077. }
  1078. });
  1079. return {
  1080. text,
  1081. icon,
  1082. };
  1083. });
  1084. // 屏幕方向 0 竖,1 横
  1085. const orientationDirection = computed(() => {
  1086. return ["hulusi-flute", "piccolo", "baroque-recorder"].includes(data.subject) ? 1 : 0;
  1087. });
  1088. const resultImg = (note: any) => {
  1089. if (data.realKey === note.realKey && !playStatus.action) {
  1090. return {
  1091. icon: icons.icon_btn_ylow,
  1092. status: false,
  1093. };
  1094. } else if (playAction.exampleAnser.realKey === note.realKey) {
  1095. return {
  1096. icon: icons.icon_btn_ylow,
  1097. status: false,
  1098. };
  1099. } else if (playAction.standardAnswer.realKey === note.realKey) {
  1100. // 没有开始答题
  1101. if (!playStatus.action) {
  1102. return {
  1103. icon: icons.icon_btn_ylow,
  1104. status: false,
  1105. };
  1106. }
  1107. // 显示答案中
  1108. if (playAction.showAnswerLoading) {
  1109. return {
  1110. icon: icons.icon_btn_green,
  1111. status: true,
  1112. };
  1113. }
  1114. // 用户答对
  1115. if (playAction.userAnswerStatus === 1) {
  1116. return {
  1117. icon: icons.icon_btn_green,
  1118. status: true,
  1119. };
  1120. }
  1121. } else {
  1122. // 用户答错
  1123. if (playAction.userAnswerStatus === 2 && playAction.userAnswer.realKey === note.realKey) {
  1124. return {
  1125. icon: icons.icon_btn_red,
  1126. status: true,
  1127. };
  1128. }
  1129. }
  1130. return {
  1131. icon: icons.icon_btn_blue,
  1132. status: true,
  1133. };
  1134. };
  1135. const userTabActive = ref<"1" | "2">("1");
  1136. const userTabs = [
  1137. {
  1138. name: "音阶",
  1139. value: "1",
  1140. },
  1141. {
  1142. name: "功能",
  1143. value: "2",
  1144. },
  1145. ];
  1146. // 引导页
  1147. const { guidanceShow, setGuidanceShow } = useDragGuidance();
  1148. // 切换乐器弹窗
  1149. let changeSubjectShowBoxDragData: any;
  1150. let changeSubjectShowBoxClass: string;
  1151. if (query.platform === "pc") {
  1152. changeSubjectShowBoxClass = "changeSubjectShowBoxClass_drag";
  1153. changeSubjectShowBoxDragData = useDrag([`${changeSubjectShowBoxClass} .dragTopBox`, `${changeSubjectShowBoxClass} .dragbomBox`], changeSubjectShowBoxClass, toRef(data, "changeSubjectShow"), storeData.user.id as string);
  1154. }
  1155. // 移调弹窗
  1156. let tnoteShowBoxDragData: any;
  1157. let tnoteShowBoxClass: string;
  1158. if (query.platform === "pc") {
  1159. tnoteShowBoxClass = "tnoteShowBoxClass_drag";
  1160. tnoteShowBoxDragData = useDrag([`${tnoteShowBoxClass} .dragTopBox`, `${tnoteShowBoxClass} .dragbomBox`], tnoteShowBoxClass, toRef(data, "tnoteShow"), storeData.user.id as string);
  1161. }
  1162. return () => {
  1163. const relationship = fingerData.subject?.relationship?.[data.realKey] || [];
  1164. const rs: number[] = Array.isArray(relationship[1]) ? relationship[fingerData.relationshipIndex] : relationship;
  1165. const canTizhi = Array.isArray(relationship[1]);
  1166. return (
  1167. <div
  1168. class={[styles.fingerBox, state.platform !== IPlatform.PC && !query.modelType && fingerData.fingeringInfo.orientation === 1 ? styles.fingerBottom : styles.fingerRight, data.linkSource === "class" ? styles.linkSourceClass : ""]}
  1169. onClick={() => {
  1170. if (data.linkSource === "class") {
  1171. window.parent.postMessage(
  1172. {
  1173. api: "clickViewFigner",
  1174. },
  1175. "*"
  1176. );
  1177. }
  1178. }}
  1179. >
  1180. {/* 老师端过来隐藏 */}
  1181. {query.platform !== "pc" && (
  1182. <div
  1183. class={styles.head}
  1184. style={{
  1185. paddingTop: data.paddingTop && !browser().ios ? data.paddingTop : "",
  1186. paddingLeft: data.paddingLeft && !browser().ios ? data.paddingLeft : "",
  1187. }}
  1188. >
  1189. <div class={styles.left}>
  1190. <button class={[styles.backBtn]} onClick={() => handleBack()}>
  1191. <img src={icons.icon_back} />
  1192. </button>
  1193. <div
  1194. class={[styles.baseBtn, styles.changeInstrumentBtn]}
  1195. onClick={(e) => {
  1196. e.stopPropagation();
  1197. //
  1198. // 播放音阶时不能切换
  1199. if (playStatus.gamut) {
  1200. return;
  1201. }
  1202. // 开始答题不能切换
  1203. if (playAction.listenLock) {
  1204. return;
  1205. }
  1206. data.changeSubjectShow = true;
  1207. }}
  1208. >
  1209. <img src={icons.icon_change_instrument} />
  1210. <span>切换乐器</span>
  1211. </div>
  1212. <div class={styles.baseBtn} onClick={onChangeFingeringModel}>
  1213. <img src={modeText.value.icon} />
  1214. <span>{modeText.value.text}</span>
  1215. </div>
  1216. {/* */}
  1217. </div>
  1218. {/* */}
  1219. </div>
  1220. )}
  1221. <div
  1222. class={styles.fingerContent}
  1223. style={{
  1224. paddingTop: data.paddingTop ? data.paddingTop : "",
  1225. paddingLeft: data.paddingLeft ? data.paddingLeft : "",
  1226. }}
  1227. >
  1228. <div class={styles.wrapFinger}>
  1229. <div
  1230. id="fingeringContainer"
  1231. class={[styles.boxFinger, query.platform === "pc" ? styles.pcBoxFinger : "", data.domOverlapping && data.notePoints?.length > 0 && styles.boxFingerOverlapping]}
  1232. style={{
  1233. paddingTop: containerBox.value.paddingTop,
  1234. paddingBottom: containerBox.value.paddingBottom,
  1235. }}
  1236. >
  1237. <div
  1238. style={{
  1239. transform: `translate3d(${data.transform.x}px,${data.transform.y}px,0px) scale(${data.transform.scale})`,
  1240. transition: data.transform.transition,
  1241. }}
  1242. class={[styles.fingeringContainer]}
  1243. >
  1244. <div class={styles.imgs}>
  1245. {!data.loadingImg && <img id="fullInstrumentImg" src={data.fingeringMode === "scaleMode" ? fingerData.subject?.json?.full : fingerData.subject?.json?.full1} />}
  1246. {rs.map((key: number | string, index: number) => {
  1247. const nk: string = typeof key === "string" ? key.replace("active-", "") : String(key);
  1248. return <img class={styles.showImgNk} data-index={nk} src={fingerData.subject?.json?.[nk]} />;
  1249. })}
  1250. <div style={{ left: data.viewIndex == 2 ? "0" : "64%" }} class={[styles.tizhi, canTizhi && styles.canDisplay]} onClick={() => (fingerData.relationshipIndex = fingerData.relationshipIndex === 0 ? 1 : 0)}>
  1251. 替指
  1252. </div>
  1253. <div id="finger-note-2" style={{ left: "50%", transform: "translateX(-50%)" }} class={styles.tizhi} onClick={() => (fingerData.relationshipIndex = fingerData.relationshipIndex === 0 ? 1 : 0)}></div>
  1254. {data.notePoints?.length > 0 && (
  1255. <div
  1256. class={[styles.fingeringPointSection]}
  1257. style={{
  1258. width: data.domOverImgPropery.width,
  1259. height: data.domOverImgPropery.height,
  1260. }}
  1261. >
  1262. <div class={[styles[data.subject], data.viewIndex === 2 && data.subject === "pan-flute" && styles["pan-flute-back"]]}>
  1263. {data.notePoints.map((point: any) => (
  1264. <div
  1265. class={styles.p1}
  1266. style={point.style}
  1267. // onClick={(e: any) => {
  1268. // e.stopPropagation();
  1269. // if (isDragging.value) return;
  1270. // noteInstrumentPlay(point, true);
  1271. // }}
  1272. onMousedown={(e: any) => {
  1273. e.stopPropagation();
  1274. e.preventDefault();
  1275. console.log("onMousedown", e);
  1276. if (isTouch) return;
  1277. startNotePress(point);
  1278. }}
  1279. onMouseup={(e: any) => {
  1280. e.stopPropagation();
  1281. e.preventDefault();
  1282. // console.log("onMouseup", e);
  1283. if (isTouch) return;
  1284. cancelNotePress(point);
  1285. }}
  1286. onMouseleave={(e: any) => {
  1287. e.stopPropagation();
  1288. e.preventDefault();
  1289. // console.log("onMouseleave", e);
  1290. if (isTouch) return;
  1291. cancelNotePress(point);
  1292. }}
  1293. onTouchstart={(e: any) => {
  1294. e.stopPropagation();
  1295. e.preventDefault();
  1296. // console.log("onTouchstart", e);
  1297. isTouch = true;
  1298. startNotePress(point);
  1299. }}
  1300. onTouchend={(e: any) => {
  1301. e.stopPropagation();
  1302. e.preventDefault();
  1303. // console.log("onTouchend", e);
  1304. cancelNotePress(point);
  1305. }}
  1306. onTouchcancel={(e: any) => {
  1307. e.stopPropagation();
  1308. e.preventDefault();
  1309. // console.log("onTouchcancel", e);
  1310. cancelNotePress(point);
  1311. }}
  1312. >
  1313. {point.children && (
  1314. <div
  1315. class={styles.p2}
  1316. // onClick={(e: any) => {
  1317. // e.stopPropagation();
  1318. // if (isDragging.value) return;
  1319. // noteInstrumentPlay(point.children, true);
  1320. // }}
  1321. onMousedown={(e: any) => {
  1322. e.stopPropagation();
  1323. e.preventDefault();
  1324. if (isTouch) return;
  1325. startNotePress(point.children);
  1326. }}
  1327. onMouseup={(e: any) => {
  1328. e.stopPropagation();
  1329. e.preventDefault();
  1330. if (isTouch) return;
  1331. cancelNotePress(point.children);
  1332. }}
  1333. onMouseleave={(e: any) => {
  1334. e.stopPropagation();
  1335. e.preventDefault();
  1336. if (isTouch) return;
  1337. cancelNotePress(point.children);
  1338. }}
  1339. onTouchstart={(e: any) => {
  1340. e.stopPropagation();
  1341. e.preventDefault();
  1342. isTouch = true;
  1343. startNotePress(point.children);
  1344. }}
  1345. onTouchend={(e: any) => {
  1346. e.stopPropagation();
  1347. e.preventDefault();
  1348. cancelNotePress(point.children);
  1349. }}
  1350. onTouchcancel={(e: any) => {
  1351. e.stopPropagation();
  1352. e.preventDefault();
  1353. cancelNotePress(point.children);
  1354. }}
  1355. style={point.children.style}
  1356. ></div>
  1357. )}
  1358. </div>
  1359. ))}
  1360. </div>
  1361. </div>
  1362. )}
  1363. </div>
  1364. </div>
  1365. </div>
  1366. {/* 老师端过来隐藏 */}
  1367. {query.platform === "pc" ? (
  1368. <div class={[styles.userTab, data.domOverlapping && data.notePoints?.length > 0 && styles.usrTabOverlaping]} id="fullInstrumentUserTab">
  1369. <Tabs v-model:active={userTabActive.value} class={styles.userTabBox}>
  1370. {userTabs.map((item) => {
  1371. return (
  1372. <Tab title={item.name} name={item.value}>
  1373. {item.value === "1" ? (
  1374. <>
  1375. <div
  1376. class={styles.notes}
  1377. style={{
  1378. paddingLeft: data.paddingLeft ? data.paddingLeft : "",
  1379. }}
  1380. >
  1381. {playAction.listenTipsStatus && <div class={[styles.tipsT, data.fingeringMode === "fingeringMode" ? styles.playTips2 : styles.playTips]}></div>}
  1382. {playAction.userAnswerStatus === 1 && <div class={[styles.tipsT, styles.playSuccess]}></div>}
  1383. {playAction.userAnswerStatus === 2 && <div class={[styles.tipsT, styles.playError]}></div>}
  1384. {playAction.resetAction && <div class={[styles.tipsT, styles.playTips5]}></div>}
  1385. <div class={[styles.backBtn, styles.changeMusBtn]} onClick={() => handleBack()}>
  1386. <span>返回</span>
  1387. </div>
  1388. <div class={styles.changeMusBtn} onClick={onChangeFingeringModel}>
  1389. <span>{modeText.value.text}</span>
  1390. </div>
  1391. <div
  1392. class={[styles.noteContent, data.fingeringMode !== "scaleMode" && orientationDirection.value === 0 && styles.noteContentOther, browsInfo.ios ? "" : styles.noteContentWrap, data.huaweiPad && styles.huaweiPad]}
  1393. onClick={(e: any) => {
  1394. e.stopPropagation();
  1395. }}
  1396. >
  1397. {((data.noteType !== "#c" && (orientationDirection.value === 0 || (orientationDirection.value === 1 && state.platform === IPlatform.PC))) || (orientationDirection.value === 1 && state.platform === IPlatform.APP)) && (
  1398. <Button
  1399. class={styles.noteBtn}
  1400. onClick={(e: any) => {
  1401. e.stopPropagation();
  1402. scrollNoteBox("left");
  1403. }}
  1404. >
  1405. <Icon name="arrow-left" />
  1406. </Button>
  1407. )}
  1408. {/* 判断是否为音阶模式 */}
  1409. {data.fingeringMode !== "scaleMode" && (
  1410. <div draggable={false} class={styles.note} onClick={noteChangeShow}>
  1411. <img draggable={false} src={data.noteType === "all" ? icons.icon_btn_orange : icons.icon_btn_orange2} />
  1412. </div>
  1413. )}
  1414. {!!data.tones.length && data.fingeringMode === "scaleMode" && (
  1415. <>
  1416. {fingerData.fingeringInfo.name == "hulusi-flute" ? (
  1417. <div id="finger-note-1" class={[styles.note, styles.btnGrToggleBtn]} onClick={() => (data.tnoteShow = true)}>
  1418. <img draggable={false} src={noteImg} />
  1419. <div class={styles.nameBox}>
  1420. <div class={styles.name}>全按作</div>
  1421. <div class={[styles.noteKey, styles.noteKeyBtn]}>
  1422. {data.activeTone.step > 0 ? <span class={styles.dot}></span> : null}
  1423. <div class={styles.noteName}>
  1424. <sup>{data.activeTone.mark && (data.activeTone.mark === "rise" ? "#" : "b")}</sup>
  1425. {data.activeTone.key}
  1426. </div>
  1427. {data.activeTone.step < 0 ? <span class={[styles.dot, styles.botDot]}></span> : null}
  1428. </div>
  1429. </div>
  1430. </div>
  1431. ) : (
  1432. <div id="finger-note-1" class={[styles.note, styles.btnGrToggleBtn]} onClick={() => (data.tnoteShow = true)}>
  1433. <img draggable={false} src={noteImg} />
  1434. <div>
  1435. <div class={styles.name}>
  1436. <div>
  1437. <sup>{data.activeTone.mark && (data.activeTone.mark === "rise" ? "#" : "b")}</sup>
  1438. {data.activeTone.name}
  1439. </div>
  1440. </div>
  1441. </div>
  1442. </div>
  1443. )}
  1444. </>
  1445. )}
  1446. {/* [styles.noteContent, browsInfo.ios ? "" : styles.noteContentWrap, data.huaweiPad && styles.huaweiPad] */}
  1447. <div class={styles.lastNoteContent}>
  1448. <div ref={noteBoxRef} class={styles.noteBox}>
  1449. {data.notes.map((note: IFIGNER_INSTRUMENT_Note, index: number) => {
  1450. const steps = new Array(Math.abs(note.step)).fill(1);
  1451. return (
  1452. <div
  1453. id={index == 0 ? "finger-note-0" : ""}
  1454. draggable={false}
  1455. class={[styles.note, "note-class"]}
  1456. key={note.realKey}
  1457. // onClick={async () => {
  1458. // noteInstrumentPlay(note);
  1459. // }}
  1460. onMousedown={(e: any) => {
  1461. e.stopPropagation();
  1462. e.preventDefault();
  1463. if (isTouch) return;
  1464. startNotePress(note, false);
  1465. }}
  1466. onMouseup={(e: any) => {
  1467. e.stopPropagation();
  1468. e.preventDefault();
  1469. if (isTouch) return;
  1470. cancelNotePress(note, false);
  1471. }}
  1472. onMouseleave={(e: any) => {
  1473. e.stopPropagation();
  1474. e.preventDefault();
  1475. if (isTouch) return;
  1476. cancelNotePress(note, false);
  1477. }}
  1478. onTouchstart={(e: any) => {
  1479. e.stopPropagation();
  1480. e.preventDefault();
  1481. isTouch = true;
  1482. startNotePress(note, false);
  1483. }}
  1484. onTouchend={(e: any) => {
  1485. e.stopPropagation();
  1486. e.preventDefault();
  1487. cancelNotePress(note, false);
  1488. }}
  1489. onTouchcancel={(e: any) => {
  1490. e.stopPropagation();
  1491. e.preventDefault();
  1492. cancelNotePress(note, false);
  1493. }}
  1494. >
  1495. <img draggable={false} src={resultImg(note).icon} />
  1496. {playStatus.action && ((playAction.showAnswerLoading && playAction.standardAnswer.realKey === note.realKey) || (playAction.userAnswerStatus === 1 && playAction.userAnswer.realKey === note.realKey)) ? <span class={styles.showAnswer}></span> : ""}
  1497. {playStatus.action && playAction.userAnswerStatus === 2 && playAction.userAnswer.realKey === note.realKey ? <span class={[styles.showAnswer, styles.errorAnswer]}></span> : ""}
  1498. <div
  1499. class={[
  1500. styles.noteKey,
  1501. ((data.realKey === note.realKey && !playStatus.action) ||
  1502. (playStatus.action && playAction.exampleAnser.realKey === note.realKey) ||
  1503. (playStatus.action && ((playAction.showAnswerLoading && playAction.standardAnswer.realKey === note.realKey) || (playAction.userAnswerStatus === 1 && playAction.userAnswer.realKey === note.realKey))) ||
  1504. (playStatus.action && playAction.userAnswerStatus === 2 && playAction.userAnswer.realKey === note.realKey)) &&
  1505. styles.keyActive,
  1506. ]}
  1507. >
  1508. {/* 显示对应的点 */}
  1509. {note.step > 0 ? steps.map((n: any) => <span class={styles.dot}></span>) : null}
  1510. <div class={styles.noteName}>
  1511. <sup>{note.mark && (note.mark === "rise" ? "#" : "b")}</sup>
  1512. {note.key}
  1513. </div>
  1514. {/* 显示对应的点 */}
  1515. {note.step < 0 ? steps.map((n: any) => <span class={styles.dot}></span>) : null}
  1516. </div>
  1517. </div>
  1518. );
  1519. })}
  1520. </div>
  1521. </div>
  1522. {((data.noteType !== "#c" && (orientationDirection.value === 0 || (orientationDirection.value === 1 && state.platform === IPlatform.PC))) || (orientationDirection.value === 1 && state.platform === IPlatform.APP)) && (
  1523. <Button
  1524. class={styles.noteBtn}
  1525. onClick={(e: any) => {
  1526. e.stopPropagation();
  1527. scrollNoteBox("right");
  1528. }}
  1529. >
  1530. <Icon name="arrow" />
  1531. </Button>
  1532. )}
  1533. </div>
  1534. </div>
  1535. {data.fingeringMode !== "scaleMode" && (
  1536. <div
  1537. class={styles.optionBtns}
  1538. onClick={(e: any) => {
  1539. e.stopPropagation();
  1540. }}
  1541. >
  1542. <Button class={[styles.oBtn, styles.gamut, playStatus.action && styles.disabled]} round onClick={onGamutPlayOrPause}>
  1543. {playStatus.gamut ? "暂停" : "播放音阶"}
  1544. </Button>
  1545. <Button class={[styles.oBtn, styles.play, playStatus.gamut && styles.disabled]} round onClick={onActionPlay}>
  1546. {listenText.value}
  1547. </Button>
  1548. <Button class={[styles.oBtn, styles.success, !playStatus.answer && styles.disabled]} round onClick={onShowAnswer}>
  1549. 显示答案
  1550. </Button>
  1551. </div>
  1552. )}
  1553. </>
  1554. ) : (
  1555. <>
  1556. <div class={styles.btnBox}>
  1557. <div class={styles.btnCon}>
  1558. <div
  1559. class={[styles.btnGr]}
  1560. onClick={(e) => {
  1561. e.stopPropagation();
  1562. //
  1563. // 播放音阶时不能切换
  1564. if (playStatus.gamut) {
  1565. return;
  1566. }
  1567. // 开始答题不能切换
  1568. if (playAction.listenLock) {
  1569. return;
  1570. }
  1571. data.changeSubjectShow = true;
  1572. }}
  1573. >
  1574. <img src={icons.icon_change_instrument} />
  1575. <span>切换乐器</span>
  1576. </div>
  1577. {data.subject !== "melodica" && data.fingeringMode === "scaleMode" && (
  1578. <div
  1579. class={styles.btnGr}
  1580. onClick={() => {
  1581. data.viewIndex++;
  1582. if (data.viewIndex > data.viewTotal) {
  1583. if (["pan-flute", "ocarina", "whistling"].includes(data.subject)) {
  1584. data.viewIndex = 1;
  1585. } else {
  1586. data.viewIndex = 0;
  1587. }
  1588. }
  1589. getFingeringData();
  1590. }}
  1591. >
  1592. <img src={icons.icon_toggle} />
  1593. <span>视图</span>
  1594. </div>
  1595. )}
  1596. <div
  1597. class={styles.btnGr}
  1598. onClick={() => {
  1599. resetElement();
  1600. data.tipShow = !data.tipShow;
  1601. onResize();
  1602. }}
  1603. >
  1604. <img src={icons.icon_2_1} />
  1605. <span>说明</span>
  1606. </div>
  1607. {instrumentTranstion.value && (
  1608. <div class={[styles.btnGr]} onClick={() => resetElement()}>
  1609. <img src={icons.icon_2_0} />
  1610. <span>还原</span>
  1611. </div>
  1612. )}
  1613. </div>
  1614. </div>
  1615. </>
  1616. )}
  1617. </Tab>
  1618. );
  1619. })}
  1620. </Tabs>
  1621. </div>
  1622. ) : (
  1623. <div class={[data.domOverlapping && data.notePoints?.length > 0 && styles.usrTabOverlapingNotes]} id="fullInstrumentUserTab">
  1624. <div
  1625. class={[styles.notes]}
  1626. style={{
  1627. paddingLeft: data.paddingLeft ? data.paddingLeft : "",
  1628. }}
  1629. >
  1630. {playAction.listenTipsStatus && <div class={[styles.tipsT, data.fingeringMode === "fingeringMode" ? styles.playTips2 : styles.playTips]}></div>}
  1631. {playAction.userAnswerStatus === 1 && <div class={[styles.tipsT, styles.playSuccess]}></div>}
  1632. {playAction.userAnswerStatus === 2 && <div class={[styles.tipsT, styles.playError]}></div>}
  1633. {playAction.resetAction && <div class={[styles.tipsT, styles.playTips5]}></div>}
  1634. {((data.noteType !== "#c" && (orientationDirection.value === 0 || (orientationDirection.value === 1 && state.platform === IPlatform.PC))) || (orientationDirection.value === 1 && state.platform === IPlatform.APP)) && (
  1635. <Button
  1636. class={styles.noteBtn}
  1637. onClick={(e: any) => {
  1638. e.stopPropagation();
  1639. scrollNoteBox("left");
  1640. }}
  1641. >
  1642. <Icon name="arrow-left" />
  1643. </Button>
  1644. )}
  1645. <div
  1646. class={[styles.noteContent, data.fingeringMode !== "scaleMode" && orientationDirection.value === 0 && styles.noteContentOther, browsInfo.ios ? "" : styles.noteContentWrap, data.huaweiPad && styles.huaweiPad]}
  1647. onClick={(e: any) => {
  1648. e.stopPropagation();
  1649. }}
  1650. >
  1651. {/* 判断是否为音阶模式 */}
  1652. {data.fingeringMode !== "scaleMode" && (
  1653. <div draggable={false} class={styles.note} onClick={noteChangeShow}>
  1654. <img draggable={false} src={data.noteType === "all" ? icons.icon_btn_orange : icons.icon_btn_orange2} />
  1655. </div>
  1656. )}
  1657. {/* [styles.noteContent, browsInfo.ios ? "" : styles.noteContentWrap, data.huaweiPad && styles.huaweiPad] */}
  1658. <div class={styles.lastNoteContent}>
  1659. <div ref={noteBoxRef} class={styles.noteBox} id="noteBox">
  1660. {data.notes.map((note: IFIGNER_INSTRUMENT_Note, index: number) => {
  1661. const steps = new Array(Math.abs(note.step)).fill(1);
  1662. return (
  1663. <div
  1664. id={index == 0 ? "finger-note-0" : ""}
  1665. draggable={false}
  1666. class={[styles.note, "note-class"]}
  1667. key={note.realKey}
  1668. // onClick={async () => {
  1669. // noteInstrumentPlay(note);
  1670. // }}
  1671. onMousedown={(e: any) => {
  1672. e.stopPropagation();
  1673. e.preventDefault();
  1674. if (isTouch) return;
  1675. startNotePress(note, false);
  1676. }}
  1677. onMouseup={(e: any) => {
  1678. e.stopPropagation();
  1679. e.preventDefault();
  1680. if (isTouch) return;
  1681. cancelNotePress(note, false);
  1682. }}
  1683. onMouseleave={(e: any) => {
  1684. e.stopPropagation();
  1685. e.preventDefault();
  1686. if (isTouch) return;
  1687. cancelNotePress(note, false);
  1688. }}
  1689. onTouchstart={(e: any) => {
  1690. e.stopPropagation();
  1691. e.preventDefault();
  1692. isTouch = true;
  1693. startNotePress(note, false);
  1694. }}
  1695. onTouchend={(e: any) => {
  1696. e.stopPropagation();
  1697. e.preventDefault();
  1698. cancelNotePress(note, false);
  1699. }}
  1700. onTouchcancel={(e: any) => {
  1701. e.stopPropagation();
  1702. e.preventDefault();
  1703. cancelNotePress(note, false);
  1704. }}
  1705. >
  1706. <img draggable={false} src={resultImg(note).icon} />
  1707. {playStatus.action && ((playAction.showAnswerLoading && playAction.standardAnswer.realKey === note.realKey) || (playAction.userAnswerStatus === 1 && playAction.userAnswer.realKey === note.realKey)) ? <span class={styles.showAnswer}></span> : ""}
  1708. {playStatus.action && playAction.userAnswerStatus === 2 && playAction.userAnswer.realKey === note.realKey ? <span class={[styles.showAnswer, styles.errorAnswer]}></span> : ""}
  1709. <div
  1710. class={[
  1711. styles.noteKey,
  1712. ((data.realKey === note.realKey && !playStatus.action) ||
  1713. (playStatus.action && playAction.exampleAnser.realKey === note.realKey) ||
  1714. (playStatus.action && ((playAction.showAnswerLoading && playAction.standardAnswer.realKey === note.realKey) || (playAction.userAnswerStatus === 1 && playAction.userAnswer.realKey === note.realKey))) ||
  1715. (playStatus.action && playAction.userAnswerStatus === 2 && playAction.userAnswer.realKey === note.realKey)) &&
  1716. styles.keyActive,
  1717. ]}
  1718. >
  1719. {/* 显示对应的点 */}
  1720. {note.step > 0 ? steps.map((n: any) => <span class={styles.dot}></span>) : null}
  1721. <div class={styles.noteName}>
  1722. <sup>{note.mark && (note.mark === "rise" ? "#" : "b")}</sup>
  1723. {note.key}
  1724. </div>
  1725. {/* 显示对应的点 */}
  1726. {note.step < 0 ? steps.map((n: any) => <span class={styles.dot}></span>) : null}
  1727. </div>
  1728. </div>
  1729. );
  1730. })}
  1731. </div>
  1732. </div>
  1733. </div>
  1734. {((data.noteType !== "#c" && (orientationDirection.value === 0 || (orientationDirection.value === 1 && state.platform === IPlatform.PC))) || (orientationDirection.value === 1 && state.platform === IPlatform.APP)) && (
  1735. <Button
  1736. class={styles.noteBtn}
  1737. onClick={(e: any) => {
  1738. e.stopPropagation();
  1739. scrollNoteBox("right");
  1740. }}
  1741. >
  1742. <Icon name="arrow" />
  1743. </Button>
  1744. )}
  1745. </div>
  1746. {data.fingeringMode !== "scaleMode" && (
  1747. <div
  1748. class={styles.optionBtns}
  1749. onClick={(e: any) => {
  1750. e.stopPropagation();
  1751. }}
  1752. >
  1753. <Button class={[styles.oBtn, styles.gamut, playStatus.action && styles.disabled]} round onClick={onGamutPlayOrPause}>
  1754. {playStatus.gamut ? "暂停" : "播放音阶"}
  1755. </Button>
  1756. <Button class={[styles.oBtn, styles.play, playStatus.gamut && styles.disabled]} round onClick={onActionPlay}>
  1757. {listenText.value}
  1758. </Button>
  1759. <Button class={[styles.oBtn, styles.success, !playStatus.answer && styles.disabled]} round onClick={onShowAnswer}>
  1760. 显示答案
  1761. </Button>
  1762. </div>
  1763. )}
  1764. </div>
  1765. )}
  1766. </div>
  1767. {/* 老师端过来隐藏 */}
  1768. {query.platform !== "pc" && (
  1769. <div
  1770. class={styles.fixedRightBtns}
  1771. style={{
  1772. paddingTop: data.paddingTop ? data.paddingTop : "",
  1773. paddingLeft: data.paddingLeft ? data.paddingLeft : "",
  1774. }}
  1775. onClick={(e: any) => {
  1776. e.stopPropagation();
  1777. }}
  1778. >
  1779. <div class={styles.rightBtn}>
  1780. {data.subject !== "melodica" && data.fingeringMode === "scaleMode" && (
  1781. <div
  1782. class={styles.baseBtn}
  1783. onClick={() => {
  1784. data.viewIndex++;
  1785. if (data.viewIndex > data.viewTotal) {
  1786. if (["pan-flute", "ocarina", "whistling"].includes(data.subject)) {
  1787. data.viewIndex = 1;
  1788. } else {
  1789. data.viewIndex = 0;
  1790. }
  1791. }
  1792. getFingeringData();
  1793. }}
  1794. >
  1795. <img src={icons.icon_toggle} />
  1796. <span>视图</span>
  1797. </div>
  1798. )}
  1799. <div
  1800. class={styles.baseBtn}
  1801. onClick={() => {
  1802. resetElement();
  1803. data.tipShow = !data.tipShow;
  1804. onResize();
  1805. }}
  1806. >
  1807. <img src={icons.icon_2_1} />
  1808. <span>说明</span>
  1809. </div>
  1810. {!!data.tones.length && data.fingeringMode === "scaleMode" && (
  1811. <>
  1812. {fingerData.fingeringInfo.name == "hulusi-flute" ? (
  1813. <div id="finger-note-1" class={[styles.baseBtn, styles.toggleBtnhulusi, styles.active]} onClick={() => (data.tnoteShow = true)}>
  1814. <div>
  1815. 全按作
  1816. <div class={[styles.noteKey, styles.noteKeyBtn]}>
  1817. {data.activeTone.step > 0 ? <span class={[styles.topDot, styles.dot]}></span> : null}
  1818. <div class={styles.noteName}>
  1819. <sup>{data.activeTone.mark && (data.activeTone.mark === "rise" ? "#" : "b")}</sup>
  1820. {data.activeTone.key}
  1821. </div>
  1822. {data.activeTone.step < 0 ? <span class={[styles.bottomDot, styles.dot]}></span> : null}
  1823. </div>
  1824. </div>
  1825. <img src={icons.icon_arrow} />
  1826. </div>
  1827. ) : (
  1828. <div id="finger-note-1" class={[styles.baseBtn, styles.toggleBtnhulusi2, styles.active]} onClick={() => (data.tnoteShow = true)}>
  1829. <div class={styles.oterhD}>
  1830. <div>
  1831. <div style={{ marginTop: "-4px" }}>
  1832. <sup>{data.activeTone.mark && (data.activeTone.mark === "rise" ? "#" : "b")}</sup>
  1833. {data.activeTone.name}
  1834. </div>
  1835. </div>
  1836. <img src={icons.icon_arrow} />
  1837. </div>
  1838. </div>
  1839. )}
  1840. </>
  1841. )}
  1842. </div>
  1843. <div class={[styles.baseBtn, !instrumentTranstion.value && styles.resetBtn]} style={{ marginTop: "8px" }} onClick={() => resetElement()}>
  1844. <img src={icons.icon_2_0} />
  1845. <span>还原</span>
  1846. </div>
  1847. </div>
  1848. )}
  1849. {/* 老师端加上遮罩点击关闭 */}
  1850. {query.platform === "pc" && data.tipShow && (
  1851. <div
  1852. class={[styles.tipsOverlay, data.tipShow ? styles.tipsOverlayBg : ""]}
  1853. onClick={() => {
  1854. data.tipShow = false;
  1855. }}
  1856. ></div>
  1857. )}
  1858. <div class={[styles.tips, data.loadingDom ? styles.hiddens : "", data.tipShow ? "" : styles.tipHidden, query.platform === "pc" && data.tipShow ? styles.tipsPcBg : ""]}>
  1859. <div class={styles.tipTitle}>
  1860. <div class={styles.tipTitleName}>{fingerData.fingeringInfo.code}使用说明</div>
  1861. <Button
  1862. class={styles.tipClose}
  1863. onClick={(e: any) => {
  1864. e.stopPropagation();
  1865. data.tipShow = false;
  1866. }}
  1867. >
  1868. <Icon name="cross" size={19} color="#fff" />
  1869. </Button>
  1870. </div>
  1871. <div class={styles.iconBook}></div>
  1872. <div class={styles.tipContentbox}>
  1873. <div class={styles.tipContent}>
  1874. {data.tips.map((tip, tipIndex) => (
  1875. <div class={styles.tipItem}>
  1876. <div class={styles.iconWrap}>
  1877. <div class={styles.tipItemIcon}>{tipIndex + 1}</div>
  1878. </div>
  1879. <div>
  1880. {tip.name}: {tip.realName}
  1881. </div>
  1882. </div>
  1883. ))}
  1884. </div>
  1885. </div>
  1886. </div>
  1887. {data.loadingSoundFonts && (
  1888. <div class={styles.loading}>
  1889. <div class={styles.loadingWrap}>
  1890. <img class={styles.loadingIcon} src={icon_loading_img} />
  1891. <Progress percentage={data.loadingSoundProgress} />
  1892. <div class={styles.loadingTip}>加载中,请稍后…</div>
  1893. </div>
  1894. </div>
  1895. )}
  1896. </div>
  1897. <Popup
  1898. class={["tonePopup", tnoteShowBoxClass]}
  1899. style={query.platform === "pc" ? tnoteShowBoxDragData.styleDrag.value : {}}
  1900. v-model:show={data.tnoteShow}
  1901. position={state.platform === IPlatform.PC ? "center" : !query.modelType && fingerData.fingeringInfo.orientation === 1 ? "bottom" : "right"}
  1902. >
  1903. <div class={styles.tones}>
  1904. <div class={[styles.toneTitle, "toneTitle_pc"]}>
  1905. <div class={styles.tipTitleName}>移调</div>
  1906. <Button
  1907. class={styles.tipClose}
  1908. onClick={(e: any) => {
  1909. e.stopPropagation();
  1910. data.tnoteShow = false;
  1911. }}
  1912. >
  1913. <Icon name="cross" size={19} color="#fff" />
  1914. </Button>
  1915. </div>
  1916. <div class={[styles.tipContentbox, "tipContentbox_pc"]}>
  1917. <div class={[styles.tipContent, "tipContent_pc"]}>
  1918. <div class={[styles.tipWrap, "tipWrap_pc"]}>
  1919. <Space size={0} class={styles.toneContent}>
  1920. {data.tones.map((tone: IFIGNER_INSTRUMENT_Note) => {
  1921. const steps = new Array(Math.abs(tone.step)).fill(1);
  1922. return (
  1923. <Button
  1924. class={[fingerData.fingeringInfo.name == "hulusi-flute" && styles.hulusiBtn]}
  1925. round
  1926. plain
  1927. type={data.popupActiveTone.realName === tone.realName ? "primary" : "default"}
  1928. onClick={(e: any) => {
  1929. e.stopPropagation();
  1930. data.popupActiveTone = tone;
  1931. setNotes();
  1932. }}
  1933. >
  1934. {fingerData.fingeringInfo.name == "hulusi-flute" ? (
  1935. <div style={{ display: "flex", alignItems: "center" }}>
  1936. 全按作
  1937. <div class={[styles.noteKey, styles.hulusiNoteKey]}>
  1938. {tone.step > 0 ? <span class={styles.dot}></span> : null}
  1939. <div class={styles.noteName} style={{ fontSize: "0.25rem" }}>
  1940. <sup>{tone.mark && (tone.mark === "rise" ? "#" : "b")}</sup>
  1941. {tone.key}
  1942. </div>
  1943. {tone.step < 0 ? <span class={styles.dot}></span> : null}
  1944. </div>
  1945. </div>
  1946. ) : (
  1947. <div class={styles.noteName}>
  1948. <sup>{tone.mark && (tone.mark === "rise" ? "#" : "b")}</sup>
  1949. {tone.name}
  1950. </div>
  1951. )}
  1952. </Button>
  1953. );
  1954. })}
  1955. </Space>
  1956. </div>
  1957. <div class={[styles.toneAction, "toneAction_pc"]}>
  1958. <img
  1959. onClick={(e: any) => {
  1960. e.stopPropagation();
  1961. data.tnoteShow = false;
  1962. }}
  1963. src={icons.icon_action_cancel}
  1964. />
  1965. <img
  1966. onClick={(e: any) => {
  1967. e.stopPropagation();
  1968. data.activeTone = data.popupActiveTone;
  1969. setNotes();
  1970. data.tnoteShow = false;
  1971. }}
  1972. src={icons.icon_action_confirm}
  1973. />
  1974. </div>
  1975. </div>
  1976. </div>
  1977. </div>
  1978. {query.platform === "pc" && (
  1979. <>
  1980. <div class={[styles.dragTopBox, "dragTopBox"]}></div>
  1981. <Dragbom showGuide={guidanceShow.value} onGuideDone={setGuidanceShow}></Dragbom>
  1982. </>
  1983. )}
  1984. </Popup>
  1985. <Popup
  1986. style={query.platform === "pc" ? changeSubjectShowBoxDragData.styleDrag.value : {}}
  1987. v-model:show={data.changeSubjectShow}
  1988. class={[styles.changeSubjectPopup, query.platform === "pc" && styles.changeSubjectPopupPc, changeSubjectShowBoxClass]}
  1989. closeOnClickOverlay={query.platform === "pc" ? false : true}
  1990. onClick={(e: any) => {
  1991. e.stopPropagation();
  1992. }}
  1993. >
  1994. <ChangeSubject
  1995. subjectList={data.subjects}
  1996. subject={data.subject}
  1997. onClose={() => (data.changeSubjectShow = false)}
  1998. onConfirm={(code: any) => {
  1999. if (data.subject === code) {
  2000. data.changeSubjectShow = false;
  2001. return;
  2002. }
  2003. const originalSubject = JSON.parse(JSON.stringify(data.subject));
  2004. data.subject = code;
  2005. data.viewIndex = 0;
  2006. data.tipShow = false;
  2007. data.loadingDom = true;
  2008. fingerData.fingeringInfo = subjectFingering(data.subject);
  2009. data.activeTone = {} as any;
  2010. data.noteType = "all";
  2011. resetElement();
  2012. resetMode(true, 0);
  2013. // api_setRequestedOrientation(orientationDirection.value);
  2014. data.changeSubjectShow = false;
  2015. // 设置屏幕方向
  2016. setTimeout(() => {
  2017. const before = ["hulusi-flute", "piccolo", "baroque-recorder"].includes(originalSubject) ? 0 : 0;
  2018. if (orientationDirection.value !== before) {
  2019. data.paddingTop = "";
  2020. data.paddingLeft = "";
  2021. }
  2022. __init();
  2023. }, 100);
  2024. }}
  2025. />
  2026. {query.platform === "pc" && (
  2027. <>
  2028. <div class={[styles.dragTopBox, "dragTopBox"]}></div>
  2029. <Dragbom showGuide={guidanceShow.value} onGuideDone={setGuidanceShow}></Dragbom>
  2030. </>
  2031. )}
  2032. </Popup>
  2033. {props.show && !data.loading && !data.loadingSoundFonts && <GuideIndex fingeringMode={data.fingeringMode} showGuide={false} list={["finger"]} />}
  2034. </div>
  2035. );
  2036. };
  2037. },
  2038. });