import { Sticky, Cell, Tag, Icon, Popup, Tabs, Tab } from 'vant' import { defineComponent, onMounted, ref } from 'vue' import Search from '@/components/col-search' import { useLocalStorage } from '@vueuse/core' import AlbumItem from '../album/item' import AlbumList from '../album' import MusicItem from '../list/item' import MusicList from '../list' import styles from './index.module.less' import classNames from 'classnames' import request from '@/helpers/request' import SelectTag from './select-tag' import ColResult from '@/components/col-result' export default defineComponent({ name: 'MusicSearch', setup() { const loading = ref(false) const keyword = ref('') const tagids = ref('') const albumRows = ref([]) const sheetRows = ref([]) const tagVisibility = ref(false) const words = useLocalStorage('music-search', []) const activeTab = ref('album') const FetchList = async () => { // loading.value = true // 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 => { keyword.value = val const indexOf = words.value.indexOf(val) if (indexOf > -1) { words.value.splice(indexOf, 1) } if (val) { words.value.unshift(val) words.value.length = Math.min(words.value.length, 5) } const activeRef = activeTab.value === 'album' ? albumList : musicList ;(activeRef.value as any).onSearch?.(val) // FetchList() } const onComfirm = tags => { const data = Object.values(tags).flat().filter(Boolean).join(',') tagids.value = data // FetchList() const activeRef = activeTab.value === 'album' ? albumList : musicList ;(activeRef.value as any).onComfirm?.(tags) tagVisibility.value = false } const albumList = ref(null) const musicList = ref(null) onMounted(() => { const activeRef = activeTab.value === 'album' ? albumList : musicList ;(activeRef.value as any).onSearch?.('') }) return () => { return (
(tagVisibility.value = true)} filterDot={!!tagids.value} /> (activeTab.value = val)} > {words.value.length > 0 && (
{words.value.map(item => ( onSearch(item)} > {item} ))}
(words.value = [])} />
)} {/* {albumRows.value.length > 0 && ( <> {albumRows.value.map(item => ( ))} )} */} {/* */} {activeTab.value === 'album' ? ( ) : ( )} {/* {sheetRows.value.map(item => ( ))} */} {/* {!loading.value && sheetRows.value.length === 0 && ( )} */} (tagVisibility.value = val)} > {}} />
) } } })