3 changed files with 100 additions and 51 deletions
Split View
Diff Options
@ -1,66 +1,82 @@ |
|||
// pages/home/customer/index.js
|
|||
Page({ |
|||
import { getFactoryOrderList, cancelOrder } from "../../../api/saas" |
|||
const util = require('../../../utils/util') |
|||
const app = getApp() |
|||
|
|||
Page({ |
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
|
|||
height: app.globalData.fragmentHeight - 100, |
|||
loading: true, |
|||
requesting: false, |
|||
finished: false, |
|||
top: 0, |
|||
orderList: [], |
|||
form: { |
|||
funcType: 0, |
|||
pageNum: 1, |
|||
pageSize: 10 |
|||
} |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad: function (options) { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload: function () { |
|||
|
|||
this.setData({ height: app.globalData.fragmentHeight - 100 }) |
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom: function () { |
|||
|
|||
onRefreshList: function () { |
|||
this.setData({ |
|||
orderList: [], |
|||
['form.pageNum']: 1, |
|||
loading: true, |
|||
finished: false |
|||
}) |
|||
this.fetchOrderList() |
|||
}, |
|||
//1:待定价,2:待过皮重,3:待过磅审核,4:待付款,5:已完成
|
|||
fetchOrderList: function () { |
|||
if (this.data.requesting || this.data.finished) { |
|||
return |
|||
} |
|||
if (this.data.loading) { |
|||
this.data.requesting = true |
|||
} else { |
|||
this.setData({ requesting: true }) |
|||
} |
|||
getFactoryOrderList(this.data.form).then(result => { |
|||
if (result.data && result.data.records.length) { |
|||
var respList = result.data.records |
|||
let nowList = `orderList[${this.data.orderList.length}]` |
|||
var num = this.data.form.pageNum |
|||
var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total |
|||
if(this.data.form.pageNum == 1){ |
|||
this.setData({ |
|||
[nowList]: respList, |
|||
['form.pageNum']: (num + 1), |
|||
top: 0, |
|||
finished, |
|||
requesting: false, |
|||
loading: false |
|||
}) |
|||
} else { |
|||
this.setData({ |
|||
[nowList]: respList, |
|||
['form.pageNum']: (num + 1), |
|||
finished, |
|||
requesting: false, |
|||
loading: false |
|||
}) |
|||
} |
|||
} else { |
|||
this.setData({ finished: true, requesting: false, loading: false }) |
|||
} |
|||
}).catch(err => { |
|||
this.setData({ requesting: false, loading: false }) |
|||
util.showToast(err) |
|||
}) |
|||
} |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage: function () { |
|||
|
|||
} |
|||
}) |
|||
@ -1,3 +1,10 @@ |
|||
{ |
|||
"usingComponents": {} |
|||
"usingComponents": { |
|||
"van-search": "/components/search/index", |
|||
"refresh-view": "/components/refresher/index", |
|||
"van-tabs": "/components/tabs/index", |
|||
"van-divider": "/components/divider/index", |
|||
"van-loading": "/components/loading/index", |
|||
"van-cell": "/components/cell/index" |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save