Commit 051dd08d authored by m's avatar m

feat: update

parent 981cc69e
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
export default { export default {
pages: [ pages: [
'pages/main/main', 'pages/main/main',
'pages/prepare/index',
'pages/group/index', 'pages/group/index',
'pages/study-market/index', 'pages/prepare/index',
'pages/market/index',
'pages/game/play/index', 'pages/game/play/index',
'pages/game/complete/index', 'pages/game/complete/index',
], ],
......
import { requestAfterSilentLogin } from '@/utils/request' import { requestAfterSilentLogin } from '@/utils/request'
import { getStorage, StorageKeys } from '@/utils/storage'
import { AccountOut } from './auth' 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', url: '/service-idea/account/pointToCard',
method: 'GET', method: 'GET',
data: { userId: getStorage(StorageKeys.userInfo)?.userId } data: {
num,
userId: userInfo?.userId
}
}) })
)
} }
...@@ -60,6 +60,9 @@ export interface StageDetail extends Stage { ...@@ -60,6 +60,9 @@ export interface StageDetail extends Stage {
content: string; content: string;
bestResultTime: number; bestResultTime: number;
ranks?: StageRank[]; ranks?: StageRank[];
nextStep: string;
nextStepReward: number;
nextStepTime: number
} }
/** 获取关卡详情 */ /** 获取关卡详情 */
......
...@@ -23,11 +23,12 @@ export const createTribe = ({ groupNo }: Pick<CreateTribeParams, 'groupNo'>) => ...@@ -23,11 +23,12 @@ export const createTribe = ({ groupNo }: Pick<CreateTribeParams, 'groupNo'>) =>
} }
// 领取每日部落积分 // 领取每日部落积分
export const getTribePoint = () => { export const postTribePoint = ({ type }: Pick<PointType, 'type'>) => {
return requestAfterSilentLogin<{}, { userId?: number }>((userInfo) => ({ return requestAfterSilentLogin<{}, { userId?: number } & Pick<PointType, 'type'>>((userInfo) => ({
url: '/service-idea/group/getTribePoint', url: '/service-idea/group/getTribePoint',
method: 'GET', method: 'POST',
data: { data: {
type,
userId: userInfo?.userId, userId: userInfo?.userId,
} }
})) }))
...@@ -44,9 +45,14 @@ export const joinTribe = () => { ...@@ -44,9 +45,14 @@ export const joinTribe = () => {
})) }))
} }
export type PointType = {
point: number;
type: 'MEMBERNUM' | 'MEMBERJOIN'
}
// 部落每日可领取积分查询 // 部落每日可领取积分查询
export const queryTribePoint = () => { export const queryTribePoint = () => {
return requestAfterSilentLogin<number, { userId?: number }>((userInfo) => ({ return requestAfterSilentLogin<PointType[], { userId?: number }>((userInfo) => ({
url: '/service-idea/group/queryTribePoint', url: '/service-idea/group/queryTribePoint',
method: 'GET', method: 'GET',
data: { data: {
......
...@@ -16,15 +16,17 @@ interface ButtonProps { ...@@ -16,15 +16,17 @@ interface ButtonProps {
loading?: boolean; loading?: boolean;
size?: ButtonSize; size?: ButtonSize;
type?: ButtonType; type?: ButtonType;
className?: string;
onClick?: () => void; onClick?: () => void;
} }
const Button = ({ const Button = ({
size = 'middle',
type = 'primary',
block, block,
disabled, disabled,
loading, loading,
size = 'middle', className,
type = 'primary',
onClick, onClick,
children, children,
}: PropsWithChildren<ButtonProps>) => { }: PropsWithChildren<ButtonProps>) => {
...@@ -36,7 +38,8 @@ const Button = ({ ...@@ -36,7 +38,8 @@ const Button = ({
[styles.block]: block, [styles.block]: block,
[styles.disabled]: disabled, [styles.disabled]: disabled,
[styles.loading]: loading, [styles.loading]: loading,
} },
className
) )
const handleClick = () => { const handleClick = () => {
......
...@@ -77,10 +77,13 @@ ...@@ -77,10 +77,13 @@
@include flexLayout(column, center); @include flexLayout(column, center);
gap: 6px; gap: 6px;
} }
&_disabled {
opacity: 0.8;
}
&_today { &_today {
margin-left: 48px; margin-left: 48px;
opacity: 0.8;
} }
&_invite { &_invite {
......
...@@ -3,7 +3,7 @@ import { showToast } from '@tarojs/taro' ...@@ -3,7 +3,7 @@ import { showToast } from '@tarojs/taro'
import classNames from 'classnames' import classNames from 'classnames'
import { useRequest } from '@/hooks' import { useRequest } from '@/hooks'
import { queryTribePoint, getTribePoint } from '@/api/group' import { queryTribePoint, postTribePoint, type PointType } from '@/api/group'
import TextPrinter from './text-printer' import TextPrinter from './text-printer'
import styles from './header.module.scss' import styles from './header.module.scss'
...@@ -25,7 +25,7 @@ const CroupHeader = ({ isCreator }: { isCreator: boolean }) => { ...@@ -25,7 +25,7 @@ const CroupHeader = ({ isCreator }: { isCreator: boolean }) => {
immediate: !isCreator immediate: !isCreator
}) })
const { run } = useRequest(getTribePoint, { const { run } = useRequest(postTribePoint, {
immediate: false, immediate: false,
throttleDelay: 1000, throttleDelay: 1000,
onSuccess: () => { onSuccess: () => {
...@@ -34,36 +34,36 @@ const CroupHeader = ({ isCreator }: { isCreator: boolean }) => { ...@@ -34,36 +34,36 @@ const CroupHeader = ({ isCreator }: { isCreator: boolean }) => {
} }
}) })
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, item.point ? styles.upDownAnimation : '')}
/>
<Text className={classNames(styles.members_number, item.point ? styles.upDownAnimation : '')}>
+{item.point || 0}
</Text>
</View>
<Text className={styles.members_stroke}>{item.type === 'MEMBERNUM' ? '今日部落津贴' : '成功邀请1人'}</Text>
</View>
)
const renderMembers = () => ( const renderMembers = () => (
<View className={styles.members}> <View className={styles.members}>
<View className={styles.members_title}> <View className={styles.members_title}>
<Text className={styles.members_text}>阳光学习帮</Text> <Text className={styles.members_text}>阳光学习帮</Text>
</View> </View>
<View className={styles.members_content}> <View className={styles.members_content}>
<View className={styles.members_today} onClick={() => data && run()}> {/* {data?.map(renderItem)} */}
<View className={styles.members_score}> {[{ type: 'MEMBERNUM', point: 1 }, { type: 'MEMBERJOIN', point: 0 }].map(renderItem)}
<Image
src={require('@/pages/main/assets/score.png')}
className={classNames(styles.members_icon, data ? styles.upDownAnimation : '')}
/>
<Text className={classNames(styles.members_number, data ? styles.upDownAnimation : '')}>
+{data || 0}
</Text>
</View>
<Text className={styles.members_stroke}>今日部落津贴</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>
</View>
</View> </View>
</View> </View>
) )
......
...@@ -114,8 +114,8 @@ ...@@ -114,8 +114,8 @@
} }
&_icon { &_icon {
width: 64px; width: 32PX;
height: 64px; height: 32PX;
} }
&_text { &_text {
......
...@@ -3,12 +3,14 @@ import classNames from 'classnames' ...@@ -3,12 +3,14 @@ import classNames from 'classnames'
import styles from './share-view.module.scss' import styles from './share-view.module.scss'
export default ({ export default ({ children, className }: { children: React.ReactNode, className?: string }) => {
children,
className
}: { children: React.ReactNode, className?: string }) => {
return ( 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} {children}
</Button> </Button>
) )
......
import { View, Text, Button } from '@tarojs/components' import { View, Text, Button } from '@tarojs/components'
import Modal from '@/components/Modal' import Modal from '@/components/Modal'
import { useBoolean } from '@/hooks/use-boolean' import { useBoolean } from '@/hooks/use-boolean'
import { MarketModalProps } from '../types' // import { MarketModalProps } from '../types'
import CardMain from './card-main' import CardMain from './card-main'
const AnswerSheet = ({ onConfirm, loading }: MarketModalProps) => { const AnswerSheet = ({ onConfirm, loading }) => {
const [isVisible, { setTrue, setFalse }] = useBoolean(false) const [isVisible, { setTrue, setFalse }] = useBoolean(false)
return ( return (
......
...@@ -3,7 +3,7 @@ import { View, Text, Button } from '@tarojs/components' ...@@ -3,7 +3,7 @@ import { View, Text, Button } from '@tarojs/components'
import { getMenuButtonBoundingClientRect, showToast, showModal } from '@tarojs/taro' import { getMenuButtonBoundingClientRect, showToast, showModal } from '@tarojs/taro'
import { useBoolean, useToggle, useRequest } from '@/hooks' import { useBoolean, useToggle, useRequest } from '@/hooks'
import { getPointToCard } from '@/api/account' import { pointToCard } from '@/api/account'
import Modal from '@/components/Modal' import Modal from '@/components/Modal'
import MainHeader from '../main/components/header' import MainHeader from '../main/components/header'
...@@ -33,7 +33,7 @@ const StudyMarket = () => { ...@@ -33,7 +33,7 @@ const StudyMarket = () => {
const [isVisible, { setTrue, setFalse }] = useBoolean(false) const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const [state, { setDefault, setReverse }] = useToggle({ defaultValue: Demo.AnswerSheet, reverseValue: Demo.Mystery }) const [state, { setDefault, setReverse }] = useToggle({ defaultValue: Demo.AnswerSheet, reverseValue: Demo.Mystery })
const { loading } = useRequest(getPointToCard, { const { loading } = useRequest(pointToCard, {
immediate: false, immediate: false,
onSuccess () { onSuccess () {
showToast({ title: '成功' }) showToast({ title: '成功' })
......
...@@ -60,14 +60,6 @@ ...@@ -60,14 +60,6 @@
@include flexLayout(column); @include flexLayout(column);
gap: 12PX; 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 { .studyTribe {
@include flexLayout(row, center, center); @include flexLayout(row, center, center);
height: 56PX; height: 56PX;
......
...@@ -22,7 +22,7 @@ const AnswerSheetModal = (props: PropsWithChildren<ModalProps>) => { ...@@ -22,7 +22,7 @@ const AnswerSheetModal = (props: PropsWithChildren<ModalProps>) => {
<View className={styles.title}>你的答题卡已经用完啦</View> <View className={styles.title}>你的答题卡已经用完啦</View>
<View className={styles.tips}>可通过以下途径获得哦</View> <View className={styles.tips}>可通过以下途径获得哦</View>
<View className={styles.footer}> <View className={styles.footer}>
<View className={styles.buy}>{children}</View> {children}
<View className={styles.studyTribe} onClick={() => switchTab({ url: '/pages/group/index' })}> <View className={styles.studyTribe} onClick={() => switchTab({ url: '/pages/group/index' })}>
<Text>建设学习部落,得更多答题卡</Text> <Text>建设学习部落,得更多答题卡</Text>
</View> </View>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
.title { .title {
font-weight: bold; font-weight: bold;
margin: 20px 0; margin: 40px 0 20px;
font-size: 26PX; font-size: 26PX;
font-weight: 600; font-weight: 600;
color: #FFFFFF; color: #FFFFFF;
...@@ -40,30 +40,35 @@ ...@@ -40,30 +40,35 @@
.requirement { .requirement {
@include flexLayout(column); @include flexLayout(column);
& > .text { & > .header {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 12PX;
text-align: center; text-align: center;
font-size: 16PX; font-size: 16PX;
font-weight: 500; font-weight: 500;
color: #FFFFFF; color: #FFFFFF;
position: relative; position: relative;
margin-bottom: 12PX;
&::before, &::after { .line {
content: ""; flex-grow: 1;
position: absolute;
width: 36%;
height: 1px; height: 1px;
top: 20px;
transform: scaleY(0.5);
background-color: #fff; background-color: #fff;
transform: scaleY(0.5);
&:first-child {
margin-right: 10PX;
}
&:last-child {
margin-left: 10PX;
}
} }
&::before { .text {
left: 0; text-align: center;
} font-weight: 500;
color: #FFFFFF;
&::after {
right: 0;
} }
} }
...@@ -118,4 +123,62 @@ ...@@ -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 { 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' import styles from './main-header.module.scss'
const scoreList = [ const MainHeader = () => {
{ u: assets['level-big-s.png'].u }, const stageDetail = useStoreState(state => state.gameModel.stageDetail) || {} as StageDetail
{ u: assets['level-big-a.png'].u },
{ u: assets['level-big-b.png'].u }, const isKing = useMemo(() => { // 是王者了
] return stageDetail.level === 'S' && stageDetail.upGear && stageDetail.gear === 10
}, [stageDetail.level, stageDetail.upGear, stageDetail.gear])
const renderItem = ({ u }) => (
<View key={u} className={styles.detail}> const type = useMemo(() => {
<View className={styles.content}> switch (stageDetail.type) {
<Image className={styles.badge} src={u} mode="widthFix" /> case StageType.OneStop:
<View className={styles.center}> return {
<Image className={styles.icon} src={assets['hook.png'].u} mode="widthFix" /> t: StageType.OneStop,
<Text>全对,</Text> 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 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" />
<View className={styles.center}>
<Image className={styles.icon} src={assets['hook.png'].u} mode="widthFix" />
<Text>全对,</Text>
</View>
<View className={styles.center}>
<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>
<View className={styles.center}> <View className={styles.score}>
<Image className={styles.icon} src={assets['clock.png'].u} mode="widthFix" /> <Image className={styles.icon} src={assets['diamond.png'].u} mode="widthFix" />
<Text>用时 ≤49s</Text> <Text className={styles.text}>+{v}</Text>
</View> </View>
</View> </View>
<View className={styles.score}> )
<Image className={styles.icon} src={assets['diamond.png'].u} mode="widthFix" />
<Text className={styles.text}>+100</Text> 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> </View>
</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 ( return (
<View className={styles.wrapper}> <View className={styles.wrapper}>
<View className={styles.title}>表内除法</View> <View className={styles.title}>{stageDetail.name || '-'}</View>
<View className={styles.labels}> <View className={styles.labels}>
<View className={styles.label}> <View className={styles.label}>
<Image className={styles.icon} src={assets['strong.png'].u} mode="widthFix" /> <Image className={styles.icon} src={type.u} mode="widthFix" />
<Text>强化</Text> <Text>{type.t}</Text>
</View> </View>
<Text className={styles.label}>计算达标1</Text> <Text className={styles.label}>{stageDetail.content || '-'}</Text>
<Text className={styles.label}>共 10 题</Text> <Text className={styles.label}>共 10 题</Text>
</View> </View>
<View className={styles.replay}>
<View className={styles.performance}>
<Text>最佳表现</Text>
<View className={styles.details}>
<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.requirement}>
<Text className={styles.text}>通关要求</Text> <View className={styles.header}>
<View className={styles.details}> <View className={styles.line}></View>
{scoreList.map(renderItem)} <Text className={styles.text}>
{stageDetail.firstTime ? '通关要求' : '继续努力,赢更多成就'}
</Text>
<View className={styles.line}></View>
</View> </View>
{stageDetail.firstTime ? renderFirst() : isKing ? null : renderAgain()}
</View> </View>
</View> </View>
) )
......
...@@ -9,9 +9,8 @@ ...@@ -9,9 +9,8 @@
.tabBar { .tabBar {
display: flex; display: flex;
border-bottom: 1px solid #ccc; height: 88PX;
height: 176px; background-size: 100% 100%;
background-size: cover;
&.active_1 { &.active_1 {
background-image: url('../assets/tab-1.png'); background-image: url('../assets/tab-1.png');
...@@ -24,7 +23,7 @@ ...@@ -24,7 +23,7 @@
.tab { .tab {
flex: 1; flex: 1;
height: 96px; height: 48PX;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
...@@ -41,10 +40,10 @@ ...@@ -41,10 +40,10 @@
position: absolute; position: absolute;
content: ""; content: "";
width: 16PX; width: 16PX;
bottom: 0; bottom: 6PX;
height: 3PX; height: 3PX;
background: #1786F7; background: #1786F7;
border-radius: 8PX; border-radius: 6PX;
} }
} }
} }
......
.header { .topBar {
position: fixed; position: fixed;
color: #fff; color: #fff;
left: 0; left: 0;
top: 0; top: 0;
right: 0; right: 0;
z-index: 999; z-index: 999;
} background-image: url(../assets/head-bg.png);
.head_bg { &_bg {
position: absolute; position: absolute;
left: 0; z-index: 1;
right: 0; left: 0;
width: 100%; right: 0;
} width: 100%;
}
.content {
position: relative;
z-index: 2;
.inner { .inner {
display: flex; display: flex;
align-items: center; align-items: center;
......
...@@ -8,27 +8,18 @@ export default () => { ...@@ -8,27 +8,18 @@ export default () => {
const nav = getMenuButtonBoundingClientRect() const nav = getMenuButtonBoundingClientRect()
const sys = getSystemInfoSync() const sys = getSystemInfoSync()
const innerStyle = useMemo(() => { const topBarStyle = useMemo(() => {
return { return {
height: `${nav.height + 10}px`, height: `${nav.height + 10}px`,
paddingRight: `${nav.width + (sys.windowWidth - nav.right) * 2}px` paddingTop: `${nav.top - 5}px`
} }
}, [sys, nav]) }, [sys, nav])
return ( return (
<View className={styles.header}> <View className={styles.topBar} style={topBarStyle}>
<Image src={require('../assets/head-bg.png')} mode="widthFix" className={styles.head_bg} /> <View className={styles.inner}>
<View
className={styles.content}
style={{
height: `${nav.height + 10}px`,
paddingTop: `${nav.top - 5}px`
}}
>
<View className={styles.inner} style={innerStyle}>
<Image className={styles.back_icon} src={require('../assets/back.png')} mode="widthFix" onClick={() => navigateBack()} /> <Image className={styles.back_icon} src={require('../assets/back.png')} mode="widthFix" onClick={() => navigateBack()} />
</View> </View>
</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',
},
}
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
.wrapper { .wrapper {
padding-bottom: 80PX; padding-bottom: 80PX;
.inner {
position: relative;
z-index: 10;
background-image: url(./assets/head-bg.png);
background-size: 100%;
background-attachment: fixed;
}
.tribe { .tribe {
&_title { &_title {
...@@ -12,20 +20,48 @@ ...@@ -12,20 +20,48 @@
font-weight: 600; font-weight: 600;
color: #465164; 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 { .empty {
color: #9999; color: #9999;
font-size: 12PX; font-size: 14PX;
margin-top: 12PX; margin-top: 12PX;
text-align: center; text-align: center;
} }
.item { .item {
display: flex; display: flex;
padding: 28px 32px 26px; padding: 30px 32px;
align-items: center; align-items: center;
&.active {
background-color: #E4F1FF;
}
&_rank { &_rank {
margin-right: 40px; margin-right: 40px;
@include flexLayout(row, center); @include flexLayout(row, center);
...@@ -61,6 +97,8 @@ ...@@ -61,6 +97,8 @@
&_crown { &_crown {
width: 36px; width: 36px;
height: 36px; height: 36px;
position: relative;
top: -1PX;
} }
} }
&_result { &_result {
...@@ -77,71 +115,111 @@ ...@@ -77,71 +115,111 @@
} }
} }
.challenge { .footer_bar {
position: fixed; position: fixed;
bottom: 60px; bottom: 0;
left: 16PX; left: 0;
right: 16PX; right: 0;
height: 100px;
z-index: 999; z-index: 999;
&_text { background-color: #fff;
font-size: 40px; padding: 16PX 0 24PX;
letter-spacing: 1PX;
font-weight: 600; .tribe_share {
border-radius: 10PX;
margin: 0 40PX;
margin-bottom: 56px;
height: 44PX;
border: 2PX solid #465164;
gap: 8PX;
@include flexLayout(row, center, center);
} }
.card {
@include flexLayout(row, center);
position: absolute;
right: 100px;
gap: 4PX;
&_icon { .challenge {
width: 32PX; margin: 0 16PX;
height: 32PX position: relative;
}
&_text { &_text {
font-size: 18PX; font-size: 40px;
font-weight: 500; letter-spacing: 1PX;
color: #FFFFFF; font-weight: 600;
} }
} .card {
.tip { @include flexLayout(row, center);
position: absolute; position: absolute;
top: -32PX; right: 100px;
right: -9PX; gap: 4PX;
padding: 8PX 13PX 12PX;
background-image: url('https://cdn.jkwljy.com/pk-math/4WgogFzhSYUSrvpmEE7JwoVg7SH5/122x42'); &_icon {
background-size: 100% 100%; width: 32PX;
height: 32PX
&_text { }
font-size: 16PX; &_text {
font-weight: 500; font-size: 18PX;
color: #FFFFFF; font-weight: 500;
color: #FFFFFF;
}
}
.tip {
position: absolute;
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;
font-weight: 500;
color: #FFFFFF;
}
} }
} }
} }
} }
.modal { .buy_card {
height: 56PX;
@include flexLayout(row, center, center); @include flexLayout(row, center, center);
font-size: 18PX; background-size: 100% 100%;
background-image: url('./assets/btn-primary.png');
font-weight: 500; font-weight: 500;
color: #FFFFFF; color: #FFFFFF;
& > { &_loading {
.logo { opacity: 0.8;
width: 32PX; }
height: 32PX;
margin-right: 4PX; &_spin {
} margin-right: 8PX;
}
.buy {
margin: 0 12PX; .inner {
} @include flexLayout(row, center, center);
font-size: 18PX;
font-weight: 500;
.balance { & > {
font-weight: 400; .logo {
font-size: 14PX; width: 32PX;
height: 32PX;
margin-right: 4PX;
}
.buy {
margin: 0 12PX;
}
.balance {
font-weight: 400;
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 { View, Text, Image } from '@tarojs/components'
import { useEffect } from 'react' import { useEffect, useMemo, useState } from 'react'
import { useRouter, getMenuButtonBoundingClientRect } from '@tarojs/taro' 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 assets from '@/assets/oss/assets-prepare'
import Button from '@/components/Button' 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 Tabs, { type TabItem } from './components/tabs'
import TopBar from './components/top-bar' import TopBar from './components/top-bar'
import MainHeader from './components/main-header' import MainHeader from './components/main-header'
import Thead from './components/thead'
import AnswerCardModal from './components/answer-card-modal' import AnswerCardModal from './components/answer-card-modal'
import { renderList, renderTribePage } from './render'
import styles from './index.module.scss' import styles from './index.module.scss'
const renderItem = (item: StageRank, index: number) => { const tabs: TabItem[] = [
return ( {
<View key={item.userId} className={styles.item}> label: '成都排行榜',
<View className={styles.item_rank}> children: renderList()
{[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> label: '学习部落排行榜',
} children: (
</View> <View className={styles.tribe}>
<View className={styles.item_username}> {renderTribePage()}
<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> </View>
</View> )
) }
} ]
const Prepare = () => { const Prepare = () => {
const nav = getMenuButtonBoundingClientRect() const nav = getMenuButtonBoundingClientRect()
const router = useRouter<{ id: string }>()
const [currentTab, setCurrentTab] = useState(0)
const [isVisible, { setTrue, setFalse }] = useBoolean(false) const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const stageDetail = useStoreState(state => state.gameModel.stageDetail) const stageDetail = useStoreState(state => state.gameModel.stageDetail)
const getStageDetail = useStoreActions(actions => actions.gameModel.getStageDetail) 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(() => { useEffect(() => {
getStageDetail(+router.params.id || 1) getStageDetail(+router.params.id || 1)
}, [router, getStageDetail]) }, [router, getStageDetail])
const renderList = (list = []) => { useShareAppMessage(() => {
const isEmpty = list.length < 1 return {
return ( title: '来看看这个有趣的页面!',
<> path: 'pages/main/main?code=1111',
<Thead /> imageUrl: 'https://picx.zhimg.com/v2-7b7b072d4bebd5ccf48c04ec1146e844_1440w.jpg?',
{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>
)
} }
] })
return ( return (
<> <View className={styles.wrapper}>
<View className={styles.wrapper}> <TopBar />
<TopBar /> <View className={styles.inner} style={innerStyle}>
<MainHeader />
<View style={{ position: 'relative', paddingTop: `${nav.height + nav.top + 5}px` }}> <Tabs initialIndex={currentTab} items={tabs} onChange={setCurrentTab} />
<MainHeader /> </View>
<Tabs items={tabs} />
</View>
<View className={styles.challenge}> <View className={styles.footer_bar}>
<Button type="custom" size="large" onClick={setTrue}> {currentTab === 1 && <ShareView>
<Text className={styles.challenge_text}>开始闯关</Text> <View className={styles.tribe_share}>
<View className={styles.card}> <Image style={{ width: 32, height: 32 }} src={require('@/pages/group/assets/icons/invite-small.png')} />
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} /> <Text style={{ color: '#FF7A18', fontSize: 16 }}>邀请更多好友加入学习部落</Text>
<Text className={styles.card_text}>-1</Text> </View>
</View> </ShareView>}
{false && <View className={styles.tip}>
<Text className={styles.tip_text}>首次免答题卡</Text>
</View>}
</Button>
</View>
<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>
{true && <View className={styles.tip}>
<Text className={styles.tip_text}>首次免答题卡</Text>
</View>}
</Button>
</View> </View>
<AnswerCardModal isVisible={isVisible} onClose={setFalse}> <AnswerCardModal isVisible={isVisible} onClose={setFalse}>
<View className={styles.modal}> <View
<Image className={styles.logo} src={assets['diamond.png'].u} mode="widthFix" /> className={classNames(styles.buy_card, {
<Text>-30</Text> // [styles.buy_card_disabled]: true,
<Text className={styles.buy}>购买</Text> [styles.buy_card_loading]: loading,
<Text className={styles.balance}>(当前剩余 120)</Text> })}
// 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> </View>
</AnswerCardModal> </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