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
{{item.name}} class="swiper-tab-item {{currentIndex == item.type ? 'active' : ''}}"
</view> wx:for="{{swiperItem}}"
</view> wx:key="{{index}}"
<scroll-view scroll-y="true"> bindtap="switchTab"
<view class="order-content"> data-type="{{item.type}}"
>
<view class="order-list"> {{item.name}}
<view class="order-header"> </view>
<view class="order-number"> </view>
<text>订单号</text> <scroll-view scroll-y="true">
<text class="number">784658743657</text> <view class="order-content">
</view> <block
<text class="order-status">待付款</text> wx:for="{{orderList}}"
</view> wx:for-item="item"
<view class="pro-list"> wx:for-index="k"
<image class="pro-img"></image> wx:key="{{k}}"
<image class="pro-img"></image> >
<image class="pro-img"></image> <view class="order-list">
<image class="pro-img"></image> <view class="order-header">
<text class="pro-img-dot">...</text> <view class="order-number">
</view> <text>订单号</text>
<view class="pro-number"> <text class="number">{{item.orderNo}}</text>
<text class="total-pro">共5件商品</text> </view>
<view class="total-price"> <text class="order-status">待付款</text>
实付 <text class="price">¥480</text> </view>
</view> <view class="pro-list">
</view> <image class="pro-img" />
<view class="btn-group"> <image class="pro-img" />
<button class="btn btn-sm btn-primary btn-outline ">立即支付</button> <image class="pro-img" />
<button class="btn btn-sm btn-default ">查看物流</button> <image class="pro-img" />
<button class="btn btn-sm btn-default ">确认收货</button> <text class="pro-img-dot">...</text>
<button class="btn btn-sm btn-primary btn-outline ">再来一单</button> </view>
<button class="btn btn-sm btn-default ">删除订单</button> <view class="pro-number">
</view> <text class="total-pro">共5件商品</text>
</view> <view class="total-price">
</view> 实付
</scroll-view> <text class="price">¥{{item.realPayMoney/100}}</text>
</view>
</view>
<view class="btn-group">
<button class="btn btn-sm btn-primary btn-outline ">立即支付</button>
<button class="btn btn-sm btn-default ">查看物流</button>
<button class="btn btn-sm btn-default ">确认收货</button>
<button class="btn btn-sm btn-primary btn-outline ">再来一单</button>
<button class="btn btn-sm btn-default ">删除订单</button>
</view>
</view>
</block>
</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