Commit 9b7e1c95 by 高淑倩

add: 订单列表分页

parent 9841d8d0
// pages/order/order.js // pages/order/order.js
Page({ const app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
const envInfo = require('../../config/index').envInfo
wxService.page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -27,7 +32,12 @@ Page({ ...@@ -27,7 +32,12 @@ Page({
name: '退款/售后' name: '退款/售后'
} }
], ],
currentIndex:1 currentIndex:1,
pageNo: 1,
pageSize:5,
noMoreFlag: false,
orderList: null,
totalPages: 0
}, },
/** /**
...@@ -41,9 +51,30 @@ Page({ ...@@ -41,9 +51,30 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
this.initOrderList(this.data.pageNo,this.data.pageSize)
}, },
initOrderList(pageNo,pageSize) {
if (this.data.noMoreFlag) { // 没有更多数据了,不调用接口
return false
}
wx.showLoading({
title: '加载中',
mask: true
})
wxService.post(`/sale/order/list?pageNo=${pageNo}&pageSize=${pageSize}`).then(res => {
if (res) {
const { result,data } = res.data
if (result == 0) {
wx.hideLoading()
this.setData({
orderList: this.data.pageNo == 1? [...data.content]: [...this.data.orderList,...data.content],
totalPages: data.totalPages
})
}
}
})
},
//点击切换tab //点击切换tab
switchTab(e){ switchTab(e){
this.setData({ this.setData({
...@@ -63,7 +94,17 @@ Page({ ...@@ -63,7 +94,17 @@ Page({
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onReachBottom: function () {
if (this.data.pageNo < this.data.totalPages) {
this.setData({
pageNo: this.data.pageNo + 1,
},()=> {
this.initOrderList(this.data.pageNo, this.data.pageSize,)
})
} else {
this.setData({
noMoreFlag: true
})
}
}, },
/** /**
......
{ {
"enablePullDownRefresh": true, "enablePullDownRefresh": true,
"navigationBarTitleText": "我的订单", "navigationBarTitleText": "我的订单",
"usingComponents": {} "usingComponents": {
"no-more": "/component/noMore/noMore"
}
} }
\ No newline at end of file
<!--pages/order/order.wxml--> <!--pages/order/order.wxml-->
<view class='page-order'> <view class='page-order'>
<view class="swiper-tab"> <view class="swiper-tab">
<view class="swiper-tab-item {{currentIndex == item.type ? 'active' : ''}}" wx:for="{{swiperItem}}" wx:key="{{index}}" bindtap="switchTab" data-type="{{item.type}}"> <view
class="swiper-tab-item {{currentIndex == item.type ? 'active' : ''}}"
wx:for="{{swiperItem}}"
wx:key="{{index}}"
bindtap="switchTab"
data-type="{{item.type}}"
>
{{item.name}} {{item.name}}
</view> </view>
</view> </view>
<scroll-view scroll-y="true"> <scroll-view scroll-y="true">
<view class="order-content"> <view class="order-content">
<block
wx:for="{{orderList}}"
wx:for-item="item"
wx:for-index="k"
wx:key="{{k}}"
>
<view class="order-list"> <view class="order-list">
<view class="order-header"> <view class="order-header">
<view class="order-number"> <view class="order-number">
<text>订单号</text> <text>订单号</text>
<text class="number">784658743657</text> <text class="number">{{item.orderNo}}</text>
</view> </view>
<text class="order-status">待付款</text> <text class="order-status">待付款</text>
</view> </view>
<view class="pro-list"> <view class="pro-list">
<image class="pro-img"></image> <image class="pro-img" />
<image class="pro-img"></image> <image class="pro-img" />
<image class="pro-img"></image> <image class="pro-img" />
<image class="pro-img"></image> <image class="pro-img" />
<text class="pro-img-dot">...</text> <text class="pro-img-dot">...</text>
</view> </view>
<view class="pro-number"> <view class="pro-number">
<text class="total-pro">共5件商品</text> <text class="total-pro">共5件商品</text>
<view class="total-price"> <view class="total-price">
实付 <text class="price">¥480</text> 实付
<text class="price">¥{{item.realPayMoney/100}}</text>
</view> </view>
</view> </view>
<view class="btn-group"> <view class="btn-group">
...@@ -38,6 +49,11 @@ ...@@ -38,6 +49,11 @@
<button class="btn btn-sm btn-default ">删除订单</button> <button class="btn btn-sm btn-default ">删除订单</button>
</view> </view>
</view> </view>
</block>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
<view class="no-bottom">
<no-more wx:if="{{noMoreFlag}}"/>
</view>
...@@ -100,12 +100,9 @@ scroll-view{ ...@@ -100,12 +100,9 @@ scroll-view{
color: #cb3c3c; color: #cb3c3c;
font-weight: 600; font-weight: 600;
} }
.no-bottom {
margin: 50rpx 0;
}
// pages/refund/refund.js // pages/refund/refund.js
Page({ const app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
const envInfo = require('../../config/index').envInfo
wxService.page({
/** /**
* 页面的初始数据 * 页面的初始数据
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment