add blank judgement for forms; fixing setstate bug in detailframework

main
Dawn1Ocean 2024-03-15 13:42:16 +08:00
parent 2d5ce655ef
commit 6b554196b3
6 changed files with 62 additions and 17 deletions

View File

@ -80,10 +80,10 @@ export default class DetailFramework extends Component<
} }
const status = this.state.ticketInfo.status; const status = this.state.ticketInfo.status;
this.setState({ // this.setState({
current: mapStatusStep.get(status) || 0, // current: mapStatusStep.get(status) || 0,
items: pt.get().ticketDetail.stepItems, // items: pt.get().ticketDetail.stepItems,
}); // });
const elements: ShowElements = { const elements: ShowElements = {
device: this.props.isInfoShow['device'] ? ( device: this.props.isInfoShow['device'] ? (

View File

@ -152,14 +152,7 @@ export default class RepairPage extends Component<{}, RepairPageState> {
} }
onSubmit() { onSubmit() {
this.setState({
isLoading: true,
isDisable: true,
});
submitTicket(this); submitTicket(this);
Taro.reLaunch({
url: '/pages/repair/repair',
});
} }
render(): ReactNode { render(): ReactNode {

View File

@ -8,6 +8,7 @@ export interface ButtonText {
submitText: { submitText: {
success: string; success: string;
error: string; error: string;
blank: string;
}; };
loginText: { loginText: {
success: string; success: string;
@ -29,6 +30,7 @@ export const buttonZhCn: ButtonText = {
submitText: { submitText: {
success: '提交成功', success: '提交成功',
error: '提交失败:', error: '提交失败:',
blank: '请填写完整!',
}, },
loginText: { loginText: {
success: '登录成功', success: '登录成功',
@ -50,6 +52,7 @@ export const buttonEnUs: ButtonText = {
submitText: { submitText: {
success: 'Success', success: 'Success',
error: 'Error: ', error: 'Error: ',
blank: 'Please fill in the blanks!',
}, },
loginText: { loginText: {
success: 'Login Success', success: 'Login Success',

View File

@ -8,8 +8,22 @@ const logInterval = 5000;
export function memberLogin(that: UserMemberPage) { export function memberLogin(that: UserMemberPage) {
that.setState({ that.setState({
isDisable: true,
isLoading: 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({ Taro.request({
url: getUrl('/member/login'), url: getUrl('/member/login'),
method: 'POST', method: 'POST',
@ -43,7 +57,7 @@ export function memberLogin(that: UserMemberPage) {
type: 'error', type: 'error',
}); });
setTimeout(() => { setTimeout(() => {
this.setState({ that.setState({
isDisable: false, isDisable: false,
}); });
}, logInterval); }, logInterval);
@ -85,7 +99,7 @@ export function memberLogout(that: UserMemberPage) {
type: 'error', type: 'error',
}); });
setTimeout(() => { setTimeout(() => {
this.setState({ that.setState({
isDisable: false, isDisable: false,
}); });
}, logInterval); }, logInterval);

View File

@ -29,7 +29,8 @@ export function getMyTicketList(that: MyTicketPage) {
item.device, item.device,
item.deviceModel, item.deviceModel,
item.status, item.status,
moment(), moment(item.createdTime),
item.isMember,
), ),
), ),
}); });

View File

@ -3,10 +3,35 @@ import Taro from '@tarojs/taro';
import pt from '@/plain-text'; import pt from '@/plain-text';
import { getUrl } from '.'; import { getUrl } from '.';
const submitInterval = 5000;
export function submitTicket(that: RepairPage) { export function submitTicket(that: RepairPage) {
that.setState({ if (that.state.isDisable != true || that.state.isLoading != true) {
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;
}
Taro.request({ Taro.request({
url: getUrl('/tickets/create'), url: getUrl('/tickets/create'),
method: 'POST', method: 'POST',
@ -30,6 +55,9 @@ export function submitTicket(that: RepairPage) {
message: pt.get().button.submitText.success, message: pt.get().button.submitText.success,
type: 'success', type: 'success',
}); });
Taro.reLaunch({
url: '/pages/repair/repair',
});
}) })
.catch((err) => { .catch((err) => {
console.log(err); console.log(err);
@ -41,4 +69,10 @@ export function submitTicket(that: RepairPage) {
type: 'error', type: 'error',
}); });
}); });
setTimeout(() => {
that.setState({
isDisable: false,
isLoading: false,
});
}, submitInterval);
} }