import ColSticky from '@/components/col-sticky' import request from '@/helpers/request' import { Button, Cell, CellGroup, Dialog, Image, Popup } from 'vant' import { defineComponent } from 'vue' import styles from './index.module.less' import dayjs from 'dayjs' import ShareModel from './share-model' import { postMessage } from '@/helpers/native-message' import { state } from '@/state' export const getAssetsHomeFile = (fileName: string) => { const path = `./images/${fileName}` const modules = import.meta.globEager('./images/*') return modules[path].default } export default defineComponent({ name: 'track-review-activity', data() { const query = this.$route.query return { id: query.id, activeInfo: {} as any, shareStatus: false, shareUrl: '' } }, computed: { activityMusic() { const activeInfo: any = this.activeInfo return activeInfo.activityMusicVoList || [] }, rewardList() { const activityRewardList = this.activeInfo.activityRewardList console.log(activityRewardList) let list = activityRewardList || [] if (activityRewardList && activityRewardList.length > 0) { const last = activityRewardList.sort((a: any, b: any) => { return Number(a.group) < Number(b.group) ? -1 : 1 }) list = this.groupBy(last, (item: any) => { return [item.group] }) console.log(list, 'list') } return list || [] } }, async mounted() { await this.getMusicInfo() // 判断活动状态的活动时间 this.checkActivityTime() }, methods: { groupBy(array: any, f: any) { const groups = {} array.forEach(function (o) { //注意这里必须是forEach 大写 const group = JSON.stringify(f(o)) groups[group] = groups[group] || [] groups[group].push(o) }) return Object.keys(groups).map(function (group) { return groups[group] }) }, async getMusicInfo() { try { // 获取活动基本信息 const res = await request.post( '/api-teacher/open/activity/info/' + this.id ) this.activeInfo = res.data document.title = this.activeInfo.activityName // 设置连接 this.shareUrl = `${location.origin}/student/#/track-review-activity?recomUserId=${state.user.data?.userId}&id=${this.activeInfo.id}` } catch { // } }, checkActivityTime() { // 判断活动状态的活动时间 try { const activeInfo = this.activeInfo if (activeInfo.activityState !== 1) { Dialog.alert({ message: '活动已结束,感谢你的关注!', theme: 'round-button', confirmButtonColor: '#2dc7aa' }) this.onBackDialog('活动已结束,感谢你的关注!') return false } const nowTime = dayjs() const startTime = dayjs(activeInfo.activityStart) const endTime = dayjs(activeInfo.activityEnd) if (dayjs(nowTime).isBefore(dayjs(startTime))) { this.onBackDialog('活动尚未开始,请您耐心等待!') return false } else if (!dayjs(nowTime).isBefore(dayjs(endTime))) { this.onBackDialog('活动已结束,感谢你的关注!') return false } return true } catch { // } }, onBackDialog(str: string) { Dialog.alert({ message: str, theme: 'round-button', confirmButtonColor: '#2dc7aa' }).then(() => { postMessage({ api: 'back' }) }) } }, render() { return (

活动时间: {dayjs(this.activeInfo.activityStart).format( 'YYYY-MM-DD' )} ~ {dayjs(this.activeInfo.activityEnd).format('YYYY-MM-DD')}

活动介绍
{this.activeInfo.describe}

活动奖品 {/* */} this.$router.push({ path: '/leaderboard', query: { id: this.id } }) } > 查看挑战排行榜 {/* 共{this.activityMusic.length || 0} 首曲目 */}

{this.rewardList.map((item: any, index: number) => ( <>
{index === 0 && ( )} {index === 1 && ( )} {index === 2 && ( )} 第{++index}名奖品
{item.map((child: any) => (
{child.rewardName}
{child.rewardDescribe}
))}
))} {/* {this.activeInfo.activityRewardList && this.activeInfo.activityRewardList.map((item: any) => (
{item.rewardName}
{item.rewardDescribe}
))} */}

活动曲目 // this.$router.push({ // path: '/leaderboard', // query: { id: this.id } // }) // } > {/* 查看挑战排行榜 */} 共{this.activityMusic.length || 0}首曲目

{this.activityMusic.map((item: any) => ( ( ), title: () => ( {item.musicSheetName} ), value: () => {item.musicSubject} }} /> (

{item.userId ? item.score : '--'}

), title: () => (
{item.userId ? ( <> ) : (
)}
{item.userId ? ( <>

{item.username}

{item.userSubject}

{' '} ) : ( 虚位以待 )}
) }} >
))}
活动规则
{this.activeInfo.ruleDescribe}
) } })