|
@@ -1,5 +1,5 @@
|
|
-import { Sticky, Cell, Tag, Icon } from 'vant'
|
|
|
|
-import { defineComponent, ref } from 'vue'
|
|
|
|
|
|
+import { Sticky, Cell, Tag, Icon, Popup } from 'vant'
|
|
|
|
+import { defineComponent, onMounted, ref } from 'vue'
|
|
import Search from '@/components/col-search'
|
|
import Search from '@/components/col-search'
|
|
import { useLocalStorage } from '@vueuse/core'
|
|
import { useLocalStorage } from '@vueuse/core'
|
|
import AlbumItem from '../album/item'
|
|
import AlbumItem from '../album/item'
|
|
@@ -7,17 +7,36 @@ import MusicItem from '../list/item'
|
|
import styles from './index.module.less'
|
|
import styles from './index.module.less'
|
|
import classNames from 'classnames'
|
|
import classNames from 'classnames'
|
|
import request from '@/helpers/request'
|
|
import request from '@/helpers/request'
|
|
|
|
+import SelectTag from './select-tag'
|
|
|
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
name: 'MusicSearch',
|
|
name: 'MusicSearch',
|
|
setup() {
|
|
setup() {
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
const keyword = ref('')
|
|
const keyword = ref('')
|
|
|
|
+ const tagids = ref('')
|
|
|
|
+ const albumRows = ref([])
|
|
|
|
+ const sheetRows = ref([])
|
|
const tagVisibility = ref(false)
|
|
const tagVisibility = ref(false)
|
|
const words = useLocalStorage<string[]>('music-search', [])
|
|
const words = useLocalStorage<string[]>('music-search', [])
|
|
const FetchList = async () => {
|
|
const FetchList = async () => {
|
|
loading.value = true
|
|
loading.value = true
|
|
- await request.post('/api-student/music/sheet/albumAndSheetList', {})
|
|
|
|
|
|
+ try {
|
|
|
|
+ const res = await request.post(
|
|
|
|
+ '/api-student/music/sheet/albumAndSheetList',
|
|
|
|
+ {
|
|
|
|
+ data: {
|
|
|
|
+ albumRow: 3,
|
|
|
|
+ sheetRow: 10,
|
|
|
|
+ search: keyword.value,
|
|
|
|
+ musicTagIds: tagids.value
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ )
|
|
|
|
+ albumRows.value = res.data.musicAlbumList.rows
|
|
|
|
+ sheetRows.value = res.data.musicSheetList.rows
|
|
|
|
+ } catch (error) {}
|
|
|
|
+ loading.value = false
|
|
}
|
|
}
|
|
const onSearch = val => {
|
|
const onSearch = val => {
|
|
keyword.value = val
|
|
keyword.value = val
|
|
@@ -29,7 +48,20 @@ export default defineComponent({
|
|
words.value.unshift(val)
|
|
words.value.unshift(val)
|
|
words.value.length = Math.min(words.value.length, 5)
|
|
words.value.length = Math.min(words.value.length, 5)
|
|
}
|
|
}
|
|
|
|
+ FetchList()
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ const onComfirm = tags => {
|
|
|
|
+ const data = Object.values(tags)
|
|
|
|
+ .map((items: any) => items.join(','))
|
|
|
|
+ .filter(Boolean)
|
|
|
|
+ .join(',')
|
|
|
|
+ tagids.value = data
|
|
|
|
+ FetchList()
|
|
|
|
+ tagVisibility.value = false
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ onMounted(() => onSearch(''))
|
|
return () => {
|
|
return () => {
|
|
return (
|
|
return (
|
|
<div class={styles.search}>
|
|
<div class={styles.search}>
|
|
@@ -37,6 +69,7 @@ export default defineComponent({
|
|
<Search
|
|
<Search
|
|
modelValue={keyword.value}
|
|
modelValue={keyword.value}
|
|
showAction
|
|
showAction
|
|
|
|
+ autofocus
|
|
onSearch={onSearch}
|
|
onSearch={onSearch}
|
|
onFilter={() => (tagVisibility.value = true)}
|
|
onFilter={() => (tagVisibility.value = true)}
|
|
/>
|
|
/>
|
|
@@ -66,16 +99,45 @@ export default defineComponent({
|
|
class={styles.title}
|
|
class={styles.title}
|
|
title="专辑"
|
|
title="专辑"
|
|
is-link
|
|
is-link
|
|
- to="/music-album"
|
|
|
|
|
|
+ to={{
|
|
|
|
+ path: '/music-album',
|
|
|
|
+ query: {
|
|
|
|
+ search: keyword.value,
|
|
|
|
+ tagids: tagids.value
|
|
|
|
+ }
|
|
|
|
+ }}
|
|
value="更多"
|
|
value="更多"
|
|
/>
|
|
/>
|
|
|
|
+ {albumRows.value.map(item => (
|
|
|
|
+ <AlbumItem data={item} />
|
|
|
|
+ ))}
|
|
<Cell
|
|
<Cell
|
|
class={styles.title}
|
|
class={styles.title}
|
|
title="曲谱"
|
|
title="曲谱"
|
|
is-link
|
|
is-link
|
|
- to="/music-list"
|
|
|
|
|
|
+ to={{
|
|
|
|
+ path: '/music-list',
|
|
|
|
+ query: {
|
|
|
|
+ search: keyword.value,
|
|
|
|
+ tagids: tagids.value
|
|
|
|
+ }
|
|
|
|
+ }}
|
|
value="更多"
|
|
value="更多"
|
|
/>
|
|
/>
|
|
|
|
+ {sheetRows.value.map(item => (
|
|
|
|
+ <MusicItem data={item} />
|
|
|
|
+ ))}
|
|
|
|
+ <Popup
|
|
|
|
+ show={tagVisibility.value}
|
|
|
|
+ round
|
|
|
|
+ closeable
|
|
|
|
+ position="bottom"
|
|
|
|
+ style={{ height: '60%' }}
|
|
|
|
+ teleport="body"
|
|
|
|
+ onUpdate:show={val => (tagVisibility.value = val)}
|
|
|
|
+ >
|
|
|
|
+ <SelectTag onComfirm={onComfirm} onCancel={() => {}} />
|
|
|
|
+ </Popup>
|
|
</div>
|
|
</div>
|
|
)
|
|
)
|
|
}
|
|
}
|