|
@@ -2,8 +2,6 @@
|
|
|
var dateTimePicker = require('../../../utils/dateTimePicker');
|
|
|
const FormData = require('../../pages/menu/formData.js');
|
|
|
const twoHours = 7200000;
|
|
|
-let page = 1;
|
|
|
-let page2 = 1;
|
|
|
const limit = 10;
|
|
|
|
|
|
import {
|
|
@@ -17,6 +15,8 @@ Page({
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
+ page: 1,
|
|
|
+ page2: 1,
|
|
|
isUser: true,
|
|
|
currentIndex: 0,
|
|
|
date: '2023-01-01',
|
|
@@ -31,7 +31,9 @@ Page({
|
|
|
completeList: [],
|
|
|
tempFileList: [],
|
|
|
nodata: false,
|
|
|
- nodata2: false
|
|
|
+ nodata2: false,
|
|
|
+ total: 0,
|
|
|
+ total2: 0
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -93,7 +95,7 @@ Page({
|
|
|
onPullDownRefresh() {
|
|
|
console.log("下拉刷新...");
|
|
|
if (this.data.currentIndex == 1) {
|
|
|
- page2 = 1;
|
|
|
+ this.setData({ page2: 1 });
|
|
|
if (this.data.isUser) {
|
|
|
this.loadMyApplication();
|
|
|
} else {
|
|
@@ -101,7 +103,7 @@ Page({
|
|
|
}
|
|
|
} else {
|
|
|
if (!this.data.isUser) {
|
|
|
- page = 1;
|
|
|
+ this.setData({ page: 1 });
|
|
|
this.loadTobeRepair();
|
|
|
}
|
|
|
}
|
|
@@ -113,15 +115,27 @@ Page({
|
|
|
onReachBottom() {
|
|
|
console.log("上拉加载....");
|
|
|
if (this.data.currentIndex == 1) {
|
|
|
- page2++;
|
|
|
+ if (this.data.total2 <= limit) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.data.list.length == this.data.total2 || this.data.completeList.length == this.data.total2) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.setData({ page2: this.data.page2++ });
|
|
|
if (this.data.isUser) {
|
|
|
this.loadMyApplication(true);
|
|
|
} else {
|
|
|
this.loadComplete(true);
|
|
|
}
|
|
|
} else {
|
|
|
+ if (this.data.total <= limit) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.data.repairList.length == this.data.total) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (!this.data.isUser) {
|
|
|
- page++;
|
|
|
+ this.setData({ page: this.data.page++ });
|
|
|
this.loadTobeRepair(true);
|
|
|
}
|
|
|
}
|
|
@@ -257,83 +271,58 @@ Page({
|
|
|
return;
|
|
|
}
|
|
|
if (res.confirm) {
|
|
|
- let formData = new FormData();
|
|
|
- formData.append('repairType', e.detail.value.type);
|
|
|
- formData.append('userDescription', e.detail.value.description);
|
|
|
- formData.append('phoneNum', e.detail.value.phone);
|
|
|
- formData.append('appointmentTime', e.detail.value.arriveTime);
|
|
|
- formData.append('maintenanceAddress', e.detail.value.address);
|
|
|
- formData.append('userId', wx.getStorageSync('userid'));
|
|
|
- for (let i in tempList) {
|
|
|
- formData.appendFile('files', tempList[i]);
|
|
|
- }
|
|
|
- let data = formData.getData();
|
|
|
- request({
|
|
|
- url: '/mini/worker/addOrder',
|
|
|
- method: 'POST',
|
|
|
- data: data.buffer,
|
|
|
- contentType: data.contentType
|
|
|
- }).then(res => {
|
|
|
- console.info(res)
|
|
|
- if (res.result) {
|
|
|
- wx.showToast({
|
|
|
- title: '提交成功',
|
|
|
- icon: 'success',
|
|
|
- mask: true,
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- wx.navigateBack();
|
|
|
- }, 1500);
|
|
|
- } else {
|
|
|
- wx.showToast({
|
|
|
- title: '提交失败',
|
|
|
- icon: 'error',
|
|
|
- mask: true
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ this.addOrder(e);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- let formData = new FormData();
|
|
|
- formData.append('repairType', e.detail.value.type);
|
|
|
- formData.append('userDescription', e.detail.value.description);
|
|
|
- formData.append('phoneNum', e.detail.value.phone);
|
|
|
- formData.append('appointmentTime', e.detail.value.arriveTime);
|
|
|
- formData.append('maintenanceAddress', e.detail.value.address);
|
|
|
- formData.append('userId', wx.getStorageSync('userid'));
|
|
|
- for (let i in tempList) {
|
|
|
- formData.appendFile('files', tempList[i]);
|
|
|
- }
|
|
|
- let data = formData.getData();
|
|
|
- request({
|
|
|
- url: '/mini/worker/addOrder',
|
|
|
- method: 'POST',
|
|
|
- data: data.buffer,
|
|
|
- contentType: data.contentType
|
|
|
- }).then(res => {
|
|
|
- console.info(res)
|
|
|
- if (res.result) {
|
|
|
- wx.showToast({
|
|
|
- title: '提交成功',
|
|
|
- icon: 'success',
|
|
|
- mask: true,
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- wx.navigateBack();
|
|
|
- }, 1500);
|
|
|
- } else {
|
|
|
- wx.showToast({
|
|
|
- title: '提交失败',
|
|
|
- icon: 'error',
|
|
|
- mask: true
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ this.addOrder(e);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ addOrder(e) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: '加载中...',
|
|
|
+ });
|
|
|
+ let tempList = this.data.tempFileList;
|
|
|
+ let formData = new FormData();
|
|
|
+ formData.append('repairType', e.detail.value.type);
|
|
|
+ formData.append('userDescription', e.detail.value.description);
|
|
|
+ formData.append('phoneNum', e.detail.value.phone);
|
|
|
+ formData.append('appointmentTime', e.detail.value.arriveTime);
|
|
|
+ formData.append('maintenanceAddress', e.detail.value.address);
|
|
|
+ formData.append('userId', wx.getStorageSync('userid'));
|
|
|
+ for (let i in tempList) {
|
|
|
+ formData.appendFile('files', tempList[i]);
|
|
|
+ }
|
|
|
+ let data = formData.getData();
|
|
|
+ request({
|
|
|
+ url: '/mini/worker/addOrder',
|
|
|
+ method: 'POST',
|
|
|
+ data: data.buffer,
|
|
|
+ contentType: data.contentType
|
|
|
+ }).then(res => {
|
|
|
+ console.info(res)
|
|
|
+ if (res.result) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '提交成功',
|
|
|
+ icon: 'success',
|
|
|
+ mask: true,
|
|
|
+ });
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.navigateBack();
|
|
|
+ }, 1500);
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: '提交失败',
|
|
|
+ icon: 'error',
|
|
|
+ mask: true
|
|
|
+ });
|
|
|
+ }
|
|
|
+ wx.hideLoading();
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
/**
|
|
|
* 上传报修图片
|
|
|
*/
|
|
@@ -391,7 +380,7 @@ Page({
|
|
|
url: '/mini/worker/myOrder',
|
|
|
method: 'GET',
|
|
|
data: {
|
|
|
- page: page2,
|
|
|
+ page: this.data.page2,
|
|
|
limit: limit,
|
|
|
userId: wx.getStorageSync('userid'),
|
|
|
isUser: true
|
|
@@ -413,7 +402,8 @@ Page({
|
|
|
data = data.concat(this.data.list);
|
|
|
}
|
|
|
this.setData({
|
|
|
- list: data
|
|
|
+ list: data,
|
|
|
+ total2: res.count
|
|
|
});
|
|
|
} else {
|
|
|
if (!ispullup) {
|
|
@@ -436,7 +426,7 @@ Page({
|
|
|
url: '/mini/worker/myOrder',
|
|
|
method: 'GET',
|
|
|
data: {
|
|
|
- page: page,
|
|
|
+ page: this.data.page,
|
|
|
limit: limit,
|
|
|
userId: wx.getStorageSync('userid'),
|
|
|
todo: true
|
|
@@ -449,7 +439,8 @@ Page({
|
|
|
data = data.concat(this.data.repairList);
|
|
|
}
|
|
|
this.setData({
|
|
|
- repairList: data
|
|
|
+ repairList: data,
|
|
|
+ total: res.count
|
|
|
});
|
|
|
} else {
|
|
|
if (!ispullup) {
|
|
@@ -472,7 +463,7 @@ Page({
|
|
|
url: '/mini/worker/myOrder',
|
|
|
method: 'GET',
|
|
|
data: {
|
|
|
- page: page2,
|
|
|
+ page: this.data.page2,
|
|
|
limit: limit,
|
|
|
userId: wx.getStorageSync('userid'),
|
|
|
close: true
|
|
@@ -485,7 +476,8 @@ Page({
|
|
|
data = data.concat(this.data.completeList);
|
|
|
}
|
|
|
this.setData({
|
|
|
- completeList: data
|
|
|
+ completeList: data,
|
|
|
+ total2: res.count
|
|
|
});
|
|
|
} else {
|
|
|
if (!ispullup) {
|