Compare commits
No commits in common. "a1aa63635f86ca45978b39f3555fb4838eda1bed" and "946a312c614b4b4bcd0a1d4726b5d1025f70f981" have entirely different histories.
a1aa63635f
...
946a312c61
|
|
@ -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,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,43 +4,15 @@ 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 { AtSteps } from 'taro-ui';
|
||||||
import moment from 'moment';
|
|
||||||
import { RequestState } from '@/service';
|
|
||||||
import { getTicketInfo } from '@/service/ticketsInfo';
|
|
||||||
|
|
||||||
interface StepItemData {
|
interface StepItemData {
|
||||||
title: string;
|
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 {
|
interface TicketDetailState {
|
||||||
id: number;
|
id: number;
|
||||||
current: number;
|
current: number;
|
||||||
items: Array<StepItemData>;
|
items: Array<StepItemData>;
|
||||||
ticketInfo: TicketInfo;
|
|
||||||
notes: Array<TicketNote>;
|
|
||||||
rs: RequestState;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class TicketDetail extends Component<{}, TicketDetailState> {
|
export default class TicketDetail extends Component<{}, TicketDetailState> {
|
||||||
|
|
@ -48,11 +20,7 @@ export default class TicketDetail extends Component<{}, TicketDetailState> {
|
||||||
id: 0,
|
id: 0,
|
||||||
current: 0,
|
current: 0,
|
||||||
items: [],
|
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({
|
||||||
|
|
@ -65,27 +33,16 @@ export default class TicketDetail extends Component<{}, TicketDetailState> {
|
||||||
id: id,
|
id: id,
|
||||||
items: items,
|
items: items,
|
||||||
});
|
});
|
||||||
|
|
||||||
getTicketInfo(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): ReactNode {
|
render(): ReactNode {
|
||||||
if (this.state.rs.loading) {
|
|
||||||
return <View>Loading</View>;
|
|
||||||
} else if (!this.state.rs.success) {
|
|
||||||
return <View>Request failed</View>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<View>{this.state.ticketInfo.deviceModel}</View>
|
|
||||||
<AtSteps
|
<AtSteps
|
||||||
items={this.state.items}
|
items={this.state.items}
|
||||||
current={this.state.current}
|
current={this.state.current}
|
||||||
onChange={() => {}}
|
onChange={() => {}}
|
||||||
/>
|
/>
|
||||||
<View>TicketDetail: {this.state.id}</View>
|
<View>TicketDetail: {this.state.id}</View>
|
||||||
<View>{this.state.notes.map(item => renderNote(item))}</View>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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