1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054 |
- import { Transition, computed, defineComponent, onMounted, onUnmounted, reactive, ref, watch, toRef, ComputedRef, nextTick, defineAsyncComponent } from "vue";
- import styles from "./index.module.less";
- import iconBack from "./image/icon-back.png";
- import listImg from "./image/list.png";
- import iconMode from "./image/mode.png";
- import { headImg } from "./image";
- import { Badge, Circle, Popover, Popup, showConfirmDialog, showToast, NoticeBar } from "vant";
- import Speed from "./speed";
- import { evaluatingData, handleStartEvaluat } from "/src/view/evaluating";
- import Settting from "./settting";
- import state, { IPlatform, handleChangeSection, handleResetPlay, handleRessetState, togglePlay, IPlayState, refreshMusicSvg, EnumMusicRenderType, resetSettings, handleGuide, resetCursorPosition } from "/src/state";
- import { getAudioCurrentTime } from "/src/view/audio-list";
- import { followData, toggleFollow } from "/src/view/follow-practice";
- import { api_back } from "/src/helpers/communication";
- import MusicType from "./music-type";
- import { getQuery } from "/src/utils/queryString";
- import { storeData } from "/src/store";
- import TeacherTop from "../custom-plugins/guide-page/teacher-top";
- import StudentTop from "../custom-plugins/guide-page/student-top";
- import { HANDLE_WORK_ADD } from "../custom-plugins/work-index";
- import { browser } from "/src/utils";
- import store from "store";
- import "../component/the-modal-tip/index.module.less";
- import { metronomeData } from "../../helpers/metronome";
- import { toggleMusicSheet } from "/src/view/plugins/toggleMusicSheet";
- import useDrag from "/src/view/plugins/useDrag/index";
- import Dragbom from "/src/view/plugins/useDrag/dragbom";
- import { getGuidance, setGuidance } from "../custom-plugins/guide-page/api";
- // import ModeView from "./modeView";
- import { smoothAnimationState } from "../view-detail/smoothAnimation";
- import { isMusicList, musicListShow } from "../component/the-music-list";
- import { EvaluatingDriver, FollowDriver, PractiseDriver } from "../custom-plugins/guide-driver";
- import { fingerRef } from "/src/page-instrument/view-detail/index"
- import { permissionPopup } from "/src/page-instrument/component/vip/permission";
- const ModeView = defineAsyncComponent(() =>
- import('./modeView')
- )
- /** 校验是否能切换模式,会员的曲子,酷乐秀跟练模式、评测模式需要svip */
- export const checkMusicBuy = (item: any, type?: string) => {
- let checked = true;
- // 学生端或者老师端需要校验点播和会员曲目
- if (state.systemType === "student" || state.systemType === "teacher") {
- // 如果是点播的曲子,并且还没有购买,需要弹窗提醒
- if (item.paymentType === "CHARGE" && !item.buyed) {
- permissionPopup.active = "demand"
- permissionPopup.musicId = item.id
- permissionPopup.musicPrice = item.musicPrice
- permissionPopup.show = true
- checked = false
- }
- /**
- * 如果是vip的曲子,当前用户不是会员时,需要弹窗提醒
- * 如果是vip的曲子,当前用户不是svip会员,点击跟练或评测时,需要弹窗提醒(会员曲子,跟练和评测需要开通svip会员才能使用)
- */
- if ( (state.vipType === "NOT_VIP" && item.paymentType !== "FREE") || (!state.vipType.includes("SVIP") && (type === "follow" || type === "evaluating")) ) {
- permissionPopup.active = item.paymentType.includes('CHARGE') ? "memberAndDemand" : "member"
- permissionPopup.musicId = item.id
- permissionPopup.musicPrice = item.musicPrice
- permissionPopup.show = true
- checked = false
- }
- }
- return checked;
- };
- /** 头部数据和方法 */
- export const headTopData = reactive({
- /** 模式 */
- modeType: "" as "init" | "show",
- /** 显示返回按钮 */
- showBack: true,
- /** 设置弹窗 */
- settingMode: false,
- /** 切换模式 */
- handleChangeModeType(value: "practise" | "follow" | "evaluating") {
- // 后台设置为不能评测
- if (value === "evaluating" && !state.enableEvaluation) return;
- // 打击乐&节奏练习不支持跟练模式
- if (value === "follow" && state.isPercussion) return;
- // 跟练模式,光标只有音符模式,无节拍模式
- if (value === "follow" && metronomeData.cursorMode === 2) {
- metronomeData.cursorMode = 1;
- }
- if (value === "practise") {
- // state.playIngSpeed = state.speed
- }
- if (value === "evaluating") {
- // 如果延迟检测资源还在加载中,给出提示
- if (!evaluatingData.jsonLoadDone) {
- evaluatingData.jsonLoading = true;
- state.audioDone && showToast("资源加载中,请稍后"); //音频资源加载完之后才提示
- return;
- }
- // 如果是pc端, 评测模式暂不可用
- if (state.platform === IPlatform.PC) {
- showConfirmDialog({
- className: "modalTip",
- title: "温馨提示",
- message: "该功能暂未开放,敬请期待!",
- showCancelButton: false,
- });
- return;
- }
- // 评测模式,只有一行谱模式
- // if (!state.isSingleLine) {
- // state.isSingleLine = true;
- // refreshMusicSvg();
- // }
- smoothAnimationState.isShow.value = false; // 隐藏旋律线
- state.playIngSpeed = state.originSpeed;
- handleStartEvaluat();
- resetCursorPosition()
- // 开发模式,把此处打开
- // state.modeType = "evaluating";
- // evaluatingData.rendered = true;
- // evaluatingData.soundEffectMode = true;
- } else if (value === "follow") {
- // 跟练模式,只有一行谱模式
- if (!state.isSingleLine) {
- state.isSingleLine = true;
- refreshMusicSvg();
- }
- smoothAnimationState.isShow.value = false;
- toggleFollow();
- }
- headTopData.modeType = "show";
- },
- // 改变模式之前的状态
- oldPlayType: "play",
- // 记录切换模式前的状态
- oldModeType: "practise" as "practise" | "follow" | "evaluating",
- });
- export const headData = reactive({
- speedShow: false,
- musicTypeShow: false,
- });
- let resetBtn: ComputedRef<{
- display: boolean;
- disabled: boolean;
- }>;
- // 点击切换的时候才触发提醒
- let isClickMode = false;
- /**
- * 处理模式切换
- * @param oldPlayType 没改变之前的播放模式
- * @param oldPlaySource 没改变之前的播放类型
- * @param isforceReset 是否强制刷新播放状态 模式times时值改变时候也刷新
- */
- export function handlerModeChange(oldPlayType: "play" | "sing", oldPlaySource: IPlayState, isforceReset?: boolean) {
- const isModeChange = modeChangeHandleTimes(oldPlayType, oldPlaySource);
- // 没有切换的时候 不处理下面的
- if (isModeChange) {
- try {
- metronomeData.metro.calculation(state.times);
- } catch (error) {}
- console.log("重新之后的times", state.times, state.fixtime);
- }
- if (isModeChange || isforceReset) {
- // 重置播放状态
- handleRessetState();
- // 隐藏重播按钮
- resetBtn && (resetBtn.value.display = false);
- }
- // 当模式改变的时候 放在这里是因为需要等谱面加载完成之后再提示(点击按钮模式切换才提示)
- if (isClickMode) {
- showToast({
- message: state.playType === "play" ? "已切换为演奏场景" : "已切换为演唱场景",
- position: "top",
- className: "selectionToast",
- });
- isClickMode = false;
- }
- }
- // 模式切换之后重新给times赋值
- function modeChangeHandleTimes(oldPlayType: "play" | "sing", oldPlaySource: IPlayState) {
- const playType = state.playType;
- const playSource = state.playSource;
- const { notBeatFixtime, xmlMp3BeatFixTime, difftime } = state.times[0];
- const { isOpenMetronome, isSingOpenMetronome } = state;
- // 演奏向演唱切
- if (oldPlayType === "play" && playType === "sing") {
- if (playSource === "mingSong") {
- // 唱名文件也要加上弱起时间 他们制作曲子加了弱起时间 注意这修改了之后给总控平台的时值也需要改
- state.fixtime = difftime;
- state.times.map((item) => {
- item.time = item.xmlNoteTime + difftime;
- item.endtime = item.xmlNoteEndTime + difftime;
- item.fixtime = difftime;
- });
- return true;
- } else {
- //演奏开了节拍器,演唱没开节拍器
- if (isOpenMetronome && !isSingOpenMetronome) {
- state.fixtime = notBeatFixtime;
- state.times.map((item) => {
- item.time = item.notBeatTime;
- item.endtime = item.notBeatEndTime;
- item.fixtime = notBeatFixtime;
- });
- return true;
- } else if (!isOpenMetronome && isSingOpenMetronome) {
- state.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
- state.times.map((item) => {
- item.time = item.notBeatTime + xmlMp3BeatFixTime;
- item.endtime = item.notBeatEndTime + xmlMp3BeatFixTime;
- item.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
- });
- return true;
- }
- }
- } else if (oldPlayType === "sing" && playType === "play") {
- // 演唱向演奏切
- if (oldPlaySource === "mingSong") {
- // 有节拍器
- if (isOpenMetronome) {
- state.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
- state.times.map((item) => {
- item.time = item.notBeatTime + xmlMp3BeatFixTime;
- item.endtime = item.notBeatEndTime + xmlMp3BeatFixTime;
- item.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
- });
- return true;
- } else {
- state.fixtime = notBeatFixtime;
- state.times.map((item) => {
- item.time = item.notBeatTime;
- item.endtime = item.notBeatEndTime;
- item.fixtime = notBeatFixtime;
- });
- return true;
- }
- }
- // 演奏开了节拍器,演唱没开节拍器
- if (isOpenMetronome && !isSingOpenMetronome) {
- state.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
- state.times.map((item) => {
- item.time = item.notBeatTime + xmlMp3BeatFixTime;
- item.endtime = item.notBeatEndTime + xmlMp3BeatFixTime;
- item.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
- });
- return true;
- } else if (!isOpenMetronome && isSingOpenMetronome) {
- state.fixtime = notBeatFixtime;
- state.times.map((item) => {
- item.time = item.notBeatTime;
- item.endtime = item.notBeatEndTime;
- item.fixtime = notBeatFixtime;
- });
- return true;
- }
- } else if (oldPlayType === "sing" && playType === "sing") {
- // 演唱之间切换
- // 切到唱名时候
- if (playSource === "mingSong") {
- // 唱名文件也要加上弱起时间 他们制作曲子加了弱起时间 注意这修改了之后给总控平台的时值也需要改
- state.fixtime = difftime;
- state.times.map((item) => {
- item.time = item.xmlNoteTime + difftime;
- item.endtime = item.xmlNoteEndTime + difftime;
- item.fixtime = difftime;
- });
- return true;
- } else if (oldPlaySource === "mingSong") {
- // 有节拍器
- if (isSingOpenMetronome) {
- state.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
- state.times.map((item) => {
- item.time = item.notBeatTime + xmlMp3BeatFixTime;
- item.endtime = item.notBeatEndTime + xmlMp3BeatFixTime;
- item.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
- });
- return true;
- } else {
- state.fixtime = notBeatFixtime;
- state.times.map((item) => {
- item.time = item.notBeatTime;
- item.endtime = item.notBeatEndTime;
- item.fixtime = notBeatFixtime;
- });
- return true;
- }
- }
- }
- return false;
- }
- export default defineComponent({
- name: "header-top",
- emits: ["close"],
- setup(props, { emit }) {
- const query = getQuery();
- // 是否显示引导
- const showGuide = ref(false);
- const showStudentGuide = ref(false);
- const showWebGuide = ref(true);
- let displayFingeringCache = false; // 指法缓存
- /** 设置按钮 */
- const settingBtn = computed(() => {
- // 音频播放中 禁用
- if (state.playState === "play") return { display: true, disabled: true };
- // 评测开始 禁用, 跟练开始 禁用
- if (evaluatingData.startBegin || followData.start) return { display: true, disabled: true };
- return {
- display: true,
- disabled: false,
- };
- });
- /** 转谱按钮 */
- const converBtn = computed(() => {
- // 音频播放中 禁用
- if (state.playState === "play") return { display: true, disabled: true };
- // 评测开始 禁用
- if (evaluatingData.startBegin || followData.start) return { display: true, disabled: true };
- return {
- disabled: false,
- display: true,
- };
- });
- /** 速度按钮 */
- const speedBtn = computed(() => {
- // 选择模式, 跟练模式 不显示
- //if (headTopData.modeType !== "show" || state.modeType === "follow") return { display: false, disabled: true };
- if (state.modeType === "follow") return { display: false, disabled: true };
- // 评测模式, 音频播放中 禁用
- if (state.modeType === "evaluating" || state.playState === "play") return { display: true, disabled: true };
- return {
- disabled: false,
- display: true,
- };
- });
- /** 节拍器按钮 */
- const metronomeBtn = computed(() => {
- // 选择模式 不显示
- //if (headTopData.modeType !== "show") return { display: false, disabled: true };
- // 音频播放中 禁用
- if (state.playState === "play") return { display: true, disabled: true };
- return {
- disabled: false,
- display: true,
- };
- });
- /** 指法按钮 */
- const fingeringBtn = computed(() => {
- // 后台设置不显示指法
- if (!state.isShowFingering) return { display: true, disabled: true };
- // 没有指法 选择模式 评测模式 跟练模式 不显示
- //if (headTopData.modeType !== "show" || !state.fingeringInfo.name || ["evaluating", "follow"].includes(state.modeType)) return { display: false, disabled: true };
- if (!state.fingeringInfo.name || ["evaluating", "follow"].includes(state.modeType)) return { display: false, disabled: true };
- // 音频播放中 禁用
- if (state.playState === "play") return { display: true, disabled: true };
- return {
- disabled: false,
- display: true,
- };
- });
- /** 摄像头按钮 */
- const cameraBtn = computed(() => {
- // 选择模式 不显示
- if (headTopData.modeType !== "show" || state.modeType !== "evaluating") return { display: false, disabled: true };
- // 音频播放中 禁用
- if (state.playState === "play") return { display: true, disabled: true };
- return {
- disabled: false,
- display: true,
- };
- });
- /** 选段按钮 */
- const selectBtn = computed(() => {
- // 选择模式 不显示
- //if (headTopData.modeType !== "show" || ["follow"].includes(state.modeType)) return { display: false, disabled: true };
- if (["follow"].includes(state.modeType)) return { display: false, disabled: true };
- // 音频播放中 禁用
- if (state.playState === "play" || state.isHomeWork) return { display: true, disabled: true };
- return {
- disabled: false,
- display: true,
- };
- });
- /** 原声按钮 */
- const originBtn = computed(() => {
- // 没有音源不显示
- if (state.noMusicSource) return { display: false, disabled: false };
- // 选择模式,跟练模式 不显示
- //if (headTopData.modeType !== "show" || state.modeType === "follow") return { display: false, disabled: false };
- if (state.modeType === "follow") return { display: false, disabled: false };
- // 评测开始 禁用
- if (state.modeType === "evaluating") return { display: false, disabled: true };
- if (!state.isAppPlay) {
- if (state.playType === "play") {
- // 原声, 伴奏 少一个,就不能切换
- if (state.music && state.accompany) return { display: true, disabled: false };
- } else {
- // 播放过程中不能切换
- if (state.playState === "play") {
- return { display: true, disabled: true };
- }
- // 范唱
- let index = 0;
- state.fanSong && index++;
- state.banSong && index++;
- state.mingSong && index++;
- if (index > 1) {
- return { display: true, disabled: false };
- }
- }
- }
- return {
- disabled: true,
- display: true,
- };
- });
- /** 播放类型按钮 */
- const playTypeBtn = computed(() => {
- // 选择模式,跟练模式,评测模式 不显示
- //if (headTopData.modeType !== "show" || state.modeType === "follow" || state.modeType === "evaluating" || state.isHomeWork) return { display: false, disabled: false };
- if (state.modeType === "follow" || state.modeType === "evaluating" || state.isHomeWork) return { display: false, disabled: false };
- if (!state.isAppPlay) {
- let index = 0;
- state.music && index++;
- state.accompany && index++;
- let songIndex = 0;
- state.fanSong && songIndex++;
- state.banSong && songIndex++;
- state.mingSong && songIndex++;
- // 演唱和演奏 都有数据的时间不禁用
- if (songIndex > 0 && index > 0) {
- // 音频播放中 禁用
- if (state.playState === "play") {
- return { display: true, disabled: true };
- }
- return { display: true, disabled: false };
- }
- }
- return {
- disabled: false,
- display: false,
- };
- });
- /** 模式切换按钮 */
- const toggleBtn = computed(() => {
- // 老师端,打击乐&节奏练习不显示
- if (state.isPercussion && state.platform === IPlatform.PC) return { display: false, disabled: false };
- if(state.isCombineRender) return { display: false, disabled: false };
- // 没有音源不显示
- if (state.noMusicSource) return { display: false, disabled: false };
- // 不是演奏模式 影藏
- if (state.playType !== "play") return { display: false, disabled: false };
- // 选择模式, url设置模式 不显示
- if (headTopData.modeType !== "show" || !headTopData.showBack) return { display: false, disabled: false };
- // 跟练开始, 评测开始 播放开始 隐藏
- if (state.playState == "play" || followData.start || evaluatingData.startBegin) return { display: true, disabled: true };
- // 课件播放,上课页面潜入云教练,不显示模式切换
- if (query.hideMode == 1) return { display: false, disabled: false };
- return {
- display: true,
- disabled: false,
- };
- });
- /** 播放按钮 */
- const playBtn = computed(() => {
- // 没有音源不显示
- if (state.noMusicSource) return { display: false, disabled: false };
- // 选择模式 不显示
- if (headTopData.modeType !== "show") return { display: false, disabled: false };
- // 评测模式 不显示,跟练模式 不显示
- if (["evaluating", "follow"].includes(state.modeType)) return { display: false, disabled: true };
- // midi音频未初始化完成不可点击
- if (state.isAppPlay && state.midiPlayIniting) return { display: true, disabled: true };
- return {
- display: true,
- disabled: false,
- };
- });
- /** 重播按钮 */
- resetBtn = computed(() => {
- // 没有音源不显示
- if (state.noMusicSource) return { display: false, disabled: false };
- // 选择模式 不显示
- if (headTopData.modeType !== "show") return { display: false, disabled: false };
- // 评测模式 不显示,跟练模式 不显示
- if (["evaluating", "follow"].includes(state.modeType)) return { display: false, disabled: true };
- // 播放状态 不显示
- if (state.playState === "play") return { display: false, disabled: true };
- // 播放进度为0 不显示
- const currentTime = getAudioCurrentTime();
- // midi音频未初始化完成不可点击
- if (state.isAppPlay && state.midiPlayIniting) return { display: false, disabled: true };
- if (!currentTime) return { display: false, disabled: true };
- return {
- display: true,
- disabled: false,
- };
- });
- /** 重置按钮 */
- const restoreBtn = computed(() => {
- // 播放中 禁用
- if (state.playState === "play" || evaluatingData.startBegin || followData.start || state.isHomeWork) return { display: true, disabled: true };
- return {
- disabled: false,
- display: true,
- };
- });
-
- const browInfo = browser();
- /** 返回 */
- const handleBack = () => {
- // 如果是乐教通,点击返回按钮,需要关闭当前窗口
- if (query["isYjt"] == "1") {
- window.parent.postMessage(
- {
- api: "api_YjtClose"
- },
- "*"
- );
- return
- }
- // 练习作业,完整练习才记录练习次数
- // HANDLE_WORK_ADD();
- // 不在APP中,
- if (!storeData.isApp) {
- window.parent.postMessage(
- {
- api: "back",
- },
- "*"
- );
- window.close();
- return;
- }
- if ((browInfo.iPhone || browInfo.ios) && state.isHomeWork) {
- setTimeout(() => {
- api_back();
- }, 550);
- return;
- }
- api_back();
- };
- /** 根据参数设置模式 */
- const getQueryModelSetModelType = () => {
- /** 作业模式 start, 如果为作业模式不处理,让作业模块处理 */
- if (state.isHomeWork) {
- return;
- }
- /** 作业模式 end */
- if (state.defaultModeType == 1) {
- headTopData.handleChangeModeType("practise");
- // if (state.platform === IPlatform.PC || state.isPreView) {
- // headTopData.showBack = false;
- // }
- if (state.isPreView) {
- headTopData.showBack = false;
- }
- } else {
- if (query.modelType) {
- if (query.modelType === "practise") {
- headTopData.handleChangeModeType("practise");
- } else if (query.modelType === "evaluating") {
- headTopData.handleChangeModeType("evaluating");
- }
- headTopData.showBack = false;
- } else {
- setTimeout(() => {
- headTopData.modeType = "init";
- }, 500);
- }
- }
- };
- /** 课件播放 */
- const changePlay = (res: any) => {
- // console.log('监听上课页面message',res)
- if (res?.data?.api === "setPlayState") {
- togglePlay("paused", true);
- }
- if(res?.data?.api === 'togglePlayState') {
- // if(state.playState === "play") {
- // togglePlay("paused");
- // }
- // if(state.playState === 'paused') {
- // togglePlay("play");
- // }
- console.log('togglePlayState', state.playState)
- togglePlay(state.playState === "play" ? "paused" : "play");
- }
- // 上课页面,按钮方向
- if (res?.data?.api === "imagePos") {
- if (res?.data.data) {
- state.playBtnDirection = res.data.data === "right" ? "right" : "left";
- // if (state.fingeringInfo.direction === "vertical" && state.setting.displayFingering) {
- // state.musicScoreBtnDirection = state.playBtnDirection === 'right' ? 'left' : 'right';
- // } else {
- // state.musicScoreBtnDirection = state.playBtnDirection;
- // }
- state.musicScoreBtnDirection = state.playBtnDirection;
- }
- }
- };
- const parentClassName = "settingBoxClass_drag";
- const userId = storeData.user?.id ? String(storeData.user?.id) : "";
- const positionInfo =
- state.platform !== IPlatform.PC
- ? {
- styleDrag: { value: null },
- }
- : useDrag([`${parentClassName} .top_draging`, `${parentClassName} .bom_drag`], parentClassName, toRef(headTopData, "settingMode"), userId);
- const speedClassName = "speedBoxClass_drag";
- const speedInfo =
- state.platform !== IPlatform.PC
- ? {
- styleDrag: { value: null },
- }
- : useDrag([`${speedClassName} .top_draging`, `${speedClassName} .bom_drag`], speedClassName, toRef(headData, "speedShow"), userId);
- onMounted(() => {
- getQueryModelSetModelType();
- window.addEventListener("message", changePlay);
- if (state.platform === IPlatform.PC) {
- showGuide.value = true;
- } else {
- showStudentGuide.value = true;
- }
- if (query.showWebGuide === "false") {
- showWebGuide.value = false;
- }
- document.addEventListener("keydown", (e: KeyboardEvent) => {
- if (e.code === "Tab") {
- e.stopPropagation();
- e.preventDefault();
- // onStartPlayState();
- togglePlay(state.playState === "play" ? "paused" : "play");
- }
- });
- });
- onUnmounted(() => {
- window.removeEventListener("message", changePlay);
- });
- const noticeBarWidth = ref<number>();
- watch(
- () => smoothAnimationState.isShow.value,
- () => {
- // NoticeBar能不能滚动
- if ((smoothAnimationState.isShow.value || state.isCombineRender) && isMusicList.value) {
- nextTick(() => {
- const widthCon = (document.querySelector("#noticeBarRollDom .van-notice-bar__content") as any)?.offsetWidth || undefined;
- noticeBarWidth.value = widthCon;
- });
- }
- },
- { immediate: true }
- );
- // 设置改变触发
- watch(state.setting, () => {
- console.log(state.setting, "state.setting");
- store.set("musicscoresetting", state.setting);
- });
- const isPad = navigator?.userAgent?.includes("UAWEIVRD-W09") || browInfo?.iPad || browInfo.isTablet;
- return () => (
- <>
- <div
- class={[styles.headerTop, state.platform === IPlatform.PC && state.musicScoreBtnDirection === "left" ? styles.headerTopRight : ""]}
- onClick={(e: Event) => {
- e.stopPropagation();
- if (state.platform === IPlatform.PC) {
- // 显示隐藏菜单
- window.parent.postMessage(
- {
- api: "onAttendToggleMenu",
- },
- "*"
- );
- }
- }}
- >
- {/* 返回和标题 */}
- {
- <div id="noticeBarRollDom" class={[styles.headTopLeftBox, (state.playState == "play" || followData.practiceStart || evaluatingData.startBegin) && styles.headTopLeftHide]}>
- {
- !query.isMove && !query.isHideBack && <img src={iconBack} class={["headTopBackBtn", styles.img, !headTopData.showBack && styles.hidenBack]} onClick={handleBack} />
- }
- {smoothAnimationState.isShow.value || state.isCombineRender ? (
- <div
- style={
- noticeBarWidth.value
- ? {
- "--noticeBarWidth": noticeBarWidth.value + "px",
- }
- : {}
- }
- class={[styles.title, state.isCbsView && styles.blackTitle, "headeTopTitleBtn", isPad && styles.isIpad]}
- onClick={() => {
- isMusicList.value && (musicListShow.value = true);
- }}
- >
- {isMusicList.value && <div class={[styles.symbolNote, "driver-8"]}></div>}
- <NoticeBar text={state.examSongName} background="none" />
- </div>
- ) : (
- isMusicList.value && (
- <img
- src={listImg}
- class={[styles.img, styles.listImg, "driver-8"]}
- onClick={() => {
- musicListShow.value = true;
- }}
- />
- )
- )}
- </div>
- }
- {/* 模式提醒 */}
- {/* {state.modeType === "practise" && (
- <div class={[styles.modeWarn, "practiseModeWarn", state.platform === IPlatform.PC && state.musicScoreBtnDirection === "left" ? styles.modeWarnRight : ""]}>
- <img src={state.playType === "play" ? headImg("perform1.png") : headImg("sing1.png")} />
- <div>{state.playType === "play" ? "演奏场景" : "演唱场景"}</div>
- </div>
- )} */}
- {/* 功能按钮 */}
- <div
- class={[styles.headRight]}
- onClick={(e: Event) => {
- e.stopPropagation();
- }}
- >
- {/* 模式切换 */}
- {
- <div
- id={state.platform === IPlatform.PC ? "teacherTop-0" : "studnetT-0"}
- style={{ display: toggleBtn.value.display ? "" : "none"}}
- class={["driver-9", styles.modeChangeBox, toggleBtn.value.disabled && styles.disabled, styles.modeType]}
- onClick={() => {
- headTopData.oldModeType = state.modeType;
- handleRessetState();
- headTopData.modeType = "init";
- }}
- >
- <img class={styles.img} src={iconMode} />
- <div class={styles.title}>{state.modeType === "practise" ? "练习模式" : state.modeType === "follow" ? "跟练模式" : state.modeType === "evaluating" ? "评测模式" : ""}</div>
- </div>
- }
- {/* 一行谱模式,暂不支持节拍指针 */}
- {/* {(
- <div
- class={[styles.btn, state.platform === IPlatform.PC ? styles.pcBtn : ""]}
- onClick={() => {
- // 切换光标模式
- let mode = metronomeData.cursorMode;
- if (["follow"].includes(state.modeType)) {
- mode = metronomeData.cursorMode === 1 ? 3 : 1;
- } else {
- mode = metronomeData.cursorMode === 1 ? 3 : metronomeData.cursorMode === 2 ? 1 : 2;
- }
- metronomeData.cursorMode = mode;
- }}
- >
- <img class={styles.iconBtn} src={headImg(metronomeData.cursorMode === 1 ? "cursor_icon1.png" : metronomeData.cursorMode === 2 ? "cursor_icon2.png" : metronomeData.cursorMode === 3 ? "cursor_icon3.png" : "")} />
- <span class={styles.iconContent}>
- {metronomeData.cursorMode === 1 ? "音符指针" : metronomeData.cursorMode === 2 ? "节拍指针" : metronomeData.cursorMode === 3 ? "关闭指针" : ""}
- {metronomeData.cursorTips && (
- <div class={[styles["botton-tips"], metronomeData.cursorMode === 3 ? styles.tipSpec : ""]}>{metronomeData.cursorTips}</div>
- )}
- </span>
- </div>
- )} */}
- <div
- style={{ display: playTypeBtn.value.display ? "" : "none" }}
- class={["driver-2", styles.btn, playTypeBtn.value.disabled && styles.disabled, styles.playType]}
- onClick={() => {
- const oldPlayType = state.playType;
- headTopData.oldPlayType = oldPlayType;
- const oldPlaySource = state.playSource;
- if (state.playType === "play") {
- state.playType = "sing";
- state.playSource = state.fanSong ? "music" : state.banSong ? "background" : "mingSong";
- } else {
- state.playType = "play";
- state.playSource = state.music ? "music" : "background";
- }
- isClickMode = true;
- // 有指法并且显示指法的时候 切换到演唱模式 需要影藏指法
- let isRefresh = false;
- if (state.isShowFingering && state.fingeringInfo.name && (state.setting.displayFingering || displayFingeringCache)) {
- if (state.playType === "sing") {
- state.setting.displayFingering = false;
- displayFingeringCache = true;
- } else {
- state.setting.displayFingering = displayFingeringCache;
- displayFingeringCache = false;
- }
- // 如果是竖屏指法和一行谱的时候 改变指法值的时候state 会调用刷新 refreshMusicSvg 所以下面不调用
- if (state.fingeringInfo.direction === "vertical" && !state.isSingleLine) {
- isRefresh = true;
- }
- }
- // 有歌词的时候,切换播放模式,需要重新渲染谱面 指法不刷新谱面的时候
- if (state.xmlHasLyric && !isRefresh) {
- refreshMusicSvg();
- } else if (!isRefresh) {
- handlerModeChange(oldPlayType, oldPlaySource, true);
- }
- }}
- >
- <img style={{ display: state.playType === "play" ? "" : "none" }} class={styles.iconBtn} src={headImg(`perform.png`)} />
- <img style={{ display: state.playType === "play" ? "none" : "" }} class={styles.iconBtn} src={headImg(`sing.png`)} />
- <span>{state.playType === "play" ? "演奏" : "演唱"}</span>
- </div>
- <div
- id={state.platform === IPlatform.PC ? "teacherTop-1" : "studnetT-1"}
- style={{ display: originBtn.value.display ? "" : "none" }}
- class={["driver-3", styles.btn, originBtn.value.disabled && styles.disabled, state.playType === "play" ? styles.playSource : styles.songSource]}
- onClick={() => {
- const oldPlayType = state.playType;
- const oldPlaySource = state.playSource;
- if (state.playType === "play") {
- state.playSource = state.playSource === "music" ? "background" : "music";
- } else {
- if (state.playSource === "music") {
- state.playSource = state.banSong ? "background" : "mingSong";
- } else if (state.playSource === "background") {
- state.playSource = state.mingSong ? "mingSong" : "music";
- } else {
- state.playSource = state.fanSong ? "music" : "background";
- }
- }
- handlerModeChange(oldPlayType, oldPlaySource);
- showToast({
- message: state.playType === "play" ? (state.playSource === "music" ? "已切换为原声" : "已切换为伴奏") : state.playSource === "music" ? "已切换为范唱" : state.playSource === "background" ? "已切换为伴唱" : "已切换为唱名",
- position: "top",
- className: "selectionToast",
- });
- }}
- >
- <img style={{ display: state.playSource === "music" ? "" : "none" }} class={styles.iconBtn} src={state.playType === "play" ? headImg(`music.png`) : headImg(`music1.png`)} />
- <img style={{ display: state.playSource === "background" ? "" : "none" }} class={styles.iconBtn} src={state.playType === "play" ? headImg(`background.png`) : headImg(`background1.png`)} />
- <img style={{ display: state.playSource === "mingSong" ? "" : "none" }} class={styles.iconBtn} src={headImg(`mingsong.png`)} />
- <span>{state.playSource === "music" ? (state.playType === "play" ? "原声" : "范唱") : state.playSource === "background" ? (state.playType === "play" ? "伴奏" : "伴唱") : "唱名"}</span>
- </div>
- <div
- id={state.platform === IPlatform.PC ? "teacherTop-2" : "studnetT-2"}
- style={{ display: selectBtn.value.display ? "" : "none" }}
- class={["driver-4", styles.btn, selectBtn.value.disabled && styles.disabled, styles.section, state.sectionStatus && styles.isSection]}
- onClick={() => handleChangeSection()}
- >
- <img style={{ display: state.section.length === 0 ? "" : "none" }} class={styles.iconBtn} src={headImg(`section0.png`)} />
- <img style={{ display: state.section.length === 1 ? "" : "none" }} class={styles.iconBtn} src={headImg(`section1.png`)} />
- <img style={{ display: state.section.length === 2 ? "" : "none" }} class={styles.iconBtn} src={headImg(`section2.png`)} />
- <span>选段</span>
- </div>
- {
- <>
- <div
- style={{ display: metronomeBtn.value.display ? "" : "none" }}
- class={["driver-5", styles.btn, styles.metronomeBtn, metronomeBtn.value.disabled && styles.disabled, headData.speedShow && styles.isSpeed, styles.speed]}
- onClick={async () => {
- headData.speedShow = !headData.speedShow;
- }}
- >
- <img style={{ display: metronomeData.disable ? "block" : "none" }} class={styles.iconBtn} src={headImg("tickon.png")} />
- <img style={{ display: !metronomeData.disable ? "block" : "none" }} class={styles.iconBtn} src={headImg("tickoff.png")} />
- <span style={{ whiteSpace: "nowrap" }}>节拍</span>
- <div class={styles.speedCon}>
- <img src={headImg(`${state.speedIcon}.png`)} />
- <div>{Math.floor(state.speed)}</div>
- </div>
- </div>
- {
- <Popup v-model:show={headData.speedShow} class="popup-custom van-scale center-closeBtn speedBoxClass_drag" transition="van-scale" teleport="body" style={speedInfo.styleDrag.value} overlay-style={{ background: "rgba(0, 0, 0, 0.7)" }}>
- <Speed />
- {state.platform === IPlatform.PC && <Dragbom showGuide={!state.guideInfo?.teacherDrag} onGuideDone={handleGuide} />}
- </Popup>
- }
- </>
- }
- {/* {state.enableNotation ? (
- <Popover trigger="manual" v-model:show={headData.musicTypeShow} class={state.platform === IPlatform.PC && styles.pcTransPop} placement={state.platform === IPlatform.PC ? "top-end" : "bottom-end"} overlay={false} offset={state.platform === IPlatform.PC ? [0, 40] : [0, 8]}>
- {{
- reference: () => (
- <div
- id={state.platform === IPlatform.PC ? "teacherTop-5" : "studnetT-5"}
- style={{ display: converBtn.value.display ? "" : "none" }}
- class={[styles.btn, converBtn.value.disabled && styles.disabled]}
- onClick={(e: Event) => {
- e.stopPropagation();
- headData.musicTypeShow = !headData.musicTypeShow;
- }}
- >
- <img class={styles.iconBtn} src={headImg("icon_zhuanpu.svg")} />
- <span>{state.musicRenderType === "staff" ? "转简谱" : "转五线谱"}</span>
- </div>
- ),
- default: () => <MusicType />,
- }}
- </Popover>
- ) : null} */}
- {state.musicRendered && !query.lessonTrainingId && !query.questionId && state.isConcert && (
- <div
- class={[styles.btn, state.playState === "play" && fingeringBtn.value.disabled && styles.disabled, toggleMusicSheet.show && styles.isMusicSheet, styles.musicSheet, "driver-10"]}
- onClick={() => {
- toggleMusicSheet.toggle(true);
- }}
- >
- <img class={styles.iconBtn} src={headImg(`shenggui.png`)} />
- <span>声部</span>
- </div>
- )}
- {
- <div
- class={[styles.btn, restoreBtn.value.disabled && styles.disabled, styles.cxSetBtn, "driver-5-1"]}
- onClick={() => resetSettings()}
- >
- <img class={styles.iconBtn} src={headImg("reset.png")} />
- <span>重置</span>
- </div>
- }
- <div
- id={state.platform === IPlatform.PC ? "teacherTop-6" : "studnetT-6"}
- style={{ display: settingBtn.value.display ? "" : "none" }}
- class={["driver-6", styles.btn, settingBtn.value.disabled && styles.disabled, headTopData.settingMode && styles.isSettingMode, styles.settingMode]}
- onClick={() => (headTopData.settingMode = true)}
- >
- <img class={styles.iconBtn} src={headImg("icon_menu.png")} />
- <span>设置</span>
- </div>
- </div>
- </div>
- {/** 指法点击区域 */}
- {
- state.fingeringInfo.direction === "transverse" && state.setting.displayFingering ?
- <div class={styles.headerMid} onClick={() => {
- fingerRef.value?.doubeClick()
- }}></div> : null
- }
- {/* 播放按钮 */}
- <div
- id="studnetT-7"
- style={{ display: playBtn.value.display ? "" : "none" }}
- class={[
- // 引导使用的类
- "driver-1",
- styles.playBtn,
- playBtn.value.disabled && styles.disabled,
- state.platform === IPlatform.PC && state.musicScoreBtnDirection === "left" ? styles.playLeftButton : state.platform === IPlatform.PC && state.musicScoreBtnDirection === "right" ? styles.playRightButton : "",
- ]}
- onClick={() => {
- // C调能播放唱名,非C调时,只有谱面类型是首调时,才能播放唱名
- if (!state.isCTone && state.playSource === 'mingSong') {
- const notPlayDesc = state.musicRenderType === EnumMusicRenderType.staff ? '该曲目的五线谱目前还不支持播放唱名' : state.musicRenderType === EnumMusicRenderType.fixedTone ? '该曲目的固定调目前还不支持播放唱名' : '';
- if (notPlayDesc) {
- showToast({
- message: notPlayDesc,
- position: "top",
- className: "selectionToast",
- });
- return
- }
- }
- togglePlay(state.playState === "play" ? "paused" : "play")
- }}
- >
- <div class={styles.btnWrap}>
- <img style={{ display: state.playState === "play" ? "none" : "" }} class={styles.iconBtn} src={headImg("icon_play.png")} />
- <img style={{ display: state.playState === "play" ? "" : "none" }} class={styles.iconBtn} src={headImg("icon_pause.png")} />
- <Circle style={{ opacity: state.playState === "play" ? 1 : 0 }} class={styles.progress} stroke-width={60} stroke-linecap={"square"} currentRate={state.playProgress} rate={100} color="#FFED78" layer-color="rgba(255,255,255,0.5)" />
- </div>
- </div>
- {/* 重播按钮 */}
- <div
- id="tips-step-9"
- style={{ display: resetBtn.value.display ? "" : "none" }}
- class={[styles.resetBtn, resetBtn.value.disabled && styles.disabled, state.platform === IPlatform.PC && state.musicScoreBtnDirection === "left" ? styles.pauseLeftButton : state.platform === IPlatform.PC && state.musicScoreBtnDirection === "right" ? styles.pauseRightButton : ""]}
- onClick={() => handleResetPlay()}
- >
- <img class={styles.iconBtn} src={headImg("icon_reset.png")} />
- </div>
- <Popup v-model:show={headTopData.settingMode} class="popup-custom van-scale center-closeBtn settingBoxClass_drag" transition="van-scale" teleport="body" style={positionInfo.styleDrag.value} overlay-style={{ background: "rgba(0, 0, 0, 0.7)" }}>
- <Settting />
- {state.platform === IPlatform.PC && <Dragbom showGuide={!state.guideInfo?.teacherDrag} onGuideDone={handleGuide} />}
- </Popup>
- {/* 模式切换 */}
- {/* <ModeTypeMode /> */}
- <ModeView></ModeView>
- {/* isAllBtns */}
- {/* {isAllBtns.value && !query.isCbs && showGuideIndex.value && <TeacherTop></TeacherTop>}
- {isAllBtnsStudent.value && !query.isCbs && showGuideIndex.value && <StudentTop></StudentTop>} */}
- {/* 练习模式功能引导 加载音频完成 不是会员 */}
- {state.modeType === "practise" && headTopData.modeType !== "init" && !query.isCbs && state.audioDone && !state.isLoading && showWebGuide.value && (
- <PractiseDriver
- statusAll={{
- playBtnStatus: playBtn.value.display,
- subjectStatus: state.musicRendered && !query.lessonTrainingId && !query.questionId && state.isConcert,
- modelTypeStatus: toggleBtn.value.display,
- playType: playTypeBtn.value.display,
- originPlayType: state.playType === "play" ? true : false,
- originBtnStatus: originBtn.value.display,
- backTitle: !(state.playState == "play" || followData.start || evaluatingData.startBegin) && isMusicList.value,
- titleType: smoothAnimationState.isShow.value ? "TEXT" : isMusicList.value ? "IMG" : "NONE",
- showSwitchList: isMusicList.value && !state.isHomeWork && !query.isHideMusicList,
- }}
- />
- )}
- {/* 跟练模式功能引导 加载音频完成 不是会员 */}
- {state.modeType === "follow" && headTopData.modeType !== "init" && !query.isCbs && state.audioDone && !state.isLoading && showWebGuide.value && (
- <FollowDriver
- statusAll={{
- subjectStatus: state.musicRendered && !query.lessonTrainingId && !query.questionId && state.isConcert,
- }}
- />
- )}
- {/* 评测模式功能引导 加载音频完成 不是会员 */}
- {state.modeType === "evaluating" && headTopData.modeType !== "init" && !evaluatingData.earphoneMode && !query.isCbs && state.audioDone && !state.isLoading && evaluatingData.websocketState && !evaluatingData.startBegin && evaluatingData.checkEnd && showWebGuide.value && (
- <EvaluatingDriver
- statusAll={{
- subjectStatus: state.musicRendered && !query.lessonTrainingId && !query.questionId && state.isConcert,
- }}
- />
- )}
- </>
- );
- },
- });
|