Commit 14df66daf9590a4c6e1bc79922290742aff2f70b

Authored by yiren
1 parent 989c722d

提前点餐菜品分享页面增加充值推荐

@@ -39,7 +39,7 @@ Page({ @@ -39,7 +39,7 @@ Page({
39 let obj = JSON.parse(options.cookbookObj); 39 let obj = JSON.parse(options.cookbookObj);
40 let textColor; 40 let textColor;
41 if(obj.themeColor=='251,246,241,1'){ 41 if(obj.themeColor=='251,246,241,1'){
42 - textColor='81,81,81,1' 42 + textColor='0,0,0,1'
43 }else{ 43 }else{
44 textColor='251,246,241,1' 44 textColor='251,246,241,1'
45 } 45 }
@@ -494,8 +494,8 @@ Page({ @@ -494,8 +494,8 @@ Page({
494 themeColor = '77,78,80,1'; //未设置 为灰色 494 themeColor = '77,78,80,1'; //未设置 为灰色
495 } 495 }
496 if (themeColor == '251,246,241,1') { 496 if (themeColor == '251,246,241,1') {
497 - textColor = "81,81,81,1"  
498 - navColor = "81,81,81,1" 497 + textColor='0,0,0,1'
  498 + navColor='0,0,0,1'
499 } else { 499 } else {
500 navColor = "255,255,255,1" 500 navColor = "255,255,255,1"
501 textColor = "255,255,255,1" 501 textColor = "255,255,255,1"
@@ -139,7 +139,6 @@ page { @@ -139,7 +139,6 @@ page {
139 font-weight: 500; 139 font-weight: 500;
140 font-size: 80rpx; 140 font-size: 80rpx;
141 margin-right: 20rpx; 141 margin-right: 20rpx;
142 - -webkit-text-stroke: 1rpx #fff;  
143 } 142 }
144 143
145 .practice { 144 .practice {
@@ -9,25 +9,13 @@ Page({ @@ -9,25 +9,13 @@ Page({
9 */ 9 */
10 data: { 10 data: {
11 cookbooklist: [], 11 cookbooklist: [],
12 - sellerName: '',  
13 - sellerid: '',  
14 probablyPrice: '', 12 probablyPrice: '',
15 vipProbablyPrice: '', 13 vipProbablyPrice: '',
16 - discount: '',  
17 - stringifyUse: '',  
18 - priceInfo: '',  
19 - scoreInfo: '',  
20 notes: '', 14 notes: '',
21 - marketing: {},  
22 - recharge_data: {},  
23 - coupon_data: {},  
24 - rid: '',  
25 - oid: '',  
26 tpls: [], 15 tpls: [],
27 - current: 0,  
28 seller: {}, 16 seller: {},
29 options: {}, 17 options: {},
30 - dataStr: Date.now() * 1 / 1000, 18 + rechargeList:[],
31 }, 19 },
32 /** 20 /**
33 * 生命周期函数--监听页面加载 21 * 生命周期函数--监听页面加载
@@ -287,6 +275,9 @@ Page({ @@ -287,6 +275,9 @@ Page({
287 this.setData({ 275 this.setData({
288 cookbooklist 276 cookbooklist
289 }) 277 })
  278 + setTimeout(() => {
  279 + this.getNewRechargeListfFun();
  280 + }, 0);
290 }) 281 })
291 this.GetDzSellerConfFun() 282 this.GetDzSellerConfFun()
292 }, 283 },
@@ -304,8 +295,8 @@ Page({ @@ -304,8 +295,8 @@ Page({
304 themeColor = '77,78,80,1'; //未设置 为灰色 295 themeColor = '77,78,80,1'; //未设置 为灰色
305 } 296 }
306 if (themeColor == '251,246,241,1') { 297 if (themeColor == '251,246,241,1') {
307 - textColor = '81,81,81,1'  
308 - navColor = "81,81,81,1" 298 + textColor = '0,0,0,1'
  299 + navColor='0,0,0,1'
309 } else { 300 } else {
310 navColor = "255,255,255,1" 301 navColor = "255,255,255,1"
311 textColor = '251,246,241,1' 302 textColor = '251,246,241,1'
@@ -365,14 +356,14 @@ Page({ @@ -365,14 +356,14 @@ Page({
365 let reserev = RS.reserve(res.data) 356 let reserev = RS.reserve(res.data)
366 let dateSmart; 357 let dateSmart;
367 if (res.data.type == 1) { 358 if (res.data.type == 1) {
368 - dateSmart = util.unixtoTime(reserev.ddate, this.data.tpls[this.data.current].timeStrSmart[0]) 359 + dateSmart = util.unixtoTime(reserev.ddate, this.data.tpls[0].timeStrSmart[0])
369 if (res.data.is_set_ddate == 1) { 360 if (res.data.is_set_ddate == 1) {
370 - dateSmart += ' ' + util.unixtoTime(reserev.ddate, this.data.tpls[this.data.current].timeStrSmart[1]) 361 + dateSmart += ' ' + util.unixtoTime(reserev.ddate, this.data.tpls[0].timeStrSmart[1])
371 } else { 362 } else {
372 dateSmart += ' ' + reserev.soltName 363 dateSmart += ' ' + reserev.soltName
373 } 364 }
374 } else { 365 } else {
375 - dateSmart = util.unixtoTime(reserev.ddate, this.data.tpls[this.data.current].timeStr) 366 + dateSmart = util.unixtoTime(reserev.ddate, this.data.tpls[0].timeStr)
376 } 367 }
377 this.setData({ 368 this.setData({
378 seller: { 369 seller: {
@@ -383,62 +374,59 @@ Page({ @@ -383,62 +374,59 @@ Page({
383 tableNum, 374 tableNum,
384 } 375 }
385 }) 376 })
386 - setTimeout(() => {  
387 - this.getSellerTemplateConfFun(reserev.sid);  
388 - }, 0);  
389 }).catch(res => { 377 }).catch(res => {
390 console.log(res, '详情请求失败'); 378 console.log(res, '详情请求失败');
391 }) 379 })
392 }, 380 },
393 - // 获取券 充值信息  
394 - getSellerTemplateConfFun() {  
395 - App.Seller.GetSellerTemplateConf({  
396 - sid: this.data.options.sid 381 + // 获取充值列表信息
  382 + getNewRechargeListfFun() {
  383 + App.Activity.GetNewRechargeList({
  384 + sellerid: this.data.options.sid,
  385 + is_expire: '0'
397 }).then(res => { 386 }).then(res => {
398 - let data = res.data  
399 - let marketing, coupon_data, priceInfo, scoreInfo, recharge_list, stringifyUse;  
400 - marketing = util.determine(data.marketing);  
401 - console.log('marketing', marketing);  
402 - if (marketing.coupon_data) {  
403 - coupon_data = marketing.coupon_data;  
404 - stringifyUse = JSON.stringify(marketing.coupon_data.use)  
405 - }  
406 - console.log('coupon_data', coupon_data);  
407 - console.log('stringifyUse', stringifyUse);  
408 - if (marketing.is_recharge == '1' && marketing.recharge_data) {  
409 - let recharge_data = marketing.recharge_data  
410 - recharge_list = marketing.recharge_data.recharge_list  
411 - if (recharge_list.is_price == '1') priceInfo = '会员充值满' + recharge_data.recharge_money + '元赠送' + recharge_list.price + '元余额';  
412 - if (recharge_list.is_score == '1') scoreInfo = '会员充值满' + recharge_data.recharge_money + '元赠送' + recharge_list.score + '积分';  
413 - console.log('scoreInfo', scoreInfo);  
414 - console.log('priceInfo', priceInfo);  
415 - this.setData({  
416 - recharge_data: marketing.recharge_data  
417 - })  
418 - console.log('recharge_data', recharge_data);  
419 - }  
420 - this.setData({  
421 - coupon_data,  
422 - stringifyUse 387 + let list = res.data;
  388 + list.forEach((item,index) => {
  389 + if(item.is_open=='0'){
  390 + list.splice(index,1)
  391 + }
  392 + item.recharge_lists = item.recharge_list ? JSON.parse(item.recharge_list) : '';
  393 + let recharge_lists = item.recharge_lists;
  394 + item.priceInfo = '';
  395 + item.scoreInfo = '';
  396 + item.certificate = '';
  397 + if (recharge_lists.is_price == '1') item.priceInfo = '会员充值满' + item.recharge_money + '元赠送' + item.recharge_lists.price + '元余额';
  398 + if (recharge_lists.is_score == '1') item.scoreInfo = '会员充值满' + item.recharge_money + '元赠送' + item.recharge_lists.score + '积分';
  399 + if (recharge_lists.is_coupons == '1' && recharge_lists.coupons_names.length > 0) item.certificate = recharge_lists.coupons_names.join('、');
423 }) 400 })
424 - // is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示  
425 - if (marketing.is_coupon == '1' && coupon_data && (!coupon_data.use.is_cash || coupon_data.use.is_cash == '1')) {  
426 - let cash = coupon_data.use.cash;  
427 - let price = coupon_data.price * 1;  
428 - let discount = ((price / cash) * 10).toFixed(2); 401 + let item=this.findClosest(list,this.data.probablyPrice)
  402 + let rechargeList=[];
  403 + item?rechargeList.push(item):'';
  404 + wx.nextTick(()=>{
429 this.setData({ 405 this.setData({
430 - discount 406 + rechargeList,
431 }) 407 })
432 - }  
433 - this.setData({  
434 - marketing,  
435 - priceInfo,  
436 - scoreInfo  
437 }) 408 })
438 }).catch(res => { 409 }).catch(res => {
439 console.log('GetSellerTemplateConf请求失败'); 410 console.log('GetSellerTemplateConf请求失败');
440 }) 411 })
441 }, 412 },
  413 + // 筛选出合适的充值优惠
  414 + findClosest (list,price){
  415 +        let i=0;
  416 +        let changzhi=0;
  417 +        list.forEach((item,index)=>{
  418 +            if (index==0) {
  419 +                changzhi=Math.abs(price*1-item.recharge_money*1)
  420 +                i=index
  421 +            }else{
  422 +                if (changzhi*1-Math.abs((price*1-item.recharge_money*1))>0) {
  423 +                    changzhi=Math.abs(price*1-item.recharge_money*1)
  424 +                    i=index
  425 +                }
  426 +            }
  427 +        })
  428 +      return list[i]
  429 + },
442 /** 430 /**
443 * 用户点击右上角分享 431 * 用户点击右上角分享
444 */ 432 */
@@ -44,48 +44,24 @@ @@ -44,48 +44,24 @@
44 </view> 44 </view>
45 <view class="information font36r">特别优惠</view> 45 <view class="information font36r">特别优惠</view>
46 <view class="poop font24r">根据您选择的菜品,我们推荐您参加以下活动,本次消费可用,预计可以节约大笔开销!</view> 46 <view class="poop font24r">根据您选择的菜品,我们推荐您参加以下活动,本次消费可用,预计可以节约大笔开销!</view>
47 - <view class="preferential" wx:if="{{marketing && (marketing.is_coupon=='1' || marketing.is_recharge=='1')}}">  
48 - <view class="preferentialItems" wx:if="{{marketing && marketing.is_coupon=='1' && dataStr<(coupon_data.etime*1)}}">  
49 - <view class="left">  
50 - <view class="top">  
51 - <text>{{coupon_data.aname}}</text>  
52 - <text class="price" wx:if="{{coupon_data.price}}">¥{{coupon_data.price}}</text>  
53 - <!-- is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示 -->  
54 - <text wx:if="{{discount!='0.00' && (coupon_data.use.is_cash=='1' || coupon_data.use.is_cash)}}" class="discount">{{discount}}折</text>  
55 - </view>  
56 - <view wx:if="{{coupon_data.exp_date.is_week=='1' || coupon_data.exp_date.is_week===true}}" class="bottom">  
57 - {{coupon_data.exp_date.week_show?coupon_data.exp_date.week_show+'可用':''}}{{coupon_data.desc?','+coupon_data.desc+'。':'。'}}  
58 - </view>  
59 - <view wx:if="{{coupon_data.exp_date.is_none=='1' || coupon_data.exp_date.is_none===true}}" class="bottom">  
60 - 无限制{{coupon_data.desc?','+coupon_data.desc+'。':'。'}}  
61 - </view>  
62 - <view wx:if="{{coupon_data.exp_date.is_birthday=='1' || coupon_data.exp_date.is_birthday===true}}" class="bottom">  
63 - 会员生日当天可用{{coupon_data.desc?','+coupon_data.desc+'。':'。'}}  
64 - </view>  
65 - </view>  
66 - <navigator url="/pack-activity/pack/buyCoupon?id={{coupon_data.id}}&name={{options.sellerName}}&use={{stringifyUse}}&rid={{options.rid}}&sid={{options.sid}}&oid={{options.oid}}&types=2" hover-class="navigator-hover">  
67 - <view class="font24r orderingFood">  
68 - 去抢购  
69 - </view>  
70 - </navigator>  
71 - </view> 47 + <view class="preferential" wx:if="{{rechargeList.length>0}}">
72 <!-- 当前日期要大于限制结束日期 --> 48 <!-- 当前日期要大于限制结束日期 -->
73 - <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)))}}"> 49 + <view class="preferentialItems" wx:for="{{rechargeList}}" data-id="{{item.id}}">
74 <view class="left"> 50 <view class="left">
75 <view class="top"> 51 <view class="top">
76 - <text>{{recharge_data.rname}}</text> 52 + <text>{{item.rname}}</text>
77 </view> 53 </view>
78 - <view class="bottom" wx:if="{{priceInfo}}">  
79 - {{priceInfo}}{{(recharge_data.recharge_list.is_coupons=='0' && recharge_data.recharge_list.is_score=='0')?'。':';'}} 54 + <view class="bottom" wx:if="{{item.priceInfo}}">
  55 + {{item.priceInfo}}{{(item.recharge_lists.is_coupons=='0' && item.recharge_lists.is_score=='0')?'。':';'}}
80 </view> 56 </view>
81 - <view class="bottom" wx:if="{{scoreInfo}}">  
82 - {{scoreInfo}}{{recharge_data.recharge_list.is_coupons=='0'?'。':';'}} 57 + <view class="bottom" wx:if="{{item.scoreInfo}}">
  58 + {{item.scoreInfo}}{{item.recharge_lists.is_coupons=='0'?'。':';'}}
83 </view> 59 </view>
84 - <view class="bottom" wx:if="{{recharge_data.recharge_list.is_coupons=='1'}}">  
85 - {{recharge_data.recharge_list.is_coupons=='1'?'会员充值满'+marketing.recharge_data.recharge_money+'元赠送优惠券':''}}。 60 + <view class="bottom" wx:if="{{item.recharge_lists.is_coupons=='1'}}">
  61 + {{item.recharge_lists.is_coupons=='1'?'会员充值满'+item.recharge_money+'元赠送'+item.certificate:''}}。
86 </view> 62 </view>
87 </view> 63 </view>
88 - <navigator url="/pack-activity/pack/vipRecharge?id={{recharge_data.id}}&name={{options.sellerName}}&sid={{options.sid}}&oid={{options.oid}}&rid={{options.rid}}&types=2" hover-class="navigator-hover"> 64 + <navigator url="/pack-activity/pack/vipRecharge?id={{item.id}}&name={{options.sellerName}}&sid={{options.sid}}&oid={{options.oid}}&rid={{options.rid}}&types=2" hover-class="navigator-hover">
89 <view class="font24r orderingFood"> 65 <view class="font24r orderingFood">
90 去充值 66 去充值
91 </view> 67 </view>