add request to repair page

This commit is contained in:
Dawn1Ocean
2024-03-12 02:25:58 +08:00
parent 9bd6c8f1b4
commit 946a312c61
3 changed files with 134 additions and 6 deletions
+44
View File
@@ -0,0 +1,44 @@
import RepairPage from '@/pages/repair/repair';
import Taro from '@tarojs/taro';
import pt from '@/plain-text';
import { getUrl } from '.';
export function submitTicket(that: RepairPage) {
that.setState({
isLoading: true,
});
Taro.request({
url: getUrl('/tickets/create'),
method: 'POST',
data: {
token: 'token_test',
type: that.state.type,
device: that.state.device,
deviceModel: that.state.deviceModel,
owner: that.state.owner,
phone: that.state.phone,
description: that.state.description,
accessories: that.state.checkedList,
},
})
.then(res => {
console.log(res.data);
that.setState({
isLoading: false,
});
Taro.atMessage({
message: pt.get().button.submitText.success,
type: 'success',
});
})
.catch(err => {
console.log(err);
that.setState({
isLoading: false,
});
Taro.atMessage({
message: pt.get().button.submitText.error + err.toString(),
type: 'error',
});
});
}