| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 | 
							- import { defineComponent, nextTick, onMounted, reactive, ref } from 'vue'
 
- import { useRoute, useRouter } from 'vue-router'
 
- import request from '@/helpers/request'
 
- import ColHeader from '@/components/col-header'
 
- import { Button, Icon, Image, List, NavBar, Sticky } from 'vant'
 
- import classNames from 'classnames'
 
- import Footer from '../album/footer'
 
- import FavoriteIcon from '../album/favorite.svg'
 
- import FavoritedIcon from '../album/favorited.svg'
 
- import styles from './index.module.less'
 
- import Item from '../list/item'
 
- import { useRect } from '@vant/use'
 
- import { useEventListener, useWindowScroll } from '@vueuse/core'
 
- import { getRandomKey, musicBuy } from '../music'
 
- import { state } from '@/state'
 
- import IconPan from './pan.png'
 
- import oStart from './oStart.png'
 
- import Title from '../component/title'
 
- import Song from '../component/song'
 
- import ColResult from '@/components/col-result'
 
- import MusicGrid from '../component/music-grid'
 
- const noop = () => {}
 
- export default defineComponent({
 
-   name: 'AlbumDetail',
 
-   props: {
 
-     onItemClick: {
 
-       type: Function,
 
-       default: noop
 
-     }
 
-   },
 
-   setup({ onItemClick }) {
 
-     localStorage.setItem('behaviorId', getRandomKey())
 
-     const router = useRouter()
 
-     const params = reactive({
 
-       search: '',
 
-       page: 1,
 
-       rows: 200
 
-     })
 
-     const albumDetail = ref<any>(null)
 
-     const data = ref<any>(null)
 
-     const rows = ref<any[]>([])
 
-     const loading = ref(false)
 
-     const finished = ref(false)
 
-     const isError = ref(false)
 
-     const favorited = ref(0)
 
-     const albumFavoriteCount = ref(0)
 
-     const headers = ref(null)
 
-     const background = ref<string>('rgba(55, 205, 177, 0)')
 
-     const heightInfo = ref<any>('auto')
 
-     const route = useRoute()
 
-     const FetchList = async () => {
 
-       if (loading.value) {
 
-         return
 
-       }
 
-       loading.value = true
 
-       isError.value = false
 
-       try {
 
-         const res = await request.post('/music/album/detail', {
 
-           prefix:
 
-             state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student',
 
-           data: { id: route.params.id, ...params }
 
-         })
 
-         const { musicSheetList, ...rest } = res.data
 
-         rows.value = [...rows.value, ...musicSheetList.rows]
 
-         const musicTagNames = rest?.musicTagNames?.split(',') || []
 
-         albumDetail.value = {
 
-           ...rest,
 
-           musicTagNames
 
-         }
 
-         data.value = musicSheetList
 
-         params.page = musicSheetList.pageNo + 1
 
-         finished.value = musicSheetList.pageNo >= musicSheetList.totalPage
 
-         favorited.value = rest.favorite
 
-         albumFavoriteCount.value = rest.albumFavoriteCount
 
-       } catch (error) {
 
-         isError.value = true
 
-       }
 
-       loading.value = false
 
-     }
 
-     const favoriteLoading = ref(false)
 
-     onMounted(() => {
 
-       FetchList()
 
-       useEventListener(document, 'scroll', evt => {
 
-         const { y } = useWindowScroll()
 
-         background.value = `rgba(55, 205, 177, ${y.value / 100})`
 
-       })
 
-     })
 
-     const toggleFavorite = async (id: number) => {
 
-       favoriteLoading.value = true
 
-       try {
 
-         await request.post('/music/album/favorite/' + id, {
 
-           prefix:
 
-             state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student'
 
-         })
 
-         favorited.value = favorited.value === 1 ? 0 : 1
 
-         albumFavoriteCount.value += favorited.value ? 1 : -1
 
-       } catch (error) {}
 
-       favoriteLoading.value = false
 
-     }
 
-     return () => {
 
-       return (
 
-         <div class={styles.detail}>
 
-           <div ref={headers}>
 
-             <ColHeader
 
-               background={background.value}
 
-               border={false}
 
-               color="#fff"
 
-               backIconColor="white"
 
-               onHeaderBack={() => {
 
-                 nextTick(() => {
 
-                   const { height } = useRect(headers as any)
 
-                   heightInfo.value = height
 
-                 })
 
-               }}
 
-             />
 
-           </div>
 
-           <img class={styles.bgImg} src={albumDetail.value?.albumCoverUrl} />
 
-           <div class={styles.musicContent}></div>
 
-           <div class={styles.bg}>
 
-             <div class={styles.alumWrap}>
 
-               <div class={styles.img}>
 
-                 <Image
 
-                   class={styles.image}
 
-                   width="100%"
 
-                   height="100%"
 
-                   fit="cover"
 
-                   src={albumDetail.value?.albumCoverUrl}
 
-                 />
 
-               </div>
 
-               <div class={styles.alumDes}>
 
-                 <div class={[styles.alumTitle, 'van-ellipsis']}>
 
-                   {albumDetail.value?.albumName}
 
-                 </div>
 
-                 <div class={styles.tags}>
 
-                   {albumDetail.value?.musicTagNames?.map((tag: any) => (
 
-                     <span class={styles.tag}>{tag}</span>
 
-                   ))}
 
-                 </div>
 
-                 <div
 
-                   class={[styles.des, 'van-multi-ellipsis--l3']}
 
-                   style={{
 
-                     height: '48px',
 
-                     lineHeight: '16px'
 
-                   }}
 
-                 >
 
-                   {albumDetail.value?.albumDesc}
 
-                 </div>
 
-               </div>
 
-             </div>
 
-             <div class={styles.alumCollect}>
 
-               <img src={IconPan} />
 
-               <span>共{albumDetail.value?.musicSheetCount}首曲目</span>
 
-               <img class={styles.right} src={oStart} />
 
-               <span>{albumDetail.value?.albumFavoriteCount}人收藏</span>
 
-             </div>
 
-           </div>
 
-           <div class={styles.alumnContainer}>
 
-             <div class={styles.alumnList}>
 
-               <Title title="曲目列表" isMore={false} />
 
-               <Song
 
-                 list={rows.value}
 
-                 onDetail={(item: any) => {
 
-                   if (onItemClick === noop || !onItemClick) {
 
-                     musicBuy(item, () => {}, {
 
-                       albumId: route.params.id
 
-                     })
 
-                   } else {
 
-                     onItemClick(item)
 
-                   }
 
-                 }}
 
-               />
 
-               {rows.value && rows.value.length <= 0 && (
 
-                 <ColResult btnStatus={false} tips="暂无曲目" />
 
-               )}
 
-             </div>
 
-             {albumDetail.value?.relatedMusicAlbum &&
 
-               albumDetail.value?.relatedMusicAlbum.length > 0 && (
 
-                 <>
 
-                   <Title
 
-                     title="相关专辑"
 
-                     onMore={() => {
 
-                       router.push({
 
-                         path: '/music-album'
 
-                       })
 
-                     }}
 
-                   />
 
-                   <MusicGrid
 
-                     list={albumDetail.value?.relatedMusicAlbum}
 
-                     onGoto={(n: any) =>
 
-                       router.push({
 
-                         path: '/music-album-detail/' + n.id
 
-                       })
 
-                     }
 
-                   />
 
-                 </>
 
-               )}
 
-           </div>
 
-         </div>
 
-       )
 
-     }
 
-   }
 
- })
 
 
  |