Browse Source

no message

feature/v1.0
xpz2018 5 years ago
parent
commit
acec90f501
3 changed files with 100 additions and 51 deletions
  1. 116
      pages/home/customer/index.js
  2. 9
      pages/home/customer/index.json
  3. 26
      pages/home/customer/index.wxml

116
pages/home/customer/index.js

@ -1,66 +1,82 @@
// pages/home/customer/index.js // pages/home/customer/index.js
Page({
import { getFactoryOrderList, cancelOrder } from "../../../api/saas"
const util = require('../../../utils/util')
const app = getApp()
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { 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) { 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 () {
}
}) })

9
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"
}
} }

26
pages/home/customer/index.wxml

@ -2,3 +2,29 @@
<cu-custom bgColor="bg-white" isBack="{{true}}"> <cu-custom bgColor="bg-white" isBack="{{true}}">
<view slot="content">客户列表</view> <view slot="content">客户列表</view>
</cu-custom> </cu-custom>
<van-search value="{{ form.name }}" shape="round" placeholder="请输入搜索关键词" use-action-slot bind:change="onChange">
<view slot="action" bind:tap="onSearch" style="padding: 0rpx 8rpx">搜索</view>
</van-search>
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchOrderList">
<view class="list-empty" style="height:{{height}}rpx" wx:if="{{!orderList.length}}">
<view style="margin-bottom:24px" wx:if="{{loading}}">
<van-loading type="spinner" size="32" />
</view>
<image class="img-empty" src="/assets/image/list_empty.png" wx:else></image>
<view class="text-empty">{{loading? '正在加载' : '暂无数据'}}</view>
</view>
<view wx:else>
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex">
<view class="bg-white" style="padding:0rpx 32rpx" wx:if="{{pageIndex>0}}">
<view style="height:2rpx;background-color:#f3f3f3"></view>
</view>
</view>
<!--加载更多的UI-->
<van-divider content-position="center" wx:if="{{ form.pageNum > 1}}" custom-style="padding:0rpx 120rpx">
<van-loading type="spinner" size="16" wx:if="{{!finished}}" />
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text>
</van-divider>
</view>
</refresh-view>
Loading…
Cancel
Save