dutycard add data

yhy
FrozenArcher 2024-03-06 15:13:35 +08:00
parent 20b9016f51
commit ff880de466
1 changed files with 53 additions and 8 deletions

View File

@ -1,4 +1,4 @@
import { View, Text } from '@tarojs/components';
import { View } from '@tarojs/components';
import { Component, ReactNode } from 'react';
import Taro from '@tarojs/taro';
import { AtCard, AtTimeline, AtAccordion } from 'taro-ui';
@ -11,19 +11,37 @@ interface CardContent {
title: string;
note: string;
extra: JSX.Element | string;
content: JSX.Element;
content: () => JSX.Element;
}
function mainPageCard(c: CardContent): JSX.Element {
return (
<View style={{ marginTop: 10 }}>
<AtCard note={c.note} extra={c.extra} title={c.title}>
{c.content}
{c.content()}
</AtCard>
</View>
);
}
type DutyState = 'off' | '1' | '2' | '3';
class DutyData {
constructor() {
this.isInDuty = false;
this.inDutyCnt = 3;
this.currentDuty = '2';
this.offDutyReason = '学园维修';
this.dutyRecoverTime = '下周一';
}
isInDuty: boolean;
inDutyCnt: number;
currentDuty: DutyState;
offDutyReason: string;
dutyRecoverTime: string;
}
class ExpandItem extends Component {
state = {
open: false,
@ -53,13 +71,39 @@ class ExpandItem extends Component {
}
class DutyInfo extends Component {
render(): ReactNode {
props = {
data: new DutyData(),
};
offDutyContent(): ReactNode {
const data = this.props.data;
return (
<View>
<Text>x</Text>
<View></View>
<View>{data.offDutyReason}</View>
<View>{data.dutyRecoverTime}</View>
</View>
);
}
inDutyContent(): ReactNode {
const data = this.props.data;
return (
<View>
<View></View>
<View> {data.currentDuty}</View>
<View>{data.inDutyCnt}</View>
</View>
);
}
render(): ReactNode {
if (this.props.data.isInDuty) {
return this.inDutyContent();
} else {
return this.offDutyContent();
}
}
}
class StepInfo extends Component {
@ -84,23 +128,24 @@ class TipsInfo extends Component {
export default class Index extends Component {
state = {
dutyData: new DutyData(),
dutyInfoCard: {
title: pt.get().mainPage.cardTitle.dutyInfo,
note: 'Tips',
extra: '额外信息',
content: <DutyInfo />,
content: () => <DutyInfo data={this.state.dutyData} />,
},
stepInfoCard: {
title: pt.get().mainPage.cardTitle.stepInfo,
note: 'Tips 请在20:30以前取走自己的物品哦',
extra: '额外信息',
content: <StepInfo />,
content: () => <StepInfo />,
},
tipsInfoCard: {
title: pt.get().mainPage.cardTitle.tipsInfo,
note: 'Tips',
extra: '额外信息',
content: <TipsInfo />,
content: () => <TipsInfo />,
},
};