| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573 | 
							- import {
 
-   computed,
 
-   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 { postMessage } from '@/helpers/native-message'
 
- import { Button, Dialog, Icon, Image, List, NavBar, Popup, 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 { openDefaultWebView, state } from '@/state'
 
- import IconPan from './pan.png'
 
- import oStart from './oStart.png'
 
- import iStart from './iStart.png'
 
- import Title from '../component/title'
 
- import Song from '../component/song'
 
- import ColResult from '@/components/col-result'
 
- import MusicGrid from '../component/music-grid'
 
- import { useEventTracking } from '@/helpers/hooks'
 
- import ColSticky from '@/components/col-sticky'
 
- import { moneyFormat } from '@/helpers/utils'
 
- import { orderStatus } from '@/views/order-detail/orderStatus'
 
- import iconShare from '../album/icon_share.svg'
 
- import iconShare2 from '../album/icon_share2.svg'
 
- import ColShare from '@/components/col-share'
 
- import iconShareMusic from '/src/views/music/component/images/icon_album_active.png'
 
- import SongShare from '../component/song-share'
 
- import icon_music_list from './icon_music_list.png'
 
- import SelectSubject from '../search/select-subject'
 
- const noop = () => {}
 
- export default defineComponent({
 
-   name: 'AlbumDetail',
 
-   props: {
 
-     onItemClick: {
 
-       type: Function,
 
-       default: noop
 
-     }
 
-   },
 
-   setup({ onItemClick }) {
 
-     localStorage.setItem('behaviorId', getRandomKey())
 
-     const router = useRouter()
 
-     const route = useRoute()
 
-     const params = reactive({
 
-       search: '',
 
-       relatedNum: 6, //相关专辑数
 
-       page: 1,
 
-       rows: 200
 
-     })
 
-     const albumDetail = ref<any>(null)
 
-     // const data = ref<any>(null)
 
-     const rows = ref<any[]>([])
 
-     const loading = ref(false)
 
-     const aId = Number(route.query.activityId) || 0
 
-     const studentActivityId = ref(aId)
 
-     // 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 color = ref<string>('#fff')
 
-     const heightInfo = ref<any>('auto')
 
-     const subjects = reactive({
 
-       show: false,
 
-       name: route.query.subjectName || '全部声部',
 
-       id: route.query.subjectId || null
 
-     })
 
-     const FetchList = async (id?: any) => {
 
-       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: id || route.params.id,
 
-             ...params,
 
-             subjectIds: subjects.id
 
-           }
 
-         })
 
-         const { musicSheetList, ...rest } = res.data
 
-         rows.value = [...musicSheetList.rows]
 
-         const musicTagNames = rest?.musicTagNames
 
-           ? rest?.musicTagNames?.split(',')
 
-           : []
 
-         albumDetail.value = {
 
-           ...rest,
 
-           musicTagNames
 
-         }
 
-         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()
 
-         if (y.value > 20) {
 
-           background.value = `rgba(255, 255, 255)`
 
-           color.value = 'black'
 
-           // postMessage({
 
-           //   api: 'backIconChange',
 
-           //   content: { iconStyle: 'black' }
 
-           // })
 
-         } else {
 
-           background.value = 'transparent'
 
-           color.value = '#fff'
 
-           // postMessage({
 
-           //   api: 'backIconChange',
 
-           //   content: { iconStyle: 'white' }
 
-           // })
 
-         }
 
-       })
 
-       useEventTracking('专辑')
 
-     })
 
-     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
 
-     }
 
