EVA-Notify/src/service/report.ts

40 lines
901 B
TypeScript

import ReportPage from '@/pages/user/report/report';
import Taro from '@tarojs/taro';
import pt from '@/plain-text';
import wechatUser from '@/wechat';
import { getUrl } from '.';
export function reportMessage(that: ReportPage) {
that.setState({
isLoading: true,
});
Taro.request({
url: getUrl('/report'),
method: 'POST',
data: {
token: wechatUser.getToken(),
report: that.state.report,
},
})
.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.errMsg);
that.setState({
isLoading: false,
});
Taro.atMessage({
message: pt.get().button.submitText.error + err.errMsg,
type: 'error',
});
});
}