refactor: merge index & member page
parent
a7c96b2e8c
commit
f3f5be793b
|
|
@ -103,6 +103,7 @@ export default {
|
|||
isInDuty: true,
|
||||
inDutyCnt: 6,
|
||||
currentDuty: '3',
|
||||
place: '204',
|
||||
},
|
||||
},
|
||||
'POST /login': {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ export default defineAppConfig({
|
|||
pages: [
|
||||
'pages/index/index',
|
||||
'pages/repair/repair',
|
||||
'pages/member/member',
|
||||
'pages/user/user',
|
||||
'pages/user/myTicket/myTicket',
|
||||
'pages/user/inform/inform',
|
||||
|
|
@ -28,10 +27,6 @@ export default defineAppConfig({
|
|||
pagePath: 'pages/repair/repair',
|
||||
text: '维修',
|
||||
},
|
||||
{
|
||||
pagePath: 'pages/member/member',
|
||||
text: '管理',
|
||||
},
|
||||
{
|
||||
pagePath: 'pages/user/user',
|
||||
text: '我的',
|
||||
|
|
|
|||
|
|
@ -7,35 +7,20 @@ import 'taro-ui/dist/style/index.scss';
|
|||
import './index.scss';
|
||||
|
||||
const navList: () => Array<Taro.TabBarItem> = () => {
|
||||
return wechatUser.getAccess()
|
||||
? [
|
||||
{
|
||||
pagePath: '/pages/member/member',
|
||||
text: pt.get().tabBar.memberText,
|
||||
},
|
||||
{
|
||||
pagePath: '/pages/repair/repair',
|
||||
text: pt.get().tabBar.repairText,
|
||||
},
|
||||
{
|
||||
pagePath: '/pages/user/user',
|
||||
text: pt.get().tabBar.userText,
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
pagePath: '/pages/index/index',
|
||||
text: pt.get().tabBar.indexText,
|
||||
},
|
||||
{
|
||||
pagePath: '/pages/repair/repair',
|
||||
text: pt.get().tabBar.repairText,
|
||||
},
|
||||
{
|
||||
pagePath: '/pages/user/user',
|
||||
text: pt.get().tabBar.userText,
|
||||
},
|
||||
];
|
||||
return [
|
||||
{
|
||||
pagePath: '/pages/index/index',
|
||||
text: pt.get().tabBar.indexText,
|
||||
},
|
||||
{
|
||||
pagePath: '/pages/repair/repair',
|
||||
text: pt.get().tabBar.repairText,
|
||||
},
|
||||
{
|
||||
pagePath: '/pages/user/user',
|
||||
text: pt.get().tabBar.userText,
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
const tabList = () => {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import { AtTimeline } from 'taro-ui';
|
|||
import pt from '@/plain-text';
|
||||
import tick from '@/assets/icons/MainPage/tick.svg';
|
||||
import cross from '@/assets/icons/MainPage/cross.svg';
|
||||
import clock from '@/assets/icons/MemberPage/clock.svg';
|
||||
import wechatUser from '@/wechat';
|
||||
|
||||
export class DutyData {
|
||||
constructor() {
|
||||
|
|
@ -17,7 +19,7 @@ export class DutyData {
|
|||
|
||||
isInDuty: boolean;
|
||||
inDutyCnt?: number;
|
||||
currentDuty?: 'off' | '1' | '2' | '3';
|
||||
currentDuty?: 'off' | '1' | '2' | '3' | 'others';
|
||||
offDutyReason?: string;
|
||||
dutyRecoverTime?: string;
|
||||
place: string;
|
||||
|
|
@ -33,7 +35,7 @@ class Card extends Component {
|
|||
const place = this.props.place;
|
||||
const dc = pt.get().mainPage.dutyCard;
|
||||
const title = inDuty ? dc.inDuty.title : dc.offDuty.title;
|
||||
const iconsrc = inDuty ? tick : cross;
|
||||
const iconsrc = inDuty ? tick : wechatUser.getAccess() ? clock : cross;
|
||||
return (
|
||||
<View>
|
||||
<View
|
||||
|
|
@ -66,6 +68,11 @@ class Card extends Component {
|
|||
}
|
||||
|
||||
export class DutyInfo extends Component {
|
||||
state: {
|
||||
isLoading: false;
|
||||
isDisable: false;
|
||||
};
|
||||
|
||||
props = {
|
||||
data: new DutyData(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,12 +2,19 @@ import { Component, ReactNode } from 'react';
|
|||
import { View } from '@tarojs/components';
|
||||
import { AtTimeline } from 'taro-ui';
|
||||
import pt from '@/plain-text';
|
||||
import wechatUser from '@/wechat';
|
||||
|
||||
export class StepInfo extends Component {
|
||||
render(): ReactNode {
|
||||
return (
|
||||
<View>
|
||||
<AtTimeline items={pt.get().mainPage.stepList}></AtTimeline>
|
||||
<AtTimeline
|
||||
items={
|
||||
wechatUser.getAccess()
|
||||
? pt.get().memberPage.stepList
|
||||
: pt.get().mainPage.stepList
|
||||
}
|
||||
></AtTimeline>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
|
@ -17,7 +24,13 @@ export class TipsInfo extends Component {
|
|||
render(): ReactNode {
|
||||
return (
|
||||
<View>
|
||||
<AtTimeline items={pt.get().mainPage.tipsList}></AtTimeline>
|
||||
<AtTimeline
|
||||
items={
|
||||
wechatUser.getAccess()
|
||||
? pt.get().memberPage.tipsList
|
||||
: pt.get().mainPage.tipsList
|
||||
}
|
||||
></AtTimeline>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,24 +2,32 @@ import React from 'react';
|
|||
import { View, Image } from '@tarojs/components';
|
||||
import pt from '@/plain-text';
|
||||
import logo from '@/assets/images/UserPage/logo.png';
|
||||
import wechatUser from '@/wechat';
|
||||
|
||||
export default class TitleCard extends React.Component {
|
||||
render(): React.ReactNode {
|
||||
const mainPage = pt.get().mainPage;
|
||||
const memberPage = pt.get().memberPage;
|
||||
return (
|
||||
<View className='at-row at-row__align--center'>
|
||||
<View className='at-col at-col-1 at-col--auto'>
|
||||
<Image
|
||||
style='width: 100rpx; height: 100rpx; margin-left: 30rpx;'
|
||||
src={logo}
|
||||
src={wechatUser.getAccess() ? wechatUser.getInfo().avatar : logo}
|
||||
mode='aspectFit'
|
||||
/>
|
||||
</View>
|
||||
<View className='page-title'>
|
||||
<View className='at-article__h1' style={{ fontWeight: 'bold' }}>
|
||||
{mainPage.mainTitleLine}
|
||||
{wechatUser.getAccess()
|
||||
? memberPage.mainTitleLine + wechatUser.getInfo().name
|
||||
: mainPage.mainTitleLine}
|
||||
</View>
|
||||
<View className='at-article__h2'>
|
||||
{wechatUser.getAccess()
|
||||
? memberPage.subTitleLine
|
||||
: mainPage.subTitleLine}
|
||||
</View>
|
||||
<View className='at-article__h2'>{mainPage.subTitleLine}</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,25 @@
|
|||
import { View } from '@tarojs/components';
|
||||
import { Component, ReactNode } from 'react';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { AtCard, AtAccordion } from 'taro-ui';
|
||||
import { AtCard, AtAccordion, AtInputNumber, AtButton, AtList } from 'taro-ui';
|
||||
import type CustomTabBar from '@/custom-tab-bar';
|
||||
import PageFooter from '@/components/PageFooter/PageFooter';
|
||||
import pt from '@/plain-text';
|
||||
import { getDutyInfo } from '@/service/dutyInfo';
|
||||
import { RequestState } from '@/service';
|
||||
import moment from 'moment';
|
||||
import wechatUser from '@/wechat';
|
||||
import { getMemberDutyInfo } from '@/service/memberDutyInfo';
|
||||
import { getUncompletedTicketList } from '@/service/uncompletedTicket';
|
||||
import { changeDutyCnt } from '@/service/changeDutyCount';
|
||||
import { TicketListItem } from '@/components/TicketListItem/TicketListItem';
|
||||
import './index.scss';
|
||||
import TitleCard from './TitleCard';
|
||||
import { DutyInfo, DutyData } from './DutyInfo';
|
||||
import { StepInfo, TipsInfo } from './StepTipsInfo';
|
||||
|
||||
const submitInterval = 5000;
|
||||
|
||||
class CardContent {
|
||||
title: string;
|
||||
note: string;
|
||||
|
|
@ -57,39 +66,77 @@ class ExpandItem extends Component {
|
|||
}
|
||||
|
||||
interface MainPageState {
|
||||
fixList: Array<TicketListItem>;
|
||||
rs: RequestState;
|
||||
dutyData: DutyData;
|
||||
inDutyCnt: number;
|
||||
dutyInfoCard: CardContent;
|
||||
stepInfoCard: CardContent;
|
||||
tipsInfoCard: CardContent;
|
||||
//rs: RequestState;
|
||||
isLoading: boolean;
|
||||
isDisable: boolean;
|
||||
}
|
||||
|
||||
export default class MainPage extends Component<{}, MainPageState> {
|
||||
state = {
|
||||
dutyData: new DutyData(),
|
||||
inDutyCnt: 0,
|
||||
dutyInfoCard: {
|
||||
title: pt.get().mainPage.cardTitle.dutyInfo,
|
||||
note: pt.get().mainPage.cardTips.dutyInfo,
|
||||
extra: pt.get().mainPage.extraInfo.dutyInfo,
|
||||
content: () => <DutyInfo data={this.state.dutyData} />,
|
||||
title: '',
|
||||
note: '',
|
||||
extra: '',
|
||||
content: () => <></>,
|
||||
},
|
||||
stepInfoCard: {
|
||||
title: pt.get().mainPage.cardTitle.stepInfo,
|
||||
note: pt.get().mainPage.cardTips.stepInfo,
|
||||
extra: pt.get().mainPage.extraInfo.dutyInfo,
|
||||
content: () => <StepInfo />,
|
||||
title: '',
|
||||
note: '',
|
||||
extra: '',
|
||||
content: () => <></>,
|
||||
},
|
||||
tipsInfoCard: {
|
||||
title: pt.get().mainPage.cardTitle.tipsInfo,
|
||||
note: pt.get().mainPage.cardTips.tipsInfo,
|
||||
extra: pt.get().mainPage.extraInfo.dutyInfo,
|
||||
content: () => <TipsInfo />,
|
||||
title: '',
|
||||
note: '',
|
||||
extra: '',
|
||||
content: () => <></>,
|
||||
},
|
||||
// rs: new RequestState(),
|
||||
fixList: [new TicketListItem(0, '', '', 1, moment())],
|
||||
rs: new RequestState(),
|
||||
isLoading: false,
|
||||
isDisable: false,
|
||||
};
|
||||
|
||||
componentDidMount(): void {
|
||||
getDutyInfo(this);
|
||||
const ptPage = wechatUser.getAccess() ? 'mainPage' : 'memberPage';
|
||||
|
||||
this.setState({
|
||||
dutyData: new DutyData(),
|
||||
inDutyCnt: 0,
|
||||
dutyInfoCard: {
|
||||
title: pt.get()[ptPage].cardTitle.dutyInfo,
|
||||
note: pt.get()[ptPage].cardTips.dutyInfo,
|
||||
extra: pt.get()[ptPage].extraInfo.dutyInfo,
|
||||
content: () => <DutyInfo data={this.state.dutyData} />,
|
||||
},
|
||||
stepInfoCard: {
|
||||
title: pt.get()[ptPage].cardTitle.stepInfo,
|
||||
note: pt.get()[ptPage].cardTips.stepInfo,
|
||||
extra: pt.get()[ptPage].extraInfo.dutyInfo,
|
||||
content: () => <StepInfo />,
|
||||
},
|
||||
tipsInfoCard: {
|
||||
title: pt.get()[ptPage].cardTitle.tipsInfo,
|
||||
note: pt.get()[ptPage].cardTips.tipsInfo,
|
||||
extra: pt.get()[ptPage].extraInfo.dutyInfo,
|
||||
content: () => <TipsInfo />,
|
||||
},
|
||||
});
|
||||
|
||||
if (wechatUser.getAccess()) {
|
||||
getMemberDutyInfo(this);
|
||||
getUncompletedTicketList(this);
|
||||
} else {
|
||||
getDutyInfo(this);
|
||||
}
|
||||
}
|
||||
|
||||
// 以下是TabBar相关
|
||||
|
|
@ -100,8 +147,35 @@ export default class MainPage extends Component<{}, MainPageState> {
|
|||
}
|
||||
// 以上是TabBar相关
|
||||
|
||||
handleCnt(inDutyCnt: number) {
|
||||
this.setState({
|
||||
inDutyCnt: inDutyCnt,
|
||||
});
|
||||
return inDutyCnt;
|
||||
}
|
||||
|
||||
onChangeCnt() {
|
||||
this.setState({
|
||||
isDisable: true,
|
||||
});
|
||||
changeDutyCnt(this);
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, submitInterval);
|
||||
}
|
||||
|
||||
render(): ReactNode {
|
||||
const mainPage = pt.get().mainPage;
|
||||
const memberPage = pt.get().memberPage;
|
||||
if (this.state.rs.loading) {
|
||||
return <View>loading</View>;
|
||||
}
|
||||
if (!this.state.rs.success) {
|
||||
return <View>Failed</View>;
|
||||
}
|
||||
const fixListRenderer = this.state.fixList.map((item) => item.render());
|
||||
return (
|
||||
<View>
|
||||
<TitleCard />
|
||||
|
|
@ -109,11 +183,66 @@ export default class MainPage extends Component<{}, MainPageState> {
|
|||
<View style={{ marginTop: '60rpx' }}>
|
||||
{mainPageCard(this.state.dutyInfoCard)}
|
||||
{mainPageCard(this.state.tipsInfoCard)}
|
||||
{wechatUser.getAccess() && this.state.dutyData.isInDuty ? (
|
||||
<ExpandItem
|
||||
title={memberPage.expandTitle.admin}
|
||||
content={
|
||||
<View
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
marginBottom: '40rpx',
|
||||
}}
|
||||
>
|
||||
<View
|
||||
className='.at-article__h3'
|
||||
style={{
|
||||
marginTop: '40rpx',
|
||||
}}
|
||||
>
|
||||
{pt.get().memberPage.dutyCount.text}
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
marginTop: '40rpx',
|
||||
}}
|
||||
>
|
||||
<AtInputNumber
|
||||
type='number'
|
||||
min={0}
|
||||
max={10}
|
||||
step={1}
|
||||
value={this.state.inDutyCnt}
|
||||
onChange={this.handleCnt.bind(this)}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ marginLeft: 'auto', marginTop: '40rpx' }}>
|
||||
<AtButton
|
||||
type='secondary'
|
||||
size='small'
|
||||
loading={this.state.isLoading}
|
||||
disabled={this.state.isDisable}
|
||||
onClick={this.onChangeCnt.bind(this)}
|
||||
>
|
||||
{pt.get().memberPage.dutyCount.button}
|
||||
</AtButton>
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<View></View>
|
||||
)}
|
||||
<ExpandItem
|
||||
title={mainPage.expandTitle.stepInfo}
|
||||
content={mainPageCard(this.state.stepInfoCard)}
|
||||
/>
|
||||
</View>
|
||||
{wechatUser.getAccess() ? (
|
||||
<AtList>{fixListRenderer}</AtList>
|
||||
) : (
|
||||
<View></View>
|
||||
)}
|
||||
<PageFooter />
|
||||
</View>
|
||||
</View>
|
||||
|
|
|
|||
|
|
@ -1,120 +0,0 @@
|
|||
import { Component, ReactNode } from 'react';
|
||||
import { View, Image } from '@tarojs/components';
|
||||
import { AtTimeline } from 'taro-ui';
|
||||
import pt from '@/plain-text';
|
||||
import tick from '@/assets/icons/MainPage/tick.svg';
|
||||
import clock from '@/assets/icons/MemberPage/clock.svg';
|
||||
|
||||
export class MemberDutyData {
|
||||
constructor() {
|
||||
this.isInDuty = false;
|
||||
this.currentDuty = '2';
|
||||
this.inDutyCnt = 3;
|
||||
this.offDutyReason = '学园维修';
|
||||
this.dutyRecoverTime = '下周一';
|
||||
}
|
||||
|
||||
isInDuty: boolean;
|
||||
currentDuty?: 'off' | '1' | '2' | '3' | 'others';
|
||||
offDutyReason?: string;
|
||||
dutyRecoverTime?: string;
|
||||
inDutyCnt?: number;
|
||||
}
|
||||
|
||||
class Card extends Component {
|
||||
props = {
|
||||
isInDuty: false,
|
||||
};
|
||||
render(): ReactNode {
|
||||
const inDuty = this.props.isInDuty;
|
||||
const dc = pt.get().memberPage.dutyCard;
|
||||
const title = inDuty ? dc.inDuty.title : dc.offDuty.title;
|
||||
const iconsrc = inDuty ? tick : clock;
|
||||
return (
|
||||
<View>
|
||||
<View
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
marginBottom: '40rpx',
|
||||
}}
|
||||
>
|
||||
<Image
|
||||
src={iconsrc}
|
||||
style={{
|
||||
width: '48rpx',
|
||||
height: '48rpx',
|
||||
}}
|
||||
/>
|
||||
<View
|
||||
style={{
|
||||
marginLeft: '20rpx',
|
||||
fontSize: '60rpx',
|
||||
fontWeight: 'bold',
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class MemberDutyInfo extends Component {
|
||||
state: {
|
||||
isLoading: false;
|
||||
isDisable: false;
|
||||
};
|
||||
|
||||
props = {
|
||||
data: new MemberDutyData(),
|
||||
};
|
||||
|
||||
offDutyContent(): ReactNode {
|
||||
const data = this.props.data;
|
||||
const od = pt.get().memberPage.dutyCard.offDuty;
|
||||
return (
|
||||
<View>
|
||||
<Card isInDuty={data.isInDuty} />
|
||||
<AtTimeline
|
||||
items={[
|
||||
{ title: od.reason(data.offDutyReason as string) },
|
||||
{ title: od.recoverTime(data.dutyRecoverTime as string) },
|
||||
]}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
inDutyContent(): ReactNode {
|
||||
const data = this.props.data;
|
||||
const id = pt.get().memberPage.dutyCard.inDuty;
|
||||
return (
|
||||
<View>
|
||||
<Card isInDuty={data.isInDuty} />
|
||||
<View
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<AtTimeline
|
||||
items={[
|
||||
{ title: id.currentDutyText(data.currentDuty || 'off') },
|
||||
{ title: id.inDutyCnt(data.inDutyCnt as number) },
|
||||
]}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
render(): ReactNode {
|
||||
if (this.props.data.isInDuty) {
|
||||
return this.inDutyContent();
|
||||
} else {
|
||||
return this.offDutyContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
import { Component, ReactNode } from 'react';
|
||||
import { View } from '@tarojs/components';
|
||||
import { AtTimeline } from 'taro-ui';
|
||||
import pt from '@/plain-text';
|
||||
|
||||
export class MemberStepInfo extends Component {
|
||||
render(): ReactNode {
|
||||
return (
|
||||
<View>
|
||||
<AtTimeline items={pt.get().memberPage.stepList}></AtTimeline>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class MemberTipsInfo extends Component {
|
||||
render(): ReactNode {
|
||||
return (
|
||||
<View>
|
||||
<AtTimeline items={pt.get().memberPage.tipsList}></AtTimeline>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
import React from 'react';
|
||||
import { View, Image } from '@tarojs/components';
|
||||
import pt from '@/plain-text';
|
||||
import wechatUser from '@/wechat';
|
||||
|
||||
export default class MemberTitleCard extends React.Component {
|
||||
render(): React.ReactNode {
|
||||
const memberPage = pt.get().memberPage;
|
||||
return (
|
||||
<View className='at-row at-row__align--end'>
|
||||
<View className='at-col at-col-1 at-col--auto'>
|
||||
<Image
|
||||
style='width: 150rpx; height: 150rpx; margin-left: 60rpx;'
|
||||
src={wechatUser.getInfo().avatar}
|
||||
mode='aspectFit'
|
||||
/>
|
||||
</View>
|
||||
<View className='page-title' style={{ marginLeft: '30rpx' }}>
|
||||
<View className='at-article__h1' style={{ fontWeight: 'bold' }}>
|
||||
{memberPage.mainTitleLine + wechatUser.getInfo().name}
|
||||
</View>
|
||||
<View className='at-article__h2'>{memberPage.subTitleLine}</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
export default definePageConfig({
|
||||
usingComponents: {},
|
||||
});
|
||||
|
|
@ -1,226 +0,0 @@
|
|||
import { View } from '@tarojs/components';
|
||||
import { Component, ReactNode } from 'react';
|
||||
import {
|
||||
AtAccordion,
|
||||
AtButton,
|
||||
AtCard,
|
||||
AtInputNumber,
|
||||
AtList,
|
||||
AtMessage,
|
||||
} from 'taro-ui';
|
||||
import Taro from '@tarojs/taro';
|
||||
import pt from '@/plain-text';
|
||||
import { getUncompletedTicketList } from '@/service/uncompletedTicket';
|
||||
import type CustomTabBar from '@/custom-tab-bar';
|
||||
import { TicketListItem } from '@/components/TicketListItem/TicketListItem';
|
||||
import { RequestState } from '@/service';
|
||||
import moment from 'moment';
|
||||
import { getMemberDutyInfo } from '@/service/memberDutyInfo';
|
||||
import PageFooter from '@/components/PageFooter/PageFooter';
|
||||
import { changeDutyCnt } from '@/service/changeDutyCount';
|
||||
import './member.scss';
|
||||
import { MemberDutyData, MemberDutyInfo } from './MemberDutyInfo';
|
||||
import { MemberStepInfo, MemberTipsInfo } from './MemberStepTipsInfo';
|
||||
import MemberTitleCard from './MemberTitleCard';
|
||||
|
||||
const submitInterval = 5000;
|
||||
|
||||
class CardContent {
|
||||
title: string;
|
||||
note: string;
|
||||
extra: JSX.Element | string;
|
||||
content: () => JSX.Element;
|
||||
}
|
||||
|
||||
function memberPageCard(c: CardContent): JSX.Element {
|
||||
return (
|
||||
<View style={{ marginTop: '20rpx', marginBottom: '40rpx' }}>
|
||||
<AtCard note={c.note} extra={c.extra} title={c.title}>
|
||||
{c.content()}
|
||||
</AtCard>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
class ExpandItem extends Component {
|
||||
state = {
|
||||
open: false,
|
||||
};
|
||||
props = {
|
||||
title: '',
|
||||
content: <View></View>,
|
||||
};
|
||||
|
||||
handleClick(value: boolean) {
|
||||
this.setState({ open: value });
|
||||
}
|
||||
|
||||
render(): ReactNode {
|
||||
return (
|
||||
<View>
|
||||
<AtAccordion
|
||||
open={this.state.open}
|
||||
onClick={this.handleClick.bind(this)}
|
||||
title={this.props.title}
|
||||
>
|
||||
{this.props.content}
|
||||
</AtAccordion>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
interface MemberPageState {
|
||||
fixList: Array<TicketListItem>;
|
||||
rs: RequestState;
|
||||
dutyData: MemberDutyData;
|
||||
inDutyCnt: number;
|
||||
dutyInfoCard: CardContent;
|
||||
stepInfoCard: CardContent;
|
||||
tipsInfoCard: CardContent;
|
||||
isLoading: boolean;
|
||||
isDisable: boolean;
|
||||
}
|
||||
|
||||
export default class MemberPage extends Component<{}, MemberPageState> {
|
||||
state = {
|
||||
dutyData: new MemberDutyData(),
|
||||
inDutyCnt: 0,
|
||||
dutyInfoCard: {
|
||||
title: pt.get().mainPage.cardTitle.dutyInfo,
|
||||
note: pt.get().mainPage.cardTips.dutyInfo,
|
||||
extra: pt.get().mainPage.extraInfo.dutyInfo,
|
||||
content: () => <MemberDutyInfo data={this.state.dutyData} />,
|
||||
},
|
||||
stepInfoCard: {
|
||||
title: pt.get().mainPage.cardTitle.stepInfo,
|
||||
note: pt.get().mainPage.cardTips.stepInfo,
|
||||
extra: pt.get().mainPage.extraInfo.dutyInfo,
|
||||
content: () => <MemberStepInfo />,
|
||||
},
|
||||
tipsInfoCard: {
|
||||
title: pt.get().mainPage.cardTitle.tipsInfo,
|
||||
note: pt.get().mainPage.cardTips.tipsInfo,
|
||||
extra: pt.get().mainPage.extraInfo.dutyInfo,
|
||||
content: () => <MemberTipsInfo />,
|
||||
},
|
||||
fixList: [new TicketListItem(0, '', '', 1, moment())],
|
||||
rs: new RequestState(),
|
||||
isLoading: false,
|
||||
isDisable: false,
|
||||
};
|
||||
|
||||
componentDidMount(): void {
|
||||
getMemberDutyInfo(this);
|
||||
Taro.setNavigationBarTitle({
|
||||
title: pt.get().navBar.user.member,
|
||||
});
|
||||
getUncompletedTicketList(this);
|
||||
}
|
||||
|
||||
// 以下是TabBar相关
|
||||
pageCtx = Taro.getCurrentInstance().page;
|
||||
componentDidShow() {
|
||||
const tabbar = Taro.getTabBar<CustomTabBar>(this.pageCtx);
|
||||
tabbar?.setSelected(0);
|
||||
}
|
||||
// 以上是TabBar相关
|
||||
|
||||
handleCnt(inDutyCnt: number) {
|
||||
this.setState({
|
||||
inDutyCnt: inDutyCnt,
|
||||
});
|
||||
return inDutyCnt;
|
||||
}
|
||||
|
||||
onChangeCnt() {
|
||||
this.setState({
|
||||
isDisable: true,
|
||||
});
|
||||
changeDutyCnt(this);
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, submitInterval);
|
||||
}
|
||||
|
||||
render(): ReactNode {
|
||||
const memberPage = pt.get().memberPage;
|
||||
if (this.state.rs.loading) {
|
||||
return <View>loading</View>;
|
||||
}
|
||||
if (!this.state.rs.success) {
|
||||
return <View>Failed</View>;
|
||||
}
|
||||
const fixListRenderer = this.state.fixList.map((item) => item.render());
|
||||
return (
|
||||
<View>
|
||||
<AtMessage />
|
||||
<MemberTitleCard />
|
||||
<View style={{ width: '94%', marginLeft: '3%' }}>
|
||||
<View style={{ marginTop: '60rpx' }}>
|
||||
{memberPageCard(this.state.dutyInfoCard)}
|
||||
{memberPageCard(this.state.tipsInfoCard)}
|
||||
{this.state.dutyData.isInDuty ? (
|
||||
<ExpandItem
|
||||
title={memberPage.expandTitle.admin}
|
||||
content={
|
||||
<View
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
marginBottom: '40rpx',
|
||||
}}
|
||||
>
|
||||
<View
|
||||
className='.at-article__h3'
|
||||
style={{
|
||||
marginTop: '40rpx',
|
||||
}}
|
||||
>
|
||||
{pt.get().memberPage.dutyCount.text}
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
marginTop: '40rpx',
|
||||
}}
|
||||
>
|
||||
<AtInputNumber
|
||||
type='number'
|
||||
min={0}
|
||||
max={10}
|
||||
step={1}
|
||||
value={this.state.inDutyCnt}
|
||||
onChange={this.handleCnt.bind(this)}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ marginLeft: 'auto', marginTop: '40rpx' }}>
|
||||
<AtButton
|
||||
type='secondary'
|
||||
size='small'
|
||||
loading={this.state.isLoading}
|
||||
disabled={this.state.isDisable}
|
||||
onClick={this.onChangeCnt.bind(this)}
|
||||
>
|
||||
{pt.get().memberPage.dutyCount.button}
|
||||
</AtButton>
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<View></View>
|
||||
)}
|
||||
<ExpandItem
|
||||
title={memberPage.expandTitle.stepInfo}
|
||||
content={memberPageCard(this.state.stepInfoCard)}
|
||||
/>
|
||||
</View>
|
||||
<AtList>{fixListRenderer}</AtList>
|
||||
<PageFooter />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ export interface MainPageText {
|
|||
};
|
||||
inDuty: {
|
||||
title: string;
|
||||
currentDutyText: (c: 'off' | '1' | '2' | '3') => string;
|
||||
currentDutyText: (c: 'off' | '1' | '2' | '3' | 'others') => string;
|
||||
inDutyCnt: (n: number) => string;
|
||||
};
|
||||
};
|
||||
|
|
@ -89,6 +89,8 @@ export const mainPageZhCn: MainPageText = {
|
|||
return '第二班 16:00-18:00';
|
||||
case '3':
|
||||
return '第三班 18:00-20:30';
|
||||
case 'others':
|
||||
return '其他值班时间,见通知';
|
||||
}
|
||||
},
|
||||
inDutyCnt: (n) => '当前值班人数:' + n,
|
||||
|
|
@ -148,6 +150,8 @@ export const mainPageEnUs: MainPageText = {
|
|||
return '2nd Shift 16:00-18:00';
|
||||
case '3':
|
||||
return '3rd Shift 18:00-20:30';
|
||||
case 'others':
|
||||
return 'Other duty time, see notice';
|
||||
}
|
||||
},
|
||||
inDutyCnt: (n) => 'EVA members on duty: ' + n,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
export interface MemberPageText {
|
||||
mainTitleLine: string;
|
||||
subTitleLine: string;
|
||||
cardTitle: {
|
||||
dutyInfo: string;
|
||||
stepInfo: string;
|
||||
tipsInfo: string;
|
||||
};
|
||||
dutyCount: {
|
||||
button: string;
|
||||
text: string;
|
||||
|
|
@ -33,6 +38,16 @@ export interface MemberPageText {
|
|||
tipsInfo: string;
|
||||
admin: string;
|
||||
};
|
||||
cardTips: {
|
||||
dutyInfo: string;
|
||||
stepInfo: string;
|
||||
tipsInfo: string;
|
||||
};
|
||||
extraInfo: {
|
||||
dutyInfo: string;
|
||||
stepInfo: string;
|
||||
tipsInfo: string;
|
||||
};
|
||||
stepList: Array<{ title: string }>;
|
||||
tipsList: Array<{ title: string }>;
|
||||
}
|
||||
|
|
@ -40,6 +55,11 @@ export interface MemberPageText {
|
|||
export const memberPageZhCn: MemberPageText = {
|
||||
mainTitleLine: '您好,',
|
||||
subTitleLine: '祝你满绩每一天',
|
||||
cardTitle: {
|
||||
dutyInfo: '值班情况',
|
||||
stepInfo: '维修步骤',
|
||||
tipsInfo: '注意事项',
|
||||
},
|
||||
dutyCount: {
|
||||
button: '更新值班人数',
|
||||
text: '当前值班人数:',
|
||||
|
|
@ -85,6 +105,16 @@ export const memberPageZhCn: MemberPageText = {
|
|||
tipsInfo: '查看注意事项',
|
||||
admin: '组长管理入口',
|
||||
},
|
||||
cardTips: {
|
||||
dutyInfo: '提示:可以先前往【维修】页面在线上预填写工单!',
|
||||
stepInfo: '提示:请在 20:30 之前取走自己的物品哦!',
|
||||
tipsInfo: '',
|
||||
},
|
||||
extraInfo: {
|
||||
dutyInfo: '',
|
||||
stepInfo: '',
|
||||
tipsInfo: '',
|
||||
},
|
||||
stepList: [
|
||||
{ title: '机主线上填写工单,审核接取维修后加入 Oreo' },
|
||||
{ title: '进行维修工作,认领工单,通过小程序与机主交流' },
|
||||
|
|
@ -102,6 +132,11 @@ export const memberPageZhCn: MemberPageText = {
|
|||
export const memberPageEnUs: MemberPageText = {
|
||||
mainTitleLine: 'Hi! ',
|
||||
subTitleLine: 'Have a great day!',
|
||||
cardTitle: {
|
||||
dutyInfo: 'Duty Situation',
|
||||
stepInfo: 'Maintenance Steps',
|
||||
tipsInfo: 'Tips',
|
||||
},
|
||||
dutyCount: {
|
||||
button: 'Update Duty Count',
|
||||
text: 'The duty count: ',
|
||||
|
|
@ -147,6 +182,16 @@ export const memberPageEnUs: MemberPageText = {
|
|||
tipsInfo: 'Check for tips',
|
||||
admin: 'Entry for admin',
|
||||
},
|
||||
cardTips: {
|
||||
dutyInfo: '提示:可以先前往【维修】页面在线上预填写工单!',
|
||||
stepInfo: '提示:请在 20:30 之前取走自己的物品哦!',
|
||||
tipsInfo: '',
|
||||
},
|
||||
extraInfo: {
|
||||
dutyInfo: '',
|
||||
stepInfo: '',
|
||||
tipsInfo: '',
|
||||
},
|
||||
stepList: [
|
||||
{ title: 'The owner fills out ticket online. Add it to Oreo after audit.' },
|
||||
{ title: 'Repair, pick the ticket, and communicate with the owner online' },
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import MemberPage from '@/pages/member/member';
|
||||
import MainPage from '@/pages/index';
|
||||
import Taro from '@tarojs/taro';
|
||||
import pt from '@/plain-text';
|
||||
import wechatUser from '@/wechat';
|
||||
|
|
@ -6,7 +6,7 @@ import { getUrl } from '.';
|
|||
|
||||
const reLaunchInterval = 1000;
|
||||
|
||||
export function changeDutyCnt(that: MemberPage) {
|
||||
export function changeDutyCnt(that: MainPage) {
|
||||
that.setState({
|
||||
isLoading: true,
|
||||
});
|
||||
|
|
@ -29,7 +29,7 @@ export function changeDutyCnt(that: MemberPage) {
|
|||
});
|
||||
setTimeout(() => {
|
||||
Taro.reLaunch({
|
||||
url: '/pages/member/member',
|
||||
url: '/pages/index/index',
|
||||
});
|
||||
}, reLaunchInterval);
|
||||
})
|
||||
|
|
|
|||
|
|
@ -12,9 +12,17 @@ export function getDutyInfo(that: MainPage) {
|
|||
},
|
||||
})
|
||||
.then((res) => {
|
||||
let former = that.state.rs;
|
||||
if (!res.data.success) {
|
||||
that.setState({
|
||||
rs: former.trans(false),
|
||||
});
|
||||
return;
|
||||
}
|
||||
const data = res.data.data;
|
||||
if (data.isInDuty) {
|
||||
that.setState({
|
||||
rs: former.trans(true),
|
||||
dutyData: {
|
||||
isInDuty: data.isInDuty,
|
||||
inDutyCnt: data.inDutyCnt,
|
||||
|
|
@ -24,6 +32,7 @@ export function getDutyInfo(that: MainPage) {
|
|||
});
|
||||
} else {
|
||||
that.setState({
|
||||
rs: former.trans(true),
|
||||
dutyData: {
|
||||
isInDuty: data.isInDuty,
|
||||
offDutyReason: data.offDutyReason,
|
||||
|
|
@ -35,7 +44,9 @@ export function getDutyInfo(that: MainPage) {
|
|||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
let former = that.state.rs;
|
||||
that.setState({
|
||||
rs: former.trans(false),
|
||||
dutyData: {
|
||||
isInDuty: false,
|
||||
offDutyReason: '获取失败!Network Error!',
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@ export function getLocaleData() {
|
|||
console.log(res.data);
|
||||
pt.setLang(res.data.data.lang);
|
||||
Taro.reLaunch({
|
||||
url: wechatUser.getAccess()
|
||||
? '/pages/member/member'
|
||||
: '/pages/index/index',
|
||||
url: '/pages/index/index',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ export function loginAte() {
|
|||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
getLocaleData();
|
||||
} else {
|
||||
console.log('Login Failed: ' + res.errMsg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import MemberPage from '@/pages/member/member';
|
||||
import MainPage from '@/pages/index';
|
||||
import Taro from '@tarojs/taro';
|
||||
import wechatUser from '@/wechat';
|
||||
import { getUrl } from '.';
|
||||
|
||||
export function getMemberDutyInfo(that: MemberPage) {
|
||||
export function getMemberDutyInfo(that: MainPage) {
|
||||
Taro.request({
|
||||
url: getUrl('/member/duty/info'),
|
||||
method: 'GET',
|
||||
|
|
@ -19,6 +19,7 @@ export function getMemberDutyInfo(that: MemberPage) {
|
|||
isInDuty: data.isInDuty,
|
||||
inDutyCnt: data.inDutyCnt,
|
||||
currentDuty: data.currentDuty,
|
||||
place: data.place,
|
||||
},
|
||||
inDutyCnt: data.inDutyCnt,
|
||||
});
|
||||
|
|
@ -28,6 +29,7 @@ export function getMemberDutyInfo(that: MemberPage) {
|
|||
isInDuty: data.isInDuty,
|
||||
offDutyReason: data.offDutyReason,
|
||||
dutyRecoverTime: data.dutyRecoverTime,
|
||||
place: data.place,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -39,6 +41,7 @@ export function getMemberDutyInfo(that: MemberPage) {
|
|||
isInDuty: false,
|
||||
offDutyReason: '获取失败!Network Error!',
|
||||
dutyRecoverTime: '获取失败!Network Error!',
|
||||
place: '204',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import MemberPage from '@/pages/member/member';
|
||||
import MainPage from '@/pages/index';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { TicketListItem } from '@/components/TicketListItem/TicketListItem';
|
||||
import moment from 'moment';
|
||||
import wechatUser from '@/wechat';
|
||||
import { getUrl } from '.';
|
||||
|
||||
export function getUncompletedTicketList(that: MemberPage) {
|
||||
export function getUncompletedTicketList(that: MainPage) {
|
||||
Taro.request({
|
||||
url: getUrl('/tickets/uncompleted'),
|
||||
method: 'GET',
|
||||
|
|
|
|||
Loading…
Reference in New Issue