-     const onBuy = async () => {
 
-       const album = albumDetail.value
 
-       orderStatus.orderObject.orderType = 'ALBUM'
 
-       orderStatus.orderObject.orderName = album.albumName
 
-       orderStatus.orderObject.orderDesc = album.albumName
 
-       orderStatus.orderObject.actualPrice = album.albumPrice
 
-       orderStatus.orderObject.recomUserId = route.query.recomUserId || 0
 
-       orderStatus.orderObject.activityId = route.query.activityId || 0
 
-       orderStatus.orderObject.orderNo = ''
 
-       orderStatus.orderObject.orderList = [
 
-         {
 
-           orderType: 'ALBUM',
 
-           goodsName: album.albumName,
 
-           recomUserId: route.query.recomUserId || 0,
 
-           price: album.albumPrice,
 
-           ...album
 
-         }
 
-       ]
 
-       const res = await request.post('/api-student/userOrder/getPendingOrder', {
 
-         data: {
 
-           goodType: 'ALBUM',
 
-           bizId: album.id
 
-         }
 
-       })
 
-       const result = res.data
 
-       if (result) {
 
-         Dialog.confirm({
 
-           title: '提示',
 
-           message: '您有一个未支付的订单,是否继续支付?',
 
-           confirmButtonColor: '#269a93',
 
-           cancelButtonText: '取消订单',
 
-           confirmButtonText: '继续支付'
 
-         })
 
-           .then(async () => {
 
-             orderStatus.orderObject.orderNo = result.orderNo
 
-             orderStatus.orderObject.actualPrice = result.actualPrice
 
-             orderStatus.orderObject.discountPrice = result.discountPrice
 
-             orderStatus.orderObject.paymentConfig = {
 
-               ...result.paymentConfig,
 
-               paymentVendor: result.paymentVendor,
 
-               paymentVersion: result.paymentVersion
 
-             }
 
-             routerTo()
 
-           })
 
-           .catch(() => {
 
-             Dialog.close()
 
-             // 只用取消订单,不用做其它处理
 
-             cancelPayment(result.orderNo)
 
-           })
 
-       } else {
 
-         routerTo()
 
-       }
 
-       // this.$router.push({
 
-       //   path: '/orderDetail',
 
-       //   query: {
 
-       //     orderType: 'VIP'
 
-       //   }
 
-       // })
 
-     }
 
-     const routerTo = () => {
 
-       const album = albumDetail.value
 
-       router.push({
 
-         path: '/orderDetail',
 
-         query: {
 
-           orderType: 'ALBUM',
 
-           album: album.id
 
-         }
 
-       })
 
-     }
 
-     const cancelPayment = async (orderNo: string) => {
 
-       try {
 
-         await request.post('/api-student/userOrder/orderCancel', {
 
-           data: {
 
-             orderNo
 
-           }
 
-         })
 
-       } catch {
 
-         //
 
-       }
 
-     }
 
-     const onComfirmSubject = item => {
 
-       subjects.name = item.name
 
-       subjects.id = item.id
 
-       subjects.show = false
 
-       FetchList()
 
-     }
 
-     const shareStatus = ref<boolean>(false)
 
-     const shareUrl = ref<string>('')
 
-     const shareDiscount = ref<number>(0)
 
-     const onShare = async () => {
 
-       const userId = state.user.data.userId
 
-       const id = route.params.id
 
-       let activityId = 0
 
-       console.log(state.user, userId)
 
-       if (state.platformType === 'TEACHER') {
 
-         const res = await request.post('/api-teacher/open/vipProfit', {
 
-           data: {
 
-             bizId: id,
 
-             userId
 
-           }
 
-         })
 
-         // 如果有会员则显示
 
-         if (buyVip.value) {
 
-           activityId = res.data.activityId || 0
 
-           shareDiscount.value = res.data.discount || 0
 
-         }
 
-       }
 
-       shareUrl.value = `${location.origin}/teacher#/shareAblum?id=${id}&recomUserId=${userId}&activityId=${activityId}&userType=${state.platformType}`
 
-       console.log(shareUrl.value, 'shareUrl')
 
-       shareStatus.value = true
 
-     }
 
-     const buyVip = computed(() => {
 
-       const album = albumDetail.value?.paymentType
 
-       return album && album.includes('VIP')
 
-     })
 
