Commit fcb26116f2439968c927829bbd2db26af8285e07

Authored by pengye
1 parent 55e3f3d0

邀请函优惠券展示多个、以及优惠券位置调整

... ... @@ -25,7 +25,7 @@ Page({
signboard: {},
store: {},
recharge_data:{},
coupon_data:{},
coupon_dataList:[],
homeColor: '',
stringifyUse:'',
current: 0,
... ... @@ -273,17 +273,40 @@ Page({
}).then(res => {
let data=res.data
console.log('data',data);
let home,chef,marketing,reserve,swich_phone,signboard,store,homeColor,coupon_data,priceInfo,certificate,scoreInfo,recharge_list,stringifyUse;
chef = util.determine(data.chef);
let coupon_dataList=[]
let home,chef,marketing,reserve,swich_phone,signboard,store,homeColor,priceInfo,certificate,scoreInfo,recharge_list,stringifyUse;
chef = util.determine(data.chef);
reserve = util.determine(data.reserve);
swich_phone = reserve && reserve.swich_phone?reserve.swich_phone:'';
marketing = util.determine(data.marketing);
signboard = util.determine(data.signboard);
store = util.determine(data.store);
home = util.determine(data.home);
if(marketing && marketing.coupon_data){
coupon_data=marketing.coupon_data;
stringifyUse=JSON.stringify(marketing.coupon_data.use)
let coupon=util.determine(marketing.coupon_data)
// is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示
if(coupon && util.getType(coupon)=='object'){
coupon.stringifyUse=JSON.stringify(coupon.use)
if(marketing.is_coupon=='1' && coupon && (!coupon.use.is_cash || coupon.use.is_cash=='1')){
let cash=coupon.use.cash;
let price=coupon.price*1;
console.log('cash',cash+'---'+'price',price+'---'+'discount',((price/cash)*10).toFixed(2));
coupon.discount=((price/cash)*10).toFixed(2);
}
coupon_dataList.push(coupon);
}
if(coupon && util.getType(coupon)=='array'){
if(coupon.length>0){
coupon.forEach(item=>{
item.stringifyUse=JSON.stringify(item.use)
if((!item.use.is_cash || item.use.is_cash=='1')){
let cash=item.use.cash;
let price=item.price*1;
console.log('cash',cash+'---'+'price',price+'---'+'discount',((price/cash)*10).toFixed(2));
item.discount=((price/cash)*10).toFixed(2);
}
})
}
coupon_dataList=coupon;
}
let obj={
chef,
... ... @@ -293,7 +316,8 @@ Page({
store,
home,
stringifyUse,
coupon_data,
coupon,
coupon_dataList,
swich_phone
}
console.log('获取数据', {...obj});
... ... @@ -312,21 +336,9 @@ Page({
console.log('recharge_data',recharge_data);
}
this.setData({
coupon_data,
coupon_dataList,
stringifyUse
})
// is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示
if(marketing && marketing.is_coupon=='1' && coupon_data && (!coupon_data.use.is_cash || coupon_data.use.is_cash=='1')){
let cash=coupon_data.use.cash;
let price=coupon_data.price*1;
let discount=((price/cash)*10).toFixed(2);
console.log('cash',cash);
console.log('price',price);
console.log('discount',discount);
this.setData({
discount
})
}
if(store && store.images.length>0) store.images =util.determine(store.images);
if(signboard && signboard.images) signboard.images = util.determine(signboard.images);
if (marketing && marketing.is_online_book=='1' && marketing.is_transpond =='1') {
... ...
... ... @@ -68,6 +68,34 @@
<text>{{seller.addr?seller.addr:reserev.seller.map_address}}</text>
</view>
</view>
<view class="preferential" wx:if="{{marketing && marketing.is_coupon=='1' && coupon_dataList.length>0}}">
<view wx:for="{{coupon_dataList}}" wx:key="index" wx:for-index="index">
<view class="preferentialItems" wx:if="{{dataStr<(item.etime*1)}}">
<view class="left">
<view class="top">
<text>{{item.aname}}</text>
<text class="price" wx:if="{{item.price}}">¥{{item.price}}</text>
<!-- is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示 -->
<text wx:if="{{item.discount!='0.00' && (item.use.is_cash=='1' || item.use.is_cash)}}" class="discount">{{item.discount}}折</text>
</view>
<view wx:if="{{item.exp_date.is_week=='1' || item.exp_date.is_week===true}}" class="bottom" >
{{item.exp_date.week_show?item.exp_date.week_show+'可用':''}}{{item.desc?','+item.desc+'。':'。'}}
</view>
<view wx:if="{{item.exp_date.is_none=='1' || item.exp_date.is_none===true}}" class="bottom" >
无限制{{item.desc?','+item.desc+'。':'。'}}
</view>
<view wx:if="{{item.exp_date.is_birthday=='1' || item.exp_date.is_birthday===true}}" class="bottom" >
会员生日当天可用{{item.desc?','+item.desc+'。':'。'}}
</view>
</view>
<navigator url="/pack-activity/pack/buyCoupon?id={{item.id}}&name={{seller.name}}&use={{item.stringifyUse}}&sid={{seller.sid}}&oid={{detail.id}}&types=1" hover-class="navigator-hover">
<view class="font24r orderingFood">
去抢购
</view>
</navigator>
</view>
</view>
</view>
<!-- <view class="visitor">
确认赴约客人:{{keepAppointment.length}}位
</view>
... ... @@ -191,30 +219,6 @@
<view class="rubric rubric1">
特别优惠
</view>
<view class="preferentialItems" wx:if="{{marketing && marketing.is_coupon=='1' && dataStr<(coupon_data.etime*1)}}">
<view class="left">
<view class="top">
<text>{{coupon_data.aname}}</text>
<text class="price" wx:if="{{coupon_data.price}}">¥{{coupon_data.price}}</text>
<!-- is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示 -->
<text wx:if="{{discount!='0.00' && (coupon_data.use.is_cash=='1' || coupon_data.use.is_cash)}}" class="discount">{{discount}}折</text>
</view>
<view wx:if="{{coupon_data.exp_date.is_week=='1' || coupon_data.exp_date.is_week===true}}" class="bottom" >
{{coupon_data.exp_date.week_show?coupon_data.exp_date.week_show+'可用':''}}{{coupon_data.desc?','+coupon_data.desc+'。':'。'}}
</view>
<view wx:if="{{coupon_data.exp_date.is_none=='1' || coupon_data.exp_date.is_none===true}}" class="bottom" >
无限制{{coupon_data.desc?','+coupon_data.desc+'。':'。'}}
</view>
<view wx:if="{{coupon_data.exp_date.is_birthday=='1' || coupon_data.exp_date.is_birthday===true}}" class="bottom" >
会员生日当天可用{{coupon_data.desc?','+coupon_data.desc+'。':'。'}}
</view>
</view>
<navigator url="/pack-activity/pack/buyCoupon?id={{coupon_data.id}}&name={{seller.name}}&use={{stringifyUse}}&sid={{seller.sid}}&oid={{detail.id}}&types=1" hover-class="navigator-hover">
<view class="font24r orderingFood">
去抢购
</view>
</navigator>
</view>
<!-- 当前日期要大于限制结束日期 -->
<view class="preferentialItems" wx:if="{{marketing && marketing.is_recharge=='1' && recharge_data && (is_fix!='1' || (is_fix=='1' && dataStr<(recharge_data.exp_date.fix_edate*1)))}}">
<view class="left">
... ...
... ... @@ -179,6 +179,10 @@ function objCompare (obj1, obj2,key){
return 0;
}
}
// 判断是数组还是对象 返回 object 或者 array
function getType(variable) {
return ({}).toString.call(variable).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
}
module.exports = {
formatTime: formatTime,
unixtoTime: unixtoTime,
... ... @@ -186,6 +190,7 @@ module.exports = {
parseDataValue,
determine,
objCompare,
getType,
imageZoomHeightUtil,
cgi: function (act) {
return uri.HOST__LINE + act //正式
... ...