Browse Source

添加全部选项

lex-xin 4 weeks ago
parent
commit
af23a81904
1 changed files with 57 additions and 124 deletions
  1. 57 124
      src/tenant/music/train-list/index.tsx

+ 57 - 124
src/tenant/music/train-list/index.tsx

@@ -1,7 +1,6 @@
 import {
   computed,
   defineComponent,
-  nextTick,
   onMounted,
   reactive,
   ref
@@ -11,11 +10,7 @@ import {
   DropdownMenu,
   DropdownItem,
   Tag,
-  Image,
   Button,
-  Cell,
-  Radio,
-  RadioGroup
 } from 'vant'
 import { postMessage } from '@/helpers/native-message'
 import Search from '@/components/col-search'
@@ -24,19 +19,13 @@ import { useRoute, useRouter } from 'vue-router'
 import ColResult from '@/components/col-result'
 import styles from './index.module.less'
 import { getRandomKey } from '../music'
-import { openDefaultWebView, state as baseState, state } from '@/state'
-import { SubjectEnum, useSubjectId } from '@/helpers/hooks'
+import { state as baseState } from '@/state'
 import Song from '../component/song'
 import ColHeader from '@/components/col-header'
 import bgImg from '../../images/bg.png'
 import TheSticky from '@/components/the-sticky'
-import dayjs from 'dayjs'
 import { browser, getHttpOrigin } from '@/helpers/utils'
 
-const noop = () => {
-  //
-}
-
 export default defineComponent({
   name: 'MusicList',
   props: {
@@ -49,7 +38,7 @@ export default defineComponent({
       default: false
     }
   },
-  setup({ onItemClick }, { expose }) {
+  setup() {
     localStorage.setItem('behaviorId', getRandomKey())
     const route = useRoute()
     const router = useRouter()
@@ -81,8 +70,8 @@ export default defineComponent({
     const isError = ref(false)
     const searchObj = ref<any>({})
     const searchRef = ref()
-    const albumRef = ref()
-    const albumRecord = ref<any>([])
+    // const albumRef = ref()
+    // const albumRecord = ref<any>([])
 
     const apiSuffix = ref(
       baseState.platformType === 'STUDENT' ? '/api-student' : '/api-teacher'
@@ -135,47 +124,63 @@ export default defineComponent({
           }
         }
       )
-      searchObj.value = data || {}
-    }
+      const result = data || {}
+      const { levelList, typeList } = result
 
-    const getAlbumRecordPage = async () => {
-      isError.value = false
-      try {
-        const { data } = await request.post('/userTenantAlbumRecord/list', {
-          prefix:
-            state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student',
-          data: {
-            page: 1,
-            rows: 999
-          }
+      if(levelList && levelList.length > 0) {
+        levelList.unshift({
+          id: '',
+          value: '全部级别'
         })
-        console.log(data)
-        albumRecord.value = data || []
-        if (albumRecord.value.length > 0) {
-          const albumCatchType = localStorage.getItem(
-            'albumCatch' + subjectType
-          )
-          if (albumCatchType) {
-            const item = albumRecord.value.find(
-              (item: any) => item.tenantAlbumId == albumCatchType
-            )
-            if (item) {
-              params.albumId = item.tenantAlbumId
-              params.albumName = item.tenantAlbumName
-            } else {
-              params.albumId = albumRecord.value[0].tenantAlbumId
-              params.albumName = albumRecord.value[0].tenantAlbumName
-            }
-          } else {
-            params.albumId = albumRecord.value[0].tenantAlbumId
-            params.albumName = albumRecord.value[0].tenantAlbumName
-          }
-        }
-      } catch (error) {
-        isError.value = true
       }
+      if(typeList && typeList.length > 0) {
+        typeList.unshift({
+          id: '',
+          value: '全部类型'
+        })
+      }
+
+      searchObj.value = result
     }
 
+    // const getAlbumRecordPage = async () => {
+    //   isError.value = false
+    //   try {
+    //     const { data } = await request.post('/userTenantAlbumRecord/list', {
+    //       prefix:
+    //         state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student',
+    //       data: {
+    //         page: 1,
+    //         rows: 999
+    //       }
+    //     })
+    //     console.log(data)
+    //     albumRecord.value = data || []
+    //     if (albumRecord.value.length > 0) {
+    //       const albumCatchType = localStorage.getItem(
+    //         'albumCatch' + subjectType
+    //       )
+    //       if (albumCatchType) {
+    //         const item = albumRecord.value.find(
+    //           (item: any) => item.tenantAlbumId == albumCatchType
+    //         )
+    //         if (item) {
+    //           params.albumId = item.tenantAlbumId
+    //           params.albumName = item.tenantAlbumName
+    //         } else {
+    //           params.albumId = albumRecord.value[0].tenantAlbumId
+    //           params.albumName = albumRecord.value[0].tenantAlbumName
+    //         }
+    //       } else {
+    //         params.albumId = albumRecord.value[0].tenantAlbumId
+    //         params.albumName = albumRecord.value[0].tenantAlbumName
+    //       }
+    //     }
+    //   } catch (error) {
+    //     isError.value = true
+    //   }
+    // }
+
     const isSearchStatus = computed(() => {
       const obj = searchObj.value
       let status = false
@@ -217,79 +222,7 @@ export default defineComponent({
                 border={false}
                 title={title}
                 color="#131415"
-              >
-                {/* {{
-                  right: () =>
-                    albumRecord.value.length > 1 &&
-                    params.albumId && (
-                      <DropdownMenu class={styles.albumSearchSection}>
-                        <DropdownItem
-                          titleClass={styles.albumSearchTitle}
-                          title={params.albumName}
-                          ref={albumRef}
-                        >
-                          <div
-                            class={styles.albumSearchResult}
-                            style={{ maxHeight: '45vh', overflowY: 'auto' }}
-                          >
-                            {albumRecord.value.map((item: any) => (
-                              <Cell
-                                border={false}
-                                class={[
-                                  styles.albumSearchCell,
-                                  item.tenantAlbumId === params.albumId &&
-                                    styles.albumSearchCellActive
-                                ]}
-                                center
-                                onClick={async () => {
-                                  localStorage.setItem(
-                                    'albumCatch' + subjectType,
-                                    item.tenantAlbumId
-                                  )
-                                  params.albumId = item.tenantAlbumId
-                                  params.albumName = item.tenantAlbumName
-                                  params.subjectId = null
-                                  params.level = ''
-                                  params.type = ''
-                                  await getSelectCondition()
-
-                                  params.page = 1
-                                  data.value = null
-                                  await FetchList()
-
-                                  albumRef.value?.toggle()
-                                }}
-                              >
-                                {{
-                                  icon: () => (
-                                    <Image
-                                      src={item.tenantAlbumCoverImg}
-                                      class={styles.albumLogo}
-                                    />
-                                  ),
-                                  title: () => (
-                                    <div class={styles.albumContent}>
-                                      <h2>{item.tenantAlbumName}</h2>
-                                      <p>
-                                        到期时间:
-                                        {dayjs(item.endTime).format(
-                                          'YYYY-MM-DD'
-                                        )}
-                                      </p>
-                                    </div>
-                                  ),
-                                  'right-icon': () => (
-                                    <div class={styles.iconSelect}></div>
-                                  )
-                                }}
-                              </Cell>
-                            ))}
-                          </div>
-                        </DropdownItem>
-                      </DropdownMenu>
-                    )
-                }} */}
-              </ColHeader>
+              ></ColHeader>
               <Search
                 placeholder={'请输入曲谱关键词'}
                 class={styles.search}