|
@@ -0,0 +1,79 @@
|
|
|
+import { computed, defineComponent, reactive } from 'vue'
|
|
|
+import styles from './index.module.less'
|
|
|
+import { Icon, Popup } from 'vant'
|
|
|
+import ChoosePartName from './choosePartName'
|
|
|
+import runtime, * as RuntimeUtils from '/src/pages/detail/runtime'
|
|
|
+import state, { togglePlay } from "/src/state";
|
|
|
+import qs from 'query-string'
|
|
|
+import { getInstrumentName } from "/src/constant/instruments";
|
|
|
+import { getQuery } from "/src/utils/queryString";
|
|
|
+
|
|
|
+export const toggleMusicSheet = reactive({
|
|
|
+ show: false,
|
|
|
+ toggle: (type = true) => {
|
|
|
+ toggleMusicSheet.show = type
|
|
|
+ },
|
|
|
+})
|
|
|
+
|
|
|
+export default defineComponent({
|
|
|
+ name: 'ToggleMusicSheet',
|
|
|
+ setup() {
|
|
|
+ const query = getQuery();
|
|
|
+
|
|
|
+ const partListNames = computed(() => {
|
|
|
+ let partList = state.partListNames || []
|
|
|
+ partList = partList.filter((item: any) => !item?.toLocaleUpperCase()?.includes('COMMON'))
|
|
|
+ return partList.map((item: any, index: number) => {
|
|
|
+ const instrumentName = getInstrumentName(item)
|
|
|
+ return {
|
|
|
+ text: item + (instrumentName ? `(${instrumentName})` : ''),
|
|
|
+ value: index,
|
|
|
+ }
|
|
|
+ }).filter(Boolean)
|
|
|
+ })
|
|
|
+
|
|
|
+ const switchMusic = (index: number) => {
|
|
|
+ // 暂停播放
|
|
|
+ togglePlay("paused");
|
|
|
+ // 销毁播放器
|
|
|
+ postMessage({
|
|
|
+ api: 'cloudDestroy',
|
|
|
+ })
|
|
|
+ postMessage({
|
|
|
+ api: 'cloudLoading',
|
|
|
+ content: {
|
|
|
+ show: true,
|
|
|
+ type: 'fullscreen',
|
|
|
+ },
|
|
|
+ })
|
|
|
+ const _url =
|
|
|
+ location.origin +
|
|
|
+ location.pathname +
|
|
|
+ '?' +
|
|
|
+ qs.stringify({
|
|
|
+ ...query,
|
|
|
+ behaviorId: sessionStorage.getItem('behaviorId') || '',
|
|
|
+ _t: new Date().valueOf(),
|
|
|
+ 'part-index': index,
|
|
|
+ })
|
|
|
+ console.log(_url)
|
|
|
+ location.href = _url
|
|
|
+ }
|
|
|
+
|
|
|
+ return () => (
|
|
|
+ <Popup class={styles.popup} v-model:show={toggleMusicSheet.show}>
|
|
|
+ <ChoosePartName
|
|
|
+ partIndex={state.partIndex}
|
|
|
+ partListNames={partListNames.value}
|
|
|
+ onClose={(value) => {
|
|
|
+ console.log("🚀 ~ value:", value)
|
|
|
+ toggleMusicSheet.show = false
|
|
|
+ if (value !== undefined) {
|
|
|
+ switchMusic(value)
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </Popup>
|
|
|
+ )
|
|
|
+ },
|
|
|
+})
|