From acec90f5015100a37eddd8b037682adae08b3506 Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Tue, 2 Feb 2021 17:19:30 +0800 Subject: [PATCH] no message --- pages/home/customer/index.js | 116 +++++++++++++++++++-------------- pages/home/customer/index.json | 9 ++- pages/home/customer/index.wxml | 26 ++++++++ 3 files changed, 100 insertions(+), 51 deletions(-) diff --git a/pages/home/customer/index.js b/pages/home/customer/index.js index e44b653..6bd6c3b 100644 --- a/pages/home/customer/index.js +++ b/pages/home/customer/index.js @@ -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 () { - } }) \ No newline at end of file diff --git a/pages/home/customer/index.json b/pages/home/customer/index.json index 8835af0..a80f24f 100644 --- a/pages/home/customer/index.json +++ b/pages/home/customer/index.json @@ -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" + } } \ No newline at end of file diff --git a/pages/home/customer/index.wxml b/pages/home/customer/index.wxml index d2ddce1..6630c7e 100644 --- a/pages/home/customer/index.wxml +++ b/pages/home/customer/index.wxml @@ -2,3 +2,29 @@ 客户列表 + + + 搜索 + + + + + + + + + {{loading? '正在加载' : '暂无数据'}} + + + + + + + + + + + {{finished?'到底啦~':'加载中...'}} + + + \ No newline at end of file