|
@@ -17,6 +17,7 @@ Page({
|
|
|
mode: '',
|
|
|
isReplied: false,
|
|
|
formSubmitted: false,
|
|
|
+ isSubmitting: false,
|
|
|
},
|
|
|
|
|
|
onLoad: function (options) {
|
|
@@ -173,7 +174,15 @@ Page({
|
|
|
repairType,
|
|
|
description
|
|
|
} = this.data;
|
|
|
- const isValid = contact && phone && address && repairType && description;
|
|
|
+
|
|
|
+ const hasAddress = address && address.trim() !== '';
|
|
|
+ const hasContact = contact && contact.trim() !== '';
|
|
|
+ const hasPhone = phone && phone.trim() !== '';
|
|
|
+ const hasValidPhone = this.validatePhone(phone);
|
|
|
+ const hasRepairType = repairType && repairType.trim() !== '';
|
|
|
+ const hasDescription = description && description.trim() !== '';
|
|
|
+
|
|
|
+ const isValid = hasAddress && hasContact && hasPhone && hasValidPhone && hasRepairType && hasDescription;
|
|
|
|
|
|
this.setData({
|
|
|
isFormValid: isValid
|
|
@@ -290,15 +299,38 @@ Page({
|
|
|
},
|
|
|
|
|
|
submitForm: function () {
|
|
|
- if (this.data.isPreviewMode) {
|
|
|
+ if (this.data.isSubmitting) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (!this.checkFormValidity()) {
|
|
|
+ this.setData({
|
|
|
+ isSubmitting: true
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!this.data.address || this.data.address.trim() === '') {
|
|
|
wx.showToast({
|
|
|
- title: '请填写完整信息',
|
|
|
+ title: '请填写地址',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ this.setData({ isSubmitting: false });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!this.data.contact || this.data.contact.trim() === '') {
|
|
|
+ wx.showToast({
|
|
|
+ title: '请填写联系人',
|
|
|
icon: 'none'
|
|
|
});
|
|
|
+ this.setData({ isSubmitting: false });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!this.data.phone || this.data.phone.trim() === '') {
|
|
|
+ wx.showToast({
|
|
|
+ title: '请填写联系电话',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ this.setData({ isSubmitting: false });
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -307,8 +339,28 @@ Page({
|
|
|
title: '请输入正确的手机号',
|
|
|
icon: 'none'
|
|
|
});
|
|
|
+ this.setData({ isSubmitting: false });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!this.data.repairType || this.data.repairType.trim() === '') {
|
|
|
+ wx.showToast({
|
|
|
+ title: '请选择报修类型',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ this.setData({ isSubmitting: false });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!this.data.description || this.data.description.trim() === '') {
|
|
|
+ wx.showToast({
|
|
|
+ title: '请填写故障说明',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ this.setData({ isSubmitting: false });
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
const fileManager = wx.getFileSystemManager();
|
|
|
this.data.imageList.map(imgInfo => {
|
|
|
const base64 = fileManager.readFileSync(imgInfo.tempFilePath, 'base64');
|
|
@@ -329,7 +381,11 @@ Page({
|
|
|
|
|
|
wx.showLoading({
|
|
|
title: '提交中...',
|
|
|
+ mask: true
|
|
|
});
|
|
|
+
|
|
|
+ const that = this;
|
|
|
+
|
|
|
wx.request({
|
|
|
url: app.globalData.interfaceUrls.repairRegistration,
|
|
|
method: 'POST',
|
|
@@ -343,22 +399,21 @@ Page({
|
|
|
success(res) {
|
|
|
wx.hideLoading();
|
|
|
if (res.data.code == '200') {
|
|
|
- debugger
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/baoxiuSuccess/baoxiuSuccess',
|
|
|
});
|
|
|
}
|
|
|
+ that.setData({ isSubmitting: false });
|
|
|
},
|
|
|
fail(error) {
|
|
|
- wx.hideLoading()
|
|
|
- utils.simleInfo('登记失败,请稍后再试')
|
|
|
+ wx.hideLoading();
|
|
|
+ wx.showToast({
|
|
|
+ title: '登记失败,请稍后再试',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ that.setData({ isSubmitting: false });
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
- // 在提交成功后设置标记
|
|
|
- this.setData({
|
|
|
- formSubmitted: true
|
|
|
- });
|
|
|
},
|
|
|
|
|
|
inputAddress: function (e) {
|