-     /** 分享曲谱列表, 最大数量4 */
 
-     const shareMusicList = computed(() => {
 
-       return rows.value.length > 4 ? rows.value.slice(0, 2) : rows.value
 
-     })
 
-     return () => {
 
-       return (
 
-         <div class={styles.detail}>
 
-           <div ref={headers}>
 
-             <ColHeader
 
-               background={background.value}
 
-               border={false}
 
-               color={color.value}
 
-               backIconColor="white"
 
-               onHeaderBack={() => {
 
-                 nextTick(() => {
 
-                   const { height } = useRect(headers as any)
 
-                   heightInfo.value = height
 
-                 })
 
-               }}
 
-               v-slots={{
 
-                 right: () => (
 
-                   <div
 
-                     class={styles.shareBtn}
 
-                     style={{
 
-                       color: color.value
 
-                     }}
 
-                     onClick={onShare}
 
-                   >
 
-                     <Image
 
-                       src={color.value === 'black' ? iconShare2 : iconShare}
 
-                     />
 
-                     分享
 
-                   </div>
 
-                 )
 
-               }}
 
-             />
 
-           </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}>
 
-                 {albumDetail.value?.paymentType === 'CHARGE' && (
 
-                   <span class={styles.albumType}>付费</span>
 
-                 )}
 
-                 <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>
 
-               <div
 
-                 class={styles.right}
 
-                 onClick={() => toggleFavorite(albumDetail.value?.id)}
 
-               >
 
-                 <img src={favorited.value ? iStart : oStart} />
 
-                 <span>{albumFavoriteCount.value}人收藏</span>
 
-               </div>
 
-             </div>
 
-             {albumDetail.value?.paymentType === 'CHARGE' &&
 
-               albumDetail.value?.orderStatus !== 'PAID' && (
 
-                 <div class={styles.albumTips}>
 
-                   <span>此专辑为付费专辑,购买即可自由练习该专辑</span>
 
-                   <span class={styles.albumPrice}>
 
-                     ¥{moneyFormat(albumDetail.value?.albumPrice)}
 
-                   </span>
 
-                 </div>
 
-               )}
 
-           </div>
 
-           <div class={styles.alumnContainer}>
 
-             <div class={styles.alumnList}>
 
-               <Title title="曲目列表" isMore={false}>
 
-                 {{
 
-                   right: () =>
 
-                     albumDetail.value?.albumType === 'CONCERT' && (
 
-                       <div
 
-                         class={[
 
-                           styles.subjectSearch,
 
-                           subjects.show ? styles.active : ''
 
-                         ]}
 
-                         onClick={() => (subjects.show = true)}
 
-                       >
 
-                         {subjects.name}
 
-                       </div>
 
-                     )
 
-                 }}
 
-               </Title>
 
-               <Song
 
-                 list={rows.value}
 
-                 onDetail={(item: any) => {
 
-                   if (onItemClick === noop || !onItemClick) {
 
-                     const url =
 
-                       location.origin +
 
-                       location.pathname +
 
-                       '#/music-detail?id=' +
 
-                       item.id +
 
-                       '&albumId=' +
 
-                       route.params.id
 
-                     openDefaultWebView(url, () => {
 
-                       router.push({
 
-                         path: '/music-detail',
 
-                         query: {
 
-                           id: item.id,
 
-                           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({
 
-                           name: 'music-album-detail',
 
-                           params: {
 
-                             id: n.id
 
-                           }
 
-                         })
 
-                         .then(() => {
 
-                           FetchList(n.id)
 
-                           window.scrollTo(0, 0)
 
-                         })
 
-                     }}
 
-                   />
 
-                 </>
 
-               )}
 
-           </div>
 
-           {/* 判断是否是收费 是否是已经购买 */}
 
-           {albumDetail.value?.paymentType === 'CHARGE' &&
 
-             albumDetail.value?.orderStatus !== 'PAID' && (
 
-               <ColSticky position="bottom" background="white">
 
-                 <div
 
-                   class={[
 
-                     'btnGroup',
 
-                     buyVip.value &&
 
-                       !(state.user.data.userVip?.vipType !== 'NOT_VIP') &&
 
-                       'btnMore'
 
-                   ]}
 
-                   style={{ padding: '0' }}
 
-                 >
 
-                   <Button
 
-                     block
 
-                     round
 
-                     type="primary"
 
-                     style={{ fontSize: '16px' }}
 
-                     onClick={onBuy}
 
-                   >
 
-                     购买专辑
 
-                   </Button>
 
-                   {buyVip.value &&
 
-                     !(state.user.data.userVip?.vipType !== 'NOT_VIP') && (
 
-                       <Button
 
-                         block
 
-                         round
 
-                         type="primary"
 
-                         style={{ fontSize: '16px' }}
 
-                         onClick={() => {
 
-                           router.push({
 
-                             path: '/memberCenter',
 
-                             query: {
 
-                               ...route.query
 
-                             }
 
-                           })
 
-                         }}
 
-                       >
 
-                         {studentActivityId.value > 0 && (
 
-                           <div class={[styles.buttonDiscount]}>专属优惠</div>
 
-                         )}
 
-                         开通会员
 
-                       </Button>
 
-                     )}
 
-                 </div>
 
-               </ColSticky>
 
-             )}
 
-           <Popup
 
-             v-model:show={shareStatus.value}
 
-             style={{ background: 'transparent' }}
 
-             class={styles.albumShare}
 
-           >
 
-             <ColShare
 
-               teacherId={state.user.data.userId}
 
-               shareUrl={shareUrl.value}
 
-               shareType="album"
 
-               shareLength={1}
 
-             >
 
-               <div class={styles.shareVip}>
 
-                 {shareDiscount.value === 1 && (
 
-                   <div class={styles.tagDiscount}>专属优惠</div>
 
-                 )}
 
-                 <img
 
-                   class={styles.icon}
 
-                   crossorigin="anonymous"
 
-                   src={albumDetail.value?.albumCoverUrl + `?t=${+new Date()}`}
 
-                 />
 
-                 <div class={styles.info}>
 
-                   <h4 class="van-multi-ellipsis--l2">
 
-                     {albumDetail.value?.albumName}
 
-                   </h4>
 
-                   <p
 
-                     class={['van-multi-ellipsis--l3']}
 
-                     style={{
 
-                       lineHeight: '16px',
 
-                       margin: '5px 0 10px 0'
 
-                     }}
 
-                   >
 
-                     {albumDetail.value?.albumDesc}
 
-                   </p>
 
-                   <div class={styles.shareAlumCollect}>
 
-                     <img src={icon_music_list} />
 
-                     <span>
 
-                       共
 
-                       <span style="color: var(--van-primary-color);">
 
-                         {albumDetail.value?.musicSheetCount}
 
-                       </span>
 
-                       首曲目
 
-                     </span>
 
-                   </div>
 
-                 </div>
 
-               </div>
 
-               <div class={[styles.shareVip, styles.shareMusicList]}>
 
-                 <SongShare list={shareMusicList.value} />
 
-               </div>
 
-             </ColShare>
 
-           </Popup>
 
-           <Popup
 
-             position="bottom"
 
-             round
 
-             v-model:show={subjects.show}
 
-             closeable
 
-             safe-area-inset-bottom
 
-             onClose={() => (subjects.show = false)}
 
-             onClosed={() => (subjects.show = false)}
 
-           >
 
-             <SelectSubject
 
-               type="ALBUM"
 
-               isShowAllSubject
 
-               searchParams={subjects}
 
-               onComfirm={onComfirmSubject}
 
-             />
 
-           </Popup>
 
-         </div>
 
-       )
 
-     }
 
-   }
 
- })
 
 
  |