Commit 9b7e1c95 by 高淑倩

add: 订单列表分页

parent 9841d8d0
// 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({
name: '退款/售后'
}
],
currentIndex:1
currentIndex:1,
pageNo: 1,
pageSize:5,
noMoreFlag: false,
orderList: null,
totalPages: 0
},
/**
......@@ -41,9 +51,30 @@ Page({
* 生命周期函数--监听页面显示
*/
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
switchTab(e){
this.setData({
......@@ -63,7 +94,17 @@ Page({
* 页面上拉触底事件的处理函数
*/
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,
"navigationBarTitleText": "我的订单",
"usingComponents": {}
"usingComponents": {
"no-more": "/component/noMore/noMore"
}
}
\ No newline at end of file
<!--pages/order/order.wxml-->
<view class='page-order'>
<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}}
</view>
</view>
<scroll-view scroll-y="true">
<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-header">
<view class="order-number">
<text>订单号</text>
<text class="number">784658743657</text>
<text class="number">{{item.orderNo}}</text>
</view>
<text class="order-status">待付款</text>
</view>
<view class="pro-list">
<image class="pro-img"></image>
<image class="pro-img"></image>
<image class="pro-img"></image>
<image class="pro-img"></image>
<image class="pro-img" />
<image class="pro-img" />
<image class="pro-img" />
<image class="pro-img" />
<text class="pro-img-dot">...</text>
</view>
<view class="pro-number">
<text class="total-pro">共5件商品</text>
<view class="total-price">
实付 <text class="price">¥480</text>
实付
<text class="price">¥{{item.realPayMoney/100}}</text>
</view>
</view>
<view class="btn-group">
......@@ -38,6 +49,11 @@
<button class="btn btn-sm btn-default ">删除订单</button>
</view>
</view>
</block>
</view>
</scroll-view>
</view>
<view class="no-bottom">
<no-more wx:if="{{noMoreFlag}}"/>
</view>
......@@ -100,12 +100,9 @@ scroll-view{
color: #cb3c3c;
font-weight: 600;
}
.no-bottom {
margin: 50rpx 0;
}
// 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