Authored by 肖亚东

优惠券等开发

Showing 46 changed files with 1971 additions and 36 deletions
... ... @@ -52,7 +52,44 @@ App({
let userInfo = getYHStorageSync('userInfo', 'app');
this.globalData.userInfo = userInfo || {};
},
/*
*union_type表示渠道号,在推广阶段通过商品详情页等传入。
* 接收到该参数时,赋值给全局变量时,持久化到本地。
* 在取值时,先从全局变量获取,若未获取到则从本地缓存中获取。
* 时效7天
*/
getUnion_type: function () {
try {
var value = this.checkUnion_type(this.globalData.union_type, this.globalData.union_type_time);
if (!value) {
let union_type = getYHStorageSync('union_type', 'app') ? getYHStorageSync('union_type', 'app'):"";
let union_type_time = getYHStorageSync('union_type_time', 'app') ? getYHStorageSync('union_type_time', 'app'):"";
value = this.checkUnion_type(union_type, union_type_time);
}
return value
} catch (e) {
// console.log(e)
}
},
checkUnion_type: function (union_type, union_type_time) {
if (!union_type)return '';
let time_old = union_type_time;
let time_new = new Date().getTime() + '';
var dayDiff = parseInt ((parseInt(time_new) - parseInt(time_old)) / 1000 );
if (dayDiff > 7 * 24 * 3600) {
return '';
}
return union_type;
},
getUnionID: function () {
var value = getYHStorageSync('unionID','app')
if (value) {
this.globalData.WXUnion_ID = value;
}
},
isLogin: function () {
return this.globalData.userInfo.uid > 0 ? true : false
},
... ...
... ... @@ -29,7 +29,9 @@
"login/bind-phone-number/bind-phone-number",
"login/select-country/select-country",
"pages/invoice/invoice",
"pages/userCenter/goodsCollect/goodsCollect"
"pages/userCenter/goodsCollect/goodsCollect",
"pages/couponList/couponList",
"pages/useCoupons/useCoupons"
],
"window":{
"navigationBarBackgroundColor": "#3a3a3a",
... ...
// page/subPackage/pages/couponList/couponCell.js
Component({
/**
* 组件的属性列表
*/
properties: {
item: {
type: Object,
},
itemType: {
type: Number,//0:可用 1: 不可用 2:未使用 3:已使用 4:已过期 5:可用 6:不可用
},
itemAvailableed: {
type: Number,
},
},
/**
* 组件的初始数据
*/
data: {
showComment: false,
},
/**
* 组件的方法列表
*/
methods: {
showCommentTap: function(e) {
let showComment = !this.data.showComment;
this.setData({
showComment,
})
},
selectCouponTap: function (e) {
if (this.properties.itemType == 5 && this.properties.item.is_selected_support == 'Y') {
this.triggerEvent('didSelectCoupon', this.properties.item.coupon_code);
}
},
useButtonTap: function (e) {
this.triggerEvent('useButtonTap', this.properties.item);
}
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class='couponCell' catchtap='selectCouponTap'>
<view class='couponCellLeftView'>
<block wx:if="{{item.catalog == 100}}">
<image class="couponCellLeftBackImage" src="{{itemAvailableed==1 ? './images/bgyellow@3x.png' : './images/bggrey@3x.png'}}"/>
</block>
<block wx:if="{{item.catalog == 200}}">
<image class="couponCellLeftBackImage" src="{{itemAvailableed==1 ? './images/bgred@3x.png' : './images/bggrey@3x.png'}}"/>
</block>
<block wx:if="{{item.catalog == 300}}">
<image class="couponCellLeftBackImage" src="{{itemAvailableed==1 ? './images/bgblack@3x.png' : './images/bggrey@3x.png'}}"/>
</block>
<view class='couponCellLeft' style="box-shadow:{{!showComment ? '0 0 0 0 #E0E0E0;' : '0 4px 5px -3px #E0E0E0;'}}" >
<block wx:if="{{item.catalog == 100}}">
<view class='priceView'>
<text class='price' style="color: {{itemAvailableed==1 ? '#FFA72E' : '#B0B0B0'}};">{{item.coupon_value_str}}</text>
</view>
<text class='priceDetail' style="color: {{itemAvailableed==1 ? '#FFA72E' : '#B0B0B0'}};">{{item.use_rule}}</text>
</block>
<block wx:if="{{item.catalog == 200}}">
<view class='priceView'>
<text class='price' style="color: {{itemAvailableed==1 ? '#FC5960' : '#B0B0B0'}};">{{item.coupon_value_str}}</text>
</view>
<text class='priceDetail' style="color: {{itemAvailableed==1 ? '#FC5960' : '#B0B0B0'}};">{{item.use_rule}}</text>
</block>
<block wx:if="{{item.catalog == 300}}">
<text class='yunfeiName' style="color: {{itemAvailableed==1 ? '#222222': '#B0B0B0'}};">{{item.coupon_value_str}}</text>
</block>
</view>
</view>
<view class='couponCellRightView' style="box-shadow:{{!showComment ? '0 0 0 0 #E0E0E0;' : '0 4px 5px -3px #E0E0E0;'}}" >
<image class="couponCellRightViewBackImage" src="./images/bg@3x.png"/>
<view class='couponCellRight'>
<view class='couponCellRightTop' style="color: {{itemAvailableed==1 ? '#444444' : '#B0B0B0'}};">
<block wx:if="{{item.catalog == 100}}">
<text class='couponIcon' style="color: {{itemAvailableed==1 ? '#FFA72E' : '#B0B0B0'}};">[{{item.catalog_name}}]</text>
</block>
<block wx:if="{{item.catalog == 200}}">
<text class='couponIcon' style="color: {{itemAvailableed==1 ? '#FC5960' : '#B0B0B0'}};">[{{item.catalog_name}}]</text>
</block>
<block wx:if="{{item.catalog == 300}}">
<text class='couponIcon' style="color: {{itemAvailableed==1 ? '#222222' : '#B0B0B0'}};">[{{item.catalog_name}}]</text>
</block>
{{item.coupon_name}}
</view>
<view class='couponCellRightMiddle'>
<text class='time' style='color: #B0B0B0;'>{{item.coupon_validity}}</text>
</view>
<view class='couponCellRightBottom'>
<block wx:if="{{itemType==5 || itemType==6}}">
<view class='commentViewButton'>
<text class='commentDesText' style="color: {{itemType==5 ? '#444444;':'#B0B0B0'}}">{{item.desc}}</text>
</view>
</block>
<block wx:else>
<view class='commentViewButton' catchtap='showCommentTap'>
<text class='commentButtonText' style='color: #B0B0B0;'>使用说明</text>
<image class="arrowIcon" style="transform: rotate({{!showComment ? '0':'180'}}deg);" src="./images/down@3x.png"/>
</view>
<text class='useButton' catchtap='useButtonTap' wx:if="{{itemType==2 && item.is_online_avail}}">立即使用</text>
</block>
<image class="rightIcon" wx:if="{{itemType==3 || itemType==4}}" src="{{itemType==3 ? './images/yishiyong@3x.png' : './images/guoqi@3x.png'}}"/>
<block wx:if="{{itemType==5 && item.is_selected_support == 'N'}}">
<view class='selectIconView'>
<image class="selectIcon" src="{{'./images/grey@3x.png'}}"/>
</view>
</block>
<block wx:if="{{itemType==5 && item.is_selected_support == 'Y'}}">
<view class='selectIconView'>
<image class="selectIcon" src="{{item.selected == 'Y' ? './images/gou@3x.png' : './images/Oval@3x.png'}}"/>
</view>
</block>
</view>
</view>
</view>
<block wx:if="{{item.is_overdue_soon == 'Y'}}">
<image class="overduSoonIcon" src="./images/tip@3x.png"/>
</block>
</view>
<view class='commentView' wx:if="{{showComment}}">
<view style="background: rgba(255, 255, 255, 0.7);width: 100%;height: 22rpx "/>
<block wx:for='{{item.notes}}' wx:key='{{index}}'>
<text class='commentText1' style="color: {{itemAvailableed==1 ? '#444444' : '#B0B0B0'}};">{{item}}</text>
</block>
</view>
... ...
.couponCell {
width: 710rpx;
height: 200rpx;
display: flex;
flex-direction: row;
margin-left: 20rpx;
}
.couponCell .couponCellLeftView {
position:relative;
z-index: 800;
display: flex;
width: 220rpx;
height: 200rpx;
}
.couponCell .couponCellLeftView .couponCellLeft {
width: 220rpx;
height: 200rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 900;
}
.couponCell .couponCellLeftView .couponCellLeftBackImage {
width: 220rpx;
height: 200rpx;
position: absolute;
margin-top: 0rpx;
z-index: 120;
}
.couponCell .couponCellLeftView .couponCellLeft .priceView {
display: flex;
flex-direction: row;
align-items: flex-end;
}
.couponCell .couponCellLeftView .couponCellLeft .yunfeiName {
text-overflow:ellipsis;
display: block;
overflow: hidden;
white-space: nowrap;
font-family: PingFang-SC-Medium;
font-size: 48rpx;
letter-spacing: -0.67px;
}
.couponCell .couponCellLeftView .couponCellLeft .priceView .priceIcon {
text-overflow:ellipsis;
display: block;
overflow: hidden;
white-space: nowrap;
font-family: PingFang-SC-Semibold;
font-size: 28rpx;
letter-spacing: -0.39px;
}
.couponCell .couponCellLeftView .couponCellLeft .priceView .price {
text-overflow:ellipsis;
display: block;
white-space: nowrap;
font-family: PingFang-SC-Semibold;
font-size: 72rpx;
letter-spacing: -0.39px;
line-height: 70rpx;
margin-left: 5rpx;
max-width: 170rpx;
word-break:break-all;
display:-webkit-box;
-webkit-line-clamp:1;
-webkit-box-orient:vertical;
overflow:hidden;
}
.couponCell .couponCellLeftView .couponCellLeft .priceDetail {
font-family: PingFang-SC-Regular;
font-size: 24rpx;
letter-spacing: 0;
margin-top: 10rpx;
}
.couponCell .couponCellRightView {
width: 490rpx;
height: 200rpx;
display: flex;
position:relative;
z-index: 800;
}
.couponCell .couponCellRightView .couponCellRightViewBackImage{
width: 490rpx;
height: 200rpx;
position: absolute;
margin-top: 0rpx;
z-index: 120;
margin-left: -1rpx;
}
.couponCell .couponCellRightView .couponCellRight {
width: 480rpx;
height: 180rpx;
display: flex;
flex-direction: column;
margin-top: 20rpx;
margin-left: 10rpx;
z-index: 900;
}
.couponCell .couponCellRightView .couponCellRight .couponCellRightTop {
width: 400rpx;
height: 72rpx;
display: flex;
flex-direction: row;
font-family: PingFang-SC-Regular;
font-size: 24rpx;
letter-spacing: 0;
line-height: 36rpx;
word-break:break-all;
display:-webkit-box;
-webkit-line-clamp:2;
-webkit-box-orient:vertical;
overflow:hidden;
}
.couponCell .couponCellRightView .couponCellRight .couponCellRightTop .couponIcon{
font-family: PingFang-SC-Medium;
font-size: 24rpx;
letter-spacing: 0;
/* margin-left: 10rpx; */
}
.couponCell .couponCellRightView .couponCellRight .couponCellRightMiddle {
width: 400rpx;
height: 32rpx;
display: flex;
flex-direction: row;
}
.couponCell .couponCellRightView .couponCellRight .couponCellRightMiddle .time {
font-family: PingFang-SC-Regular;
font-size: 22rpx;
letter-spacing: 0;
}
.couponCell .couponCellRightView .couponCellRight .couponCellRightBottom {
width: 480rpx;
height: 60rpx;
display: flex;
flex-direction: row;
align-items: flex-end;
justify-content: space-between;
margin-top: 5rpx;
}
.couponCell .couponCellRightView .couponCellRight .couponCellRightBottom .commentViewButton {
display: flex;
flex-direction: row;
align-items: center;
}
.couponCell .couponCellRightView .couponCellRight .couponCellRightBottom .commentViewButton .commentButtonText {
font-family: PingFang-SC-Regular;
font-size: 22rpx;
letter-spacing: 0;
margin-bottom: 5rpx;
}
.couponCell .couponCellRightView .couponCellRight .couponCellRightBottom .commentViewButton .commentDesText {
word-break:break-all;
display:-webkit-box;
-webkit-line-clamp:2;
-webkit-box-orient:vertical;
overflow:hidden;
line-height: 26rpx;
font-family: PingFang-SC-Regular;
font-size: 20rpx;
letter-spacing: 0;
}
.couponCell .couponCellRightView .couponCellRight .couponCellRightBottom .commentViewButton .arrowIcon {
width: 27rpx;
height: 18rpx;
margin-left: 10rpx;
margin-bottom: 5rpx;
}
.couponCell .couponCellRightView .couponCellRight .couponCellRightBottom .useButton {
width: 128rpx;
height: 48rpx;
font-family: PingFang-SC-Medium;
font-size: 22rpx;
letter-spacing: 0;
margin-right: 22rpx;
border-radius: 76rpx;
border:1px solid #444444;
align-items: center;
justify-content: center;
display: flex;
color: #444444;
margin-bottom: 5rpx;
}
.couponCell .couponCellRightView .couponCellRight .rightIcon {
width: 126rpx;
height: 114rpx;
margin-bottom: 30rpx;
margin-right: 20rpx;
}
.couponCell .couponCellRightView .couponCellRight .selectIconView {
width: 100rpx;
height: 160rpx;
margin-right: 30rpx;
display: flex;
align-items: center;
justify-content: flex-end;
}
.couponCell .couponCellRightView .couponCellRight .selectIconView .selectIcon {
width: 40rpx;
height: 40rpx;
margin-bottom: 5rpx;
}
.couponCell .overduSoonIcon {
width: 86rpx;
height: 86rpx;
position: absolute;
margin-top: 0rpx;
right: 20rpx;
z-index: 997;
display: flex;
}
.commentView {
width: 710rpx;
height: 160rpx;
margin-left: 20rpx;
background: rgba(255, 255, 255, 0.7);
display: flex;
flex-direction: column;
margin-top: -10rpx;
}
.commentView .commentText1{
font-family: PingFang-SC-Regular;
font-size: 22rpx;
letter-spacing: 0;
line-height: 32rpx;
word-break:break-all;
display:-webkit-box;
-webkit-line-clamp:1;
-webkit-box-orient:vertical;
overflow:hidden;
margin-top: 8rpx;
margin-left: 26rpx;
max-width: 670rpx;
}
.commentView .commentText2{
font-family: PingFang-SC-Regular;
font-size: 22rpx;
letter-spacing: 0;
line-height: 32rpx;
word-break:break-all;
display:-webkit-box;
-webkit-line-clamp:2;
-webkit-box-orient:vertical;
overflow:hidden;
margin-top: 8rpx;
margin-left: 26rpx;
max-width: 670rpx;
}
\ No newline at end of file
... ...
// page/subPackage/pages/couponList/couponFilter.js
Component({
/**
* 组件的属性列表
*/
properties: {
customIndex: {
type: Number,
value: 0,
observer: 'propertyChange'
},
filters: {
type: Array,
value: [],
}
},
/**
* 组件的初始数据
*/
data: {
selectIndex: 1,
},
/**
* 组件的方法列表
*/
methods: {
propertyChange: function (newVal, oldVal) {
let selectIndex = newVal;
this.setData({ selectIndex });
},
selectTapped: function (event) {
let selectIndex = event.currentTarget.dataset.type;
let item = event.currentTarget.dataset.item;
if (item) {
item.selectIndex = selectIndex;
}
this.setData({ selectIndex });
this.triggerEvent('didSelectFliter', item);
}
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--page/subPackage/pages/couponList/couponFilter.wxml-->
<view class='con'>
<view class='backV'>
<block wx:for='{{filters}}' wx:key='{{index}}'>
<view class="{{selectIndex == index+1 ? 'buttonSelected' : 'buttonNormal'}}" style="background: {{selectIndex == index+1 ? '#444444' : 'white'}};color: {{selectIndex == index+1 ? 'white' : '#444444'}};" data-type="{{index+1}}" data-item="{{item}}" bindtap="selectTapped">{{item.filter_name}}</view>
</block>
<!-- <view class="{{selectIndex == 1 ? 'buttonSelected' : 'buttonNormal'}}" style="background: {{selectIndex == 1 ? '#444444' : 'white'}};color: {{selectIndex == 1 ? 'white' : '#444444'}};" data-type='1' bindtap="selectTapped">全部</view>
<view class="{{selectIndex == 2 ? 'buttonSelected' : 'buttonNormal'}}" style="background: {{selectIndex == 2 ? '#444444' : 'white'}};color: {{selectIndex == 2 ? 'white' : '#444444'}};" data-type='2' bindtap="selectTapped">店铺卷</view>
<view class="{{selectIndex == 3 ? 'buttonSelected' : 'buttonNormal'}}" style="background: {{selectIndex == 3 ? '#444444' : 'white'}};color: {{selectIndex == 3 ? 'white' : 'v'}};" data-type='3' bindtap="selectTapped">活动卷</view>
<view class="{{selectIndex == 4 ? 'buttonSelected' : 'buttonNormal'}}" style="background: {{selectIndex == 4 ? '#444444' : 'white'}};color: {{selectIndex == 4 ? 'white' : '#444444'}};" data-type='4' bindtap="selectTapped">运费劵</view> -->
</view>
<view class='mask' data-type='-1' data-item="" bindtap="selectTapped">
</view>
</view>
\ No newline at end of file
... ...
.con {
margin-top: 90rpx;
position: fixed;
z-index: 1000;
display: flex;
flex-direction: column;
}
.con .backV {
width: 750rpx;
height: 130rpx;
display: flex;
flex-direction: row;
align-items: center;
background: white;
}
.buttonNormal {
width: 150rpx;
height: 70rpx;
font-family: PingFang-SC-Medium;
font-size: 28rpx;
letter-spacing: 0;
display: flex;
align-items: center;
justify-content: center;
margin-left: 30rpx;
border: 1rpx solid #E0E0E0;
border-radius: 2px;
}
.buttonSelected {
width: 150rpx;
height: 70rpx;
font-family: PingFang-SC-Medium;
font-size: 28rpx;
letter-spacing: 0;
display: flex;
align-items: center;
justify-content: center;
margin-left: 30rpx;
border: 1rpx solid #E0E0E0;
border-radius: 2px;
}
.con .mask {
width: 100%;
height: 2000rpx;
background-color: rgba(0, 0, 0, 0.4);
}
\ No newline at end of file
... ...
// pages/couponList/couponList.js
import api from '../../common/api.js';
let app = getApp();
const screenHeight = app.globalData.systemInfo.screenHeight;
Page({
/**
* 页面的初始数据
*/
data: {
currentFixedFilterIndex: 0,// 0已使用,1:未使用,2:过期
showFliter: false,
selectedSearchFliterIndex: 1,//筛选项Index
screenHeight,
filters: [],
useCoupons: {
page: 0,
limit: 20,
list: [],
isLast: false,
filter: 0, //优惠券过滤:0/null:无; 1:店铺券; 2:活动券; 3:免邮券
useType: 'use',
totleNum: 0,
totleText: '0',
},//已使用
notuseCoupons: {
page: 0,
limit: 20,
list: [],
isLast: false,
filter: 0,//优惠券过滤:0/null:无; 1:店铺券; 2:活动券; 3:免邮券
useType: 'notuse',
totleNum: 0,
totleText: '0',
},//未使用
overtimeCoupons: {
page: 0,
limit: 20,
list: [],
isLast: false,
filter: 0,//优惠券过滤:0/null:无; 1:店铺券; 2:活动券; 3:免邮券
useType: 'overtime',
totleNum: 0,
totleText: '0',
},//过期
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getCouponList(this.data.notuseCoupons,true);
this.getCouponNums();
let that = this;
wx.getSystemInfo({
success: function (res) {
// console.info(res.windowHeight);
that.setData({
scHeight: res.windowHeight
});
}
});
},
getCouponNums: function (params, reload) {
//如果用户未登录,则不调用获取优惠券相关接口
if (!app.getUid()) {
return;
}
let that = this;
let param = {
method: 'app.coupons.getCouponNums',
uid: app.getUid(),
};
api.get({data: param})
.then(json => {
if (json && json.code == 200 && json.data) {
let notuse = json.data.notuse > 99 ? '99+' : json.data.notuse;
let use = json.data.use > 99 ? '99+' : json.data.use;
let overtime = json.data.overtime > 99 ? '99+' : json.data.overtime;
let useCoupons = that.data.useCoupons;
useCoupons.totleText = use;
useCoupons.totleNum = json.data.use ? json.data.use : 0;
let notuseCoupons = that.data.notuseCoupons;
notuseCoupons.totleText = notuse;
notuseCoupons.totleNum = json.data.notuse ? json.data.notuse : 0;
let overtimeCoupons = that.data.overtimeCoupons;
overtimeCoupons.totleText = overtime;
overtimeCoupons.totleNum = json.data.overtime ? json.data.overtime : 0;
that.setData({ useCoupons, notuseCoupons, overtimeCoupons });
}
})
.catch(error => {
// console.log(error)
})
},
getCouponList: function (params,reload) {
//如果用户未登录,则不调用获取优惠券相关接口
if (!app.getUid()) {
return;
}
if (reload) {
params.page = 0;
params.list = [];
params.isLast = false;
}
let that = this;
let param = {
method: 'app.coupons.get',
uid: app.getUid(),
type: params.useType,
filter: params.filter,
limit: params.limit,
page: params.page + 1,
};
api.get({data: param})
.then(json => {
if (json && json.code == 200 && json.data) {
if (that.data.currentFixedFilterIndex == 0) {
let notuseCoupons = that.data.notuseCoupons;
let list = notuseCoupons.list;
list = list.concat(json.data.couponList ? json.data.couponList : []);
notuseCoupons.list = list;
notuseCoupons.page = param.page;
notuseCoupons.filter = params.filter;
notuseCoupons.isLast = list.length == json.data.total ? true : false;
let filters = json.data.filters ? json.data.filters : [];
that.setData({ notuseCoupons, filters});
} else if (that.data.currentFixedFilterIndex == 1) {
let useCoupons = that.data.useCoupons;
let list = useCoupons.list;
list = list.concat(json.data.couponList ? json.data.couponList:[]);
useCoupons.page = param.page;
useCoupons.list = list;
useCoupons.filter = params.filter;
useCoupons.isLast = list.length == json.data.total ? true : false;
that.setData({ useCoupons });
} else if (that.data.currentFixedFilterIndex == 2) {
let overtimeCoupons = that.data.overtimeCoupons;
let list = overtimeCoupons.list;
list = list.concat(json.data.couponList ? json.data.couponList : []);
overtimeCoupons.page = param.page;
overtimeCoupons.list = list;
overtimeCoupons.filter = params.filter;
overtimeCoupons.isLast = list.length == json.data.total ? true : false;
that.setData({ overtimeCoupons });
}
}
})
.catch(error => {
// console.log(error)
})
},
selectFliterContent: function (event) {
if (this.data.currentFixedFilterIndex == 0) {
let showFliter = !this.data.showFliter;
this.setData({ showFliter });
}
},
didSelectFliter: function (event) {
let item = event.detail;
if (item) {
let selectedSearchFliterIndex = item.selectIndex;
let showFliter = !this.data.showFliter;
if (selectedSearchFliterIndex == -1) {
selectedSearchFliterIndex = this.data.selectedSearchFliterIndex;
}
this.setData({
showFliter,
selectedSearchFliterIndex
});
if (this.data.currentFixedFilterIndex == 0) {
let notuseCoupons = this.data.notuseCoupons
notuseCoupons.filter = event.detail.filter_id;
this.getCouponList(notuseCoupons, true);
}
} else{
let showFliter = !this.data.showFliter;
this.setData({
showFliter,
});
}
},
useButtonTap: function (e) {
let couponCode = e.detail.coupon_code;
let couponId = e.detail.coupon_id;
let couponTitle = e.detail.coupon_name;
wx.navigateTo({
url: '../../../../pages/goodsList/PromotionList?' + 'page_name=coupon' + '&coupon_id=' + couponId + '&coupon_code=' + couponCode + '&promotionTitle=' + '以下商品可使用' + couponTitle + '的优惠券' + '&title=优惠活动商品' + '&page_param' + '',
})
},
fixedFilterTapped: function (event) {
let currentFixedFilterIndex = event.currentTarget.dataset.type;
let showFliter = this.data.showFliter;
showFliter = currentFixedFilterIndex != this.data.currentFixedFilterIndex ? false : showFliter;
this.setData({ currentFixedFilterIndex, showFliter});
let item = this.data.notuseCoupons;
if (currentFixedFilterIndex == 0) {
item = this.data.notuseCoupons
} else if (currentFixedFilterIndex == 1) {
item = this.data.useCoupons
} else if (currentFixedFilterIndex == 2) {
item = this.data.overtimeCoupons
}
if (item.list.length == 0){
this.getCouponList(item, true);
}
},
duihuanTapped: function (event) {
let inputValue = event.detail;
this.bindPCoupon(inputValue);
},
loadMore: function(event) {
let item = this.data.notuseCoupons;
if (this.data.currentFixedFilterIndex == 0) {
item = this.data.notuseCoupons
} else if (this.data.currentFixedFilterIndex == 1) {
item = this.data.useCoupons
} else if (this.data.currentFixedFilterIndex == 2) {
item = this.data.overtimeCoupons
}
// console.log(item)
if (!item.isLast) {
this.getCouponList(item, false);
}
},
bindPCoupon: function (inputValue) {
let that = this;
if (app.getUid()) {
let param = {
method: 'app.coupons.bindPCoupon',
uid: app.getUid(),
fromPage: 'iFP_Coupon',
coupon_code: inputValue ? inputValue : '',
};
api.get({data: param})
.then(function (data) {
if (data && data.code == 200) {
wx.showToast({
title: '优惠券兑换成功!',
icon:'success',
duration:2000
})
that.getCouponList(that.data.notuseCoupons, true);
that.getCouponNums();
} else {
wx.showModal({
content: data.message,
showCancel: false,
confirmText: "确定",
});
}
})
.catch(function (error) {
});
} else {
wx.showModal({
content: "请先登录!",
showCancel: false,
confirmText: "确定",
});
}
},
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "优惠券",
"usingComponents": {
"couponCell": "./couponCell",
"couponSearch": "./couponSearch",
"couponFilter": "../couponList/couponFilter",
"empty": "../couponList/empty"
}
}
\ No newline at end of file
... ...
<view class='coupon_container'>
<view class='coupon_header'>
<view class="{{currentFixedFilterIndex == 0 ? 'filterSelect' : 'filterNormal'}}" data-type='0' catchtap='fixedFilterTapped' style='margin-left: 27rpx;'>未使用 ({{notuseCoupons.totleText}})
<view class='arrowIconView' catchtap='selectFliterContent'>
<block wx:if="{{currentFixedFilterIndex == 0}}">
<image class="arrowIcon" src="{{showFliter ? './images/blackupa@3x.png' : './images/blackdwona@3x.png'}}" catchtap='selectFliterContent'/>
</block>
<block wx:else>
<image class="arrowIcon" src="{{showFliter ? './images/up@3x.png' : './images/down@3x.png'}}" catchtap='selectFliterContent'/>
</block>
</view>
</view>
<view class='dividingLine'></view>
<view class="{{currentFixedFilterIndex == 1 ? 'filterSelect' : 'filterNormal'}}" data-type='1' catchtap='fixedFilterTapped'>已使用 ({{useCoupons.totleText}})</view>
<view class='dividingLine'></view>
<view class="{{currentFixedFilterIndex == 2 ? 'filterSelect' : 'filterNormal'}}" data-type='2' catchtap='fixedFilterTapped'>已失效 ({{overtimeCoupons.totleText}})</view>
</view>
<block wx:if="{{showFliter}}">
<couponFilter id="couponFilter" filters="{{filters}}" bind:didSelectFliter="didSelectFliter" custom-index="{{selectedSearchFliterIndex}}"></couponFilter>
</block>
<scroll-view scroll-y class='scrollView' scroll-y style="height: {{scHeight}}px" bindscrolltolower="loadMore">
<couponSearch id="couponSearch" wx:if="{{currentFixedFilterIndex == 0}}" bind:duihuanTapped="duihuanTapped"></couponSearch>
<view style="background: #F0F0F0;width: 100%;height: 90rpx "/>
<view wx:if="{{currentFixedFilterIndex == 0}}" style="background: #F0F0F0;width: 100%;height: 90rpx "/>
<block wx:if="{{currentFixedFilterIndex == 0}}">
<empty id="empty" wx:if="{{notuseCoupons.list.length == 0 || !notuseCoupons}}"></empty>
<block wx:for='{{notuseCoupons.list}}' wx:key='{{index}}'>
<view class='space'></view>
<couponCell id="couponCell" item="{{item}}" itemType="2" item-availableed="1" bind:useButtonTap="useButtonTap"></couponCell>
</block>
</block>
<block wx:elif="{{currentFixedFilterIndex == 1}}">
<empty id="empty" wx:if="{{useCoupons.list.length == 0 || !useCoupons}}"></empty>
<block wx:for='{{useCoupons.list}}' wx:key='{{index}}'>
<view class='space'></view>
<couponCell id="couponCell" item="{{item}}" itemType="3" item-availableed="0"></couponCell>
</block>
<view class='sepTips' wx:if="{{useCoupons.list.length > 0}}">
<view class='sepTipsLine'></view>
<text class='sepTipsText'>以上是近期已使用的优惠券</text>
<view class='sepTipsLine'></view>
</view>
</block>
<block wx:elif="{{currentFixedFilterIndex == 2}}">
<empty id="empty" wx:if="{{overtimeCoupons.list.length == 0 || !overtimeCoupons}}"></empty>
<block wx:for='{{overtimeCoupons.list}}' wx:key='{{index}}'>
<view class='space'></view>
<couponCell id="couponCell" item="{{item}}" itemType="4" item-availableed="0"></couponCell>
</block>
<view class='sepTips' wx:if="{{overtimeCoupons.list.length > 0}}">
<view class='sepTipsLine'></view>
<text class='sepTipsText'>以上是近期已失效的优惠券</text>
<view class='sepTipsLine'></view>
</view>
</block>
<view style="background: #F0F0F0;width: 100%;height: 120rpx; "/>
</scroll-view>
</view>
... ...
.coupon_container {
display: flex;
}
.coupon_header {
position: fixed;
width: 100%;
height: 88rpx;
top: 0;
background-color: #FFFFFF;
display: flex;
flex-direction:row;
justify-content: space-around;
align-items: center;
z-index: 999;
border-bottom: 1rpx solid #F0F0F0;
box-shadow: 0 4px 5px -3px #E0E0E0;
}
.coupon_header .filterNormal {
font-family: PingFang-SC-Regular;
font-size: 28rpx;
color: #B0B0B0;
letter-spacing: -0.6px;
width: 33%;
display: flex;
justify-content: center;
align-items: center;
}
.coupon_header .dividingLine {
width: 2rpx;
height: 60rpx;
background: #E0E0E0;
}
.coupon_header .filterSelect {
font-family: PingFang-SC-Semibold;
font-size: 28rpx;
color: #444444;
letter-spacing: -0.6px;
width: 33%;
display: flex;
justify-content: center;
align-items: center;
}
.coupon_header .arrowIconView {
width: 60rpx;
height: 80rpx;
margin-left: 20rpx;
display: flex;
align-items: center;
}
.coupon_header .arrowIconView .arrowIcon {
width: 22rpx;
height: 15rpx;
}
.scrollView {
background: #F0F0F0;
}
.space {
width: 100%;
height: 20rpx;
background: #F0F0F0;
}
.sepTips {
width: 100%;
height: 95rpx;
background: #F0F0F0;
display: flex;
flex-direction:row;
justify-content: center;
align-items: center;
}
.sepTips .sepTipsLine {
width: 160rpx;
height: 2rpx;
background: #E0E0E0;
}
.sepTips .sepTipsText {
font-family: PingFang-SC-Regular;
font-size: 12px;
color: #B0B0B0;
letter-spacing: -0.51px;
padding-left: 24rpx;
padding-right: 24rpx;
}
\ No newline at end of file
... ...
// page/subPackage/pages/couponList/couponSearch.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
duihuanButtonEnable: false,
inputValue: null,
},
/**
* 组件的方法列表
*/
methods: {
listenerPhoneInput: function (e) {
let inputValue = e.detail.value;
let duihuanButtonEnable = inputValue.length > 0 ? true : false;
this.setData({
duihuanButtonEnable,
inputValue,
})
},
duihuanTapped: function (e) {
if (this.data.duihuanButtonEnable) {
this.triggerEvent('duihuanTapped', this.data.inputValue);
}
},
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--page/subPackage/pages/couponList/couponSearch.wxml-->
<view class='header'>
<view class='headerTopView'>
<view class="inputView">
<input class="input" type="text" placeholder="请输入优惠券码" placeholder-class="input-placeholder" bindinput="listenerPhoneInput" />
</view>
<view class='button' style="background-color:{{duihuanButtonEnable ? 'black' : '#BDBDBD'}} ;"bindtap="duihuanTapped">
<text class="buttonText" >兑换</text>
</view>
</view>
</view>
\ No newline at end of file
... ...
/* page/subPackage/pages/couponList/couponSearch.wxss */
.header {
width: 100%;
height: 90rpx;
position: fixed;
top: 88rpx;
z-index: 998;
display: flex;
align-items: center;
background: white;
border-bottom: 1rpx solid #F0F0F0;
}
.header .headerTopView{
width: 100%;
height: 60rpx;
display: flex;
flex-direction:row;
background: white;
}
.header .headerTopView .button {
width: 110rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
margin-left: 20rpx;
border-radius: 2px;
}
.header .headerTopView .button .buttonText{
font-family: PingFang-SC-Regular;
font-size: 28rpx;
color: #FFFFFF;
letter-spacing: -0.39px;
}
.header .headerTopView .inputView {
border-radius: 2px;
margin-left: 20rpx;
width: 580rpx;
height: 60rpx;
}
.header .headerTopView .inputView .input {
padding-left: 10px;
height: 60rpx;
background: #F0F0F0;
border-radius: 4rpx;
}
.header .headerTopView .inputView .input .input-placeholder {
font-family: PingFang-SC-Regular;
font-size: 28rpx;
color: #B0B0B0;
letter-spacing: -0.39px;
}
\ No newline at end of file
... ...
// page/subPackage/pages/couponList/empty.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class='emptyClass'>
<image src="./images/coupon.png" class='icon'></image>
<view class='text'>暂无优惠券</view>
</view>
... ...
.emptyClass {
display: flex;
flex-direction: column;
align-items: center;
background: #f0f0f0;
}
.emptyClass .icon {
width: 208rpx;
height:130rpx;
margin-top:260rpx;
}
.emptyClass .text {
text-align:center;
margin-top:30rpx;
font-family: PingFang-SC-Regular;
font-size: 28rpx;
color: #B0B0B0;
letter-spacing: -0.39px;
}
\ No newline at end of file
... ...
... ... @@ -18,16 +18,16 @@ Page({
data: {
is_deposit_advance:false,
//固定不变数据
arrowIcon_h: "./images/disclosure-arrow_h@2x.png",
arrowIcon_i: "./images/disclosure-arrow_i@2x.png",
arrowIcon_m: "./images/disclosure-arrow_m@2x.png",
address_UnCheckIcon: "./images/address_Check@2x.png",
address_CheckedIcon: "./images/address_Checked@2x.png",
productImageBottomImage_price_gift: "./images/jjg-lab@2x.png",
productImageBottomImage_gift: "./images/zp-lab@2x.png",
addressIcon: "./images/dizhi_icon@2x.png",
invoiceIcon: "./images/payment_yoho_coin@2x.png",
arrowIcon_h: "../../images/disclosure-arrow_h@2x.png",
arrowIcon_i: "../../images/disclosure-arrow_i@2x.png",
arrowIcon_m: "../../images/disclosure-arrow_m@2x.png",
address_UnCheckIcon: "../../images/address_Check@2x.png",
address_CheckedIcon: "../../images/address_Checked@2x.png",
productImageBottomImage_price_gift: "../../images/jjg-lab@2x.png",
productImageBottomImage_gift: "../../images/zp-lab@2x.png",
addressIcon: "../../images/dizhi_icon@2x.png",
invoiceIcon: "../../images/payment_yoho_coin@2x.png",
addressPlaceholder: "请填入收货地址",
deliveryTitle: "配送方式",
... ... @@ -51,12 +51,12 @@ Page({
payAmount: "实付金额",
finalPayment: '商品到货后需支付尾款金额',
payMentButtonTitle: "微信安全支付",
payMentButtonTitle: "支付宝支付",
invoiceDetailTitle: "发票信息",
invoiceDetail: "电子发票-个人",
invoiceData: null,
needInvoice: false,
lineIcon: "./images/boy_xie@2x.png",
lineIcon: "../../images/boy_xie@2x.png",
//可变变数据
productData: {},
... ... @@ -138,10 +138,10 @@ Page({
// }
if (!this.data.isBtnClicking) {
let formId = e.detail.formId;
this.setData({
formId,
});
// let formId = e.detail.formId;
// this.setData({
// formId,
// });
let that = this;
// tt.showModal({
... ... @@ -171,10 +171,10 @@ Page({
}
if (!this.data.isBtnClicking) {
let formId = e.detail.formId;
this.setData({
formId,
});
// let formId = e.detail.formId;
// this.setData({
// formId,
// });
if (this.data.from_page_name == 'shopCart') {
this.paymentFromShopCar();
... ... @@ -395,7 +395,7 @@ Page({
console.log(delivery_way_id)
let open_yoho_code = this.data.needYohoCode ? 1 : 0;
tt.navigateTo({
url: '../../page/subPackage/pages/useCoupons/useCoupons' + '?timestamp=' + timestamp + '' + '&delivery_way=' + delivery_way_id + '&product_sku=' + selectedSKU + '&is_buyNow=' + is_buyNow + '&buy_number=' + buy_number + "&use_red_pacakge=" + use_red_pacakge + "&open_red_package=" + open_red_package + "&open_yoho_code=" + open_yoho_code,
url: '../useCoupons/useCoupons' + '?timestamp=' + timestamp + '' + '&delivery_way=' + delivery_way_id + '&product_sku=' + selectedSKU + '&is_buyNow=' + is_buyNow + '&buy_number=' + buy_number + "&use_red_pacakge=" + use_red_pacakge + "&open_red_package=" + open_red_package + "&open_yoho_code=" + open_yoho_code,
})
},
... ... @@ -509,7 +509,7 @@ Page({
addre_ID = encodeURIComponent(addre_ID);
tt.navigateTo({
url: '../addressManager/addressManager?fromPage=statement&currentMode=modeSelect&address_id=' + addre_ID + '&addType=' + addType
url: '../userCenter/addressManager/addressManager?fromPage=statement&currentMode=modeSelect&address_id=' + addre_ID + '&addType=' + addType
})
}
... ...
... ... @@ -27,11 +27,11 @@
<text class="addressPlaceholder">手动新增收货地址</text>
<image class="addressArrow" src='../../images/disclosure-arrow_m@2x.png'></image>
</view>
<view tt:if="{{false}}" class="noAddress" bindtap="otherAddressTapped" data-type='wechat'>
<!-- <view tt:if="{{false}}" class="noAddress" bindtap="otherAddressTapped" data-type='wechat'>
<image class="addressIconNew" src="../../images/weixin@2x.png"></image>
<text class="addressPlaceholder">一键获取微信地址</text>
<image class="addressArrow" src='../../images/disclosure-arrow_m@2x.png'></image>
</view>
</view> -->
</view>
</view>
<scroll-view scroll-y style="margin-top: {{listTop}}rpx;" enable-back-to-top="true">
... ...
// pages/useCoupons/useCoupons.js
import api from '../../common/api.js';
import { contains, getYHStorageSync } from '../../utils/util';
let app = getApp();
const screenHeight = app.globalData.systemInfo.screenHeight;
Page({
/**
* 页面的初始数据
*/
data: {
currentFixedFilterIndex: 0,
selectedSearchFliterIndex: 1,
screenHeight,
usable_coupon_catalogs: null,
head_msg: '',
showAd: false,
usable_coupon_Num: 0,
usable_coupon_numText: '0',
unusable_coupon_catalogs: [],
unusable_coupon_numText: '0',
unusable_coupon_Num: 0,
delivery_way: 1,
hasSelectyohoCoupon: '',
hasSelectyohoCouponList: [],
buy_number: 0,
product_sku: 0,
is_buyNow: false,
scHeight: 0,
// scHeight2: 0,
coupon_pay: null,
use_red_pacakge:0,
open_red_package:true,
open_yoho_code: false,
isDepositTail: false,
select_yoho_coupon_code_count: 0,
commit: false
},
onUnload: function(options) {
let pages = getCurrentPages();//当前页面
let prevPage = pages[pages.length - 2];//上一页面
let select_yoho_coupon_code_count = 0;
let hasSelectyohoCoupon = ''
if (this.data.commit) {
select_yoho_coupon_code_count = this.data.coupon_pay.coupon_count;
hasSelectyohoCoupon = this.data.hasSelectyohoCoupon;
prevPage.setData({
coupon_code: hasSelectyohoCoupon,
select_yoho_coupon_code_count: select_yoho_coupon_code_count
});
}
prevPage.setData({//直接给上移页面赋值
open_red_package: this.data.open_red_package,
needYohoCode: this.data.open_yoho_code === '0' ? false: true,
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// console.log(options);
let timestamp = options.timestamp;
let delivery_way = options.delivery_way;
let product_sku = options.product_sku;
let is_buyNow = options.is_buyNow == '1' ? true : false;
let buy_number = options.buy_number;
let use_red_pacakge = options.use_red_pacakge;
let open_red_package = options.open_red_package;
let value = getYHStorageSync(timestamp,'useCoupons');
let isDepositTail = options.isDepositTail || false;
let order_code = options.order_code || '';
let open_yoho_code = options.open_yoho_code;
wx.setStorageSync(timestamp, null);//清除内存
let hasSelectyohoCoupon = value ? value : '';
let hasSelectyohoCouponList = hasSelectyohoCoupon ? hasSelectyohoCoupon.split(","): [];
// let scHeight1 = screenHeight - 186 / app.globalData.systemInfo.pixelRatio;
// let scHeight2 = screenHeight - 186 / app.globalData.systemInfo.pixelRatio;
let that = this;
wx.getSystemInfo({
success: function (res) {
// console.info(res.windowHeight);
that.setData({
scHeight: res.windowHeight
});
}
});
this.setData({
hasSelectyohoCoupon,
hasSelectyohoCouponList,
delivery_way,
product_sku,
is_buyNow,
buy_number,
use_red_pacakge,
open_red_package,
open_yoho_code,
isDepositTail,
order_code,
coupon_code: value
// scHeight2,
// scHeight1,
});
if (this.data.is_buyNow) {
this.getCouponListForBuynow();
} else {
this.loadCouponListForShopingCar();
}
},
fixedFilterTapped: function (event) {
let currentFixedFilterIndex = event.currentTarget.dataset.type;
this.setData({ currentFixedFilterIndex});
},
didSelectCoupon: function (e) {
let coupon_code = e.detail;
let hasSelectyohoCouponList = this.data.hasSelectyohoCouponList;
let index = contains(hasSelectyohoCouponList, coupon_code);
if (index >= 0) {
hasSelectyohoCouponList.splice(index, 1);
}else {
hasSelectyohoCouponList.push(coupon_code);
}
let hasSelectyohoCoupon = '';
for (var i = 0; i < hasSelectyohoCouponList.length;i++) {
if (i == hasSelectyohoCouponList.length - 1){
hasSelectyohoCoupon = hasSelectyohoCoupon + hasSelectyohoCouponList[i]
}else{
hasSelectyohoCoupon = hasSelectyohoCoupon + hasSelectyohoCouponList[i] + ','
}
}
this.setData({ hasSelectyohoCouponList, hasSelectyohoCoupon });
if (this.data.is_buyNow) {
this.getCouponListForBuynow();
} else {
this.loadCouponListForShopingCar();
}
},
duihuanTapped: function (event) {
let inputValue = event.detail;
this.bindPCoupon(inputValue);
},
useTapped: function (e) {
let coupon_pay = this.data.coupon_pay;
// if (coupon_pay.coupon_count == 0) {
// } else {
if (this.data.is_buyNow) {
// console.log('useCouponForBuyNow');
this.useCouponForBuyNow();
} else {
// console.log('useCoupon');
this.useCoupon();
}
// }
},
hiddenAdViewTap: function (e) {
let showAd = false;
try {
wx.setStorageSync('userCouponCloseAd', true);
} catch (e) {
// console.error(e);
}
this.setData({
showAd
});
},
useCouponForBuyNow: function (items) {
let that = this;
let coupon_pay = this.data.coupon_pay;
let coupon_code = coupon_pay ? coupon_pay.coupon_code : '';
let param = {
method: 'app.Buynow.useCoupon',
uid: app.getUid(),
fromPage: 'iFP_Coupon',
product_sku: this.data.product_sku,
sku_type: 'I',
coupon_code: coupon_code,
buy_number: this.data.buy_number,
};
if (this.data.isDepositTail) {
param = {
method: "app.Shopping.depositTail.assets.useCoupon",
order_code: this.data.order_code,
open_red_package: that.data.open_red_package,
coupon_code: coupon_code
}
}
api.get({data: param})
.then(function (data) {
if (data && data.code == 200) {
let prePage = getCurrentPages();
if (prePage.length > 1 && prePage[prePage.length - 2].couponTapped != undefined) {
prePage[prePage.length - 2].couponTapped(coupon_code);
}
that.setData({
commit: true
})
wx.navigateBack({
delta: 1
})
} else {
wx.showModal({
content: data.message,
showCancel: false,
confirmText: "确定",
});
}
})
.catch(function (error) {
});
},
useCoupon: function (items) {
let that = this;
let coupon_pay = this.data.coupon_pay;
let coupon_code = coupon_pay ? coupon_pay.coupon_code : '';
let param = {
method: 'app.Shopping.useCoupon',
uid: app.getUid(),
fromPage: 'iFP_Coupon',
coupon_code: coupon_code,
delivery_way: that.data.delivery_way,
};
api.get({data: param})
.then(function (data) {
if (data && data.code == 200) {
let prePage = getCurrentPages();
if (prePage.length > 1 && prePage[prePage.length - 2].couponTapped != undefined) {
prePage[prePage.length - 2].couponTapped(coupon_code);
}
wx.navigateBack({
delta: 1
})
} else {
wx.showModal({
content: data.message,
showCancel: false,
confirmText: "确定",
});
}
})
.catch(function (error) {
});
},
getCouponListForBuynow: function () {
// console.log('getCouponListForBuynow');
let that = this;
let param = {
method: 'app.Buynow.selectCoupon',
uid: app.getUid(),
fromPage: 'iFP_Coupon',
product_sku: that.data.product_sku,
sku_type: 'I',
buy_number: that.data.buy_number,
delivery_way: that.data.delivery_way,
coupon_code: that.data.hasSelectyohoCoupon,
open_red_package: that.data.open_red_package,
// use_red_package: that.data.use_red_pacakge
};
if (this.data.isDepositTail) {
param = {
method: "app.Shopping.depositTail.assets.selectCoupon",
order_code: this.data.order_code,
open_red_package: that.data.open_red_package,
coupon_code: that.data.hasSelectyohoCoupon
}
}
api.get({data: param})
.then(function (data) {
if (data && data.code == 200) {
let userCouponCloseAd = getYHStorageSync('userCouponCloseAd','useCoupons');
let usable_coupon_catalogs = data.data.usable_coupon_catalogs;
let head_msg = usable_coupon_catalogs ? usable_coupon_catalogs.head_msg : '';
let usable_coupon_List = usable_coupon_catalogs.list;
let usable_coupon_Num = usable_coupon_List[0].coupons.length ? usable_coupon_List[0].coupons.length : 0;
let usable_coupon_numText = usable_coupon_Num > 99 ? '99+' : usable_coupon_Num;
let coupon_pay = usable_coupon_List[0].coupon_pay;
let showAd = head_msg && usable_coupon_Num > 0 ? true : false;
showAd = userCouponCloseAd ? false : showAd;
let unusable_coupon_catalogs = data.data.unusable_coupon_catalogs;
let list = unusable_coupon_catalogs ? unusable_coupon_catalogs.list : [];
let unusable_coupon_Num = 0;
for (var i = 0; i < list.length; i++) {
let itemList = list[i].coupons;
let itemListNum = itemList.length ? itemList.length : 0;
unusable_coupon_Num = unusable_coupon_Num + itemListNum;
}
let unusable_coupon_numText = unusable_coupon_Num > 99 ? '99+' : unusable_coupon_Num;
that.setData({
unusable_coupon_catalogs,
usable_coupon_catalogs,
usable_coupon_numText,
unusable_coupon_numText,
unusable_coupon_Num,
usable_coupon_Num,
coupon_pay,
head_msg,
showAd,
});
} else {
wx.showModal({
content: data.message,
showCancel: false,
confirmText: "确定",
});
}
})
.catch(function (error) {
});
},
loadCouponListForShopingCar: function () {
// console.log('loadCouponListForShopingCar');
let that = this;
let param = {
method: 'app.Shopping.selectCoupon',
uid: app.getUid(),
fromPage: 'iFP_Coupon',
delivery_way: that.data.delivery_way,
coupon_code: that.data.hasSelectyohoCoupon,
// use_red_package: that.data.use_red_pacakge,
open_red_package: that.data.open_red_package,
};
api.get({data: param})
.then(function (data) {
if (data && data.code == 200) {
let userCouponCloseAd = getYHStorageSync('userCouponCloseAd','useCoupons');
let usable_coupon_catalogs = data.data.usable_coupon_catalogs;
let usable_coupon_List = usable_coupon_catalogs.list;
let head_msg = usable_coupon_catalogs ? usable_coupon_catalogs.head_msg : '';
let usable_coupon_Num = usable_coupon_List[0].coupons.length ? usable_coupon_List[0].coupons.length : 0;
let usable_coupon_numText = usable_coupon_Num > 99 ? '99+' : usable_coupon_Num;
let coupon_pay = usable_coupon_List[0].coupon_pay;
let showAd = head_msg && usable_coupon_Num > 0 ? true : false;
showAd = userCouponCloseAd ? false : showAd;
let unusable_coupon_catalogs = data.data.unusable_coupon_catalogs;
let list = unusable_coupon_catalogs ? unusable_coupon_catalogs.list : [];
let unusable_coupon_Num = 0;
for (var i = 0; i < list.length; i++) {
let itemList = list[i].coupons;
let itemListNum = itemList.length ? itemList.length : 0;
unusable_coupon_Num = unusable_coupon_Num + itemListNum;
}
let unusable_coupon_numText = unusable_coupon_Num > 99 ? '99+' : unusable_coupon_Num;
that.setData({
unusable_coupon_catalogs,
usable_coupon_catalogs,
usable_coupon_numText,
unusable_coupon_numText,
unusable_coupon_Num,
usable_coupon_Num,
coupon_pay,
head_msg,
showAd,
});
} else {
wx.showModal({
content: data.message,
showCancel: false,
confirmText: "确定",
});
}
})
.catch(function (error) {
});
},
bindPCoupon: function (inputValue) {
let that = this;
if (app.getUid()) {
let param = {
method: 'app.coupons.bindPCoupon',
uid: app.getUid(),
fromPage: 'iFP_Coupon',
coupon_code: inputValue ? inputValue : '',
};
api.get({data: param})
.then(function (data) {
if (data && data.code == 200) {
wx.showToast({
title: '领取成功',
icon: 'success',
duration: 2000
})
if (that.data.is_buyNow) {
that.getCouponListForBuynow();
} else {
that.loadCouponListForShopingCar();
}
} else {
wx.showModal({
content: data.message,
showCancel: false,
confirmText: "确定",
});
}
})
.catch(function (error) {
});
} else {
wx.showModal({
content: "请先登录!",
showCancel: false,
confirmText: "确定",
});
}
},
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "使用优惠券",
"usingComponents": {
"couponCell": "../couponList/couponCell",
"couponSearch": "../couponList/couponSearch",
"couponFilter": "../couponList/couponFilter",
"empty": "../couponList/empty"
}
}
\ No newline at end of file
... ...
<view class='coupon_container'>
<view class='coupon_header'>
<view class="{{currentFixedFilterIndex == 0 ? 'filterSelect' : 'filterNormal'}}" data-type='0' catchtap='fixedFilterTapped' style='margin-left: 25rpx;'>可用 ({{usable_coupon_numText}})
</view>
<view class='dividingLine'></view>
<view class="{{currentFixedFilterIndex == 1 ? 'filterSelect' : 'filterNormal'}}" data-type='1' catchtap='fixedFilterTapped'>不可用 ({{unusable_coupon_numText}})</view>
</view>
<scroll-view scroll-y class='scrollView' scroll-y style="height: {{scHeight}}px" bindscrolltolower="loadMore">
<couponSearch id="couponSearch" wx:if="{{currentFixedFilterIndex == 0}}" bind:duihuanTapped="duihuanTapped"></couponSearch>
<view style="background: #F0F0F0;width: 100%;height: 90rpx "/>
<view wx:if="{{currentFixedFilterIndex == 0}}" style="background: #F0F0F0;width: 100%;height: 90rpx "/>
<block wx:if="{{currentFixedFilterIndex == 0}}">
<view class='adVew' wx:if="{{showAd}}">
<text class='adVewText'>{{head_msg}}</text>
<view class='adVewExit' catchtap='hiddenAdViewTap'>
<image class="adVewExitIcon" src="../couponList/images/CombinedShape@2x.png"/>
</view>
</view>
<view wx:if="{{showAd}}" style="background: #F0F0F0;width: 100%;height: 88rpx "/>
<empty id="empty" wx:if="{{usable_coupon_Num == 0}}"></empty>
<block wx:for='{{usable_coupon_catalogs.list}}' wx:key='{{index}}'>
<block wx:for='{{item.coupons}}' wx:key='{{index}}'>
<view class='space'></view>
<couponCell id="couponCell" item="{{item}}" itemType="5" item-availableed="{{item.is_selected_support == 'Y' ? '1' : '0'}}" bind:didSelectCoupon="didSelectCoupon"></couponCell>
</block>
</block>
<view style="background: #F0F0F0;width: 100%;height: 120rpx; "/>
</block>
<block wx:elif="{{currentFixedFilterIndex == 1}}">
<empty id="empty" wx:if="{{unusable_coupon_Num == 0}}"></empty>
<block wx:for='{{unusable_coupon_catalogs.list}}' wx:key='{{index}}'>
<view class='sepTips' wx:if="{{item.coupons.length > 0}}">
<view class='sepTipsLine'></view>
<text class='sepTipsText' style='color: #444444;'>{{item.name}}</text>
<view class='sepTipsLine'></view>
</view>
<block wx:for='{{item.coupons}}' wx:key='{{index}}' wx:for-item="item">
<couponCell id="couponCell" item="{{item}}" itemType="6" item-availableed="1"></couponCell>
<view class='space'></view>
</block>
</block>
</block>
</scroll-view>
<view class='bottom' wx:if="{{currentFixedFilterIndex == 0}}">
<view class='bottomView'>
<view class='top1'>
<text class='bottomText'>已选择</text>
<text class='bottomRedText'>{{coupon_pay.coupon_count}}</text>
<text class='bottomText'>张,共优惠</text>
<text class='bottomRedText'>{{coupon_pay.coupon_amount_str}}</text>
<text class='bottomText'>元</text>
</view>
<view class='bottom1'>
<text class='bottomText'>待支付</text>
<text class='bottomRedText'>{{coupon_pay.to_pay_amount_str}}</text>
<text class='bottomText'>元</text>
</view>
</view>
<view class='bottomButton' catchtap='useTapped' style="background: #D0021B;">
<text class='text'>确认</text>
</view>
</view>
</view>
\ No newline at end of file
... ...
.coupon_container {
/* display: flex; */
}
.coupon_header {
position: fixed;
width: 100%;
height: 88rpx;
top: 0;
background-color: #FFFFFF;
display: flex;
flex-direction:row;
justify-content: space-around;
align-items: center;
z-index: 999;
border-bottom: 1rpx solid #F0F0F0;
box-shadow: 0 4px 5px -3px #E0E0E0;
}
.coupon_header .filterNormal {
font-family: PingFang-SC-Regular;
font-size: 28rpx;
color: #B0B0B0;
letter-spacing: -0.6px;
width: 50%;
display: flex;
justify-content: center;
align-items: center;
}
.coupon_header .dividingLine {
width: 2rpx;
height: 60rpx;
background: #E0E0E0;
}
.coupon_header .filterSelect {
font-family: PingFang-SC-Semibold;
font-size: 28rpx;
color: #444444;
letter-spacing: -0.6px;
width: 50%;
display: flex;
justify-content: center;
align-items: center;
}
.scrollView {
background: #F0F0F0;
}
.space {
width: 100%;
height: 20rpx;
background: #F0F0F0;
}
.sepTips {
width: 100%;
height: 95rpx;
background: #F0F0F0;
display: flex;
flex-direction:row;
justify-content: center;
align-items: center;
}
.sepTips .sepTipsLine {
width: 160rpx;
height: 2rpx;
background: #E0E0E0;
}
.sepTips .sepTipsText {
font-family: PingFang-SC-Regular;
font-size: 12px;
color: #B0B0B0;
letter-spacing: -0.51px;
padding-left: 24rpx;
padding-right: 24rpx;
}
.bottom {
position: fixed;
width: 100%;
height: 100rpx;
bottom: 0;
background-color: white;
display: flex;
flex-direction:row;
align-items: center;
z-index: 1000;
border-top: 1rpx solid #F0F0F0;
}
.bottom .bottomView {
width: 470rpx;
display: flex;
align-items: center;
justify-content: flex-end;
flex-direction: column;
}
.bottom .bottomView .top1{
width: 470rpx;
display: flex;
align-items: center;
justify-content: flex-end;
flex-direction: row;
}
.bottom .bottomView .bottom1{
width: 470rpx;
display: flex;
align-items: center;
justify-content: flex-end;
flex-direction: row;
margin-top: 10rpx;
}
.bottomText {
font-family: PingFang-SC-Regular;
font-size: 24rpx;
letter-spacing: 0;
word-break:break-all;
display:-webkit-box;
-webkit-line-clamp:1;
-webkit-box-orient:vertical;
overflow:hidden;
line-height: 26rpx;
margin-left: 10rpx;
}
.bottomRedText {
font-family: PingFang-SC-Medium;
font-size: 24rpx;
line-height: 26rpx;
color: #D0021B;
margin-left: 10rpx;
font-weight: bold;
}
.bottom .bottomButton {
width: 260rpx;
height: 100rpx;
display: flex;
align-items: center;
justify-content: center;
margin-left: 20rpx;
}
.bottom .bottomButton .text{
font-family: PingFang-SC-Regular;
font-size: 34rpx;
color: #FFFFFF;
letter-spacing: 0;
word-break:break-all;
display:-webkit-box;
-webkit-line-clamp:1;
-webkit-box-orient:vertical;
overflow:hidden;
}
.adVew {
width: 100%;
height: 88rpx;
background: #FF8083;
flex-direction: row;
align-items: center;
position: fixed;
z-index: 998;
margin-top: -1rpx;
display: flex;
}
.adVew .adVewText {
width: 612rpx;
font-family: PingFang-SC-Regular;
font-size: 22rpx;
color: #FFFFFF;
letter-spacing: -0.47px;
line-height: 30rpx;
margin-left: 30rpx;
word-break:break-all;
display:-webkit-box;
-webkit-box-pack: center;
-webkit-line-clamp:2;
-webkit-box-orient:vertical;
overflow:hidden;
}
.adVew .adVewExit {
width: 88rpx;
height: 88rpx;
margin-left: 20rpx;
display: flex;
align-items: center;
justify-content: center;
}
.adVew .adVewExit .adVewExitIcon {
width: 30rpx;
height: 30rpx;
}
\ No newline at end of file
... ...
... ... @@ -22,17 +22,6 @@
"appId": "",
"extraData": ""
}
},
{
"id": 1,
"name": "确认订单",
"pathName": "pages/statements/statements",
"query": "timestamp=paymentdata&page_name=shopCart",
"scene": "011001",
"referrerInfo": {
"appId": "",
"extraData": ""
}
}
]
}
... ...