|
@@ -1,33 +1,38 @@
|
|
|
import { Sticky, Cell, Tag, Icon, Popup, Tabs, Tab, Dialog } from 'vant'
|
|
|
-import { defineComponent, onMounted, ref } from 'vue'
|
|
|
-import Search from '@/components/col-search'
|
|
|
+import { defineComponent, onMounted, onUnmounted, 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 classNames from 'classnames'
|
|
|
// import request from '@/helpers/request'
|
|
|
import SelectTag from './select-tag'
|
|
|
// import ColResult from '@/components/col-result'
|
|
|
// import { orderStatus } from '@/views/order-detail/orderStatus'
|
|
|
-import { useRouter } from 'vue-router'
|
|
|
+import { useRoute, useRouter } from 'vue-router'
|
|
|
import { getRandomKey, musicBuy } from '../music'
|
|
|
+import { mitter } from './header'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'MusicSearch',
|
|
|
+ emits: ['confirm'],
|
|
|
setup() {
|
|
|
+ const searchInputRef = ref()
|
|
|
localStorage.setItem('behaviorId', getRandomKey())
|
|
|
+ const route = useRoute()
|
|
|
const router = useRouter()
|
|
|
const loading = ref(false)
|
|
|
- const keyword = ref('')
|
|
|
- const tagids = ref('')
|
|
|
+ const keyword = ref(route.query.keyword || '')
|
|
|
+ const tagids = ref(route.query.tagids || '')
|
|
|
const albumRows = ref([])
|
|
|
const sheetRows = ref([])
|
|
|
const tagVisibility = ref(false)
|
|
|
const words = useLocalStorage<string[]>('music-search', [])
|
|
|
const activeTab = ref('songe')
|
|
|
+
|
|
|
const FetchList = async () => {
|
|
|
// loading.value = true
|
|
|
// try {
|
|
@@ -47,6 +52,7 @@ export default defineComponent({
|
|
|
// } catch (error) {}
|
|
|
// loading.value = false
|
|
|
}
|
|
|
+
|
|
|
const onSearch = val => {
|
|
|
keyword.value = val
|
|
|
const indexOf = words.value.indexOf(val)
|
|
@@ -58,6 +64,7 @@ export default defineComponent({
|
|
|
words.value.length = Math.min(words.value.length, 5)
|
|
|
}
|
|
|
const activeRef = activeTab.value === 'album' ? albumList : musicList
|
|
|
+ console.log(val)
|
|
|
;(activeRef.value as any).onSearch?.(val)
|
|
|
// FetchList()
|
|
|
}
|
|
@@ -74,89 +81,27 @@ export default defineComponent({
|
|
|
const albumList = ref(null)
|
|
|
const musicList = ref(null)
|
|
|
|
|
|
+ const changeTab = (val: any) => {
|
|
|
+ activeTab.value = val
|
|
|
+ }
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
- const activeRef = activeTab.value === 'album' ? albumList : musicList
|
|
|
- ;(activeRef.value as any).onSearch?.('')
|
|
|
+ mitter.on('changeTab', changeTab)
|
|
|
+ mitter.on('search', onSearch)
|
|
|
+ mitter.on('confirm', onComfirm)
|
|
|
+ // ;(activeRef.value as any).onSearch?.('')
|
|
|
+ // console.log(searchInputRef.value)
|
|
|
+ })
|
|
|
+
|
|
|
+ onUnmounted(() => {
|
|
|
+ mitter.off('changeTab', changeTab)
|
|
|
+ mitter.off('search', onSearch)
|
|
|
+ mitter.off('confirm', onComfirm)
|
|
|
})
|
|
|
+
|
|
|
return () => {
|
|
|
return (
|
|
|
<div class={styles.search}>
|
|
|
- <Sticky class={styles.sticky}>
|
|
|
- <Search
|
|
|
- modelValue={keyword.value}
|
|
|
- showAction
|
|
|
- autofocus
|
|
|
- onSearch={onSearch}
|
|
|
- onFilter={() => (tagVisibility.value = true)}
|
|
|
- filterDot={!!tagids.value}
|
|
|
- />
|
|
|
- <Tabs
|
|
|
- color="var(--van-primary)"
|
|
|
- background="transparent"
|
|
|
- lineWidth={20}
|
|
|
- shrink
|
|
|
- v-model:active={activeTab.value}
|
|
|
- onChange={val => (activeTab.value = val)}
|
|
|
- >
|
|
|
- <Tab title="单曲" name="songe"></Tab>
|
|
|
- <Tab title="专辑" name="album"></Tab>
|
|
|
- </Tabs>
|
|
|
- </Sticky>
|
|
|
- {words.value.length > 0 && (
|
|
|
- <div class={classNames(styles.keywords, 'van-hairline--bottom')}>
|
|
|
- <div class={styles.content}>
|
|
|
- {words.value.map(item => (
|
|
|
- <Tag
|
|
|
- round
|
|
|
- class={styles.searchKeyword}
|
|
|
- key={item}
|
|
|
- onClick={() => onSearch(item)}
|
|
|
- >
|
|
|
- {item}
|
|
|
- </Tag>
|
|
|
- ))}
|
|
|
- </div>
|
|
|
- <Icon
|
|
|
- class={styles.remove}
|
|
|
- name="delete-o"
|
|
|
- onClick={() => (words.value = [])}
|
|
|
- />
|
|
|
- </div>
|
|
|
- )}
|
|
|
-
|
|
|
- {/* {albumRows.value.length > 0 && (
|
|
|
- <>
|
|
|
- <Cell
|
|
|
- class={styles.title}
|
|
|
- title="专辑"
|
|
|
- is-link
|
|
|
- to={{
|
|
|
- path: '/music-album',
|
|
|
- query: {
|
|
|
- search: keyword.value,
|
|
|
- tagids: tagids.value
|
|
|
- }
|
|
|
- }}
|
|
|
- value="更多"
|
|
|
- />
|
|
|
- {albumRows.value.map(item => (
|
|
|
- <AlbumItem data={item} />
|
|
|
- ))}
|
|
|
- </>
|
|
|
- )} */}
|
|
|
- {/* <Cell
|
|
|
- class={styles.title}
|
|
|
- title="曲谱"
|
|
|
- is-link
|
|
|
- to={{
|
|
|
- path: '/music-list',
|
|
|
- query: {
|
|
|
- search: keyword.value,
|
|
|
- tagids: tagids.value
|
|
|
- }
|
|
|
- }}
|
|
|
- value="更多"
|
|
|
- /> */}
|
|
|
{activeTab.value === 'album' ? (
|
|
|
<AlbumList
|
|
|
hideSearch
|
|
@@ -186,17 +131,7 @@ export default defineComponent({
|
|
|
}}
|
|
|
/>
|
|
|
)}
|
|
|
- {/* {sheetRows.value.map(item => (
|
|
|
- <MusicItem data={item} />
|
|
|
- ))} */}
|
|
|
- {/* {!loading.value && sheetRows.value.length === 0 && (
|
|
|
- <ColResult
|
|
|
- tips={activeTab.value === 'album' ? '暂无专辑' : '暂无曲目'}
|
|
|
- classImgSize="SMALL"
|
|
|
- btnStatus={false}
|
|
|
- />
|
|
|
- )} */}
|
|
|
- <Popup
|
|
|
+ {/* <Popup
|
|
|
show={tagVisibility.value}
|
|
|
round
|
|
|
closeable
|
|
@@ -205,8 +140,8 @@ export default defineComponent({
|
|
|
teleport="body"
|
|
|
onUpdate:show={val => (tagVisibility.value = val)}
|
|
|
>
|
|
|
- <SelectTag onComfirm={onComfirm} onCancel={() => {}} />
|
|
|
- </Popup>
|
|
|
+ <SelectTag onConfirm={onComfirm} onCancel={() => {}} />
|
|
|
+ </Popup> */}
|
|
|
</div>
|
|
|
)
|
|
|
}
|