EVA-Notify/src/service/submitTicket.ts

45 lines
1.1 KiB
TypeScript

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',
});
});
}