add blank judgement; fixed setstate in render bug
parent
6b554196b3
commit
b41498976e
|
|
@ -57,6 +57,11 @@ export default class DetailFramework extends Component<
|
|||
title: navBar.ticketDetail,
|
||||
});
|
||||
getTicketInfo(this, this.props.id);
|
||||
const status = this.state.ticketInfo.status;
|
||||
this.setState({
|
||||
current: mapStatusStep.get(status) || 0,
|
||||
items: pt.get().ticketDetail.stepItems,
|
||||
});
|
||||
}
|
||||
|
||||
props: Readonly<DetailFrameworkProps> = {
|
||||
|
|
@ -79,12 +84,6 @@ export default class DetailFramework extends Component<
|
|||
return <View>Request failed</View>;
|
||||
}
|
||||
|
||||
const status = this.state.ticketInfo.status;
|
||||
// this.setState({
|
||||
// current: mapStatusStep.get(status) || 0,
|
||||
// items: pt.get().ticketDetail.stepItems,
|
||||
// });
|
||||
|
||||
const elements: ShowElements = {
|
||||
device: this.props.isInfoShow['device'] ? (
|
||||
<View className='at-article__h1'>
|
||||
|
|
|
|||
|
|
@ -152,7 +152,34 @@ export default class RepairPage extends Component<{}, RepairPageState> {
|
|||
}
|
||||
|
||||
onSubmit() {
|
||||
this.setState({
|
||||
isDisable: true,
|
||||
});
|
||||
if (
|
||||
this.state.description == '' ||
|
||||
this.state.device == '' ||
|
||||
this.state.deviceModel == '' ||
|
||||
this.state.owner == '' ||
|
||||
this.state.phone == '' ||
|
||||
this.state.checkedList.length === 0
|
||||
) {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.blank,
|
||||
type: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, submitInterval);
|
||||
return;
|
||||
}
|
||||
submitTicket(this);
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, submitInterval);
|
||||
}
|
||||
|
||||
render(): ReactNode {
|
||||
|
|
|
|||
|
|
@ -36,10 +36,16 @@ export default class InformPage extends Component {
|
|||
}
|
||||
onSubmit() {
|
||||
this.setState({
|
||||
isLoading: true,
|
||||
isDisable: true,
|
||||
});
|
||||
console.log(this.state.name, this.state.phone);
|
||||
if (this.state.name == '' || this.state.phone == '') {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.blank,
|
||||
type: 'error',
|
||||
});
|
||||
return;
|
||||
}
|
||||
updateUserInfo(this);
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import { memberLogin, memberLogout } from '@/service/memberLogin';
|
|||
import wechatUser from '@/wechat';
|
||||
import './member.scss';
|
||||
|
||||
const logInterval = 5000;
|
||||
|
||||
export default class UserMemberPage extends Component {
|
||||
state = {
|
||||
stuid: '',
|
||||
|
|
@ -31,11 +33,39 @@ export default class UserMemberPage extends Component {
|
|||
return passwd;
|
||||
}
|
||||
onSubmit() {
|
||||
this.setState({
|
||||
isDisable: true,
|
||||
});
|
||||
if (this.state.stuid == '' || this.state.passwd == '') {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.blank,
|
||||
type: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, logInterval);
|
||||
return;
|
||||
}
|
||||
memberLogin(this);
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, logInterval);
|
||||
}
|
||||
|
||||
onLogout() {
|
||||
this.setState({
|
||||
isDisable: true,
|
||||
});
|
||||
memberLogout(this);
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, logInterval);
|
||||
}
|
||||
|
||||
render(): ReactNode {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { AtTextarea, AtButton, AtForm, AtMessage } from 'taro-ui';
|
||||
import { Component, ReactNode } from 'react';
|
||||
import { getUrl } from '@/service';
|
||||
import Taro from '@tarojs/taro';
|
||||
import pt from '@/plain-text';
|
||||
import { reportMessage } from '@/service/report';
|
||||
import './report.scss';
|
||||
|
||||
const submitInterval = 5000;
|
||||
|
|
@ -27,35 +27,21 @@ export default class ReportPage extends Component {
|
|||
}
|
||||
onSubmit() {
|
||||
this.setState({
|
||||
isLoading: true,
|
||||
isDisable: true,
|
||||
});
|
||||
console.log(this.state.report);
|
||||
Taro.request({
|
||||
url: getUrl('/report'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
token: 'token_test',
|
||||
report: this.state.report,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.success,
|
||||
type: 'success',
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.error + err.toString(),
|
||||
type: 'error',
|
||||
});
|
||||
if (this.state.report == '') {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.blank,
|
||||
type: 'error',
|
||||
});
|
||||
this.setState({
|
||||
isLoading: false,
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, submitInterval);
|
||||
return;
|
||||
}
|
||||
reportMessage(this);
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
|
|
|
|||
|
|
@ -4,26 +4,10 @@ import pt from '@/plain-text';
|
|||
import wechatUser from '@/wechat';
|
||||
import { getUrl } from '.';
|
||||
|
||||
const logInterval = 5000;
|
||||
|
||||
export function memberLogin(that: UserMemberPage) {
|
||||
that.setState({
|
||||
isDisable: true,
|
||||
isLoading: true,
|
||||
});
|
||||
if (that.state.stuid == '' || that.state.passwd == '') {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.blank,
|
||||
type: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
that.setState({
|
||||
isDisable: false,
|
||||
isLoading: false,
|
||||
});
|
||||
}, logInterval);
|
||||
return;
|
||||
}
|
||||
Taro.request({
|
||||
url: getUrl('/member/login'),
|
||||
method: 'POST',
|
||||
|
|
@ -56,11 +40,6 @@ export function memberLogin(that: UserMemberPage) {
|
|||
message: pt.get().button.loginText.error + err.toString(),
|
||||
type: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
that.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, logInterval);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -98,10 +77,5 @@ export function memberLogout(that: UserMemberPage) {
|
|||
message: pt.get().button.logoutText.error + err.toString(),
|
||||
type: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
that.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, logInterval);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
import ReportPage from '@/pages/user/report/report';
|
||||
import Taro from '@tarojs/taro';
|
||||
import pt from '@/plain-text';
|
||||
import { getUrl } from '.';
|
||||
|
||||
export function reportMessage(that: ReportPage) {
|
||||
that.setState({
|
||||
isLoading: true,
|
||||
});
|
||||
Taro.request({
|
||||
url: getUrl('/report'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
token: 'token_test',
|
||||
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);
|
||||
that.setState({
|
||||
isLoading: false,
|
||||
});
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.error + err.toString(),
|
||||
type: 'error',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -3,35 +3,10 @@ import Taro from '@tarojs/taro';
|
|||
import pt from '@/plain-text';
|
||||
import { getUrl } from '.';
|
||||
|
||||
const submitInterval = 5000;
|
||||
|
||||
export function submitTicket(that: RepairPage) {
|
||||
if (that.state.isDisable != true || that.state.isLoading != true) {
|
||||
that.setState({
|
||||
isDisable: true,
|
||||
isLoading: true,
|
||||
});
|
||||
}
|
||||
if (
|
||||
that.state.description == '' ||
|
||||
that.state.device == '' ||
|
||||
that.state.deviceModel == '' ||
|
||||
that.state.owner == '' ||
|
||||
that.state.phone == '' ||
|
||||
that.state.checkedList.length === 0
|
||||
) {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.blank,
|
||||
type: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
that.setState({
|
||||
isDisable: false,
|
||||
isLoading: false,
|
||||
});
|
||||
}, submitInterval);
|
||||
return;
|
||||
}
|
||||
that.setState({
|
||||
isLoading: true,
|
||||
});
|
||||
Taro.request({
|
||||
url: getUrl('/tickets/create'),
|
||||
method: 'POST',
|
||||
|
|
@ -69,10 +44,4 @@ export function submitTicket(that: RepairPage) {
|
|||
type: 'error',
|
||||
});
|
||||
});
|
||||
setTimeout(() => {
|
||||
that.setState({
|
||||
isDisable: false,
|
||||
isLoading: false,
|
||||
});
|
||||
}, submitInterval);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue