Commit 051dd08d authored by m's avatar m

feat: update

parent 981cc69e
......@@ -7,9 +7,9 @@
export default {
pages: [
'pages/main/main',
'pages/prepare/index',
'pages/group/index',
'pages/study-market/index',
'pages/prepare/index',
'pages/market/index',
'pages/game/play/index',
'pages/game/complete/index',
],
......
import { requestAfterSilentLogin } from '@/utils/request'
import { getStorage, StorageKeys } from '@/utils/storage'
import { AccountOut } from './auth'
export const getPointToCard = () => {
return requestAfterSilentLogin<AccountOut[], { userId?: number }>({
// 积分兑换答题卡
export const pointToCard = ({ num }: { num: number }) => {
return requestAfterSilentLogin<AccountOut[], { userId?: number, num: number }>((userInfo) => ({
url: '/service-idea/account/pointToCard',
method: 'GET',
data: { userId: getStorage(StorageKeys.userInfo)?.userId }
data: {
num,
userId: userInfo?.userId
}
})
)
}
......@@ -60,6 +60,9 @@ export interface StageDetail extends Stage {
content: string;
bestResultTime: number;
ranks?: StageRank[];
nextStep: string;
nextStepReward: number;
nextStepTime: number
}
/** 获取关卡详情 */
......
......@@ -23,11 +23,12 @@ export const createTribe = ({ groupNo }: Pick<CreateTribeParams, 'groupNo'>) =>
}
// 领取每日部落积分
export const getTribePoint = () => {
return requestAfterSilentLogin<{}, { userId?: number }>((userInfo) => ({
export const postTribePoint = ({ type }: Pick<PointType, 'type'>) => {
return requestAfterSilentLogin<{}, { userId?: number } & Pick<PointType, 'type'>>((userInfo) => ({
url: '/service-idea/group/getTribePoint',
method: 'GET',
method: 'POST',
data: {
type,
userId: userInfo?.userId,
}
}))
......@@ -44,9 +45,14 @@ export const joinTribe = () => {
}))
}
export type PointType = {
point: number;
type: 'MEMBERNUM' | 'MEMBERJOIN'
}
// 部落每日可领取积分查询
export const queryTribePoint = () => {
return requestAfterSilentLogin<number, { userId?: number }>((userInfo) => ({
return requestAfterSilentLogin<PointType[], { userId?: number }>((userInfo) => ({
url: '/service-idea/group/queryTribePoint',
method: 'GET',
data: {
......
......@@ -16,15 +16,17 @@ interface ButtonProps {
loading?: boolean;
size?: ButtonSize;
type?: ButtonType;
className?: string;
onClick?: () => void;
}
const Button = ({
size = 'middle',
type = 'primary',
block,
disabled,
loading,
size = 'middle',
type = 'primary',
className,
onClick,
children,
}: PropsWithChildren<ButtonProps>) => {
......@@ -36,7 +38,8 @@ const Button = ({
[styles.block]: block,
[styles.disabled]: disabled,
[styles.loading]: loading,
}
},
className
)
const handleClick = () => {
......
......@@ -78,9 +78,12 @@
gap: 6px;
}
&_disabled {
opacity: 0.8;
}
&_today {
margin-left: 48px;
opacity: 0.8;
}
&_invite {
......
......@@ -3,7 +3,7 @@ import { showToast } from '@tarojs/taro'
import classNames from 'classnames'
import { useRequest } from '@/hooks'
import { queryTribePoint, getTribePoint } from '@/api/group'
import { queryTribePoint, postTribePoint, type PointType } from '@/api/group'
import TextPrinter from './text-printer'
import styles from './header.module.scss'
......@@ -25,7 +25,7 @@ const CroupHeader = ({ isCreator }: { isCreator: boolean }) => {
immediate: !isCreator
})
const { run } = useRequest(getTribePoint, {
const { run } = useRequest(postTribePoint, {
immediate: false,
throttleDelay: 1000,
onSuccess: () => {
......@@ -34,36 +34,36 @@ const CroupHeader = ({ isCreator }: { isCreator: boolean }) => {
}
})
const renderMembers = () => (
<View className={styles.members}>
<View className={styles.members_title}>
<Text className={styles.members_text}>阳光学习帮</Text>
</View>
<View className={styles.members_content}>
<View className={styles.members_today} onClick={() => data && run()}>
const renderItem = (item: PointType) => (
<View
className={classNames({
[styles.members_today]: item.type === 'MEMBERNUM',
[styles.members_invite]: item.type === 'MEMBERJOIN',
[styles.members_disabled]: !item.point,
})}
onClick={() => item.point && run({ type: item.type })}
>
<View className={styles.members_score}>
<Image
src={require('@/pages/main/assets/score.png')}
className={classNames(styles.members_icon, data ? styles.upDownAnimation : '')}
className={classNames(styles.members_icon, item.point ? styles.upDownAnimation : '')}
/>
<Text className={classNames(styles.members_number, data ? styles.upDownAnimation : '')}>
+{data || 0}
<Text className={classNames(styles.members_number, item.point ? styles.upDownAnimation : '')}>
+{item.point || 0}
</Text>
</View>
<Text className={styles.members_stroke}>今日部落津贴</Text>
<Text className={styles.members_stroke}>{item.type === 'MEMBERNUM' ? '今日部落津贴' : '成功邀请1人'}</Text>
</View>
<View className={styles.members_invite}>
<View className={styles.members_score}>
<Image
className={classNames(styles.members_icon, styles.upDownAnimation)}
src={require('@/pages/main/assets/score.png')}
/>
<Text className={classNames(styles.members_number, styles.upDownAnimation)}>
+100
</Text>
</View>
<Text className={styles.members_stroke}>成功邀请1人</Text>
)
const renderMembers = () => (
<View className={styles.members}>
<View className={styles.members_title}>
<Text className={styles.members_text}>阳光学习帮</Text>
</View>
<View className={styles.members_content}>
{/* {data?.map(renderItem)} */}
{[{ type: 'MEMBERNUM', point: 1 }, { type: 'MEMBERJOIN', point: 0 }].map(renderItem)}
</View>
</View>
)
......
......@@ -114,8 +114,8 @@
}
&_icon {
width: 64px;
height: 64px;
width: 32PX;
height: 32PX;
}
&_text {
......
......@@ -3,12 +3,14 @@ import classNames from 'classnames'
import styles from './share-view.module.scss'
export default ({
children,
className
}: { children: React.ReactNode, className?: string }) => {
export default ({ children, className }: { children: React.ReactNode, className?: string }) => {
return (
<Button openType="share" plain style={{ border: 'none' }} className={classNames(styles.wrapper, className)}>
<Button
plain
openType="share"
style={{ border: 'none' }}
className={classNames(styles.wrapper, className)}
>
{children}
</Button>
)
......
import { View, Text, Button } from '@tarojs/components'
import Modal from '@/components/Modal'
import { useBoolean } from '@/hooks/use-boolean'
import { MarketModalProps } from '../types'
// import { MarketModalProps } from '../types'
import CardMain from './card-main'
const AnswerSheet = ({ onConfirm, loading }: MarketModalProps) => {
const AnswerSheet = ({ onConfirm, loading }) => {
const [isVisible, { setTrue, setFalse }] = useBoolean(false)
return (
......
......@@ -3,7 +3,7 @@ import { View, Text, Button } from '@tarojs/components'
import { getMenuButtonBoundingClientRect, showToast, showModal } from '@tarojs/taro'
import { useBoolean, useToggle, useRequest } from '@/hooks'
import { getPointToCard } from '@/api/account'
import { pointToCard } from '@/api/account'
import Modal from '@/components/Modal'
import MainHeader from '../main/components/header'
......@@ -33,7 +33,7 @@ const StudyMarket = () => {
const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const [state, { setDefault, setReverse }] = useToggle({ defaultValue: Demo.AnswerSheet, reverseValue: Demo.Mystery })
const { loading } = useRequest(getPointToCard, {
const { loading } = useRequest(pointToCard, {
immediate: false,
onSuccess () {
showToast({ title: '成功' })
......
......@@ -60,14 +60,6 @@
@include flexLayout(column);
gap: 12PX;
.buy {
height: 56PX;
@include flexLayout(row, center, center);
background-size: 100% 100%;
background-image: url('../assets/btn-primary.png');
font-weight: 500;
}
.studyTribe {
@include flexLayout(row, center, center);
height: 56PX;
......
......@@ -22,7 +22,7 @@ const AnswerSheetModal = (props: PropsWithChildren<ModalProps>) => {
<View className={styles.title}>你的答题卡已经用完啦</View>
<View className={styles.tips}>可通过以下途径获得哦</View>
<View className={styles.footer}>
<View className={styles.buy}>{children}</View>
{children}
<View className={styles.studyTribe} onClick={() => switchTab({ url: '/pages/group/index' })}>
<Text>建设学习部落,得更多答题卡</Text>
</View>
......
......@@ -9,7 +9,7 @@
.title {
font-weight: bold;
margin: 20px 0;
margin: 40px 0 20px;
font-size: 26PX;
font-weight: 600;
color: #FFFFFF;
......@@ -40,30 +40,35 @@
.requirement {
@include flexLayout(column);
& > .text {
& > .header {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 12PX;
text-align: center;
font-size: 16PX;
font-weight: 500;
color: #FFFFFF;
position: relative;
margin-bottom: 12PX;
&::before, &::after {
content: "";
position: absolute;
width: 36%;
.line {
flex-grow: 1;
height: 1px;
top: 20px;
transform: scaleY(0.5);
background-color: #fff;
transform: scaleY(0.5);
&:first-child {
margin-right: 10PX;
}
&:last-child {
margin-left: 10PX;
}
&::before {
left: 0;
}
&::after {
right: 0;
.text {
text-align: center;
font-weight: 500;
color: #FFFFFF;
}
}
......@@ -118,4 +123,62 @@
}
}
}
.replay {
background: rgba(226,233,255,0.2);
border-radius: 30px;
border: 1px solid #FFFFFF;
@include flexLayout(row, center);
font-size: 15PX;
font-weight: 500;
color: #FFFFFF;
padding: 32px 0;
position: relative;
margin-bottom: 48px;
&::before {
content: '';
position: absolute;
width: 1px;
transform: scaleY(0.5);
background-color: rgba(255,255,255,0.4);
right: 50%;
top: 0;
bottom: 0;
}
.performance {
width: 50%;
.details {
@include flexLayout(row, center, center);
gap: 6PX;
margin-top: 12PX;
.logo {
width: 24PX;
height: 24PX;
}
.consume {
font-size: 20PX;
}
}
}
.achievement {
width: 50%;
.details {
margin-top: 12PX;
@include flexLayout(row, center, center);
gap: 20px;
.logo {
width: 32PX;
height: 32PX;
}
}
}
}
}
\ No newline at end of file
import { View, Text, Image } from '@tarojs/components'
import assets from '@/assets/oss/assets-prepare'
import { useMemo } from 'react'
import { useStoreState } from '@/store/hooks'
import { StageType, StageLevel, StageDetail } from '@/api'
import assets from '@/assets/oss/assets-prepare'
import styles from './main-header.module.scss'
const scoreList = [
{ u: assets['level-big-s.png'].u },
{ u: assets['level-big-a.png'].u },
{ u: assets['level-big-b.png'].u },
]
const MainHeader = () => {
const stageDetail = useStoreState(state => state.gameModel.stageDetail) || {} as StageDetail
const isKing = useMemo(() => { // 是王者了
return stageDetail.level === 'S' && stageDetail.upGear && stageDetail.gear === 10
}, [stageDetail.level, stageDetail.upGear, stageDetail.gear])
const type = useMemo(() => {
switch (stageDetail.type) {
case StageType.OneStop:
return {
t: StageType.OneStop,
u: assets['fight.png'].u,
}
case StageType.Enhance:
return {
t: StageType.Enhance,
u: assets['book.png'].u,
}
default:
return {
t: StageType.Strong,
u: assets['strong.png'].u,
}
}
}, [stageDetail?.type])
const topAchieve = useMemo(() => {
switch (stageDetail.gear) {
case 10:
return assets['top-10.png'].u
case 20:
return assets['top-20.png'].u
case 30:
return assets['top-30.png'].u
default:
return assets['top-un.png'].u
}
}, [stageDetail.gear])
const levelAchieve = useMemo(() => {
switch (stageDetail.level) {
case StageLevel.S:
return assets['level-s.png'].u
case StageLevel.A:
return assets['level-a.png'].u
case StageLevel.B:
return assets['level-b.png'].u
default:
return assets['level-b-un.png'].u
}
}, [stageDetail.level])
const renderItem = ({ u }) => (
// const levelRequirement = useMemo(() => {
// switch (stageDetail.level) {
// case StageLevel.S:
// return {
// v: 10,
// u: assets['level-big-s.png'].u
// }
// case StageLevel.A:
// return {
// v: 5,
// u: assets['level-big-a.png'].u
// }
// case StageLevel.B:
// return {
// v: 1,
// u: assets['level-big-b.png'].u
// }
// }
// }, [stageDetail.level, stageDetail])
const RequireItem = ({ u, v, t = 0 }: { u: string, v: number, t: number }) => (
<View key={u} className={styles.detail}>
<View className={styles.content}>
<Image className={styles.badge} src={u} mode="widthFix" />
......@@ -18,36 +88,73 @@ const renderItem = ({ u }) => (
<Text>全对,</Text>
</View>
<View className={styles.center}>
<Image className={styles.icon} src={assets['clock.png'].u} mode="widthFix" />
<Text>用时 ≤49s</Text>
<Image className={styles.icon} src={stageDetail.firstTime ? assets['clock.png'].u : assets['clock-up.png'].u} mode="widthFix" />
<Text>{stageDetail.firstTime ? `用时 ≤${t}s` : `用时需提高${t}s`}</Text>
</View>
</View>
<View className={styles.score}>
<Image className={styles.icon} src={assets['diamond.png'].u} mode="widthFix" />
<Text className={styles.text}>+100</Text>
<Text className={styles.text}>+{v}</Text>
</View>
</View>
)
)
const renderFirst = () => (
<View className={styles.details}>
<RequireItem u={assets['level-big-s.png'].u} v={10} t={stageDetail.sTime} />
<RequireItem u={assets['level-big-a.png'].u} v={5} t={stageDetail.aTime} />
<RequireItem u={assets['level-big-b.png'].u} v={1} t={stageDetail.bTime} />
</View>
)
const renderAgain = () => (
<View className={styles.details}>
{/* <RequireItem u={levelRequirement.u} v={levelRequirement.v} t={stageDetail.nextStepTime} /> */}
{/* <RequireItem u={stageDetail.upGear ? assets['upgear.png'].u : assets['upgear-un.png'].u} v={5} t={stageDetail.nextStepTime} /> */}
{/* <RequireItem u={stageDetail.upGear ? assets['upgear.png'].u : assets['upgear-un.png'].u} v={5} t={stageDetail.nextStepTime} /> */}
</View>
)
const MainHeader = () => {
return (
<View className={styles.wrapper}>
<View className={styles.title}>表内除法</View>
<View className={styles.title}>{stageDetail.name || '-'}</View>
<View className={styles.labels}>
<View className={styles.label}>
<Image className={styles.icon} src={assets['strong.png'].u} mode="widthFix" />
<Text>强化</Text>
<Image className={styles.icon} src={type.u} mode="widthFix" />
<Text>{type.t}</Text>
</View>
<Text className={styles.label}>计算达标1</Text>
<Text className={styles.label}>{stageDetail.content || '-'}</Text>
<Text className={styles.label}>共 10 题</Text>
</View>
<View className={styles.requirement}>
<Text className={styles.text}>通关要求</Text>
<View className={styles.replay}>
<View className={styles.performance}>
<Text>最佳表现</Text>
<View className={styles.details}>
{scoreList.map(renderItem)}
<Image src={assets['clock.png'].u} className={styles.logo} />
<Text className={styles.consume}>{stageDetail.bestResultTime || 0}s</Text>
</View>
</View>
<View className={styles.achievement}>
<Text>勋章成就</Text>
<View className={styles.details}>
<Image src={levelAchieve} className={styles.logo} />
<Image src={topAchieve} className={styles.logo} />
<Image src={stageDetail.upGear ? assets['upgear.png'].u : assets['upgear-un.png'].u} className={styles.logo} />
</View>
</View>
</View>
<View className={styles.requirement}>
<View className={styles.header}>
<View className={styles.line}></View>
<Text className={styles.text}>
{stageDetail.firstTime ? '通关要求' : '继续努力,赢更多成就'}
</Text>
<View className={styles.line}></View>
</View>
{stageDetail.firstTime ? renderFirst() : isKing ? null : renderAgain()}
</View>
</View>
)
......
......@@ -9,9 +9,8 @@
.tabBar {
display: flex;
border-bottom: 1px solid #ccc;
height: 176px;
background-size: cover;
height: 88PX;
background-size: 100% 100%;
&.active_1 {
background-image: url('../assets/tab-1.png');
......@@ -24,7 +23,7 @@
.tab {
flex: 1;
height: 96px;
height: 48PX;
display: flex;
align-items: center;
justify-content: center;
......@@ -41,10 +40,10 @@
position: absolute;
content: "";
width: 16PX;
bottom: 0;
bottom: 6PX;
height: 3PX;
background: #1786F7;
border-radius: 8PX;
border-radius: 6PX;
}
}
}
......
.header {
.topBar {
position: fixed;
color: #fff;
left: 0;
top: 0;
right: 0;
z-index: 999;
}
background-image: url(../assets/head-bg.png);
.head_bg {
&_bg {
position: absolute;
z-index: 1;
left: 0;
right: 0;
width: 100%;
}
.content {
position: relative;
z-index: 2;
}
.inner {
display: flex;
......
......@@ -8,27 +8,18 @@ export default () => {
const nav = getMenuButtonBoundingClientRect()
const sys = getSystemInfoSync()
const innerStyle = useMemo(() => {
const topBarStyle = useMemo(() => {
return {
height: `${nav.height + 10}px`,
paddingRight: `${nav.width + (sys.windowWidth - nav.right) * 2}px`
paddingTop: `${nav.top - 5}px`
}
}, [sys, nav])
return (
<View className={styles.header}>
<Image src={require('../assets/head-bg.png')} mode="widthFix" className={styles.head_bg} />
<View
className={styles.content}
style={{
height: `${nav.height + 10}px`,
paddingTop: `${nav.top - 5}px`
}}
>
<View className={styles.inner} style={innerStyle}>
<View className={styles.topBar} style={topBarStyle}>
<View className={styles.inner}>
<Image className={styles.back_icon} src={require('../assets/back.png')} mode="widthFix" onClick={() => navigateBack()} />
</View>
</View>
</View>
)
}
import assets from '@/assets/oss/assets-prepare'
export const requirement = {
newcomer: {
title: '通关要求',
clock: assets['clock.png'].u,
text: '用时 ≤49s'
},
strive: {
title: '继续努力,赢更多成就',
clock: assets['clock-up.png'].u,
text: '用时需提高0.3s',
},
}
......@@ -3,6 +3,14 @@
.wrapper {
padding-bottom: 80PX;
.inner {
position: relative;
z-index: 10;
background-image: url(./assets/head-bg.png);
background-size: 100%;
background-attachment: fixed;
}
.tribe {
&_title {
@include flexLayout(row, center, center);
......@@ -12,20 +20,48 @@
font-weight: 600;
color: #465164;
}
&_empty {
@include flexLayout(column, center, center);
font-size: 14PX;
font-weight: 500;
color: rgba(70,81,100,0.5);
margin: 48px 0;
&_logo {
width: 220px;
height: 220px;
margin-bottom: 4PX;
}
&_btn {
border-radius: 20px;
width: 272px;
padding: 10PX 0;
letter-spacing: 1PX;
border: 2PX solid #465164;
text-align: center;
color: #FF7A18;
margin-top: 24PX;
}
}
}
.empty {
color: #9999;
font-size: 12PX;
font-size: 14PX;
margin-top: 12PX;
text-align: center;
}
.item {
display: flex;
padding: 28px 32px 26px;
padding: 30px 32px;
align-items: center;
&.active {
background-color: #E4F1FF;
}
&_rank {
margin-right: 40px;
@include flexLayout(row, center);
......@@ -61,6 +97,8 @@
&_crown {
width: 36px;
height: 36px;
position: relative;
top: -1PX;
}
}
&_result {
......@@ -77,13 +115,28 @@
}
}
.challenge {
.footer_bar {
position: fixed;
bottom: 60px;
left: 16PX;
right: 16PX;
height: 100px;
bottom: 0;
left: 0;
right: 0;
z-index: 999;
background-color: #fff;
padding: 16PX 0 24PX;
.tribe_share {
border-radius: 10PX;
margin: 0 40PX;
margin-bottom: 56px;
height: 44PX;
border: 2PX solid #465164;
gap: 8PX;
@include flexLayout(row, center, center);
}
.challenge {
margin: 0 16PX;
position: relative;
&_text {
font-size: 40px;
letter-spacing: 1PX;
......@@ -107,11 +160,13 @@
}
.tip {
position: absolute;
top: -32PX;
right: -9PX;
padding: 8PX 13PX 12PX;
top: -28PX;
right: -4PX;
height: 42PX;
padding: 0 13PX;
background-image: url('https://cdn.jkwljy.com/pk-math/4WgogFzhSYUSrvpmEE7JwoVg7SH5/122x42');
background-size: 100% 100%;
@include flexLayout(row, center);
&_text {
font-size: 16PX;
......@@ -120,14 +175,31 @@
}
}
}
}
}
.modal {
.buy_card {
height: 56PX;
@include flexLayout(row, center, center);
font-size: 18PX;
background-size: 100% 100%;
background-image: url('./assets/btn-primary.png');
font-weight: 500;
color: #FFFFFF;
&_loading {
opacity: 0.8;
}
&_spin {
margin-right: 8PX;
}
.inner {
@include flexLayout(row, center, center);
font-size: 18PX;
font-weight: 500;
& > {
.logo {
width: 32PX;
......@@ -144,4 +216,10 @@
font-size: 14PX;
}
}
}
}
.buy_card_disabled {
background-image: url('./assets/btn-disabled.png');
color: #C2C8D1;
}
\ No newline at end of file
import { View, Text, Image } from '@tarojs/components'
import { useEffect } from 'react'
import { useRouter, getMenuButtonBoundingClientRect } from '@tarojs/taro'
import { useEffect, useMemo, useState } from 'react'
import { useRouter, getMenuButtonBoundingClientRect, useShareAppMessage, navigateTo } from '@tarojs/taro'
import classNames from 'classnames'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { useBoolean } from '@/hooks'
import { type StageRank } from '@/api/game'
import assets from '@/assets/oss/assets-prepare'
import Button from '@/components/Button'
import Loading from '@/components/Loading'
import ShareView from '@/pages/group/components/share-view'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { useBoolean, useRequest } from '@/hooks'
import { pointToCard } from '@/api/account'
import Tabs, { type TabItem } from './components/tabs'
import TopBar from './components/top-bar'
import MainHeader from './components/main-header'
import Thead from './components/thead'
import AnswerCardModal from './components/answer-card-modal'
import { renderList, renderTribePage } from './render'
import styles from './index.module.scss'
const renderItem = (item: StageRank, index: number) => {
return (
<View key={item.userId} className={styles.item}>
<View className={styles.item_rank}>
{[0, 1, 2].includes(index)
? <Image className={styles.item_rank_icon} src={require(`@/pages/group/assets/icons/rank-${index + 1}.png`)} />
: <Text className={styles.item_rank_index}>{index}</Text>
}
</View>
<View className={styles.item_username}>
<Text className={styles.item_username_text}>{item.nickName || '-'}</Text>
<Image className={styles.item_username_crown} src={require('@/pages/group/assets/icons/crown-small.png')} />
</View>
<View className={styles.item_result}>
<Text className={styles.item_result_first}>{65.23}s</Text>
<Text>|</Text>
<Text className={styles.item_result_best}>{34.23}s</Text>
</View>
const tabs: TabItem[] = [
{
label: '成都排行榜',
children: renderList()
},
{
label: '学习部落排行榜',
children: (
<View className={styles.tribe}>
{renderTribePage()}
</View>
)
}
}
]
const Prepare = () => {
const nav = getMenuButtonBoundingClientRect()
const router = useRouter<{ id: string }>()
const [currentTab, setCurrentTab] = useState(0)
const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const stageDetail = useStoreState(state => state.gameModel.stageDetail)
const getStageDetail = useStoreActions(actions => actions.gameModel.getStageDetail)
const router = useRouter<{ id: string }>()
const { run: exchange, loading } = useRequest(pointToCard, { immediate: false })
const innerStyle = useMemo(() => {
const h = nav.height + nav.top + 5
return {
paddingTop: `${h}px`,
}
}, [nav.height, nav.top])
useEffect(() => {
getStageDetail(+router.params.id || 1)
}, [router, getStageDetail])
const renderList = (list = []) => {
const isEmpty = list.length < 1
return (
<>
<Thead />
{list.map(renderItem)}
{isEmpty && <View className={styles.empty}>暂无数据</View>}
</>
)
}
const tabs: TabItem[] = [
{
label: '成都排行榜',
children: (
<>{renderList()}</>
)
},
{
label: '学习部落排行榜',
children: (
<View className={styles.tribe}>
<Text className={styles.tribe_title}>极客学霸俱乐部</Text>
{renderList()}
</View>
)
useShareAppMessage(() => {
return {
title: '来看看这个有趣的页面!',
path: 'pages/main/main?code=1111',
imageUrl: 'https://picx.zhimg.com/v2-7b7b072d4bebd5ccf48c04ec1146e844_1440w.jpg?',
}
]
})
return (
<>
<View className={styles.wrapper}>
<TopBar />
<View style={{ position: 'relative', paddingTop: `${nav.height + nav.top + 5}px` }}>
<View className={styles.inner} style={innerStyle}>
<MainHeader />
<Tabs items={tabs} />
<Tabs initialIndex={currentTab} items={tabs} onChange={setCurrentTab} />
</View>
<View className={styles.challenge}>
<Button type="custom" size="large" onClick={setTrue}>
<View className={styles.footer_bar}>
{currentTab === 1 && <ShareView>
<View className={styles.tribe_share}>
<Image style={{ width: 32, height: 32 }} src={require('@/pages/group/assets/icons/invite-small.png')} />
<Text style={{ color: '#FF7A18', fontSize: 16 }}>邀请更多好友加入学习部落</Text>
</View>
</ShareView>}
<Button type="custom" size="large" onClick={setTrue} className={styles.challenge}>
<Text className={styles.challenge_text}>开始闯关</Text>
<View className={styles.card}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text>
</View>
{false && <View className={styles.tip}>
{true && <View className={styles.tip}>
<Text className={styles.tip_text}>首次免答题卡</Text>
</View>}
</Button>
</View>
</View>
<AnswerCardModal isVisible={isVisible} onClose={setFalse}>
<View className={styles.modal}>
<View
className={classNames(styles.buy_card, {
// [styles.buy_card_disabled]: true,
[styles.buy_card_loading]: loading,
})}
// onClick={() => !loading && exchange({ num: 1 })}
onClick={() => navigateTo({ url: '/pages/game/play/index' })}
>
<Loading size="small" className={styles.buy_card_spin} spinning={loading} />
<View className={styles.inner}>
{/* <Image className={styles.logo} src={false ? assets['diamond.png'].u : assets['diamond-un.png'].u} mode="widthFix" /> */}
<Image className={styles.logo} src={assets['diamond.png'].u} mode="widthFix" />
<Text>-30</Text>
<Text className={styles.buy}>购买</Text>
<Text className={styles.balance}>(当前剩余 120)</Text>
</View>
</View>
</AnswerCardModal>
</>
</View>
)
}
......
import { View, Text, Image } from '@tarojs/components'
import { switchTab } from '@tarojs/taro'
import classNames from 'classnames'
import { type StageRank } from '@/api/game'
import assets from '@/assets/oss/assets-prepare'
import Thead from './components/thead'
import styles from './index.module.scss'
export const formatTime = (time: number) => {
const minutes = Math.floor(time / 60)
const seconds = time % 60
return `${minutes}分${seconds}秒`
}
export const renderList = (list: StageRank[] = []) => {
const isEmpty = list.length < 1
const user = list.find(item => item.me)
return (
<>
<Thead />
{user && user.no > 3 && renderItem(user)}
{list.map(renderItem)}
{isEmpty && <View className={styles.empty}>暂无数据</View>}
</>
)
}
export const renderItem = (item: StageRank) => {
return (
<View key={item.userId} className={classNames(styles.item, { [styles.active]: item.me })}>
<View className={styles.item_rank}>
{[1, 2, 3].includes(item.no)
? <Image className={styles.item_rank_icon} src={require(`@/pages/group/assets/icons/rank-${item.no}.png`)} />
: <Text className={styles.item_rank_index}>{item.no}</Text>
}
</View>
<View className={styles.item_username}>
<Text className={styles.item_username_text}>
{item.nickName || '-'}
{item.me && <Text>(你)</Text>}
</Text>
<Image className={styles.item_username_crown} src={require('@/pages/group/assets/icons/crown-small.png')} />
</View>
<View className={styles.item_result}>
<Text className={styles.item_result_first}>{65.23}s</Text>
<Text>|</Text>
<Text className={styles.item_result_best}>{34.23}s</Text>
</View>
</View>
)
}
const renderEmptyTribe = () => (
<View className={styles.tribe_empty}>
<Image className={styles.tribe_empty_logo} src={assets['tribe.png'].u} mode="widthFix" />
<Text>创建你的部落,和好友互相激励</Text>
<Text>还能获得非常多的奖励哦</Text>
<Text className={styles.tribe_empty_btn} onClick={() => switchTab({ url: '/pages/group/index' })}>立即创建</Text>
</View>
)
const renderTribeList = () => (
<View style={{ paddingBottom: 100 }}>
<Text className={styles.tribe_title}>极客学霸俱乐部</Text>
{renderList()}
</View>
)
export const renderTribePage = () => {
return (
<View className={styles.tribe}>
{[{}].length > 0 ? renderTribeList() : renderEmptyTribe()}
</View>
)
}
export const formatTime = (time: number) => {
const minutes = Math.floor(time / 60)
const seconds = time % 60
return `${minutes}分${seconds}秒`
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment