Compare commits
No commits in common. "9c6cbd91ffbf378905461d4af29e9292967523bd" and "2fd629d479be84655f9b995dd4193cd9a3841794" have entirely different histories.
9c6cbd91ff
...
2fd629d479
|
|
@ -15,10 +15,10 @@ export class DutyData {
|
||||||
}
|
}
|
||||||
|
|
||||||
isInDuty: boolean;
|
isInDuty: boolean;
|
||||||
inDutyCnt?: number;
|
inDutyCnt: number;
|
||||||
currentDuty?: 'off' | '1' | '2' | '3';
|
currentDuty: 'off' | '1' | '2' | '3';
|
||||||
offDutyReason?: string;
|
offDutyReason: string; // from backend
|
||||||
dutyRecoverTime?: string;
|
dutyRecoverTime: string; // from backend
|
||||||
}
|
}
|
||||||
|
|
||||||
class Card extends Component {
|
class Card extends Component {
|
||||||
|
|
@ -73,8 +73,8 @@ export class DutyInfo extends Component {
|
||||||
<Card isInDuty={data.isInDuty} />
|
<Card isInDuty={data.isInDuty} />
|
||||||
<AtTimeline
|
<AtTimeline
|
||||||
items={[
|
items={[
|
||||||
{ title: od.reason(data.offDutyReason as string) },
|
{ title: od.reason(data.offDutyReason) },
|
||||||
{ title: od.recoverTime(data.dutyRecoverTime as string) },
|
{ title: od.recoverTime(data.dutyRecoverTime) },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -89,8 +89,8 @@ export class DutyInfo extends Component {
|
||||||
<Card isInDuty={data.isInDuty} />
|
<Card isInDuty={data.isInDuty} />
|
||||||
<AtTimeline
|
<AtTimeline
|
||||||
items={[
|
items={[
|
||||||
{ title: id.currentDutyText(data.currentDuty || 'off') },
|
{ title: id.currentDutyText(data.currentDuty) },
|
||||||
{ title: id.inDutyCnt(data.inDutyCnt as number) },
|
{ title: id.inDutyCnt(data.inDutyCnt) },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ 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 { getDutyInfo } from '@/service/dutyInfo';
|
import { getUrl } from '@/service';
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
import TitleCard from './TitleCard';
|
import TitleCard from './TitleCard';
|
||||||
import { DutyInfo, DutyData } from './DutyInfo';
|
import { DutyInfo, DutyData } from './DutyInfo';
|
||||||
|
|
@ -56,15 +56,7 @@ class ExpandItem extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MainPageState {
|
export default class Index extends Component {
|
||||||
dutyData: DutyData;
|
|
||||||
dutyInfoCard: CardContent;
|
|
||||||
stepInfoCard: CardContent;
|
|
||||||
tipsInfoCard: CardContent;
|
|
||||||
//rs: RequestState;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class MainPage extends Component<{}, MainPageState> {
|
|
||||||
state = {
|
state = {
|
||||||
dutyData: new DutyData(),
|
dutyData: new DutyData(),
|
||||||
dutyInfoCard: {
|
dutyInfoCard: {
|
||||||
|
|
@ -85,11 +77,46 @@ export default class MainPage extends Component<{}, MainPageState> {
|
||||||
extra: '额外信息',
|
extra: '额外信息',
|
||||||
content: () => <TipsInfo />,
|
content: () => <TipsInfo />,
|
||||||
},
|
},
|
||||||
// rs: new RequestState(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount(): void {
|
componentDidMount(): void {
|
||||||
getDutyInfo(this);
|
Taro.request({
|
||||||
|
url: getUrl('/dutyinfo'),
|
||||||
|
method: 'GET',
|
||||||
|
data: {
|
||||||
|
token: 'token_test',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
if (data.isInDuty) {
|
||||||
|
this.setState({
|
||||||
|
dutyData: {
|
||||||
|
isInDuty: data.isInDuty,
|
||||||
|
inDutyCnt: data.inDutyCnt,
|
||||||
|
currentDuty: data.currentDuty,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
dutyData: {
|
||||||
|
isInDuty: data.isInDuty,
|
||||||
|
offDutyReason: data.offDutyReason,
|
||||||
|
dutyRecoverTime: data.dutyRecoverTime,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
this.setState({
|
||||||
|
dutyData: {
|
||||||
|
isInDuty: false,
|
||||||
|
offDutyReason: '获取失败!Network Error!',
|
||||||
|
dutyRecoverTime: '获取失败!Network Error!',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 以下是TabBar相关
|
// 以下是TabBar相关
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { Component, ReactNode } from 'react';
|
import { Component, ReactNode } from 'react';
|
||||||
import { AtForm, AtInput, AtButton, AtMessage } from 'taro-ui';
|
import { AtForm, AtInput, AtButton, AtMessage } from 'taro-ui';
|
||||||
import { View } from '@tarojs/components';
|
import { View } from '@tarojs/components';
|
||||||
|
import { getUrl } from '@/service';
|
||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
import pt from '@/plain-text';
|
import pt from '@/plain-text';
|
||||||
import { updateUserInfo } from '@/service/userData';
|
|
||||||
import './inform.scss';
|
import './inform.scss';
|
||||||
|
|
||||||
const submitInterval = 5000;
|
const submitInterval = 5000;
|
||||||
|
|
@ -40,7 +40,32 @@ export default class InformPage extends Component {
|
||||||
isDisable: true,
|
isDisable: true,
|
||||||
});
|
});
|
||||||
console.log(this.state.name, this.state.phone);
|
console.log(this.state.name, this.state.phone);
|
||||||
updateUserInfo(this);
|
Taro.request({
|
||||||
|
url: getUrl('/user/update'),
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
token: 'token_test',
|
||||||
|
name: this.state.name,
|
||||||
|
phone: this.state.phone,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.data);
|
||||||
|
Taro.atMessage({
|
||||||
|
message: pt.get().button.submitText.success,
|
||||||
|
type: 'success',
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
Taro.atMessage({
|
||||||
|
message: pt.get().button.submitText.error + err.toString(),
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.setState({
|
||||||
|
isLoading: false,
|
||||||
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
isDisable: false,
|
isDisable: false,
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
import MainPage from '@/pages/index';
|
|
||||||
import Taro from '@tarojs/taro';
|
|
||||||
import { getUrl } from '.';
|
|
||||||
|
|
||||||
export function getDutyInfo(that: MainPage) {
|
|
||||||
Taro.request({
|
|
||||||
url: getUrl('/dutyinfo'),
|
|
||||||
method: 'GET',
|
|
||||||
data: {
|
|
||||||
token: 'token_test',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
const data = res.data.data;
|
|
||||||
if (data.isInDuty) {
|
|
||||||
that.setState({
|
|
||||||
dutyData: {
|
|
||||||
isInDuty: data.isInDuty,
|
|
||||||
inDutyCnt: data.inDutyCnt,
|
|
||||||
currentDuty: data.currentDuty,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
that.setState({
|
|
||||||
dutyData: {
|
|
||||||
isInDuty: data.isInDuty,
|
|
||||||
offDutyReason: data.offDutyReason,
|
|
||||||
dutyRecoverTime: data.dutyRecoverTime,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.log(err);
|
|
||||||
that.setState({
|
|
||||||
dutyData: {
|
|
||||||
isInDuty: false,
|
|
||||||
offDutyReason: '获取失败!Network Error!',
|
|
||||||
dutyRecoverTime: '获取失败!Network Error!',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
import InformPage from '@/pages/user/inform/inform';
|
|
||||||
import Taro from '@tarojs/taro';
|
|
||||||
import pt from '@/plain-text';
|
|
||||||
import { getUrl } from '.';
|
|
||||||
|
|
||||||
export function updateUserInfo(that: InformPage) {
|
|
||||||
Taro.request({
|
|
||||||
url: getUrl('/user/update'),
|
|
||||||
method: 'POST',
|
|
||||||
data: {
|
|
||||||
token: 'token_test',
|
|
||||||
name: that.state.name,
|
|
||||||
phone: that.state.phone,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
console.log(res.data);
|
|
||||||
that.setState({
|
|
||||||
isLoading: false,
|
|
||||||
});
|
|
||||||
Taro.atMessage({
|
|
||||||
message: pt.get().button.submitText.success,
|
|
||||||
type: 'success',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.log(err);
|
|
||||||
that.setState({
|
|
||||||
isLoading: false,
|
|
||||||
});
|
|
||||||
Taro.atMessage({
|
|
||||||
message: pt.get().button.submitText.error + err.toString(),
|
|
||||||
type: 'error',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue