Compare commits
2 Commits
eaa22dcaa5
...
388814f9d9
| Author | SHA1 | Date |
|---|---|---|
|
|
388814f9d9 | |
|
|
32ce506764 |
|
|
@ -38,7 +38,7 @@ export default {
|
||||||
success: true,
|
success: true,
|
||||||
data: mytickets,
|
data: mytickets,
|
||||||
},
|
},
|
||||||
'GET /tickets/info/': {
|
'GET /tickets/info': {
|
||||||
success: true,
|
success: true,
|
||||||
data: ticketInfo,
|
data: ticketInfo,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,23 +3,90 @@ import { View } from '@tarojs/components';
|
||||||
import { getCurrentInstance } from '@tarojs/runtime';
|
import { getCurrentInstance } from '@tarojs/runtime';
|
||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
import pt from '@/plain-text';
|
import pt from '@/plain-text';
|
||||||
|
import { AtSteps } from 'taro-ui';
|
||||||
|
import moment from 'moment';
|
||||||
|
import { RequestState } from '@/service';
|
||||||
|
import { getTicketInfo } from '@/service/ticketsInfo';
|
||||||
|
|
||||||
export default class TicketDetail extends Component {
|
interface StepItemData {
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TicketInfo {
|
||||||
|
id: number;
|
||||||
|
type: 0 | 1;
|
||||||
|
device: string;
|
||||||
|
deviceModel: string;
|
||||||
|
description: string;
|
||||||
|
createdTime: moment.Moment;
|
||||||
|
status: 1 | 2 | 3 | 4 | 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TicketNote {
|
||||||
|
id: number;
|
||||||
|
op: string;
|
||||||
|
type: 0 | 1 | 2;
|
||||||
|
content: string;
|
||||||
|
createdTime: moment.Moment;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderNote(n: TicketNote): JSX.Element {
|
||||||
|
return <View>{n.id}</View>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TicketDetailState {
|
||||||
|
id: number;
|
||||||
|
current: number;
|
||||||
|
items: Array<StepItemData>;
|
||||||
|
ticketInfo: TicketInfo;
|
||||||
|
notes: Array<TicketNote>;
|
||||||
|
rs: RequestState;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class TicketDetail extends Component<{}, TicketDetailState> {
|
||||||
state = {
|
state = {
|
||||||
id: 0,
|
id: 0,
|
||||||
|
current: 0,
|
||||||
|
items: [],
|
||||||
|
ticketInfo: new TicketInfo(),
|
||||||
|
notes: [new TicketNote()],
|
||||||
|
rs: new RequestState(),
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount(): void {
|
componentDidMount(): void {
|
||||||
const navBar = pt.get().navBar;
|
const navBar = pt.get().navBar;
|
||||||
Taro.setNavigationBarTitle({
|
Taro.setNavigationBarTitle({
|
||||||
title: navBar.ticketDetail,
|
title: navBar.ticketDetail,
|
||||||
});
|
});
|
||||||
const { router } = getCurrentInstance();
|
const { router } = getCurrentInstance();
|
||||||
const id = router?.params.id;
|
const id = router?.params.id as number;
|
||||||
|
const items = pt.get().ticketDetail.stepItems;
|
||||||
this.setState({
|
this.setState({
|
||||||
id: id,
|
id: id,
|
||||||
|
items: items,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
getTicketInfo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): ReactNode {
|
render(): ReactNode {
|
||||||
return <View>TicketDetail: {this.state.id}</View>;
|
if (this.state.rs.loading) {
|
||||||
|
return <View>Loading</View>;
|
||||||
|
} else if (!this.state.rs.success) {
|
||||||
|
return <View>Request failed</View>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<View>{this.state.ticketInfo.deviceModel}</View>
|
||||||
|
<AtSteps
|
||||||
|
items={this.state.items}
|
||||||
|
current={this.state.current}
|
||||||
|
onChange={() => {}}
|
||||||
|
/>
|
||||||
|
<View>TicketDetail: {this.state.id}</View>
|
||||||
|
<View>{this.state.notes.map(item => renderNote(item))}</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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' },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
@ -9,6 +9,11 @@ import { ButtonText, buttonEnUs, buttonZhCn } from './Button';
|
||||||
import { MemberPageText, memberPageEnUs, memberPageZhCn } from './MemberPage';
|
import { MemberPageText, memberPageEnUs, memberPageZhCn } from './MemberPage';
|
||||||
import { TicketListText, ticketListEnUs, ticketListZhCn } from './TicketList';
|
import { TicketListText, ticketListEnUs, ticketListZhCn } from './TicketList';
|
||||||
import { NavBarTitle, navBarTitleEnUs, navBarTitleZhCh } from './NavBarTitle';
|
import { NavBarTitle, navBarTitleEnUs, navBarTitleZhCh } from './NavBarTitle';
|
||||||
|
import {
|
||||||
|
TicketDetailText,
|
||||||
|
ticketDetailEnUs,
|
||||||
|
ticketDetailZhCn,
|
||||||
|
} from './TicketDetail';
|
||||||
|
|
||||||
interface TextRecord {
|
interface TextRecord {
|
||||||
pageFooter: PageFooterText;
|
pageFooter: PageFooterText;
|
||||||
|
|
@ -22,6 +27,7 @@ interface TextRecord {
|
||||||
memberPage: MemberPageText;
|
memberPage: MemberPageText;
|
||||||
ticketList: TicketListText;
|
ticketList: TicketListText;
|
||||||
navBar: NavBarTitle;
|
navBar: NavBarTitle;
|
||||||
|
ticketDetail: TicketDetailText;
|
||||||
}
|
}
|
||||||
|
|
||||||
const textZhCn: TextRecord = {
|
const textZhCn: TextRecord = {
|
||||||
|
|
@ -36,6 +42,7 @@ const textZhCn: TextRecord = {
|
||||||
memberPage: memberPageZhCn,
|
memberPage: memberPageZhCn,
|
||||||
ticketList: ticketListZhCn,
|
ticketList: ticketListZhCn,
|
||||||
navBar: navBarTitleZhCh,
|
navBar: navBarTitleZhCh,
|
||||||
|
ticketDetail: ticketDetailZhCn,
|
||||||
};
|
};
|
||||||
|
|
||||||
const textEnUs: TextRecord = {
|
const textEnUs: TextRecord = {
|
||||||
|
|
@ -50,6 +57,7 @@ const textEnUs: TextRecord = {
|
||||||
memberPage: memberPageEnUs,
|
memberPage: memberPageEnUs,
|
||||||
ticketList: ticketListEnUs,
|
ticketList: ticketListEnUs,
|
||||||
navBar: navBarTitleEnUs,
|
navBar: navBarTitleEnUs,
|
||||||
|
ticketDetail: ticketDetailEnUs,
|
||||||
};
|
};
|
||||||
|
|
||||||
// type Lang = 'zh_CN' | 'en_US' | ...;
|
// type Lang = 'zh_CN' | 'en_US' | ...;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
import TicketDetail, {
|
||||||
|
TicketInfo,
|
||||||
|
TicketNote,
|
||||||
|
} from '@/pages/TicketDetail/TicketDetail';
|
||||||
|
import Taro from '@tarojs/taro';
|
||||||
|
import moment from 'moment';
|
||||||
|
import { getUrl } from '.';
|
||||||
|
|
||||||
|
export function getTicketInfo(that: TicketDetail) {
|
||||||
|
Taro.request({
|
||||||
|
url: getUrl('/tickets/info'),
|
||||||
|
method: 'GET',
|
||||||
|
data: {
|
||||||
|
id: that.state.id,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (!res.data.success) {
|
||||||
|
that.setState({
|
||||||
|
rs: {
|
||||||
|
loading: false,
|
||||||
|
success: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const data = res.data.data;
|
||||||
|
const ticketDetail: TicketInfo = {
|
||||||
|
id: data.id,
|
||||||
|
type: data.type,
|
||||||
|
device: data.device,
|
||||||
|
deviceModel: data.deviceModel,
|
||||||
|
description: data.description,
|
||||||
|
createdTime: moment(),
|
||||||
|
status: data.status,
|
||||||
|
};
|
||||||
|
const notes: Array<TicketNote> = [];
|
||||||
|
data.notes.map(item => {
|
||||||
|
notes.push({
|
||||||
|
id: item.id,
|
||||||
|
op: item.op,
|
||||||
|
type: item.type,
|
||||||
|
content: item.content,
|
||||||
|
createdTime: moment(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
that.setState({
|
||||||
|
ticketInfo: ticketDetail,
|
||||||
|
notes: notes,
|
||||||
|
rs: {
|
||||||
|
loading: false,
|
||||||
|
success: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(reason => {
|
||||||
|
that.setState({
|
||||||
|
rs: {
|
||||||
|
loading: false,
|
||||||
|
success: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(reason);
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue