Compare commits
No commits in common. "388814f9d910c05b8d0a641e7a966ed326ab49d7" and "eaa22dcaa56cff2b37632d6789116d99fcb41b79" have entirely different histories.
388814f9d9
...
eaa22dcaa5
|
|
@ -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,90 +3,23 @@ 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';
|
|
||||||
|
|
||||||
interface StepItemData {
|
export default class TicketDetail extends Component {
|
||||||
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 as number;
|
const id = router?.params.id;
|
||||||
const items = pt.get().ticketDetail.stepItems;
|
|
||||||
this.setState({
|
this.setState({
|
||||||
id: id,
|
id: id,
|
||||||
items: items,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
getTicketInfo(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): ReactNode {
|
render(): ReactNode {
|
||||||
if (this.state.rs.loading) {
|
return <View>TicketDetail: {this.state.id}</View>;
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 { 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;
|
||||||
|
|
@ -27,7 +22,6 @@ interface TextRecord {
|
||||||
memberPage: MemberPageText;
|
memberPage: MemberPageText;
|
||||||
ticketList: TicketListText;
|
ticketList: TicketListText;
|
||||||
navBar: NavBarTitle;
|
navBar: NavBarTitle;
|
||||||
ticketDetail: TicketDetailText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const textZhCn: TextRecord = {
|
const textZhCn: TextRecord = {
|
||||||
|
|
@ -42,7 +36,6 @@ const textZhCn: TextRecord = {
|
||||||
memberPage: memberPageZhCn,
|
memberPage: memberPageZhCn,
|
||||||
ticketList: ticketListZhCn,
|
ticketList: ticketListZhCn,
|
||||||
navBar: navBarTitleZhCh,
|
navBar: navBarTitleZhCh,
|
||||||
ticketDetail: ticketDetailZhCn,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const textEnUs: TextRecord = {
|
const textEnUs: TextRecord = {
|
||||||
|
|
@ -57,7 +50,6 @@ 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' | ...;
|
||||||
|
|
|
||||||
|
|
@ -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