|
@@ -17,10 +17,12 @@ 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: {
|
|
@@ -30,9 +32,12 @@ export default defineComponent({
|
|
|
hotSearch,
|
|
|
silder,
|
|
|
searchInput,
|
|
|
+ pagination,
|
|
|
+ ColEmpty,
|
|
|
banner
|
|
|
},
|
|
|
setup() {
|
|
|
+ const route = useRoute()
|
|
|
let subjectId = 0
|
|
|
const subjectIds = baseState.user.data?.subjectId || ''
|
|
|
if (subjectIds) {
|
|
@@ -43,36 +48,35 @@ export default defineComponent({
|
|
|
subjectId = subjects.id || subjectId
|
|
|
const state = reactive({
|
|
|
albumList: [],
|
|
|
- musicList: []
|
|
|
+ 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 router = useRouter()
|
|
|
- const getAlbumList = async () => {
|
|
|
- try {
|
|
|
- const res = await request.post('/api-website/open/music/album/list', {
|
|
|
- data: {
|
|
|
- albumStatus: 1,
|
|
|
- page: 1,
|
|
|
- subjectIds: subjectId ? subjectId : null,
|
|
|
- rows: 10
|
|
|
- },
|
|
|
- params: {
|
|
|
- clientType: getUserType()
|
|
|
- }
|
|
|
- })
|
|
|
|
|
|
- state.albumList = res.data.rows
|
|
|
- } catch (e) {
|
|
|
- console.log(e)
|
|
|
- }
|
|
|
- }
|
|
|
const getMusicList = async () => {
|
|
|
try {
|
|
|
+ const { search, subject, ...more } = state.searchs
|
|
|
const res = await request.post('/api-website/open/music/sheet/list', {
|
|
|
data: {
|
|
|
- albumStatus: 'PASS',
|
|
|
- subjectIds: subjectId ? subjectId : null,
|
|
|
- page: 1,
|
|
|
- rows: 5,
|
|
|
+ auditStatus: 'PASS',
|
|
|
+ ...more,
|
|
|
+ idAndName: search,
|
|
|
+ subjectIds: subject,
|
|
|
+ page: state.pageInfo.page,
|
|
|
+ rows: state.pageInfo.limit,
|
|
|
state: 1
|
|
|
}
|
|
|
})
|
|
@@ -83,25 +87,60 @@ export default defineComponent({
|
|
|
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 gotoSearch = (val: string | object) => {
|
|
|
- if (typeof val == 'string') {
|
|
|
- router.push({ name: 'searchdetail', params: { search: val } })
|
|
|
- } else {
|
|
|
- router.push({ name: 'searchdetail', params: { ...val } })
|
|
|
+ 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 gotoMusic = () => {
|
|
|
- router.push({ name: 'searchdetail', params: { type: 'music' } })
|
|
|
+
|
|
|
+ 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 gotoAlbum = () => {
|
|
|
- router.push({ name: 'searchdetail', params: { type: '' } })
|
|
|
+
|
|
|
+ const startSearch = (val: any) => {
|
|
|
+ state.searchs = { ...state.searchs, ...val }
|
|
|
+ getMusicList()
|
|
|
}
|
|
|
onMounted(() => {
|
|
|
- getAlbumList()
|
|
|
+ getTagTree()
|
|
|
getMusicList()
|
|
|
})
|
|
|
return () => (
|
|
@@ -109,79 +148,89 @@ export default defineComponent({
|
|
|
<banner></banner>
|
|
|
<div class="bg-white">
|
|
|
<div class={styles.w1200}>
|
|
|
- <div class={styles.section}>
|
|
|
- {/* <div class={styles.titleWrap}>
|
|
|
- <img src={titleDot} class={styles.dotImg} alt="" />
|
|
|
- <h4>热门专辑</h4>
|
|
|
- <img src={titleDot} class={styles.dotImg} alt="" />
|
|
|
- </div> */}
|
|
|
+ <div class={styles.section} style="padding-bottom: 0;">
|
|
|
+ <div class={styles.tagList}>
|
|
|
+ <div
|
|
|
+ class={[styles.tagContainer, state.hideSearch && styles.hide]}
|
|
|
+ >
|
|
|
+ {state.tagTree.map((tag: any) => (
|
|
|
+ <span
|
|
|
+ class={[styles.tagItem, tag.isCheck && styles.active]}
|
|
|
+ onClick={() => {
|
|
|
+ state.tagTree.forEach((item: any) => {
|
|
|
+ item.isCheck = false
|
|
|
+ })
|
|
|
+ tag.isCheck = true
|
|
|
+
|
|
|
+ startSearch({ musicTagIds: tag.id })
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {tag.name}
|
|
|
+ </span>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class={styles.wrapRight}
|
|
|
+ onClick={() => {
|
|
|
+ state.hideSearch = !state.hideSearch
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <span>{state.hideSearch ? '更多' : '收起'}</span>
|
|
|
+ <img
|
|
|
+ class={[styles.arrow, !state.hideSearch && styles.active]}
|
|
|
+ src={arrow}
|
|
|
+ alt=""
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
|
|
|
<searchInput
|
|
|
isWhile={false}
|
|
|
type="search"
|
|
|
- onStartSearch={(val: any) => gotoSearch(val)}
|
|
|
+ showSearch
|
|
|
+ placeholder="搜索你想练习的专辑"
|
|
|
+ searchVal={{ ...state.searchs }}
|
|
|
+ onStartSearch={(val: any) => {
|
|
|
+ state.pageInfo.page = 1
|
|
|
+ startSearch(val)
|
|
|
+ }}
|
|
|
></searchInput>
|
|
|
<div class={styles.hotSearch}>
|
|
|
<hotSearch
|
|
|
+ onSearchRust={(val: any) => searchRust(val)}
|
|
|
onHotTag={(val: string) => {
|
|
|
- gotoSearch(val)
|
|
|
+ state.searchs.search = val
|
|
|
+ getMusicList()
|
|
|
}}
|
|
|
type={''}
|
|
|
+ isChiose={true}
|
|
|
></hotSearch>
|
|
|
</div>
|
|
|
|
|
|
- {state.albumList && state.albumList.length > 0 && (
|
|
|
+ {state.musicList && state.musicList.length > 0 && (
|
|
|
<>
|
|
|
- <div class={[styles.videoNav, styles.mt25]}>
|
|
|
- <div class={styles.titleWrap}>
|
|
|
- <h5 class={styles.hotAlbum}>热门专辑</h5>
|
|
|
- <img src={titleDot} class={styles.dotImg} alt="" />
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class={styles.wrapRight} onClick={() => gotoAlbum()}>
|
|
|
- <span>更多</span>
|
|
|
- <img class={styles.arrow} src={arrow} alt="" />
|
|
|
+ <div
|
|
|
+ class={[styles.section, styles.pb40]}
|
|
|
+ style="padding-top: 0"
|
|
|
+ >
|
|
|
+ <div class={styles.musicList}>
|
|
|
+ {state.musicList.map(item => {
|
|
|
+ return <musicLIstItem item={item}></musicLIstItem>
|
|
|
+ })}
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
- <div class={styles.albumList}>
|
|
|
- {state.albumList.map(item => {
|
|
|
- return <albumItem detail={item}></albumItem>
|
|
|
- })}
|
|
|
- </div>
|
|
|
</>
|
|
|
)}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- <div class={styles.w1200}>
|
|
|
- {state.musicList && state.musicList.length > 0 && (
|
|
|
- <>
|
|
|
- <div
|
|
|
- class={[styles.section, styles.pb40]}
|
|
|
- style="padding-top: 0"
|
|
|
- >
|
|
|
- <div class={styles.videoNav}>
|
|
|
- <div class={styles.titleWrap}>
|
|
|
- <h5>热门乐谱</h5>
|
|
|
- <img src={titleDot} class={styles.dotImg} alt="" />
|
|
|
- </div>
|
|
|
- <div class={styles.wrapRight} onClick={() => gotoMusic()}>
|
|
|
- <span>更多</span>
|
|
|
- <img class={styles.arrow} src={arrow} alt="" />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class={styles.musicList}>
|
|
|
- {state.musicList.map(item => {
|
|
|
- return <musicLIstItem item={item}></musicLIstItem>
|
|
|
- })}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </>
|
|
|
- )}
|
|
|
+ {state.isshowData && <ColEmpty></ColEmpty>}
|
|
|
|
|
|
- {/* <musicLIstItem></musicLIstItem> */}
|
|
|
+ <pagination
|
|
|
+ total={state.pageInfo.total}
|
|
|
+ v-model:page={state.pageInfo.page}
|
|
|
+ v-model:limit={state.pageInfo.limit}
|
|
|
+ pageSizes={state.pageInfo.page_size}
|
|
|
+ pagination={getMusicList}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<silder></silder>
|