Showing
3 changed files
with
65 additions
and
44 deletions
| @@ -25,7 +25,7 @@ Page({ | @@ -25,7 +25,7 @@ Page({ | ||
| 25 | signboard: {}, | 25 | signboard: {}, |
| 26 | store: {}, | 26 | store: {}, |
| 27 | recharge_data:{}, | 27 | recharge_data:{}, |
| 28 | - coupon_data:{}, | 28 | + coupon_dataList:[], |
| 29 | homeColor: '', | 29 | homeColor: '', |
| 30 | stringifyUse:'', | 30 | stringifyUse:'', |
| 31 | current: 0, | 31 | current: 0, |
| @@ -273,17 +273,40 @@ Page({ | @@ -273,17 +273,40 @@ Page({ | ||
| 273 | }).then(res => { | 273 | }).then(res => { |
| 274 | let data=res.data | 274 | let data=res.data |
| 275 | console.log('data',data); | 275 | console.log('data',data); |
| 276 | - let home,chef,marketing,reserve,swich_phone,signboard,store,homeColor,coupon_data,priceInfo,certificate,scoreInfo,recharge_list,stringifyUse; | ||
| 277 | - chef = util.determine(data.chef); | 276 | + let coupon_dataList=[] |
| 277 | + let home,chef,marketing,reserve,swich_phone,signboard,store,homeColor,priceInfo,certificate,scoreInfo,recharge_list,stringifyUse; | ||
| 278 | + chef = util.determine(data.chef); | ||
| 278 | reserve = util.determine(data.reserve); | 279 | reserve = util.determine(data.reserve); |
| 279 | swich_phone = reserve && reserve.swich_phone?reserve.swich_phone:''; | 280 | swich_phone = reserve && reserve.swich_phone?reserve.swich_phone:''; |
| 280 | marketing = util.determine(data.marketing); | 281 | marketing = util.determine(data.marketing); |
| 281 | signboard = util.determine(data.signboard); | 282 | signboard = util.determine(data.signboard); |
| 282 | store = util.determine(data.store); | 283 | store = util.determine(data.store); |
| 283 | home = util.determine(data.home); | 284 | home = util.determine(data.home); |
| 284 | - if(marketing && marketing.coupon_data){ | ||
| 285 | - coupon_data=marketing.coupon_data; | ||
| 286 | - stringifyUse=JSON.stringify(marketing.coupon_data.use) | 285 | + let coupon=util.determine(marketing.coupon_data) |
| 286 | + // is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示 | ||
| 287 | + if(coupon && util.getType(coupon)=='object'){ | ||
| 288 | + coupon.stringifyUse=JSON.stringify(coupon.use) | ||
| 289 | + if(marketing.is_coupon=='1' && coupon && (!coupon.use.is_cash || coupon.use.is_cash=='1')){ | ||
| 290 | + let cash=coupon.use.cash; | ||
| 291 | + let price=coupon.price*1; | ||
| 292 | + console.log('cash',cash+'---'+'price',price+'---'+'discount',((price/cash)*10).toFixed(2)); | ||
| 293 | + coupon.discount=((price/cash)*10).toFixed(2); | ||
| 294 | + } | ||
| 295 | + coupon_dataList.push(coupon); | ||
| 296 | + } | ||
| 297 | + if(coupon && util.getType(coupon)=='array'){ | ||
| 298 | + if(coupon.length>0){ | ||
| 299 | + coupon.forEach(item=>{ | ||
| 300 | + item.stringifyUse=JSON.stringify(item.use) | ||
| 301 | + if((!item.use.is_cash || item.use.is_cash=='1')){ | ||
| 302 | + let cash=item.use.cash; | ||
| 303 | + let price=item.price*1; | ||
| 304 | + console.log('cash',cash+'---'+'price',price+'---'+'discount',((price/cash)*10).toFixed(2)); | ||
| 305 | + item.discount=((price/cash)*10).toFixed(2); | ||
| 306 | + } | ||
| 307 | + }) | ||
| 308 | + } | ||
| 309 | + coupon_dataList=coupon; | ||
| 287 | } | 310 | } |
| 288 | let obj={ | 311 | let obj={ |
| 289 | chef, | 312 | chef, |
| @@ -293,7 +316,8 @@ Page({ | @@ -293,7 +316,8 @@ Page({ | ||
| 293 | store, | 316 | store, |
| 294 | home, | 317 | home, |
| 295 | stringifyUse, | 318 | stringifyUse, |
| 296 | - coupon_data, | 319 | + coupon, |
| 320 | + coupon_dataList, | ||
| 297 | swich_phone | 321 | swich_phone |
| 298 | } | 322 | } |
| 299 | console.log('获取数据', {...obj}); | 323 | console.log('获取数据', {...obj}); |
| @@ -312,21 +336,9 @@ Page({ | @@ -312,21 +336,9 @@ Page({ | ||
| 312 | console.log('recharge_data',recharge_data); | 336 | console.log('recharge_data',recharge_data); |
| 313 | } | 337 | } |
| 314 | this.setData({ | 338 | this.setData({ |
| 315 | - coupon_data, | 339 | + coupon_dataList, |
| 316 | stringifyUse | 340 | stringifyUse |
| 317 | }) | 341 | }) |
| 318 | - // is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示 | ||
| 319 | - if(marketing && marketing.is_coupon=='1' && coupon_data && (!coupon_data.use.is_cash || coupon_data.use.is_cash=='1')){ | ||
| 320 | - let cash=coupon_data.use.cash; | ||
| 321 | - let price=coupon_data.price*1; | ||
| 322 | - let discount=((price/cash)*10).toFixed(2); | ||
| 323 | - console.log('cash',cash); | ||
| 324 | - console.log('price',price); | ||
| 325 | - console.log('discount',discount); | ||
| 326 | - this.setData({ | ||
| 327 | - discount | ||
| 328 | - }) | ||
| 329 | - } | ||
| 330 | if(store && store.images.length>0) store.images =util.determine(store.images); | 342 | if(store && store.images.length>0) store.images =util.determine(store.images); |
| 331 | if(signboard && signboard.images) signboard.images = util.determine(signboard.images); | 343 | if(signboard && signboard.images) signboard.images = util.determine(signboard.images); |
| 332 | if (marketing && marketing.is_online_book=='1' && marketing.is_transpond =='1') { | 344 | if (marketing && marketing.is_online_book=='1' && marketing.is_transpond =='1') { |
| @@ -68,6 +68,34 @@ | @@ -68,6 +68,34 @@ | ||
| 68 | <text>{{seller.addr?seller.addr:reserev.seller.map_address}}</text> | 68 | <text>{{seller.addr?seller.addr:reserev.seller.map_address}}</text> |
| 69 | </view> | 69 | </view> |
| 70 | </view> | 70 | </view> |
| 71 | + <view class="preferential" wx:if="{{marketing && marketing.is_coupon=='1' && coupon_dataList.length>0}}"> | ||
| 72 | + <view wx:for="{{coupon_dataList}}" wx:key="index" wx:for-index="index"> | ||
| 73 | + <view class="preferentialItems" wx:if="{{dataStr<(item.etime*1)}}"> | ||
| 74 | + <view class="left"> | ||
| 75 | + <view class="top"> | ||
| 76 | + <text>{{item.aname}}</text> | ||
| 77 | + <text class="price" wx:if="{{item.price}}">¥{{item.price}}</text> | ||
| 78 | + <!-- is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示 --> | ||
| 79 | + <text wx:if="{{item.discount!='0.00' && (item.use.is_cash=='1' || item.use.is_cash)}}" class="discount">{{item.discount}}折</text> | ||
| 80 | + </view> | ||
| 81 | + <view wx:if="{{item.exp_date.is_week=='1' || item.exp_date.is_week===true}}" class="bottom" > | ||
| 82 | + {{item.exp_date.week_show?item.exp_date.week_show+'可用':''}}{{item.desc?','+item.desc+'。':'。'}} | ||
| 83 | + </view> | ||
| 84 | + <view wx:if="{{item.exp_date.is_none=='1' || item.exp_date.is_none===true}}" class="bottom" > | ||
| 85 | + 无限制{{item.desc?','+item.desc+'。':'。'}} | ||
| 86 | + </view> | ||
| 87 | + <view wx:if="{{item.exp_date.is_birthday=='1' || item.exp_date.is_birthday===true}}" class="bottom" > | ||
| 88 | + 会员生日当天可用{{item.desc?','+item.desc+'。':'。'}} | ||
| 89 | + </view> | ||
| 90 | + </view> | ||
| 91 | + <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"> | ||
| 92 | + <view class="font24r orderingFood"> | ||
| 93 | + 去抢购 | ||
| 94 | + </view> | ||
| 95 | + </navigator> | ||
| 96 | + </view> | ||
| 97 | + </view> | ||
| 98 | + </view> | ||
| 71 | <!-- <view class="visitor"> | 99 | <!-- <view class="visitor"> |
| 72 | 确认赴约客人:{{keepAppointment.length}}位 | 100 | 确认赴约客人:{{keepAppointment.length}}位 |
| 73 | </view> | 101 | </view> |
| @@ -191,30 +219,6 @@ | @@ -191,30 +219,6 @@ | ||
| 191 | <view class="rubric rubric1"> | 219 | <view class="rubric rubric1"> |
| 192 | 特别优惠 | 220 | 特别优惠 |
| 193 | </view> | 221 | </view> |
| 194 | - <view class="preferentialItems" wx:if="{{marketing && marketing.is_coupon=='1' && dataStr<(coupon_data.etime*1)}}"> | ||
| 195 | - <view class="left"> | ||
| 196 | - <view class="top"> | ||
| 197 | - <text>{{coupon_data.aname}}</text> | ||
| 198 | - <text class="price" wx:if="{{coupon_data.price}}">¥{{coupon_data.price}}</text> | ||
| 199 | - <!-- is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示 --> | ||
| 200 | - <text wx:if="{{discount!='0.00' && (coupon_data.use.is_cash=='1' || coupon_data.use.is_cash)}}" class="discount">{{discount}}折</text> | ||
| 201 | - </view> | ||
| 202 | - <view wx:if="{{coupon_data.exp_date.is_week=='1' || coupon_data.exp_date.is_week===true}}" class="bottom" > | ||
| 203 | - {{coupon_data.exp_date.week_show?coupon_data.exp_date.week_show+'可用':''}}{{coupon_data.desc?','+coupon_data.desc+'。':'。'}} | ||
| 204 | - </view> | ||
| 205 | - <view wx:if="{{coupon_data.exp_date.is_none=='1' || coupon_data.exp_date.is_none===true}}" class="bottom" > | ||
| 206 | - 无限制{{coupon_data.desc?','+coupon_data.desc+'。':'。'}} | ||
| 207 | - </view> | ||
| 208 | - <view wx:if="{{coupon_data.exp_date.is_birthday=='1' || coupon_data.exp_date.is_birthday===true}}" class="bottom" > | ||
| 209 | - 会员生日当天可用{{coupon_data.desc?','+coupon_data.desc+'。':'。'}} | ||
| 210 | - </view> | ||
| 211 | - </view> | ||
| 212 | - <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"> | ||
| 213 | - <view class="font24r orderingFood"> | ||
| 214 | - 去抢购 | ||
| 215 | - </view> | ||
| 216 | - </navigator> | ||
| 217 | - </view> | ||
| 218 | <!-- 当前日期要大于限制结束日期 --> | 222 | <!-- 当前日期要大于限制结束日期 --> |
| 219 | <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)))}}"> | 223 | <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)))}}"> |
| 220 | <view class="left"> | 224 | <view class="left"> |
| @@ -179,6 +179,10 @@ function objCompare (obj1, obj2,key){ | @@ -179,6 +179,10 @@ function objCompare (obj1, obj2,key){ | ||
| 179 | return 0; | 179 | return 0; |
| 180 | } | 180 | } |
| 181 | } | 181 | } |
| 182 | +// 判断是数组还是对象 返回 object 或者 array | ||
| 183 | +function getType(variable) { | ||
| 184 | + return ({}).toString.call(variable).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); | ||
| 185 | +} | ||
| 182 | module.exports = { | 186 | module.exports = { |
| 183 | formatTime: formatTime, | 187 | formatTime: formatTime, |
| 184 | unixtoTime: unixtoTime, | 188 | unixtoTime: unixtoTime, |
| @@ -186,6 +190,7 @@ module.exports = { | @@ -186,6 +190,7 @@ module.exports = { | ||
| 186 | parseDataValue, | 190 | parseDataValue, |
| 187 | determine, | 191 | determine, |
| 188 | objCompare, | 192 | objCompare, |
| 193 | + getType, | ||
| 189 | imageZoomHeightUtil, | 194 | imageZoomHeightUtil, |
| 190 | cgi: function (act) { | 195 | cgi: function (act) { |
| 191 | return uri.HOST__LINE + act //正式 | 196 | return uri.HOST__LINE + act //正式 |
-
Please register or login to post a comment