Commit 73195b5a by 谢中龙

部分页面重构

parent f378c3b1
...@@ -10,28 +10,56 @@ wxService.page({ ...@@ -10,28 +10,56 @@ wxService.page({
*/ */
data: { data: {
couponDetail:{}, couponDetail:{},
cardno: '' cardno: '',
couponType : '',
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow () { onShow () {
const {cardno} = this.options
this.getCouponDetail(cardno)
this.setData({
cardno
})
}, },
onLoad() { onLoad(options) {
wx.hideShareMenu(); wx.hideShareMenu();
const {cardno,type} = options
this.data.couponType = type;
this.getCouponDetail(cardno,type)
this.setData({
cardno : cardno,
couponType : type,
});
}, },
// 卡券详情 // 卡券详情
getCouponDetail(id){ getCouponDetail(id,type){
wx.showLoading({ wx.showLoading({
title: '加载中' title: '加载中'
}) });
if(!type){
this.getNormalCouponInfo(id);
}
//支付券
else if(type == 1){
this.getPayCardInfo(id);
}
//包邮券
else if(type == 2){
this.getPostalVoucherInfo(id);
}
},
//获取支付券详情
getPayCardInfo(id){
},
//获取包邮券详情
getPostalVoucherInfo(id){
},
//获取优惠券相信
getNormalCouponInfo(id){
wxService.post(`/coupon/coupon/get?cardNo=${id}`).then(res => { wxService.post(`/coupon/coupon/get?cardNo=${id}`).then(res => {
const {result,data} = res.data const {result,data} = res.data
if(result == 0){ if(result == 0){
...@@ -52,6 +80,8 @@ wxService.page({ ...@@ -52,6 +80,8 @@ wxService.page({
wx.hideLoading() wx.hideLoading()
}) })
}, },
//展示券码
handelPresentCouponCode(e) { handelPresentCouponCode(e) {
// let data = e.currentTarget.dataset // let data = e.currentTarget.dataset
const {cardno} = this.data const {cardno} = this.data
......
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
<view class='coupon-name fs-28'>{{couponDetail.couponSetting.title}}</view> <view class='coupon-name fs-28'>{{couponDetail.couponSetting.title}}</view>
<view class='coupon-desc fs-28'>{{couponDetail.coupon.startTime}} 至 {{couponDetail.coupon.endTime}}</view> <view class='coupon-desc fs-28'>{{couponDetail.coupon.startTime}} 至 {{couponDetail.coupon.endTime}}</view>
</view> </view>
<view class='coupon-code fs-24' bindtap="handelPresentCouponCode">出示券码</view> <view class='coupon-code fs-24' bindtap="handelPresentCouponCode" wx:if="{{!couponType}}">出示券码</view>
<view class='coupon-code fs-24' wx:if="{{couponType == 1}}">支付券</view>
<view class='coupon-code fs-24' wx:if="{{couponType == 2}}">包邮券</view>
</view> </view>
<view class='integral-detail'> <view class='integral-detail'>
<!-- <view class='integral-list'> <!-- <view class='integral-list'>
...@@ -30,7 +32,7 @@ ...@@ -30,7 +32,7 @@
<!--goHome--> <!--goHome-->
<go-home/> <go-home/>
<floatNav bind:getAuth="_getUserInfo" bind:updatePage="updatePage"/> <floatNav bind:getAuth="_getUserInfo" bind:updatePage="updatePage"/>
<view class="position-bottom"> <view class="position-bottom" wx:if="{{!couponType}}">
<button type='primary' class="redeem-now" bindtap='handelPresentCouponCode'>出示券码</button> <button type='primary' class="redeem-now" bindtap='handelPresentCouponCode'>出示券码</button>
</view> </view>
......
...@@ -42,10 +42,14 @@ ...@@ -42,10 +42,14 @@
color: #ffffff; color: #ffffff;
position: absolute; position: absolute;
right: 20rpx; right: 20rpx;
top: 30rpx; top: 0rpx;
width: 24rpx; width: 24rpx;
word-wrap: break-word; word-wrap: break-word;
font-weight: bold; font-weight: bold;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
} }
.integral-detail{ .integral-detail{
margin: 90rpx 0 160rpx 0; margin: 90rpx 0 160rpx 0;
......
...@@ -9,59 +9,31 @@ wxService.page({ ...@@ -9,59 +9,31 @@ wxService.page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
nav:[
{
type:'1',
name:'可使用'
},{
type:'2',
name:'已失效'
}
],
pageNo: 1,
pageSize: 10,
invalidPageNo: 1,
totalPages: 0,
totalElements: 0,
invalidTotalElements: 0,
couponList: [], couponList: [],
invalidCouponList: [],
invalidTotalPages: 0,
invalidTotalElements: 0,
currentTab: 0, currentTab: 0,
noMoreCoupon: false, noMoreCoupon: false,
noMoreCouponInvalid: false // 支付券
payCouponList : [],
//包邮券
postalVoucherList : []
}, },
//滑动切换 //滑动切换
swiperTab: function (e) { swiperTab: function (e) {
const {current} = e.detail const {current} = e.detail
if (this.data.currentTab == current) { this.tabSwitch(current);
return false;
} else {
this.setData({
currentTab: current
})
}
// 可使用
if( current == 0 ){
this.getCouponList(1,10,1)
}else if( current == 1){
// 失效
this.getCouponList(1,10,0)
}
}, },
// 点击切换 // 点击切换
clickTab: function (e) { clickTab: function (e) {
const {current} = e.target.dataset const {current} = e.target.dataset
if (this.data.currentTab == current) { this.tabSwitch(current);
return false; },
} else { //tab栏切换
tabSwitch(current){
if (this.data.currentTab == current) return false;
this.data.currentTab = current;
this.setData({ this.setData({
currentTab: current, currentTab: this.data.currentTab,
// couponList: [], // 清空数据 });
// invalidCouponList: [],
})
}
// 所有可使用优惠券 // 所有可使用优惠券
if( current == 0 ){ if( current == 0 ){
...@@ -74,7 +46,7 @@ wxService.page({ ...@@ -74,7 +46,7 @@ wxService.page({
//包邮券 //包邮券
} }
}, } ,
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
...@@ -86,12 +58,19 @@ wxService.page({ ...@@ -86,12 +58,19 @@ wxService.page({
*/ */
onShow () { onShow () {
// 可使用 已失效 // 可使用 已失效
this.getCouponList(1,10,1) this.getCouponList(1,10,1);
}, },
//跳转到卡券详情
handelPresentCouponDetail(e) { handelPresentCouponDetail(e) {
let {cardno} = e.currentTarget.dataset let {cardno,type} = e.currentTarget.dataset
wxService.router(`/pages/couponDetail/couponDetail`).search({cardno}) if(type){
wxService.router(`/pages/couponDetail/couponDetail`).search({cardno:cardno,type:type});
}
else{
wxService.router(`/pages/couponDetail/couponDetail`).search({cardno:cardno});
}
}, },
//
handelPresentCouponCode(e) { handelPresentCouponCode(e) {
let {cardno} = e.currentTarget.dataset let {cardno} = e.currentTarget.dataset
wxService.router(`/pages/couponCodeDetail/couponCodeDetail`).search({cardno}) wxService.router(`/pages/couponCodeDetail/couponCodeDetail`).search({cardno})
...@@ -99,59 +78,32 @@ wxService.page({ ...@@ -99,59 +78,32 @@ wxService.page({
//获取优惠券列表 //获取优惠券列表
getCouponList(pageNo,pageSize,statusNum){ getCouponList(pageNo,pageSize,statusNum){
//获取我的优惠券
wx.showLoading({ wx.showLoading({
title: '加载中' title: '加载中'
}) });
let params;
if(statusNum == 1){ let params = {};
params = { params.status = 1;
status: 1 this.data.couponList = [];
}
if(pageNo == 1){
this.setData({
pageNo: 1,
couponList: [], // 清空数据
})
}
} else {
params = {
statusNot: 1
}
if(pageNo == 1){
this.setData({
invalidCouponList: [],
invalidPageNo: 1
})
}
}
wxService.post(`/coupon/coupon/listWithMember4Mina?number=${pageNo}&size=${pageSize}`, params).then(res => { wxService.post(`/coupon/coupon/listWithMember4Mina?number=1&size=1000000`, params).then(res => {
if(!res) return false if(!res) return false
const {result,data} = res.data const {result,data} = res.data
if(result == 0){ if(result == 0){
console.log(res)
wx.hideLoading() wx.hideLoading()
// 处理时间显示 // 处理时间显示
if(!data.content) return false if(!data.content) return false
data.content.forEach(item=> { data.content.forEach(item=> {
item.startTime = item.startTime.substring(0,10) item.startTime = item.startTime.substring(0,10)
item.endTime = item.endTime.substring(0,10) item.endTime = item.endTime.substring(0,10)
}) });
// 可使用 or 已失效
if(statusNum == 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({ this.setData({
invalidCouponList: this.data.invalidPageNo == 1? [...data.content]: [...this.data.invalidCouponList,...data.content], couponList: data.content,
invalidTotalPages: data.totalPages, });
invalidTotalElements: data.totalElements
})
}
} }
}).finally(() => { }).finally(() => {
...@@ -167,29 +119,6 @@ wxService.page({ ...@@ -167,29 +119,6 @@ wxService.page({
}, },
//scoll view 触到底部 //scoll view 触到底部
onBottom(){ onBottom(){
const { currentTab, pageNo, pageSize, totalPages, invalidPageNo, invalidTotalPages } = this.data
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({
noMoreCouponInvalid: true
})
}
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
}, },
}) })
\ No newline at end of file
...@@ -40,23 +40,22 @@ ...@@ -40,23 +40,22 @@
</view> </view>
</view> </view>
</view> </view>
<no-more wx:if="{{noMoreCoupon}}" />
</scroll-view> </scroll-view>
<view class='empty-wrap' wx:if="{{!couponList.length}}"> <view class='empty-wrap' wx:if="{{!couponList.length}}">
<view class='empty-info'> <view class='empty-info'>
<image class='empty-img' <image class='empty-img'
src='https://img3.bigaka.com/prd/3001/202003/20200309/30012bce7628-f373-4fa7-a6a4-ada9c1c721d6.png' /> src='https://img3.bigaka.com/prd/3001/202003/20200309/30012bce7628-f373-4fa7-a6a4-ada9c1c721d6.png' />
<view class='empty-text'>没有任何卡劵</view> <view class='empty-text'>没有任何优惠券~</view>
</view> </view>
</view> </view>
</swiper-item> </swiper-item>
<!-- 微信支付券 --> <!-- 微信支付券 -->
<swiper-item> <swiper-item>
<scroll-view scroll-y wx:if="{{couponList.length}}"> <scroll-view scroll-y wx:if="{{payCouponList.length}}">
<view class='coupon-wrap'> <view class='coupon-wrap'>
<view <view
class='coupon-list' class='coupon-list'
wx:for="{{couponList}}" wx:for="{{payCouponList}}"
wx:for-item="item" wx:for-item="item"
wx:for-index="k" wx:for-index="k"
wx:key="*this"> wx:key="*this">
...@@ -64,6 +63,7 @@ ...@@ -64,6 +63,7 @@
data-title="{{item.title}}" data-title="{{item.title}}"
data-cardNo="{{item.cardNo}}" data-cardNo="{{item.cardNo}}"
data-id="{{item.couponId}}" data-id="{{item.couponId}}"
data-type="1"
bindtap="handelPresentCouponDetail" bindtap="handelPresentCouponDetail"
> >
<image class='coupon-bg' <image class='coupon-bg'
...@@ -81,24 +81,23 @@ ...@@ -81,24 +81,23 @@
</view> </view>
</view> </view>
</view> </view>
<no-more wx:if="{{noMoreCoupon}}" />
</scroll-view> </scroll-view>
<view class='empty-wrap' wx:if="{{!couponList.length}}"> <view class='empty-wrap' wx:if="{{!payCouponList.length}}">
<view class='empty-info'> <view class='empty-info'>
<image class='empty-img' <image class='empty-img'
src='https://img3.bigaka.com/prd/3001/202003/20200309/30012bce7628-f373-4fa7-a6a4-ada9c1c721d6.png' /> src='https://img3.bigaka.com/prd/3001/202003/20200309/30012bce7628-f373-4fa7-a6a4-ada9c1c721d6.png' />
<view class='empty-text'>没有任何卡劵</view> <view class='empty-text'>没有任何支付券~</view>
</view> </view>
</view> </view>
</swiper-item> </swiper-item>
<!-- 包邮券 --> <!-- 包邮券 -->
<swiper-item> <swiper-item>
<scroll-view scroll-y wx:if="{{couponList.length}}"> <scroll-view scroll-y wx:if="{{postalVoucherList.length}}">
<view class='coupon-wrap'> <view class='coupon-wrap'>
<view <view
class='coupon-list' class='coupon-list'
wx:for="{{couponList}}" wx:for="{{postalVoucherList}}"
wx:for-item="item" wx:for-item="item"
wx:for-index="k" wx:for-index="k"
wx:key="{{k}}" wx:key="{{k}}"
...@@ -107,6 +106,7 @@ ...@@ -107,6 +106,7 @@
data-title="{{item.title}}" data-title="{{item.title}}"
data-cardNo="{{item.cardNo}}" data-cardNo="{{item.cardNo}}"
data-id="{{item.couponId}}" data-id="{{item.couponId}}"
data-type="2"
bindtap="handelPresentCouponDetail" bindtap="handelPresentCouponDetail"
> >
<image class='coupon-bg' <image class='coupon-bg'
...@@ -124,14 +124,13 @@ ...@@ -124,14 +124,13 @@
</view> </view>
</view> </view>
</view> </view>
<no-more wx:if="{{noMoreCoupon}}" />
</scroll-view> </scroll-view>
<view class='empty-wrap' wx:if="{{!couponList.length}}"> <view class='empty-wrap' wx:if="{{!postalVoucherList.length}}">
<view class='empty-info'> <view class='empty-info'>
<image class='empty-img' <image class='empty-img'
src='https://img3.bigaka.com/prd/3001/202003/20200309/30012bce7628-f373-4fa7-a6a4-ada9c1c721d6.png' /> src='https://img3.bigaka.com/prd/3001/202003/20200309/30012bce7628-f373-4fa7-a6a4-ada9c1c721d6.png' />
<view class='empty-text'>没有任何卡劵</view> <view class='empty-text'>没有任何包邮券~</view>
</view> </view>
</view> </view>
</swiper-item> </swiper-item>
......
...@@ -56,8 +56,6 @@ wxService.page({ ...@@ -56,8 +56,6 @@ wxService.page({
if (res) { if (res) {
let obj = res.data.data ? res.data.data : null; let obj = res.data.data ? res.data.data : null;
if (obj) { if (obj) {
console.log(obj)
obj.activityDesc = obj.definition ? JSON.parse(obj.definition) : []; obj.activityDesc = obj.definition ? JSON.parse(obj.definition) : [];
obj.acPayMoney = parseFloat(obj.buyPrice / 10 / 10).toFixed(2); obj.acPayMoney = parseFloat(obj.buyPrice / 10 / 10).toFixed(2);
...@@ -159,18 +157,21 @@ wxService.page({ ...@@ -159,18 +157,21 @@ wxService.page({
signType: wxParams.signType, signType: wxParams.signType,
paySign: wxParams.paySign, paySign: wxParams.paySign,
success: res => { success: res => {
wx.showToast({ wx.showModal({
title: '支付成功!', title: '购买成功提示',
}); content: '购买成功,是否到我的优惠券中查看?',
wx.showLoading({ showCancel: true,
title: '跳转中...', cancelText: '取消',
}); confirmText: '确认',
setTimeout(() => { confirmColor: '#cb3c3c',
wx.hideLoading(); success: function (modalRes) {
if (modalRes.confirm) {
wx.navigateTo({ wx.navigateTo({
url: '/pages/coupons/coupons', url: '/pages/coupons/coupons',
}); });
}, 500); }
}
});
}, },
fail: error => { fail: error => {
wx.showToast({ wx.showToast({
......
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