start refactor

This commit is contained in:
2024-03-11 22:19:32 +08:00
parent d5b8af7d7b
commit 2fd629d479
6 changed files with 131 additions and 98 deletions
+9
View File
@@ -1,5 +1,14 @@
import process from 'process';
export class RequestState {
loading: boolean;
success: boolean;
constructor() {
this.loading = true;
this.success = false;
}
}
/**
* Get URL of backend
* @param path Relative path to base url, begins with `/`
+51
View File
@@ -0,0 +1,51 @@
import MyTicketPage from '@/pages/user/myTicket/myTicket';
import { TicketListItem } from '@/pages/user/myTicket/TicketListItem';
import Taro from '@tarojs/taro';
import moment from 'moment';
import { getUrl } from '.';
export function getMyTicketList(that: MyTicketPage) {
Taro.request({
url: getUrl('/user/mytickets'),
method: 'GET',
data: {
token: 'token_test',
},
})
.then(res => {
if (!res.data.success) {
that.setState({
rs: {
loading: false,
success: false,
},
});
return;
}
that.setState({
rs: {
loading: false,
success: true,
},
fixList: res.data.data.list.map(
item =>
new TicketListItem(
item.id,
item.device,
item.deviceModel,
item.status,
moment(),
),
),
});
})
.catch(reason => {
that.setState({
rs: {
loading: false,
success: false,
},
});
console.log(reason);
});
}