|
@@ -15,7 +15,8 @@ import { usePageVisibility } from "@vant/use";
|
|
|
import { watch } from "vue";
|
|
|
import icon_loading_img from "./image/icon_loading_img.png";
|
|
|
import state, { IPlatform } from "/src/state";
|
|
|
-import { getSubjectList } from "../api";
|
|
|
+import { api_subjectList, getSubjectList } from "../api";
|
|
|
+import ChangeSubject from "./change-subject";
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: "viewFigner",
|
|
@@ -68,6 +69,8 @@ export default defineComponent({
|
|
|
loadingSoundFonts: true,
|
|
|
loadingSoundProgress: 0,
|
|
|
|
|
|
+ changeSubjectShow: false,
|
|
|
+
|
|
|
huaweiPad: navigator?.userAgent?.includes("UAWEIVRD-W09") ? true : false,
|
|
|
paddingTop: "",
|
|
|
paddingLeft: "",
|
|
@@ -201,22 +204,22 @@ export default defineComponent({
|
|
|
data.loadingSoundFonts = false;
|
|
|
};
|
|
|
|
|
|
- const selectSubjectType = (subject: string) => {
|
|
|
- data.subjects.forEach((item: any) => {
|
|
|
- if (item.value === subject) {
|
|
|
- item.className = styles.selected;
|
|
|
- } else {
|
|
|
- item.className = "";
|
|
|
- }
|
|
|
- });
|
|
|
- };
|
|
|
+ // const selectSubjectType = (subject: string) => {
|
|
|
+ // data.subjects.forEach((item: any) => {
|
|
|
+ // if (item.value === subject) {
|
|
|
+ // item.className = styles.selected;
|
|
|
+ // } else {
|
|
|
+ // item.className = "";
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // };
|
|
|
|
|
|
// 切换当前模式
|
|
|
const onChangeFingeringModel = () => {
|
|
|
//
|
|
|
if (playAction.listenLock) return;
|
|
|
if (playAction.showAnswerLoading) return;
|
|
|
- data.loadingImg = true
|
|
|
+ data.loadingImg = true;
|
|
|
if (data.fingeringMode === "scaleMode") {
|
|
|
if (["pan-flute", "ocarina"].includes(data.subject)) {
|
|
|
data.viewIndex = 1;
|
|
@@ -250,7 +253,7 @@ export default defineComponent({
|
|
|
data.loadingDom = true;
|
|
|
getNotes();
|
|
|
|
|
|
- selectSubjectType(data.subject);
|
|
|
+ // selectSubjectType(data.subject);
|
|
|
|
|
|
if (data.fingeringMode === "fingeringMode") {
|
|
|
if (data.subject === "pan-flute") {
|
|
@@ -285,19 +288,40 @@ export default defineComponent({
|
|
|
// 获取声部
|
|
|
const getSubjects = async () => {
|
|
|
try {
|
|
|
- const subjects = await getSubjectList({
|
|
|
+ // api_subjectList
|
|
|
+ const subjects = await api_subjectList({
|
|
|
enableFlag: true,
|
|
|
delFlag: 0,
|
|
|
page: 1,
|
|
|
rows: 999,
|
|
|
});
|
|
|
- const rows = subjects.data.rows || [];
|
|
|
+
|
|
|
+ const rows = subjects.data || [];
|
|
|
rows.forEach((row: any) => {
|
|
|
- data.subjects.push({
|
|
|
+ const tempList: any = {
|
|
|
text: row.name,
|
|
|
value: mappingVoicePart(row.code, "INSTRUMENT"),
|
|
|
- className: "",
|
|
|
- });
|
|
|
+ id: row.id,
|
|
|
+ children: [] as any,
|
|
|
+ };
|
|
|
+ if (row.instruments && row.instruments.length > 0) {
|
|
|
+ if (row.instruments.length > 1) {
|
|
|
+ row.instruments.forEach((i: any) => {
|
|
|
+ tempList.children.push({
|
|
|
+ text: i.name,
|
|
|
+ id: i.id,
|
|
|
+ value: mappingVoicePart(i.code, "INSTRUMENT"),
|
|
|
+ });
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ const singleRow = row.instruments[0];
|
|
|
+ if (singleRow.code) {
|
|
|
+ tempList.value = mappingVoicePart(singleRow.code, "INSTRUMENT");
|
|
|
+ tempList.id = singleRow.id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.subjects.push(tempList);
|
|
|
});
|
|
|
// console.log(data.subjects, "subjects");
|
|
|
} catch {
|
|
@@ -391,10 +415,10 @@ export default defineComponent({
|
|
|
// 排箫,默认0.9显示
|
|
|
const setDefaultScale = () => {
|
|
|
if (data.subject === "pan-flute") {
|
|
|
- data.transform.scale = 0.9
|
|
|
- data.transform.startScale = 0.9
|
|
|
+ data.transform.scale = 0.9;
|
|
|
+ data.transform.startScale = 0.9;
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
onMounted(() => {
|
|
|
loadElement();
|
|
@@ -402,7 +426,7 @@ export default defineComponent({
|
|
|
});
|
|
|
const loadElement = () => {
|
|
|
const fingeringContainer = document.getElementById("fingeringContainer");
|
|
|
- setDefaultScale()
|
|
|
+ setDefaultScale();
|
|
|
// console.log("🚀 ~ fingeringContainer:", fingeringContainer);
|
|
|
const mc = new Hammer.Manager(fingeringContainer as HTMLElement);
|
|
|
mc.add(new Hammer.Pan({ threshold: 0, pointers: 0 }));
|
|
@@ -910,65 +934,25 @@ export default defineComponent({
|
|
|
<img src={icons.icon_back} />
|
|
|
</button>
|
|
|
|
|
|
- <Popover
|
|
|
- placement="bottom"
|
|
|
- class={styles.popoverContainer}
|
|
|
- actions={data.subjects}
|
|
|
- onUpdate:show={() => {
|
|
|
+ <div
|
|
|
+ class={styles.baseBtn}
|
|
|
+ onClick={(e) => {
|
|
|
+ //
|
|
|
// 播放音阶时不能切换
|
|
|
- if (playStatus.gamut) return;
|
|
|
+ if (playStatus.gamut) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 开始答题不能切换
|
|
|
- if (playStatus.action) return;
|
|
|
- }}
|
|
|
- onSelect={(val: any) => {
|
|
|
- if (data.subject === val.value) return;
|
|
|
- const originalSubject = JSON.parse(JSON.stringify(data.subject));
|
|
|
- data.subject = val.value;
|
|
|
- data.viewIndex = 0;
|
|
|
- data.tipShow = false;
|
|
|
- data.loadingDom = true;
|
|
|
- fingerData.fingeringInfo = subjectFingering(data.subject);
|
|
|
- data.activeTone = {} as any;
|
|
|
- resetElement();
|
|
|
- resetMode(true, 0);
|
|
|
- api_setRequestedOrientation(orientationDirection.value);
|
|
|
- // 设置屏幕方向
|
|
|
- setTimeout(() => {
|
|
|
- const before = ["hulusi-flute", "piccolo", "baroque-recorder"].includes(originalSubject) ? 1 : 0;
|
|
|
- if (orientationDirection.value !== before) {
|
|
|
- data.paddingTop = "";
|
|
|
- data.paddingLeft = "";
|
|
|
- }
|
|
|
+ if (playAction.listenLock) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- __init();
|
|
|
- }, 100);
|
|
|
+ data.changeSubjectShow = true;
|
|
|
}}
|
|
|
>
|
|
|
- {{
|
|
|
- reference: () => (
|
|
|
- <div
|
|
|
- class={styles.baseBtn}
|
|
|
- onClick={(e) => {
|
|
|
- //
|
|
|
- // 播放音阶时不能切换
|
|
|
- if (playStatus.gamut) {
|
|
|
- e.stopPropagation();
|
|
|
- e.preventDefault();
|
|
|
- }
|
|
|
- // 开始答题不能切换
|
|
|
- // if (playStatus.action) return;
|
|
|
- if (playAction.listenLock) {
|
|
|
- e.stopPropagation();
|
|
|
- e.preventDefault();
|
|
|
- }
|
|
|
- }}
|
|
|
- >
|
|
|
- <img src={icons.icon_change_instrument} />
|
|
|
- <span>切换乐器</span>
|
|
|
- </div>
|
|
|
- ),
|
|
|
- }}
|
|
|
- </Popover>
|
|
|
+ <img src={icons.icon_change_instrument} />
|
|
|
+ <span>切换乐器</span>
|
|
|
+ </div>
|
|
|
<div class={styles.baseBtn} onClick={onChangeFingeringModel}>
|
|
|
<img src={modeText.value.icon} />
|
|
|
<span>{modeText.value.text}</span>
|
|
@@ -995,9 +979,7 @@ export default defineComponent({
|
|
|
class={[styles.fingeringContainer]}
|
|
|
>
|
|
|
<div class={styles.imgs}>
|
|
|
- {
|
|
|
- !data.loadingImg && <img src={data.fingeringMode === "scaleMode" ? fingerData.subject?.json?.full : fingerData.subject?.json?.full1} />
|
|
|
- }
|
|
|
+ {!data.loadingImg && <img src={data.fingeringMode === "scaleMode" ? fingerData.subject?.json?.full : fingerData.subject?.json?.full1} />}
|
|
|
{rs.map((key: number | string, index: number) => {
|
|
|
const nk: string = typeof key === "string" ? key.replace("active-", "") : String(key);
|
|
|
return <img data-index={nk} src={fingerData.subject?.json?.[nk]} />;
|
|
@@ -1294,6 +1276,39 @@ export default defineComponent({
|
|
|
</div>
|
|
|
</Popup>
|
|
|
|
|
|
+ <Popup v-model:show={data.changeSubjectShow} class={styles.changeSubjectPopup}>
|
|
|
+ <ChangeSubject
|
|
|
+ subjectList={data.subjects}
|
|
|
+ subject={data.subject}
|
|
|
+ onClose={() => (data.changeSubjectShow = false)}
|
|
|
+ onConfirm={(code: any) => {
|
|
|
+ if (data.subject === code) return;
|
|
|
+ const originalSubject = JSON.parse(JSON.stringify(data.subject));
|
|
|
+ data.subject = code;
|
|
|
+ data.viewIndex = 0;
|
|
|
+ data.tipShow = false;
|
|
|
+ data.loadingDom = true;
|
|
|
+ fingerData.fingeringInfo = subjectFingering(data.subject);
|
|
|
+ data.activeTone = {} as any;
|
|
|
+ resetElement();
|
|
|
+ resetMode(true, 0);
|
|
|
+ api_setRequestedOrientation(orientationDirection.value);
|
|
|
+
|
|
|
+ data.changeSubjectShow = false;
|
|
|
+ // 设置屏幕方向
|
|
|
+ setTimeout(() => {
|
|
|
+ const before = ["hulusi-flute", "piccolo", "baroque-recorder"].includes(originalSubject) ? 1 : 0;
|
|
|
+ if (orientationDirection.value !== before) {
|
|
|
+ data.paddingTop = "";
|
|
|
+ data.paddingLeft = "";
|
|
|
+ }
|
|
|
+
|
|
|
+ __init();
|
|
|
+ }, 100);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </Popup>
|
|
|
+
|
|
|
{props.show && !data.loading && !data.loadingSoundFonts && <GuideIndex fingeringMode={data.fingeringMode} showGuide={false} list={["finger"]} />}
|
|
|
</div>
|
|
|
);
|