refactor main page
parent
7cd56d7c79
commit
d9d005986e
|
|
@ -0,0 +1,57 @@
|
||||||
|
import { Component, ReactNode } from 'react';
|
||||||
|
import { View } from '@tarojs/components';
|
||||||
|
import pt from '@/plain-text';
|
||||||
|
|
||||||
|
export class DutyData {
|
||||||
|
constructor() {
|
||||||
|
this.isInDuty = false;
|
||||||
|
this.inDutyCnt = 3;
|
||||||
|
this.currentDuty = '2';
|
||||||
|
this.offDutyReason = '学园维修';
|
||||||
|
this.dutyRecoverTime = '下周一';
|
||||||
|
}
|
||||||
|
|
||||||
|
isInDuty: boolean;
|
||||||
|
inDutyCnt: number;
|
||||||
|
currentDuty: 'off' | '1' | '2' | '3';
|
||||||
|
offDutyReason: string; // from backend
|
||||||
|
dutyRecoverTime: string; // from backend
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DutyInfo extends Component {
|
||||||
|
props = {
|
||||||
|
data: new DutyData(),
|
||||||
|
};
|
||||||
|
|
||||||
|
offDutyContent(): ReactNode {
|
||||||
|
const data = this.props.data;
|
||||||
|
const od = pt.get().mainPage.dutyCard.offDuty;
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<View>{od.title}</View>
|
||||||
|
<View>{od.reason(data.offDutyReason)}</View>
|
||||||
|
<View>{od.recoverTime(data.dutyRecoverTime)}</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
inDutyContent(): ReactNode {
|
||||||
|
const data = this.props.data;
|
||||||
|
const id = pt.get().mainPage.dutyCard.inDuty;
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<View>{id.title}</View>
|
||||||
|
<View>{id.currentDutyText(data.currentDuty)}</View>
|
||||||
|
<View>{id.inDutyCnt(data.inDutyCnt)}</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
render(): ReactNode {
|
||||||
|
if (this.props.data.isInDuty) {
|
||||||
|
return this.inDutyContent();
|
||||||
|
} else {
|
||||||
|
return this.offDutyContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { Component, ReactNode } from 'react';
|
||||||
|
import { View } from '@tarojs/components';
|
||||||
|
import { AtTimeline } from 'taro-ui';
|
||||||
|
import pt from '@/plain-text';
|
||||||
|
|
||||||
|
export class StepInfo extends Component {
|
||||||
|
render(): ReactNode {
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<AtTimeline items={pt.get().mainPage.stepList}></AtTimeline>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TipsInfo extends Component {
|
||||||
|
render(): ReactNode {
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<AtTimeline items={pt.get().mainPage.tipsList}></AtTimeline>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { View } from '@tarojs/components';
|
||||||
|
import pt from '@/plain-text';
|
||||||
|
|
||||||
|
export default class TitleCard extends React.Component {
|
||||||
|
render(): React.ReactNode {
|
||||||
|
const mainPage = pt.get().mainPage;
|
||||||
|
return (
|
||||||
|
<View className='page-title'>
|
||||||
|
<View className='at-article__h1'>{mainPage.mainTitleLine}</View>
|
||||||
|
<View className='at-article__h2'>{mainPage.subTitleLine}</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
import { View } from '@tarojs/components';
|
import { View } from '@tarojs/components';
|
||||||
import { Component, ReactNode } from 'react';
|
import { Component, ReactNode } from 'react';
|
||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
import { AtCard, AtTimeline, AtAccordion } from 'taro-ui';
|
import { AtCard, AtAccordion } from 'taro-ui';
|
||||||
import type CustomTabBar from '@/custom-tab-bar';
|
import type CustomTabBar from '@/custom-tab-bar';
|
||||||
import PageFooter from '@/components/PageFooter/PageFooter';
|
import PageFooter from '@/components/PageFooter/PageFooter';
|
||||||
import pt from '@/plain-text';
|
import pt from '@/plain-text';
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
|
import TitleCard from './TitleCard';
|
||||||
|
import { DutyInfo, DutyData } from './DutyInfo';
|
||||||
|
import { StepInfo, TipsInfo } from './StepTipsInfo';
|
||||||
|
|
||||||
interface CardContent {
|
class CardContent {
|
||||||
title: string;
|
title: string;
|
||||||
note: string;
|
note: string;
|
||||||
extra: JSX.Element | string;
|
extra: JSX.Element | string;
|
||||||
|
|
@ -24,22 +27,6 @@ function mainPageCard(c: CardContent): JSX.Element {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DutyData {
|
|
||||||
constructor() {
|
|
||||||
this.isInDuty = false;
|
|
||||||
this.inDutyCnt = 3;
|
|
||||||
this.currentDuty = '2';
|
|
||||||
this.offDutyReason = '学园维修';
|
|
||||||
this.dutyRecoverTime = '下周一';
|
|
||||||
}
|
|
||||||
|
|
||||||
isInDuty: boolean;
|
|
||||||
inDutyCnt: number;
|
|
||||||
currentDuty: 'off' | '1' | '2' | '3';
|
|
||||||
offDutyReason: string; // from backend
|
|
||||||
dutyRecoverTime: string; // from backend
|
|
||||||
}
|
|
||||||
|
|
||||||
class ExpandItem extends Component {
|
class ExpandItem extends Component {
|
||||||
state = {
|
state = {
|
||||||
open: false,
|
open: false,
|
||||||
|
|
@ -68,64 +55,6 @@ class ExpandItem extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DutyInfo extends Component {
|
|
||||||
props = {
|
|
||||||
data: new DutyData(),
|
|
||||||
};
|
|
||||||
|
|
||||||
offDutyContent(): ReactNode {
|
|
||||||
const data = this.props.data;
|
|
||||||
const od = pt.get().mainPage.dutyCard.offDuty;
|
|
||||||
return (
|
|
||||||
<View>
|
|
||||||
<View>{od.title}</View>
|
|
||||||
<View>{od.reason(data.offDutyReason)}</View>
|
|
||||||
<View>{od.recoverTime(data.dutyRecoverTime)}</View>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
inDutyContent(): ReactNode {
|
|
||||||
const data = this.props.data;
|
|
||||||
const id = pt.get().mainPage.dutyCard.inDuty;
|
|
||||||
return (
|
|
||||||
<View>
|
|
||||||
<View>{id.title}</View>
|
|
||||||
<View>{id.currentDutyText(data.currentDuty)}</View>
|
|
||||||
<View>{id.inDutyCnt(data.inDutyCnt)}</View>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
render(): ReactNode {
|
|
||||||
if (this.props.data.isInDuty) {
|
|
||||||
return this.inDutyContent();
|
|
||||||
} else {
|
|
||||||
return this.offDutyContent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class StepInfo extends Component {
|
|
||||||
render(): ReactNode {
|
|
||||||
return (
|
|
||||||
<View>
|
|
||||||
<AtTimeline items={pt.get().mainPage.stepList}></AtTimeline>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TipsInfo extends Component {
|
|
||||||
render(): ReactNode {
|
|
||||||
return (
|
|
||||||
<View>
|
|
||||||
<AtTimeline items={pt.get().mainPage.tipsList}></AtTimeline>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class Index extends Component {
|
export default class Index extends Component {
|
||||||
state = {
|
state = {
|
||||||
dutyData: new DutyData(),
|
dutyData: new DutyData(),
|
||||||
|
|
@ -161,10 +90,7 @@ export default class Index extends Component {
|
||||||
const mainPage = pt.get().mainPage;
|
const mainPage = pt.get().mainPage;
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<View className='page-title'>
|
<TitleCard />
|
||||||
<View className='at-article__h1'>{mainPage.mainTitleLine}</View>
|
|
||||||
<View className='at-article__h1'>{mainPage.subTitleLine}</View>
|
|
||||||
</View>
|
|
||||||
<View style={{ marginTop: 30 }}>
|
<View style={{ marginTop: 30 }}>
|
||||||
{mainPageCard(this.state.dutyInfoCard)}
|
{mainPageCard(this.state.dutyInfoCard)}
|
||||||
{mainPageCard(this.state.tipsInfoCard)}
|
{mainPageCard(this.state.tipsInfoCard)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue