47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import TicketDetail from '@/pages/TicketDetail/TicketDetail';
|
|
import Taro from '@tarojs/taro';
|
|
import pt from '@/plain-text';
|
|
import wechatUser from '@/wechat';
|
|
import { getUrl } from '.';
|
|
|
|
const reLaunchInterval = 1000;
|
|
|
|
export function pickTicket(that: TicketDetail) {
|
|
that.setState({
|
|
isPickLoading: true,
|
|
});
|
|
Taro.request({
|
|
url: getUrl('/tickets/pick'),
|
|
method: 'POST',
|
|
data: {
|
|
token: wechatUser.getToken(),
|
|
id: that.state.id,
|
|
},
|
|
})
|
|
.then((res) => {
|
|
console.log(res.data);
|
|
that.setState({
|
|
isPickLoading: false,
|
|
});
|
|
Taro.atMessage({
|
|
message: pt.get().button.submitText.success,
|
|
type: 'success',
|
|
});
|
|
setTimeout(() => {
|
|
Taro.reLaunch({
|
|
url: '/pages/TicketDetail/TicketDetail?id=' + that.state.id,
|
|
});
|
|
}, reLaunchInterval);
|
|
})
|
|
.catch((err) => {
|
|
console.log(err.errMsg);
|
|
that.setState({
|
|
isPickLoading: false,
|
|
});
|
|
Taro.atMessage({
|
|
message: pt.get().button.submitText.error + err.errMsg.toString(),
|
|
type: 'error',
|
|
});
|
|
});
|
|
}
|