Compare commits
No commits in common. "388814f9d910c05b8d0a641e7a966ed326ab49d7" and "eaa22dcaa56cff2b37632d6789116d99fcb41b79" have entirely different histories.
388814f9d9
...
eaa22dcaa5
|
|
@ -38,7 +38,7 @@ export default {
|
|||
success: true,
|
||||
data: mytickets,
|
||||
},
|
||||
'GET /tickets/info': {
|
||||
'GET /tickets/info/': {
|
||||
success: true,
|
||||
data: ticketInfo,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,90 +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';
|
||||
import moment from 'moment';
|
||||
import { RequestState } from '@/service';
|
||||
import { getTicketInfo } from '@/service/ticketsInfo';
|
||||
|
||||
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> {
|
||||
export default class TicketDetail extends Component {
|
||||
state = {
|
||||
id: 0,
|
||||
current: 0,
|
||||
items: [],
|
||||
ticketInfo: new TicketInfo(),
|
||||
notes: [new TicketNote()],
|
||||
rs: new RequestState(),
|
||||
};
|
||||
|
||||
componentDidMount(): void {
|
||||
const navBar = pt.get().navBar;
|
||||
Taro.setNavigationBarTitle({
|
||||
title: navBar.ticketDetail,
|
||||
});
|
||||
const { router } = getCurrentInstance();
|
||||
const id = router?.params.id as number;
|
||||
const items = pt.get().ticketDetail.stepItems;
|
||||
const id = router?.params.id;
|
||||
this.setState({
|
||||
id: id,
|
||||
items: items,
|
||||
});
|
||||
|
||||
getTicketInfo(this);
|
||||
}
|
||||
|
||||
render(): ReactNode {
|
||||
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>
|
||||
);
|
||||
return <View>TicketDetail: {this.state.id}</View>;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
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,11 +9,6 @@ import { ButtonText, buttonEnUs, buttonZhCn } from './Button';
|
|||
import { MemberPageText, memberPageEnUs, memberPageZhCn } from './MemberPage';
|
||||
import { TicketListText, ticketListEnUs, ticketListZhCn } from './TicketList';
|
||||
import { NavBarTitle, navBarTitleEnUs, navBarTitleZhCh } from './NavBarTitle';
|
||||
import {
|
||||
TicketDetailText,
|
||||
ticketDetailEnUs,
|
||||
ticketDetailZhCn,
|
||||
} from './TicketDetail';
|
||||
|
||||
interface TextRecord {
|
||||
pageFooter: PageFooterText;
|
||||
|
|
@ -27,7 +22,6 @@ interface TextRecord {
|
|||
memberPage: MemberPageText;
|
||||
ticketList: TicketListText;
|
||||
navBar: NavBarTitle;
|
||||
ticketDetail: TicketDetailText;
|
||||
}
|
||||
|
||||
const textZhCn: TextRecord = {
|
||||
|
|
@ -42,7 +36,6 @@ const textZhCn: TextRecord = {
|
|||
memberPage: memberPageZhCn,
|
||||
ticketList: ticketListZhCn,
|
||||
navBar: navBarTitleZhCh,
|
||||
ticketDetail: ticketDetailZhCn,
|
||||
};
|
||||
|
||||
const textEnUs: TextRecord = {
|
||||
|
|
@ -57,7 +50,6 @@ const textEnUs: TextRecord = {
|
|||
memberPage: memberPageEnUs,
|
||||
ticketList: ticketListEnUs,
|
||||
navBar: navBarTitleEnUs,
|
||||
ticketDetail: ticketDetailEnUs,
|
||||
};
|
||||
|
||||
// type Lang = 'zh_CN' | 'en_US' | ...;
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
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