|
@@ -19,6 +19,7 @@ import {
|
|
|
NEmpty,
|
|
|
NImage,
|
|
|
NModal,
|
|
|
+ NPopselect,
|
|
|
NSpace,
|
|
|
NSpin
|
|
|
} from 'naive-ui';
|
|
@@ -36,6 +37,7 @@ import { useRoute, useRouter } from 'vue-router';
|
|
|
import PlayItem from './component/play-item';
|
|
|
import PlayLoading from './component/play-loading';
|
|
|
import TheNoticeBar from '/src/components/TheNoticeBar';
|
|
|
+import { useCatchStore } from '/src/store/modules/catchData';
|
|
|
import {
|
|
|
api_materialFavorite,
|
|
|
api_materialFavoriteStatus,
|
|
@@ -50,6 +52,7 @@ import { useResizeObserver } from '@vueuse/core';
|
|
|
export default defineComponent({
|
|
|
name: 'XiaokuMusic',
|
|
|
setup() {
|
|
|
+ const catchStore = useCatchStore();
|
|
|
const user = useUserStore();
|
|
|
const route = useRoute();
|
|
|
const router = useRouter();
|
|
@@ -68,12 +71,14 @@ export default defineComponent({
|
|
|
tagIndex: 0,
|
|
|
list: [] as unknown as IMusicItem[],
|
|
|
listActive: 0,
|
|
|
+ musicInstrumentIndex: 0,
|
|
|
playState: 'pause' as 'play' | 'pause',
|
|
|
showPlayer: false,
|
|
|
previewModal: false,
|
|
|
showPreivew: false,
|
|
|
previewUrl: '',
|
|
|
- showCloseBtn: true
|
|
|
+ showCloseBtn: true,
|
|
|
+ iframeSrc: ''
|
|
|
});
|
|
|
const showGuide = ref(false);
|
|
|
const userStore = useUserStore();
|
|
@@ -81,10 +86,18 @@ export default defineComponent({
|
|
|
const getSubjects = async () => {
|
|
|
// const res = await api_subjectList();
|
|
|
// if (Array.isArray(res?.data)) {
|
|
|
+ const tempSubjectList = catchStore.getSubjectAllList;
|
|
|
const subjectList = sessionStorage.getItem('musicSubjectList')
|
|
|
? JSON.parse(sessionStorage.getItem('musicSubjectList') as any)
|
|
|
: [];
|
|
|
- data.tags = [{ name: '全部', id: 0 }, ...subjectList];
|
|
|
+ const resultList: any[] = [];
|
|
|
+ tempSubjectList.forEach((item: any) => {
|
|
|
+ const hasItem = subjectList.find((s: any) => s.id === item.id);
|
|
|
+ if (hasItem) {
|
|
|
+ resultList.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ data.tags = [{ name: '全部', id: 0 }, ...resultList];
|
|
|
// }
|
|
|
};
|
|
|
const getList = async () => {
|
|
@@ -140,13 +153,15 @@ export default defineComponent({
|
|
|
};
|
|
|
|
|
|
onMounted(async () => {
|
|
|
+ // 获取声部列表
|
|
|
+ await catchStore.getSubjects();
|
|
|
// musicList-container
|
|
|
useResizeObserver(
|
|
|
document.querySelector('.musicList-container') as HTMLElement,
|
|
|
(entries: any) => {
|
|
|
const entry = entries[0];
|
|
|
const { height } = entry.contentRect;
|
|
|
- console.log(height, 'height - 11');
|
|
|
+ // console.log(height, 'height - 11');
|
|
|
document.documentElement.style.setProperty(
|
|
|
'--xiaoku-music-height',
|
|
|
height + 'px'
|
|
@@ -188,6 +203,17 @@ export default defineComponent({
|
|
|
}
|
|
|
getFavitor(item);
|
|
|
};
|
|
|
+
|
|
|
+ const selectChildObj = (item: any) => {
|
|
|
+ const obj: any = {};
|
|
|
+ item?.forEach((child: any) => {
|
|
|
+ if (child.id === data.tagIndex) {
|
|
|
+ obj.selected = true;
|
|
|
+ obj.name = child.name;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return obj;
|
|
|
+ };
|
|
|
/** 选中的item */
|
|
|
const activeItem = computed(() => {
|
|
|
if (data.list[data.listActive]) {
|
|
@@ -232,6 +258,42 @@ export default defineComponent({
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ const musicalInstruments = computed(() => {
|
|
|
+ const details: any = data.list[data.listActive];
|
|
|
+ const musics = details?.musicalInstruments || [];
|
|
|
+ const temp: any = [];
|
|
|
+ musics.forEach((item: any, index: number) => {
|
|
|
+ temp.push({
|
|
|
+ label: item.name,
|
|
|
+ value: index
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return temp;
|
|
|
+ });
|
|
|
+ const isEnsemble = computed(() => {
|
|
|
+ const details: any = data.list[data.listActive];
|
|
|
+ const musics: any = details?.musicalInstruments;
|
|
|
+ if (musics && musics.length > 1) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ const musicIframeLoad = () => {
|
|
|
+ const token = userStore.getToken;
|
|
|
+ const details = data.list[data.listActive];
|
|
|
+ const origin = /(localhost|192)/.test(location.host)
|
|
|
+ ? 'https://test.lexiaoya.cn'
|
|
|
+ : location.origin;
|
|
|
+ console.log(
|
|
|
+ origin,
|
|
|
+ 'origin',
|
|
|
+ `${origin}/instrument/?id=${details.id}&modelType=practise&modeType=json&Authorization=${token}&isPreView=true&part-index=${data.musicInstrumentIndex}`
|
|
|
+ );
|
|
|
+ data.iframeSrc = `${origin}/instrument/?id=${details.id}&modelType=practise&modeType=json&Authorization=${token}&isPreView=true&part-index=${data.musicInstrumentIndex}`;
|
|
|
+ };
|
|
|
+
|
|
|
/** 音频控制 */
|
|
|
const handleChangeAudio = (
|
|
|
type: 'play' | 'pause' | 'pre' | 'next' | 'favitor'
|
|
@@ -285,20 +347,84 @@ export default defineComponent({
|
|
|
style={{ width: '100%' }}
|
|
|
size={[24, 12]}
|
|
|
wrapItem={false}>
|
|
|
- {data.tags.map(item => (
|
|
|
- <NButton
|
|
|
- round
|
|
|
- textColor={data.tagIndex === item.id ? '#fff' : '#000'}
|
|
|
- color={data.tagIndex === item.id ? '#198CFE' : '#fff'}
|
|
|
- type={data.tagIndex === item.id ? 'primary' : 'default'}
|
|
|
- onClick={() => {
|
|
|
- data.tagIndex = item.id;
|
|
|
- data.reshing = true;
|
|
|
- handleGetList();
|
|
|
- }}>
|
|
|
- {item.name}
|
|
|
- </NButton>
|
|
|
- ))}
|
|
|
+ {data.tags.map(item =>
|
|
|
+ item.instruments && item.instruments.length > 1 ? (
|
|
|
+ <NPopselect
|
|
|
+ options={item.instruments}
|
|
|
+ trigger="hover"
|
|
|
+ v-model:value={data.tagIndex}
|
|
|
+ onUpdate:value={() => {
|
|
|
+ // onSearch();
|
|
|
+ console.log(
|
|
|
+ data.tagIndex,
|
|
|
+ 'tagIndex',
|
|
|
+ data.tagIndex
|
|
|
+ );
|
|
|
+ data.reshing = true;
|
|
|
+ handleGetList();
|
|
|
+ }}
|
|
|
+ key={item.id}
|
|
|
+ class={[styles.popSelect]}>
|
|
|
+ {/* <span
|
|
|
+ class={[
|
|
|
+ styles.textBtn,
|
|
|
+ selectChildObj(item.instruments).selected &&
|
|
|
+ styles.textBtnActive
|
|
|
+ ]}>
|
|
|
+ {selectChildObj(item.instruments).name || item.name}
|
|
|
+ <i class={styles.iconArrow}></i>
|
|
|
+ </span> */}
|
|
|
+ <NButton
|
|
|
+ round
|
|
|
+ textColor={
|
|
|
+ selectChildObj(item.instruments).selected
|
|
|
+ ? '#fff'
|
|
|
+ : '#000'
|
|
|
+ }
|
|
|
+ color={
|
|
|
+ selectChildObj(item.instruments).selected
|
|
|
+ ? '#198CFE'
|
|
|
+ : '#fff'
|
|
|
+ }
|
|
|
+ type={
|
|
|
+ selectChildObj(item.instruments).selected
|
|
|
+ ? 'primary'
|
|
|
+ : 'default'
|
|
|
+ }
|
|
|
+ class={[
|
|
|
+ styles.textBtn,
|
|
|
+ selectChildObj(item.instruments).selected &&
|
|
|
+ styles.textBtnActive
|
|
|
+ ]}
|
|
|
+ // onClick={() => {
|
|
|
+ // data.tagIndex = item.id;
|
|
|
+ // data.reshing = true;
|
|
|
+ // handleGetList();
|
|
|
+ // }}
|
|
|
+ >
|
|
|
+ {selectChildObj(item.instruments).name || item.name}
|
|
|
+ <i class={styles.iconArrow}></i>
|
|
|
+ </NButton>
|
|
|
+ </NPopselect>
|
|
|
+ ) : (
|
|
|
+ <NButton
|
|
|
+ round
|
|
|
+ textColor={
|
|
|
+ data.tagIndex === item.id ? '#fff' : '#000'
|
|
|
+ }
|
|
|
+ color={data.tagIndex === item.id ? '#198CFE' : '#fff'}
|
|
|
+ type={
|
|
|
+ data.tagIndex === item.id ? 'primary' : 'default'
|
|
|
+ }
|
|
|
+ onClick={() => {
|
|
|
+ data.tagIndex = item.id;
|
|
|
+ data.reshing = true;
|
|
|
+ handleGetList();
|
|
|
+ }}>
|
|
|
+ {item.name}
|
|
|
+ </NButton>
|
|
|
+ )
|
|
|
+ )}
|
|
|
</NSpace>
|
|
|
</div>
|
|
|
</NSpace>
|
|
@@ -325,7 +451,10 @@ export default defineComponent({
|
|
|
styles.item,
|
|
|
data.listActive === index && styles.active
|
|
|
]}
|
|
|
- onClick={() => handleChange(item)}>
|
|
|
+ onClick={() => {
|
|
|
+ handleChange(item);
|
|
|
+ musicIframeLoad();
|
|
|
+ }}>
|
|
|
<div class={styles.img}>
|
|
|
<NImage
|
|
|
lazy
|
|
@@ -448,30 +577,65 @@ export default defineComponent({
|
|
|
}}
|
|
|
/>
|
|
|
<div
|
|
|
- style={{ display: activeItem.value.id ? '' : 'none' }}
|
|
|
- class={styles.favitor}
|
|
|
- onClick={() => handleFavitor()}>
|
|
|
- <Transition name="favitor" mode="out-in">
|
|
|
- {activeItem.value.favitor ? (
|
|
|
- <img src={icon_favitorActive} key="1" />
|
|
|
- ) : (
|
|
|
- <img src={icon_favitor} key="2" />
|
|
|
- )}
|
|
|
- </Transition>
|
|
|
+ class={styles.rightBtns}
|
|
|
+ style={{ display: activeItem.value.id ? '' : 'none' }}>
|
|
|
+ {isEnsemble.value && (
|
|
|
+ <NPopselect
|
|
|
+ options={musicalInstruments.value}
|
|
|
+ trigger="hover"
|
|
|
+ v-model:value={data.musicInstrumentIndex}
|
|
|
+ onUpdate:value={(val: any) => {
|
|
|
+ if (val === data.musicInstrumentIndex) return;
|
|
|
+
|
|
|
+ musicIframeLoad();
|
|
|
+ }}
|
|
|
+ // key={item.id}
|
|
|
+ class={[styles.popSelect]}>
|
|
|
+ <NButton round class={[styles.textBtn]}>
|
|
|
+ 切换声轨
|
|
|
+ <i class={styles.iconArrow}></i>
|
|
|
+ </NButton>
|
|
|
+ </NPopselect>
|
|
|
+ )}
|
|
|
+
|
|
|
+ <div class={styles.favitor} onClick={() => handleFavitor()}>
|
|
|
+ <Transition name="favitor" mode="out-in">
|
|
|
+ {activeItem.value.favitor ? (
|
|
|
+ <img src={icon_favitorActive} key="1" />
|
|
|
+ ) : (
|
|
|
+ <img src={icon_favitor} key="2" />
|
|
|
+ )}
|
|
|
+ </Transition>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
+
|
|
|
<div class={styles.staffImgs}>
|
|
|
- <TransitionGroup name="van-fade">
|
|
|
- {activeItem.value?.musicSvg ||
|
|
|
- activeItem.value?.musicImg ? (
|
|
|
- (activeItem.value?.musicSvg || activeItem.value?.musicImg)
|
|
|
- ?.split(',')
|
|
|
- .map((item, index) => {
|
|
|
- return <img src={item} key={item} />;
|
|
|
- })
|
|
|
- ) : (
|
|
|
- <TheEmpty></TheEmpty>
|
|
|
- )}
|
|
|
- </TransitionGroup>
|
|
|
+ {isEnsemble.value ? (
|
|
|
+ <iframe
|
|
|
+ id="staffIframeRef"
|
|
|
+ style={{
|
|
|
+ width: '100%'
|
|
|
+ // opacity: loading.value ? 0 : 1
|
|
|
+ }}
|
|
|
+ src={data.iframeSrc}
|
|
|
+ onLoad={musicIframeLoad}></iframe>
|
|
|
+ ) : (
|
|
|
+ <TransitionGroup name="van-fade">
|
|
|
+ {activeItem.value?.musicSvg ||
|
|
|
+ activeItem.value?.musicImg ? (
|
|
|
+ (
|
|
|
+ activeItem.value?.musicSvg ||
|
|
|
+ activeItem.value?.musicImg
|
|
|
+ )
|
|
|
+ ?.split(',')
|
|
|
+ .map(item => {
|
|
|
+ return <img src={item} key={item} />;
|
|
|
+ })
|
|
|
+ ) : (
|
|
|
+ <TheEmpty></TheEmpty>
|
|
|
+ )}
|
|
|
+ </TransitionGroup>
|
|
|
+ )}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|