Commit 278b9fb3 by 高淑倩

modify: 优惠券列表状态判断

parent 001f8a3e
......@@ -20,11 +20,14 @@ wxService.page({
],
pageNo: 1,
pageSize: 10,
invalidPageNo: 1,
totalPages: 0,
totalElements: 0,
invalidTotalElements: 0,
couponList: [],
invalidCouponList: [],
invalidTotalPages: 0,
invalidTotalElements: 0,
currentTab: 0,
noMoreCoupon: false,
noMoreCouponInvalid: false
......@@ -32,41 +35,28 @@ wxService.page({
//滑动切换
swiperTab: function (e) {
const {current} = e.detail
console.log('滑动切换', current)
this.setData({
currentTab: current
});
// 可使用
// if(current == 0){
// this.getCouponList(this.data.pageNo,this.data.pageSize,1)
// }else if( current == 1){
// // 失效
// this.getCouponList(this.data.pageNo,this.data.pageSize,0)
// }
},
// 点击切换
clickTab: function (e) {
const {current} = e.target.dataset
console.log('点击切换', current, this.data.currentTab)
if (this.data.currentTab == current) {
return false;
} else {
this.setData({
currentTab: current -0
currentTab: current
})
}
// 可使用
// if( current == 0 ){
// this.getCouponList(this.data.pageNo,this.data.pageSize,1)
// }else if( current == 1){
// // 失效
// this.getCouponList(this.data.pageNo,this.data.pageSize,0)
// }
if( current == 0 ){
this.getCouponList(1,10,1)
}else if( current == 1){
// 失效
this.getCouponList(1,10,0)
}
},
/**
* 生命周期函数--监听页面加载
......@@ -76,7 +66,7 @@ wxService.page({
* 生命周期函数--监听页面显示
*/
onShow () {
this.getCouponList(this.data.pageNo,this.data.pageSize,1)
this.getCouponList(1,10,1)
},
handelPresentCouponCode(e) {
let data = e.currentTarget.dataset
......@@ -92,15 +82,28 @@ wxService.page({
const params = {
status
}
wxService.post(`/coupon/coupon/listWithMember?number=${pageNo}&size=${pageSize}`, params).then(res => {
const {result,data} = res.data
if(result == 0){
wx.hideLoading()
this.setData({
couponList: this.data.pageNo == 1? [...data.content]: [...this.data.couponList,...data.content],
totalPages: data.totalPages,
totalElements: data.totalElements
})
// 可使用 or 已失效
if(status == 1) {
// couponList
this.setData({
couponList: this.data.pageNo == 1? [...data.content]: [...this.data.couponList,...data.content],
totalPages: data.totalPages,
totalElements: data.totalElements
})
} else {
// invalidCouponList
this.setData({
invalidCouponList: this.data.invalidPageNo == 1? [...data.content]: [...this.data.invalidCouponList,...data.content],
invalidTotalPages: data.totalPages,
invalidTotalElements: data.totalElements
})
}
}
}).finally(() => {
......@@ -115,19 +118,33 @@ wxService.page({
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
if (this.data.pageNo < this.data.totalPages) {
this.setData({
pageNo: this.data.pageNo + 1,
})
if(this.data.currentTab == 0){
this.getCouponList(this.data.pageNo,this.data.pageSize, 1)
} else {
this.getCouponList(this.data.pageNo,this.data.pageSize, 0)
}
// 可使用 0 or 已失效 1
const { currentTab, pageNo, pageSize, totalPages, invalidPageNo,invalidTotalPages } = this.data
console.log('2222',currentTab)
if(currentTab == 0) {
if ( pageNo < totalPages) {
this.setData({
pageNo: pageNo + 1,
})
// status 1
this.getCouponList(this.data.pageNo,pageSize, 1)
} else {
this.setData({
noMoreCoupon: true
})
}
} else {
this.setData({
noMoreCoupon: true
})
if ( invalidPageNo < invalidTotalPages) {
this.setData({
invalidPageNo: invalidPageNo + 1,
})
// status 0
this.getCouponList(this.data.invalidPageNo, pageSize, 0)
} else {
this.setData({
noMoreCouponInvalid: true
})
}
}
},
})
\ No newline at end of file
......@@ -4,7 +4,8 @@
<view class="swiper-tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="clickTab">可使用 ({{totalElements}})</view>
<view class="swiper-tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="clickTab">已失效 ({{invalidTotalElements}})</view>
</view>
<swiper current="{{currentTab}}" duration="300" bindchange="swiperTab">
<!--bindchange="swiperTab"-->
<swiper current="{{currentTab}}" duration="300">
<swiper-item>
<scroll-view scroll-y wx:if="{{couponList.length}}">
<view class='coupon-wrap'>
......
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