|
@@ -1,11 +1,11 @@
|
|
|
-import { Sticky, Cell, Tag, Icon, Popup, Tabs, Tab, Dialog } from 'vant'
|
|
|
+import { Sticky, Cell, Tag, Icon, Popup, Tabs, Tab, Dialog, Button } from 'vant'
|
|
|
import {
|
|
|
RouterView,
|
|
|
useRouter,
|
|
|
useRoute,
|
|
|
onBeforeRouteUpdate
|
|
|
} from 'vue-router'
|
|
|
-import { defineComponent, onMounted, reactive, ref, watch } from 'vue'
|
|
|
+import { defineComponent, nextTick, onMounted, reactive, ref, watch } from 'vue'
|
|
|
import mitt from 'mitt'
|
|
|
import Search from '@/components/col-search'
|
|
|
import { useLocalStorage } from '@vueuse/core'
|
|
@@ -16,6 +16,8 @@ import { getRandomKey } from '../music'
|
|
|
import SelectSubject from './select-subject'
|
|
|
import { SubjectEnum, useSubjectId } from '@/helpers/hooks'
|
|
|
import { state } from '@/state'
|
|
|
+import TheSticky from '@/components/the-sticky'
|
|
|
+import bgImg from '../../images/bg-image.png'
|
|
|
|
|
|
export const mitter = mitt()
|
|
|
|
|
@@ -85,7 +87,7 @@ export default defineComponent({
|
|
|
}
|
|
|
if (val) {
|
|
|
words.value.unshift(val)
|
|
|
- words.value.length = Math.min(words.value.length, 5)
|
|
|
+ words.value.length = Math.min(words.value.length, 10)
|
|
|
}
|
|
|
mitter.emit('search', val)
|
|
|
}
|
|
@@ -121,42 +123,120 @@ export default defineComponent({
|
|
|
name: getSubject.name || '全部声部',
|
|
|
id: getSubject.id || ''
|
|
|
})
|
|
|
+
|
|
|
+ // this.historyTag = [{id: 0, title: '血液病'},{id: 7, title: '血液病有哪几种'},
|
|
|
+ // {id: 3, title: '儿童淋巴瘤'}, {id: 4, title: '喉咙痛声音嘶哑'}, {id: 5, title: '咽喉癌的早期症状'},
|
|
|
+ // {id: 6, title: '成人淋巴癌'},{id: 1, title: '肺癌'},{id: 2, title: '白血病'}
|
|
|
+ // ]
|
|
|
+ const tagRef = ref<any>([])
|
|
|
+ const collapse = reactive({
|
|
|
+ // historyTag:
|
|
|
+ line: 1,
|
|
|
+ arrowStatus: true
|
|
|
+ })
|
|
|
+
|
|
|
+ // 历史搜索默认收起
|
|
|
+ const defaultClose = () => {
|
|
|
+ nextTick(() => {
|
|
|
+ if (!words.value || !words.value.length) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let offsetLeft = 0
|
|
|
+ collapse.line = 0
|
|
|
+ const tags = tagRef.value
|
|
|
+ tags.forEach((item: any, index: number) => {
|
|
|
+ try {
|
|
|
+ console.log(index, '1212', 'tagRef', item)
|
|
|
+ if (index === 0) {
|
|
|
+ collapse.line = 1
|
|
|
+ offsetLeft = item.$el.offsetLeft
|
|
|
+ } else if (item.$el.offsetLeft === offsetLeft && index != 0) {
|
|
|
+ // 如果某个标签的offsetLeft和第一个标签的offsetLeft相等 说明增加了一行
|
|
|
+ collapse.line += 1
|
|
|
+ console.log(11111, collapse.line)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (collapse.line > 2) {
|
|
|
+ //从第3行开始 隐藏标签
|
|
|
+ item.$el.style.display = 'none'
|
|
|
+ console.log(item.$el.style)
|
|
|
+ // 显示展开按钮 class名chu是在前面动态添加的
|
|
|
+ if (item.className === 'chu') {
|
|
|
+ // item.style.display = 'inline-block'
|
|
|
+ // item.style.marginTop = 0 + 'px'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e: any) {
|
|
|
+ console.log(e, 'Error')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (collapse.line > 2) {
|
|
|
+ // 超过2行 手动添加“展开”按钮
|
|
|
+ // words.value.push({id:0, title: '展开'})
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(collapse.line, 'collapse.line')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 历史搜索展开
|
|
|
+ // const openAll = () => {
|
|
|
+ // let tags = tagRef
|
|
|
+ // let index = words.value.findIndex((item) => {
|
|
|
+ // return item.title === '展开'
|
|
|
+ // })
|
|
|
+ // // 展开状态 删除“展开”按钮
|
|
|
+ // words.value.splice(index, 1, )
|
|
|
+ // // 添加“收起”按钮
|
|
|
+ // words.value.splice(tags.length - 1, 0, {id:0, title: '收起'})
|
|
|
+ // // 将所有的标签都显示
|
|
|
+ // tags.forEach((item,index) => {
|
|
|
+ // item.style.display = 'inline-block'
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+
|
|
|
+ // // 点击某个历史搜索
|
|
|
+ // clickTag(item) {
|
|
|
+ // if (item.title === '展开') {
|
|
|
+ // this.openAll()
|
|
|
+ // } else if (item.title === '收起') {
|
|
|
+ // this.defaultClose()
|
|
|
+ // } else {
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }
|
|
|
+ // 首先调用默认收起的方法
|
|
|
+ defaultClose()
|
|
|
+
|
|
|
return () => {
|
|
|
return (
|
|
|
<div class={styles.search}>
|
|
|
- <Sticky class={styles.sticky}>
|
|
|
- <Search
|
|
|
- modelValue={keyword.value}
|
|
|
- // showAction
|
|
|
- ref={searchInputRef}
|
|
|
- onSearch={onSearch}
|
|
|
- // onFilter={() => (tagVisibility.value = true)}
|
|
|
- // filterDot={!!tagids.value}
|
|
|
- onClick={() => {
|
|
|
- if (route.path === '/music-songbook') {
|
|
|
- router.push({
|
|
|
- path: '/music-songbook/search'
|
|
|
- })
|
|
|
- }
|
|
|
- }}
|
|
|
- v-slots={{
|
|
|
- left: () => (
|
|
|
- <div
|
|
|
- class={styles.label}
|
|
|
- onClick={() => (subject.show = true)}
|
|
|
- >
|
|
|
- {subject.name}
|
|
|
- <Icon
|
|
|
- classPrefix="iconfont"
|
|
|
- name="down"
|
|
|
- size={12}
|
|
|
- color="#333"
|
|
|
- />
|
|
|
- </div>
|
|
|
- )
|
|
|
- }}
|
|
|
- />
|
|
|
- {route.path === '/music-songbook/search' && (
|
|
|
+ <div class={styles.sticky}>
|
|
|
+ <TheSticky position="top">
|
|
|
+ <Search
|
|
|
+ modelValue={keyword.value}
|
|
|
+ background="transparent"
|
|
|
+ ref={searchInputRef}
|
|
|
+ onSearch={onSearch}
|
|
|
+ type="tenant"
|
|
|
+ v-slots={{
|
|
|
+ left: () => (
|
|
|
+ <div
|
|
|
+ class={styles.label}
|
|
|
+ onClick={() => (subject.show = true)}
|
|
|
+ >
|
|
|
+ {subject.name}
|
|
|
+ <Icon
|
|
|
+ classPrefix="iconfont"
|
|
|
+ name="down"
|
|
|
+ size={12}
|
|
|
+ color="#333"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ {/* {route.path === '/music-songbook/search' && (
|
|
|
<Tabs
|
|
|
color="var(--van-primary)"
|
|
|
background="transparent"
|
|
@@ -168,29 +248,57 @@ export default defineComponent({
|
|
|
<Tab title="单曲" name="songe"></Tab>
|
|
|
<Tab title="专辑" name="album"></Tab>
|
|
|
</Tabs>
|
|
|
- )}
|
|
|
- </Sticky>
|
|
|
+ )} */}
|
|
|
+ </TheSticky>
|
|
|
+ <img class={styles.bgImg} src={bgImg} />
|
|
|
+ </div>
|
|
|
{words.value.length > 0 && route.path === '/music-songbook/search' && (
|
|
|
- <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 class={styles.keywordSection}>
|
|
|
+ <div class={styles.keywordTitle}>
|
|
|
+ <span class={styles.t}>搜索历史</span>
|
|
|
+ <Icon
|
|
|
+ class={styles.remove}
|
|
|
+ name="delete-o"
|
|
|
+ onClick={() => (words.value = [])}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div class={classNames(styles.keywords)}>
|
|
|
+ <div class={styles.content}>
|
|
|
+ {words.value.map((item: any, index: number) => (
|
|
|
+ <Tag
|
|
|
+ // ref={(el: any) => (tagRef[index] = el)}
|
|
|
+ ref={(el: any) => (tagRef.value[index] = el)}
|
|
|
+ round
|
|
|
+ class={[styles.searchKeyword, 'van-ellipsis']}
|
|
|
+ key={item}
|
|
|
+ onClick={() => onSearch(item)}
|
|
|
+ >
|
|
|
+ {item}
|
|
|
+ </Tag>
|
|
|
+ ))}
|
|
|
+ {collapse.line > 2 && (
|
|
|
+ <span class={styles.arrowMore}>
|
|
|
+ <Icon name={'arrow-down'} />
|
|
|
+ </span>
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <Icon
|
|
|
- class={styles.remove}
|
|
|
- name="delete-o"
|
|
|
- onClick={() => (words.value = [])}
|
|
|
- />
|
|
|
</div>
|
|
|
)}
|
|
|
+ {route.path === '/music-songbook/search' && (
|
|
|
+ <Tabs
|
|
|
+ color="var(--van-primary)"
|
|
|
+ background="transparent"
|
|
|
+ lineWidth={20}
|
|
|
+ shrink
|
|
|
+ class={styles.tagTabs}
|
|
|
+ v-model:active={activeTab.value}
|
|
|
+ onChange={val => (activeTab.value = val)}
|
|
|
+ >
|
|
|
+ <Tab title="单曲" name="songe"></Tab>
|
|
|
+ <Tab title="专辑" name="album"></Tab>
|
|
|
+ </Tabs>
|
|
|
+ )}
|
|
|
<RouterView />
|
|
|
<Popup
|
|
|
show={tagVisibility.value}
|