Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
7
7-Eleven
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
高淑倩
7-Eleven
Commits
278b9fb3
Commit
278b9fb3
authored
Jun 03, 2019
by
高淑倩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify: 优惠券列表状态判断
parent
001f8a3e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
39 deletions
+58
-39
coupons.js
src/pages/coupons/coupons.js
+56
-38
coupons.wxml
src/pages/coupons/coupons.wxml
+2
-1
No files found.
src/pages/coupons/coupons.js
View file @
278b9fb3
...
@@ -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
()
this
.
setData
({
// 可使用 or 已失效
couponList
:
this
.
data
.
pageNo
==
1
?
[...
data
.
content
]:
[...
this
.
data
.
couponList
,...
data
.
content
],
if
(
status
==
1
)
{
totalPages
:
data
.
totalPages
,
// couponList
totalElements
:
data
.
totalElements
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
(()
=>
{
}).
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
this
.
setData
({
const
{
currentTab
,
pageNo
,
pageSize
,
totalPages
,
invalidPageNo
,
invalidTotalPages
}
=
this
.
data
pageNo
:
this
.
data
.
pageNo
+
1
,
console
.
log
(
'2222'
,
currentTab
)
})
if
(
currentTab
==
0
)
{
if
(
this
.
data
.
currentTab
==
0
){
if
(
pageNo
<
totalPages
)
{
this
.
getCouponList
(
this
.
data
.
pageNo
,
this
.
data
.
pageSize
,
1
)
this
.
setData
({
}
else
{
pageNo
:
pageNo
+
1
,
this
.
getCouponList
(
this
.
data
.
pageNo
,
this
.
data
.
pageSize
,
0
)
})
}
// status 1
this
.
getCouponList
(
this
.
data
.
pageNo
,
pageSize
,
1
)
}
else
{
this
.
setData
({
noMoreCoupon
:
true
})
}
}
else
{
}
else
{
this
.
setData
({
if
(
invalidPageNo
<
invalidTotalPages
)
{
noMoreCoupon
:
true
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
src/pages/coupons/coupons.wxml
View file @
278b9fb3
...
@@ -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'>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment