|
@@ -0,0 +1,129 @@
|
|
|
+import { defineComponent, onMounted, reactive } from 'vue';
|
|
|
+import styles from './index.module.less';
|
|
|
+import { postMessage } from '@/helpers/native-message';
|
|
|
+import icon_title from './images/icon-title.png';
|
|
|
+import icon_back from './images/icon-back.png';
|
|
|
+import icon_setting from './images/icon-setting.png';
|
|
|
+import iconPlay from './images/icon-play.png';
|
|
|
+import iconPause from './images/icon-pause.png';
|
|
|
+import beat from './images/btn-2.png';
|
|
|
+import tempo from './images/btn-3.png';
|
|
|
+import randDom from './images/btn-1.png';
|
|
|
+import iconPlus from './images/icon-plus.png';
|
|
|
+import iconAdd from './images/icon-add.png';
|
|
|
+import { getImage } from './images/music';
|
|
|
+import j1 from './images/music/j-1.png';
|
|
|
+// import j2 from './images/music/j-2.png';
|
|
|
+import { Popup } from 'vant';
|
|
|
+import SettingModal from './setting-modal';
|
|
|
+import { randomScoreElement, renderScore, setting } from './setting';
|
|
|
+
|
|
|
+export default defineComponent({
|
|
|
+ name: 'tempo-practice',
|
|
|
+ setup() {
|
|
|
+ const state = reactive({
|
|
|
+ settingStatus: false,
|
|
|
+ playState: 'pause' as 'pause' | 'play',
|
|
|
+ playType: 'beat' as 'beat' | 'tempo'
|
|
|
+ });
|
|
|
+ // 返回
|
|
|
+ const goback = () => {
|
|
|
+ postMessage({ api: 'goBack' });
|
|
|
+ };
|
|
|
+
|
|
|
+ /** 播放切换 */
|
|
|
+ const handlePlay = () => {
|
|
|
+ if (state.playState === 'pause') {
|
|
|
+ state.playState = 'play';
|
|
|
+ } else {
|
|
|
+ state.playState = 'pause';
|
|
|
+ }
|
|
|
+ };
|
|
|
+ /** 播放类型 */
|
|
|
+ const handlePlayType = () => {
|
|
|
+ if (state.playType === 'beat') {
|
|
|
+ state.playType = 'tempo';
|
|
|
+ } else {
|
|
|
+ state.playType = 'beat';
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ renderScore();
|
|
|
+ });
|
|
|
+ return () => (
|
|
|
+ <div class={styles.tempoPractice}>
|
|
|
+ <div class={styles.head}>
|
|
|
+ <div class={styles.back} onClick={goback}>
|
|
|
+ <img src={icon_back} />
|
|
|
+ </div>
|
|
|
+ <div class={styles.title}>
|
|
|
+ <img src={icon_title} />
|
|
|
+ </div>
|
|
|
+ <div class={styles.back} onClick={() => (state.settingStatus = true)}>
|
|
|
+ <img src={icon_setting} />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class={styles.container}>
|
|
|
+ {setting.scorePart.map((item: any) => (
|
|
|
+ <div
|
|
|
+ class={[
|
|
|
+ styles.beatSection,
|
|
|
+ styles.small,
|
|
|
+ // styles.minLength,
|
|
|
+ styles.maxLength
|
|
|
+ ]}>
|
|
|
+ {item.map((child: any) => (
|
|
|
+ // , styles.active
|
|
|
+ <div
|
|
|
+ class={[styles.beat]}
|
|
|
+ onClick={() => {
|
|
|
+ const obj = randomScoreElement(child.index);
|
|
|
+ child.index = obj.index;
|
|
|
+ child.url = obj.url;
|
|
|
+ }}>
|
|
|
+ <div class={styles.imgSection}>
|
|
|
+ <img src={getImage(child.url)} />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ <div class={styles.footer}>
|
|
|
+ {/* 播放 */}
|
|
|
+ <div class={styles.play} onClick={handlePlay}>
|
|
|
+ {state.playState === 'pause' ? (
|
|
|
+ <img src={iconPause} />
|
|
|
+ ) : (
|
|
|
+ <img src={iconPlay} />
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ {/* 播放类型 */}
|
|
|
+ <div class={styles.playType} onClick={handlePlayType}>
|
|
|
+ {state.playType === 'beat' ? (
|
|
|
+ <img src={beat} />
|
|
|
+ ) : (
|
|
|
+ <img src={tempo} />
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ {/* 随机生成 */}
|
|
|
+ <div class={styles.randomTempo}>
|
|
|
+ <img src={randDom} />
|
|
|
+ </div>
|
|
|
+ {/* 速度 */}
|
|
|
+ <div class={styles.speedChange}>
|
|
|
+ <img src={iconPlus} class={styles.speedPlus} />
|
|
|
+ <div class={styles.speedNum}>90</div>
|
|
|
+ <img src={iconAdd} class={styles.speedAdd} />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <Popup v-model:show={state.settingStatus} class={styles.settingPopup}>
|
|
|
+ <SettingModal onClose={() => (state.settingStatus = false)} />
|
|
|
+ </Popup>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ }
|
|
|
+});
|