// import { PaperClipIcon } from '@heroicons/vue/solid' import { defineComponent, toRefs, reactive, onMounted, ref } from 'vue' import arrow from '@/views/home/images/moreArrow.png' import styles from './index.module.less' import albumItem from './modals/albumItem' import videoDetailItem from '@/components/videoDetailItem' import musicLIstItem from '@/components/musicLIstItem' import hotSearch from '@/components/hotSearch' import { Swiper, SwiperSlide } from 'swiper/vue' import { Navigation, Pagination, Scrollbar, A11y } from 'swiper' import request from '@/helpers/request' import silder from '@/components/silder' import searchInput from '@/components/searchInput' import banner from '@/components/banner' import titleDot from '@/views/home/images/titleDot.png' import 'swiper/css' import 'swiper/css/navigation' import 'swiper/css/pagination' import 'swiper/css/scrollbar' import pagination from '@/components/pagination' import { useRoute, useRouter } from 'vue-router' import { state as baseState } from '@/state' import { SubjectEnum, useSubjectId } from '@/helpers/hooks' import { getUserType } from '@/helpers/utils' import ColEmpty from '@/components/col-empty' export default defineComponent({ name: 'musicLibrary', components: { albumItem, videoDetailItem, musicLIstItem, hotSearch, silder, searchInput, pagination, ColEmpty, banner }, setup() { const route = useRoute() let subjectId = 0 const subjectIds = baseState.user.data?.subjectId || '' if (subjectIds) { subjectId = Number(subjectIds.split(',')[0]) } // 判断是否在默认的声部 const subjects: any = useSubjectId(SubjectEnum.SEARCH) subjectId = subjects.id || subjectId const state = reactive({ albumList: [], musicList: [], tagTree: [], hideSearch: true, isshowData: false, pageInfo: { // 分页规则 limit: 20, // 限制显示条数 page: 1, // 当前页 total: 0, // 总条数 page_size: [5, 10, 20, 40, 50] // 选择限制显示条数 }, searchs: { musicTagIds: route.query.musicTagIds || '', search: route.query.search || '', subject: subjectId || '' } }) const getMusicList = async () => { try { const { search, subject, ...more } = state.searchs const res = await request.post('/api-website/open/music/sheet/list', { data: { auditStatus: 'PASS', ...more, idAndName: search, subjectIds: subject, page: state.pageInfo.page, rows: state.pageInfo.limit, state: 1 } }) // state.musicList = res.data.rows state.musicList = res.data.rows.map(n => { if (typeof n.paymentType === 'string') n.paymentType = n.paymentType.split(',') return n }) state.pageInfo.total = res.data.total if (state.pageInfo.total == 0) { state.isshowData = true } else { state.isshowData = false } } catch (e) { console.log(e) } } const getTagTree = async () => { try { const res = await request.get('/api-website/open/MusicTag/tree', { params: { type: 'MUSIC' } }) const tree = res.data || [] state.tagTree = [ { name: '全部', id: '', isCheck: true }, ...tree ] as any if (state.searchs.musicTagIds) { state.tagTree.forEach((tag: any) => { tag.isCheck = false if (tag.id == state.searchs.musicTagIds) { tag.isCheck = true } }) } } catch (e) { console.log(e) } } const searchRust = (val: any) => { // const smallTag = (val || ([] as any)).filter(tag => tag < 0) const maxTag = (val || ([] as any)).filter(tag => tag > 0) state.searchs.musicTagIds = maxTag.join(',') as string startSearch(state.searchs) } const startSearch = (val: any) => { state.searchs = { ...state.searchs, ...val } getMusicList() } onMounted(() => { getTagTree() getMusicList() }) return () => (