Commit 73195b5a by 谢中龙

部分页面重构

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