Commit 278b9fb3 by 高淑倩

modify: 优惠券列表状态判断

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