42 lines
974 B
TypeScript
42 lines
974 B
TypeScript
import { Comment } from '@/pages/TicketDetail/Comment';
|
|
import Taro from '@tarojs/taro';
|
|
import pt from '@/plain-text';
|
|
import wechatUser from '@/wechat';
|
|
import { getUrl } from '.';
|
|
|
|
export function submitComment(that: Comment) {
|
|
that.setState({
|
|
isLoading: true,
|
|
});
|
|
Taro.request({
|
|
url: getUrl('/tickets/addnote'),
|
|
method: 'POST',
|
|
data: {
|
|
token: wechatUser.getToken(),
|
|
content: that.state.comment,
|
|
id: that.props.id,
|
|
},
|
|
})
|
|
.then((res) => {
|
|
console.log(res.data);
|
|
that.setState({
|
|
isLoading: false,
|
|
commentId: res.data.data.id,
|
|
});
|
|
Taro.atMessage({
|
|
message: pt.get().button.submitText.success,
|
|
type: 'success',
|
|
});
|
|
})
|
|
.catch((err) => {
|
|
console.log(err.errMsg);
|
|
that.setState({
|
|
isLoading: false,
|
|
});
|
|
Taro.atMessage({
|
|
message: pt.get().button.submitText.error + err.errMsg,
|
|
type: 'error',
|
|
});
|
|
});
|
|
}
|