add request to mytickets
parent
4e31eb70e2
commit
51106ead5e
|
|
@ -1,12 +1,14 @@
|
||||||
import { Component, ReactNode } from 'react';
|
import { Component, ReactNode } from 'react';
|
||||||
import { View } from '@tarojs/components';
|
import { View } from '@tarojs/components';
|
||||||
import { AtList, AtListItem } from 'taro-ui';
|
import { AtList, AtListItem } from 'taro-ui';
|
||||||
|
import Taro from '@tarojs/taro';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import repair from '@/assets/icons/MyTickets/repair.svg';
|
import repair from '@/assets/icons/MyTickets/repair.svg';
|
||||||
import finished from '@/assets/icons/MyTickets/finished.svg';
|
import finished from '@/assets/icons/MyTickets/finished.svg';
|
||||||
import tick from '@/assets/icons/MyTickets/tick.svg';
|
import tick from '@/assets/icons/MyTickets/tick.svg';
|
||||||
import fail from '@/assets/icons/MyTickets/fail.svg';
|
import fail from '@/assets/icons/MyTickets/fail.svg';
|
||||||
import pt from '@/plain-text';
|
import pt from '@/plain-text';
|
||||||
|
import { getUrl } from '@/service';
|
||||||
import './myTicket.scss';
|
import './myTicket.scss';
|
||||||
|
|
||||||
type FixStatus = 1 | 2 | 3 | 4 | 5;
|
type FixStatus = 1 | 2 | 3 | 4 | 5;
|
||||||
|
|
@ -53,12 +55,57 @@ class TicketListItem {
|
||||||
|
|
||||||
export default class SettingsPage extends Component {
|
export default class SettingsPage extends Component {
|
||||||
state = {
|
state = {
|
||||||
fixList: [
|
loading: true,
|
||||||
new TicketListItem('华硕', '天选3', 3, moment()),
|
success: false,
|
||||||
new TicketListItem('联想', '拯救者', 5, moment()),
|
fixList: [new TicketListItem('华硕', '天选3', 3, moment())],
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
componentDidMount(): void {
|
||||||
|
Taro.request({
|
||||||
|
url: getUrl('/user/mytickets'),
|
||||||
|
method: 'GET',
|
||||||
|
data: {
|
||||||
|
token: 'token_test',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (!res.data.success) {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
success: false,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
success: true,
|
||||||
|
fixList: res.data.data.list.map(
|
||||||
|
item =>
|
||||||
|
new TicketListItem(
|
||||||
|
item.device,
|
||||||
|
item.deviceModel,
|
||||||
|
item.status,
|
||||||
|
moment(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(reason => {
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
success: false,
|
||||||
|
});
|
||||||
|
console.log(reason);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render(): ReactNode {
|
render(): ReactNode {
|
||||||
|
if (this.state.loading) {
|
||||||
|
return <View>loading</View>;
|
||||||
|
}
|
||||||
|
if (!this.state.success) {
|
||||||
|
return <View>Failed</View>;
|
||||||
|
}
|
||||||
const fixListRenderer = this.state.fixList.map(item => item.render());
|
const fixListRenderer = this.state.fixList.map(item => item.render());
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue