Merge branch 'dev' into mgy
commit
9bd6c8f1b4
19
src/app.ts
19
src/app.ts
|
|
@ -1,26 +1,13 @@
|
|||
import { PropsWithChildren } from 'react';
|
||||
import Taro, { useLaunch } from '@tarojs/taro';
|
||||
import { getUrl } from '@/service';
|
||||
import pt from '@/plain-text';
|
||||
import { useLaunch } from '@tarojs/taro';
|
||||
import 'taro-ui/dist/style/index.scss';
|
||||
import './app.scss';
|
||||
import { getLocaleData } from './service/localeData';
|
||||
|
||||
function App({ children }: PropsWithChildren<any>) {
|
||||
useLaunch(() => {
|
||||
console.log('App launched.');
|
||||
Taro.request({
|
||||
url: getUrl('/user/locale/get'),
|
||||
method: 'GET',
|
||||
data: {
|
||||
token: 'token_test',
|
||||
},
|
||||
}).then(res => {
|
||||
console.log(res.data);
|
||||
pt.setLang(res.data.data.lang);
|
||||
Taro.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
});
|
||||
});
|
||||
getLocaleData();
|
||||
});
|
||||
|
||||
// children 是将要会渲染的页面
|
||||
|
|
|
|||
|
|
@ -3,10 +3,23 @@ import { View } from '@tarojs/components';
|
|||
import { getCurrentInstance } from '@tarojs/runtime';
|
||||
import Taro from '@tarojs/taro';
|
||||
import pt from '@/plain-text';
|
||||
import { AtSteps } from 'taro-ui';
|
||||
|
||||
export default class TicketDetail extends Component {
|
||||
interface StepItemData {
|
||||
title: string;
|
||||
}
|
||||
|
||||
interface TicketDetailState {
|
||||
id: number;
|
||||
current: number;
|
||||
items: Array<StepItemData>;
|
||||
}
|
||||
|
||||
export default class TicketDetail extends Component<{}, TicketDetailState> {
|
||||
state = {
|
||||
id: 0,
|
||||
current: 0,
|
||||
items: [],
|
||||
};
|
||||
componentDidMount(): void {
|
||||
const navBar = pt.get().navBar;
|
||||
|
|
@ -14,12 +27,23 @@ export default class TicketDetail extends Component {
|
|||
title: navBar.ticketDetail,
|
||||
});
|
||||
const { router } = getCurrentInstance();
|
||||
const id = router?.params.id;
|
||||
const id = router?.params.id as number;
|
||||
const items = pt.get().ticketDetail.stepItems;
|
||||
this.setState({
|
||||
id: id,
|
||||
items: items,
|
||||
});
|
||||
}
|
||||
render(): ReactNode {
|
||||
return <View>TicketDetail: {this.state.id}</View>;
|
||||
return (
|
||||
<View>
|
||||
<AtSteps
|
||||
items={this.state.items}
|
||||
current={this.state.current}
|
||||
onChange={() => {}}
|
||||
/>
|
||||
<View>TicketDetail: {this.state.id}</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ export class DutyData {
|
|||
}
|
||||
|
||||
isInDuty: boolean;
|
||||
inDutyCnt: number;
|
||||
currentDuty: 'off' | '1' | '2' | '3';
|
||||
offDutyReason: string; // from backend
|
||||
dutyRecoverTime: string; // from backend
|
||||
inDutyCnt?: number;
|
||||
currentDuty?: 'off' | '1' | '2' | '3';
|
||||
offDutyReason?: string;
|
||||
dutyRecoverTime?: string;
|
||||
}
|
||||
|
||||
class Card extends Component {
|
||||
|
|
@ -73,8 +73,8 @@ export class DutyInfo extends Component {
|
|||
<Card isInDuty={data.isInDuty} />
|
||||
<AtTimeline
|
||||
items={[
|
||||
{ title: od.reason(data.offDutyReason) },
|
||||
{ title: od.recoverTime(data.dutyRecoverTime) },
|
||||
{ title: od.reason(data.offDutyReason as string) },
|
||||
{ title: od.recoverTime(data.dutyRecoverTime as string) },
|
||||
]}
|
||||
/>
|
||||
</View>
|
||||
|
|
@ -89,8 +89,8 @@ export class DutyInfo extends Component {
|
|||
<Card isInDuty={data.isInDuty} />
|
||||
<AtTimeline
|
||||
items={[
|
||||
{ title: id.currentDutyText(data.currentDuty) },
|
||||
{ title: id.inDutyCnt(data.inDutyCnt) },
|
||||
{ title: id.currentDutyText(data.currentDuty || 'off') },
|
||||
{ title: id.inDutyCnt(data.inDutyCnt as number) },
|
||||
]}
|
||||
/>
|
||||
</View>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { AtCard, AtAccordion } from 'taro-ui';
|
|||
import type CustomTabBar from '@/custom-tab-bar';
|
||||
import PageFooter from '@/components/PageFooter/PageFooter';
|
||||
import pt from '@/plain-text';
|
||||
import { getUrl } from '@/service';
|
||||
import { getDutyInfo } from '@/service/dutyInfo';
|
||||
import './index.scss';
|
||||
import TitleCard from './TitleCard';
|
||||
import { DutyInfo, DutyData } from './DutyInfo';
|
||||
|
|
@ -56,7 +56,15 @@ class ExpandItem extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
export default class Index extends Component {
|
||||
interface MainPageState {
|
||||
dutyData: DutyData;
|
||||
dutyInfoCard: CardContent;
|
||||
stepInfoCard: CardContent;
|
||||
tipsInfoCard: CardContent;
|
||||
//rs: RequestState;
|
||||
}
|
||||
|
||||
export default class MainPage extends Component<{}, MainPageState> {
|
||||
state = {
|
||||
dutyData: new DutyData(),
|
||||
dutyInfoCard: {
|
||||
|
|
@ -77,46 +85,11 @@ export default class Index extends Component {
|
|||
extra: '额外信息',
|
||||
content: () => <TipsInfo />,
|
||||
},
|
||||
// rs: new RequestState(),
|
||||
};
|
||||
|
||||
componentDidMount(): void {
|
||||
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!',
|
||||
},
|
||||
});
|
||||
});
|
||||
getDutyInfo(this);
|
||||
}
|
||||
|
||||
// 以下是TabBar相关
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { Component, ReactNode } from 'react';
|
||||
import { AtForm, AtInput, AtButton, AtMessage } from 'taro-ui';
|
||||
import { View } from '@tarojs/components';
|
||||
import { getUrl } from '@/service';
|
||||
import Taro from '@tarojs/taro';
|
||||
import pt from '@/plain-text';
|
||||
import { updateUserInfo } from '@/service/userData';
|
||||
import './inform.scss';
|
||||
|
||||
const submitInterval = 5000;
|
||||
|
|
@ -40,32 +40,7 @@ export default class InformPage extends Component {
|
|||
isDisable: true,
|
||||
});
|
||||
console.log(this.state.name, this.state.phone);
|
||||
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,
|
||||
});
|
||||
updateUserInfo(this);
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { AtList, AtListItem, AtToast } from 'taro-ui';
|
||||
import { Component, ReactNode } from 'react';
|
||||
import { View, Picker, Image, Text } from '@tarojs/components';
|
||||
import { getUrl } from '@/service';
|
||||
import Taro from '@tarojs/taro';
|
||||
import type CustomTabBar from '@/custom-tab-bar';
|
||||
import PageFooter from '@/components/PageFooter/PageFooter';
|
||||
|
|
@ -9,6 +8,7 @@ import aboutIcon from '@/assets/icons/AboutPage/about.svg';
|
|||
import pt, { Lang } from '@/plain-text';
|
||||
import wechatUser from '@/wechat';
|
||||
import logo from '@/assets/images/UserPage/logo.png';
|
||||
import { setLocaleData } from '@/service/localeData';
|
||||
import './user.scss';
|
||||
|
||||
const listLangInterval = 20;
|
||||
|
|
@ -70,16 +70,7 @@ export default class UserPage extends Component {
|
|||
});
|
||||
let currentLang = this.showLangDict[this.state.selector[e.detail.value]];
|
||||
pt.setLang(currentLang);
|
||||
Taro.request({
|
||||
url: getUrl('/user/locale/update'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
token: 'token_test',
|
||||
lang: currentLang,
|
||||
},
|
||||
}).then(res => {
|
||||
console.log(res.data);
|
||||
});
|
||||
setLocaleData(currentLang);
|
||||
Taro.reLaunch({
|
||||
url: '/pages/user/user',
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
interface StepItem {
|
||||
title: string;
|
||||
}
|
||||
|
||||
export interface TicketDetailText {
|
||||
stepItems: Array<StepItem>;
|
||||
}
|
||||
|
||||
export const ticketDetailZhCn: TicketDetailText = {
|
||||
stepItems: [{ title: '创建成功' }, { title: '维修中' }, { title: '待取回' }],
|
||||
};
|
||||
|
||||
export const ticketDetailEnUs: TicketDetailText = {
|
||||
stepItems: [
|
||||
{ title: 'Ticket created' },
|
||||
{ title: 'Repairing' },
|
||||
{ title: 'Take home' },
|
||||
],
|
||||
};
|
||||
|
|
@ -10,6 +10,11 @@ import { MemberPageText, memberPageEnUs, memberPageZhCn } from './MemberPage';
|
|||
import { TicketListText, ticketListEnUs, ticketListZhCn } from './TicketList';
|
||||
import { NavBarTitle, navBarTitleEnUs, navBarTitleZhCh } from './NavBarTitle';
|
||||
import { RepairPageText, repairPageEnUs, repairPageZhCn } from './RepairPage';
|
||||
import {
|
||||
TicketDetailText,
|
||||
ticketDetailEnUs,
|
||||
ticketDetailZhCn,
|
||||
} from './TicketDetail';
|
||||
|
||||
interface TextRecord {
|
||||
pageFooter: PageFooterText;
|
||||
|
|
@ -24,6 +29,7 @@ interface TextRecord {
|
|||
ticketList: TicketListText;
|
||||
navBar: NavBarTitle;
|
||||
repairPage: RepairPageText;
|
||||
ticketDetail: TicketDetailText;
|
||||
}
|
||||
|
||||
const textZhCn: TextRecord = {
|
||||
|
|
@ -39,6 +45,7 @@ const textZhCn: TextRecord = {
|
|||
ticketList: ticketListZhCn,
|
||||
navBar: navBarTitleZhCh,
|
||||
repairPage: repairPageZhCn,
|
||||
ticketDetail: ticketDetailZhCn,
|
||||
};
|
||||
|
||||
const textEnUs: TextRecord = {
|
||||
|
|
@ -54,6 +61,7 @@ const textEnUs: TextRecord = {
|
|||
ticketList: ticketListEnUs,
|
||||
navBar: navBarTitleEnUs,
|
||||
repairPage: repairPageEnUs,
|
||||
ticketDetail: ticketDetailEnUs,
|
||||
};
|
||||
|
||||
// type Lang = 'zh_CN' | 'en_US' | ...;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
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!',
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
import Taro from '@tarojs/taro';
|
||||
import pt, { Lang } from '@/plain-text';
|
||||
import { getUrl } from '.';
|
||||
|
||||
export function setLocaleData(lang: Lang) {
|
||||
Taro.request({
|
||||
url: getUrl('/user/locale/update'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
token: 'token_test',
|
||||
lang: lang,
|
||||
},
|
||||
}).then(res => {
|
||||
console.log(res.data);
|
||||
});
|
||||
}
|
||||
|
||||
export function getLocaleData() {
|
||||
Taro.request({
|
||||
url: getUrl('/user/locale/get'),
|
||||
method: 'GET',
|
||||
data: {
|
||||
token: 'token_test',
|
||||
},
|
||||
}).then(res => {
|
||||
console.log(res.data);
|
||||
pt.setLang(res.data.data.lang);
|
||||
Taro.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
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