|
@@ -2,6 +2,9 @@
|
|
|
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 {
|
|
|
baseUrl,
|
|
@@ -14,7 +17,7 @@ Page({
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- isUser: true,
|
|
|
+ isUser: false,
|
|
|
currentIndex: 0,
|
|
|
date: '2023-10-01',
|
|
|
time: '12:00',
|
|
@@ -24,7 +27,11 @@ Page({
|
|
|
endYear: 2250,
|
|
|
typeList: ['报修类型一', '报修类型二', '报修类型三'],
|
|
|
list: [],
|
|
|
- tempFileList: []
|
|
|
+ repairList: [],
|
|
|
+ completeList: [],
|
|
|
+ tempFileList: [],
|
|
|
+ nodata: false,
|
|
|
+ nodata2: false
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -42,6 +49,14 @@ Page({
|
|
|
});
|
|
|
|
|
|
// 查询所有报修类型
|
|
|
+
|
|
|
+ let isUser = this.data.isUser;
|
|
|
+ if (!isUser) {
|
|
|
+ // 初始化待维修工单
|
|
|
+ this.loadTobeRepair();
|
|
|
+ // 初始化已完成工单
|
|
|
+ // this.loadComplete();
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -76,14 +91,40 @@ Page({
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh() {
|
|
|
-
|
|
|
+ console.log("下拉刷新...");
|
|
|
+ if (this.data.currentIndex == 1) {
|
|
|
+ page2 = 1;
|
|
|
+ if (this.data.isUser) {
|
|
|
+ this.loadMyApplication();
|
|
|
+ } else {
|
|
|
+ this.loadComplete();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!this.data.isUser) {
|
|
|
+ page = 1;
|
|
|
+ this.loadTobeRepair();
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom() {
|
|
|
-
|
|
|
+ console.log("上拉加载....");
|
|
|
+ if (this.data.currentIndex == 1) {
|
|
|
+ page2++;
|
|
|
+ if (this.data.isUser) {
|
|
|
+ this.loadMyApplication(true);
|
|
|
+ } else {
|
|
|
+ this.loadComplete(true);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!this.data.isUser) {
|
|
|
+ page++;
|
|
|
+ this.loadTobeRepair(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -94,8 +135,16 @@ Page({
|
|
|
this.setData({
|
|
|
currentIndex: e.currentTarget.dataset.idx
|
|
|
});
|
|
|
- if (e.currentTarget.dataset.idx == 1) {
|
|
|
- this.loadMyApplication();
|
|
|
+ if (this.data.isUser) {
|
|
|
+ if (e.currentTarget.dataset.idx == 1) {
|
|
|
+ this.loadMyApplication();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (e.currentTarget.dataset.idx == 1) {
|
|
|
+ this.loadComplete();
|
|
|
+ } else {
|
|
|
+ this.loadTobeRepair();
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -104,7 +153,7 @@ Page({
|
|
|
* @param {*} e
|
|
|
*/
|
|
|
pagechange: function (e) {
|
|
|
- console.info(e)
|
|
|
+ // console.info(e)
|
|
|
// 通过touch判断,改变tab的下标值
|
|
|
if ("touch" === e.detail.source) {
|
|
|
// let currentPageIndex = this.data.currentIndex;
|
|
@@ -113,8 +162,16 @@ Page({
|
|
|
this.setData({
|
|
|
currentIndex: e.detail.current
|
|
|
});
|
|
|
- if (e.detail.current == 1) {
|
|
|
- this.loadMyApplication();
|
|
|
+ if (this.data.isUser) {
|
|
|
+ if (e.detail.current == 1) {
|
|
|
+ this.loadMyApplication();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (e.detail.current == 1) {
|
|
|
+ this.loadComplete();
|
|
|
+ } else {
|
|
|
+ this.loadTobeRepair();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -326,40 +383,23 @@ Page({
|
|
|
/**
|
|
|
* 加载我的申请
|
|
|
*/
|
|
|
- loadMyApplication() {
|
|
|
- let that = this;
|
|
|
- // let formData = new FormData();
|
|
|
- // formData.append('id', wx.getStorageSync('userid'));
|
|
|
- // let data = formData.getData();
|
|
|
- // request({
|
|
|
- // url: '/mini/worker/myOrder',
|
|
|
- // method: 'GET',
|
|
|
- // data: data.buffer,
|
|
|
- // contentType: data.contentType
|
|
|
- // }).then(res => {
|
|
|
- // console.info(res)
|
|
|
- // if (res.result) {
|
|
|
- // } else {
|
|
|
- // wx.showToast({
|
|
|
- // title: '加载失败',
|
|
|
- // icon: 'error',
|
|
|
- // mask: true
|
|
|
- // });
|
|
|
- // }
|
|
|
- // });
|
|
|
- wx.request({
|
|
|
- url: baseUrl + '/mini/worker/myOrder',
|
|
|
+ loadMyApplication(ispullup) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: '加载中...'
|
|
|
+ });
|
|
|
+ request({
|
|
|
+ url: '/mini/worker/myOrder',
|
|
|
method: 'GET',
|
|
|
- header: {
|
|
|
- 'mini-token': wx.getStorageSync('token')
|
|
|
- },
|
|
|
data: {
|
|
|
- 'id': wx.getStorageSync('userid')
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- success: function (res) {
|
|
|
- console.info(res)
|
|
|
- let data = res.data.data;
|
|
|
+ page: page2,
|
|
|
+ limit: limit,
|
|
|
+ userId: wx.getStorageSync('userid'),
|
|
|
+ isUser: true
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.info(res)
|
|
|
+ let data = res.data;
|
|
|
+ if (data && data.length > 0) {
|
|
|
for (let i in data) {
|
|
|
if (data[i].status == 2) {
|
|
|
data[i].image = 'status-complete.png';
|
|
@@ -369,10 +409,92 @@ Page({
|
|
|
data[i].image = 'status-repair.png';
|
|
|
}
|
|
|
}
|
|
|
- that.setData({
|
|
|
+ if (ispullup) {
|
|
|
+ data = data.concat(this.data.list);
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
list: data
|
|
|
});
|
|
|
+ } else {
|
|
|
+ if (!ispullup) {
|
|
|
+ this.setData({
|
|
|
+ nodata: true
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ wx.hideLoading();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 加载待维修工单
|
|
|
+ */
|
|
|
+ loadTobeRepair(ispullup) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: '加载中...'
|
|
|
+ });
|
|
|
+ request({
|
|
|
+ url: '/mini/worker/myOrder',
|
|
|
+ method: 'GET',
|
|
|
+ data: {
|
|
|
+ page: page,
|
|
|
+ limit: limit,
|
|
|
+ userId: wx.getStorageSync('userid'),
|
|
|
+ todo: true
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.info(res)
|
|
|
+ let data = res.data;
|
|
|
+ if (data && data.length > 0) {
|
|
|
+ if (ispullup) {
|
|
|
+ data = data.concat(this.data.repairList);
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ repairList: data
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if (!ispullup) {
|
|
|
+ this.setData({
|
|
|
+ nodata: true
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ wx.hideLoading();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 加载已完成工单
|
|
|
+ */
|
|
|
+ loadComplete(ispullup) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: '加载中...'
|
|
|
+ });
|
|
|
+ request({
|
|
|
+ url: '/mini/worker/myOrder',
|
|
|
+ method: 'GET',
|
|
|
+ data: {
|
|
|
+ page: page2,
|
|
|
+ limit: limit,
|
|
|
+ userId: wx.getStorageSync('userid'),
|
|
|
+ close: true
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.info(res)
|
|
|
+ let data = res.data;
|
|
|
+ if (data && data.length > 0) {
|
|
|
+ if (ispullup) {
|
|
|
+ data = data.concat(this.data.completeList);
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ completeList: data
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if (!ispullup) {
|
|
|
+ this.setData({
|
|
|
+ nodata2: true
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
+ wx.hideLoading();
|
|
|
});
|
|
|
}
|
|
|
|