|
@@ -1,4 +1,4 @@
|
|
|
-import { List, NoticeBar } from "vant";
|
|
|
+import { List, NoticeBar, closeToast, showLoadingToast, showToast } from "vant";
|
|
|
import { defineComponent, reactive } from "vue";
|
|
|
import styles from "./index.module.less";
|
|
|
import iconMusic from "../header-top/image/music.png";
|
|
@@ -14,6 +14,7 @@ import { useRoute } from "vue-router";
|
|
|
import iconBack from "./icons/icon-back.png";
|
|
|
import VipModel from "./vipModel";
|
|
|
import { postMessage } from "/src/utils/native-message";
|
|
|
+import request from "umi-request";
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: "detail-list",
|
|
@@ -32,6 +33,7 @@ export default defineComponent({
|
|
|
selectedPartIndex: 0,
|
|
|
vipShow: false,
|
|
|
partShow: false,
|
|
|
+ partListNames: [] as any[]
|
|
|
});
|
|
|
//获取曲谱列表
|
|
|
const getData = async () => {
|
|
@@ -57,9 +59,32 @@ export default defineComponent({
|
|
|
musicData.loading = false;
|
|
|
};
|
|
|
|
|
|
+ const getPartNames = async (xmlUrl: string) => {
|
|
|
+ const partNames: string[] = [];
|
|
|
+ showLoadingToast({
|
|
|
+ type: "loading",
|
|
|
+ overlay: true,
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ const res = await request.get(xmlUrl, { mode: "cors" });
|
|
|
+ const xml = new DOMParser().parseFromString(res, "text/xml");
|
|
|
+ const parts: any = xml.getElementsByTagName("part-name");
|
|
|
+ for (const item of parts) {
|
|
|
+ if (item.textContent) {
|
|
|
+ partNames.push(item.textContent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ closeToast();
|
|
|
+ } catch (error) {
|
|
|
+ showToast("读取分谱信息失败,请重试");
|
|
|
+ }
|
|
|
+ return partNames;
|
|
|
+ };
|
|
|
+
|
|
|
/** */
|
|
|
- const handleClick = (item: any) => {
|
|
|
+ const handleClick = async (item: any) => {
|
|
|
musicData.row = { ...item };
|
|
|
+ musicData.partListNames = await getPartNames(item.xmlUrl);
|
|
|
// 选择声部
|
|
|
if (state.partListNames.length > 1) {
|
|
|
musicData.partShow = true;
|
|
@@ -120,6 +145,7 @@ export default defineComponent({
|
|
|
</List>
|
|
|
<Popup v-model:show={musicData.partShow} teleport="body" defaultStyle={false}>
|
|
|
<ChoosePartName
|
|
|
+ partListNames={musicData.partListNames}
|
|
|
onClose={(index: number) => {
|
|
|
if ((index ?? -1) > -1) {
|
|
|
musicData.selectedPartIndex = index;
|