自动选择最优优惠券;是否可开发票判断

develop
mice2333 4 years ago
parent b72eaf5f25
commit 7dc2339671

@ -24,7 +24,9 @@ Page({
})
},
de() {
this.setData({fee_detail:!this.data.fee_detail})
this.setData({
fee_detail: !this.data.fee_detail
})
},
check(event) {
@ -33,7 +35,9 @@ Page({
});
},
agreement() {
this.setData({show:true})
this.setData({
show: true
})
},
viewer_sel(event) {
this.setData({
@ -56,7 +60,9 @@ this.setData({show:true})
var viewer_id = this.data.viewer_sel
if (viewer_id && tid.split(',').length == viewer_id.length) {
if (this.data.checked) {
this.setData({show1:true})
this.setData({
show1: true
})
} else {
wx.showToast({
title: '请勾选服务条款',
@ -70,12 +76,15 @@ this.setData({show:true})
icon: 'none',
duration: 2000
})
}}else if(this.data._info.show_info.is_real_name==2){
}
} else if (this.data._info.show_info.is_real_name == 2) {
var tid = this.data.tid
var viewer_id = this.data.viewer_sel
if (viewer_id && viewer_id.length == 1) {
if (this.data.checked) {
this.setData({show1:true})
this.setData({
show1: true
})
} else {
wx.showToast({
title: '请勾选服务条款',
@ -89,10 +98,12 @@ wx.showToast({
icon: 'none',
duration: 2000
})
}}
else{
}
} else {
if (this.data.checked) {
this.setData({show1:true})
this.setData({
show1: true
})
} else {
wx.showToast({
title: '请勾选服务条款',
@ -163,6 +174,51 @@ else{
},
// 使用最大减免优惠券
getRecommendCoupons(drama_id,tid){
http('/api/v1/coupon-list', "post", {drama_id,tid,mode:1}).then(Response => {
if (Response.coupon_list.length > 0) {
let coupon_list = Response.coupon_list
// 去除日期格式
let a = []
coupon_list.forEach((item) => {
item.end_date = item.end_date.replace(/[\u4e00-\u9fa5]/g, '')
a.push(item)
})
coupon_list = a
// 优惠券筛选策略
function couponSort(list, params) {
let descList
if (arguments[2] == 'asc') {
descList = list.sort((a, b) => {
return a[params] - b[params]
})
} else {
descList = list.sort((a, b) => {
return b[params] - a[params]
})
}
let l = []
l.push(descList[0])
descList.forEach((item, index) => {
if (index != 0 && item[params] == l[0][params]) {
l.push(item)
}
})
return l;
}
let recommendCoupons = couponSort(couponSort(couponSort(coupon_list, "subtract"), 'full'), 'end_date', 'asc')
if (recommendCoupons && recommendCoupons.length > 0) {
this.setData({
coupon: recommendCoupons[0]
})
}
}
})
},
/**
@ -178,8 +234,12 @@ else{
for (let i in _info.ticket_info) {
tprice += _info.ticket_info[i].price * _info.ticket_info[i].tkt_num
}
this.getRecommendCoupons(options.drama_id,options.tid)
this.setData({
_info,tprice,
_info,
tprice,
tid: options.tid,
drama_id: options.drama_id,
})

@ -13,7 +13,12 @@
</view>
<view class="line">
<van-icon name="passed" color="green" /> 不支持退票
<block wx:if="{{_info.show_info.is_invoice==0}}">
<van-icon name="close" color="red" /> 不可开发票
</block>
<block wx:elif="{{_info.show_info.is_invoice==1}}">
<van-icon name="passed" color="green" /> 可开发票
</block>
</view>
</view>
</view>

@ -23,7 +23,12 @@
</view>
<view class="line" style="font-weight:normal;">
<van-icon name="passed" color="green" /> 不支持退票
<block wx:if="{{show_info.is_invoice==0}}">
<van-icon name="close" color="red" /> 不可开发票
</block>
<block wx:elif="{{show_info.is_invoice==1}}">
<van-icon name="passed" color="green" /> 可开发票
</block>
</view>
</view>
</view>

Loading…
Cancel
Save