Commit 0319e33e5d678e0972c59e1d7a1a75dbea422244

Authored by pengye
1 parent 330fb60e

排菜套餐页面

  1 +// pack-cookbook/pages/comboBuy.js
  2 +import util from '../../utils/util';
  3 +import App from '../../utils/api';
  4 +Page({
  5 +
  6 + /**
  7 + * 页面的初始数据
  8 + */
  9 + data: {
  10 + sid: '',
  11 + details: {}, //上页面传入的套餐信息
  12 + seller: {}, //商家信息
  13 + couponArr: [], //本套餐可用的优惠券列表
  14 + finalList: [], //勾选的券列表
  15 + planPrice: '', //套餐价格
  16 + memberPrice: '', //菜品原价
  17 + discountPrice: '', //优惠金额
  18 + actualPrice: '', //抵扣后价格
  19 + couponSwitch: true, //本单使用优惠券开关
  20 + dataStr: Date.now() * 1 / 1000,
  21 + },
  22 + couponModal: '',
  23 +
  24 + /**
  25 + * 生命周期函数--监听页面加载
  26 + */
  27 + onLoad(options) {
  28 + console.log('comboBuy options----', options);
  29 + this.couponModal = this.selectComponent("#couponModal");
  30 + let details = {};
  31 + if (options.details) {
  32 + details = JSON.parse(options.details);
  33 + }
  34 + let planPrice = details.plan_price || '';
  35 + let memberPrice = details.member_price || details.menu_price || '';
  36 + if (planPrice !== '') {
  37 + planPrice = parseFloat(planPrice).toFixed(2);
  38 + }
  39 + if (memberPrice !== '') {
  40 + memberPrice = parseFloat(memberPrice).toFixed(2);
  41 + }
  42 + this.setData({
  43 + details,
  44 + planPrice,
  45 + memberPrice,
  46 + actualPrice: planPrice || '0.00',
  47 + })
  48 + let sid = (details.seller && details.seller.sid) || options.sid || '';
  49 + if (sid) {
  50 + this.setData({
  51 + sid
  52 + })
  53 + if (details.seller) {
  54 + this.setData({
  55 + seller: details.seller
  56 + })
  57 + }
  58 + this.getSellerDetailFun(sid)
  59 + }
  60 + },
  61 + // 获取商家名称、照片
  62 + getSellerDetailFun(sid) {
  63 + App.Customer.GetSellerDetail({
  64 + sid
  65 + }).then(res => {
  66 + let data = res.data;
  67 + this.setData({
  68 + seller: {
  69 + seller_image: data.seller_image,
  70 + sellername: data.sellername,
  71 + sid: data.id
  72 + }
  73 + })
  74 + this.getCoupon()
  75 + })
  76 + },
  77 + // 获取所有优惠券,只展示本套餐可用的
  78 + getCoupon() {
  79 + if (!this.data.sid) return;
  80 + App.Activity.ActivityListByOpenid({
  81 + sellerid: this.data.sid
  82 + }).then(res => {
  83 + if (res.ret == 200 && res.data && res.data.length > 0) {
  84 + let list = res.data;
  85 + list.forEach(detail => {
  86 + detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
  87 + detail.arule = detail.arule ? util.determine(detail.arule) : '';
  88 + detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
  89 + detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
  90 + if (detail.arule) {
  91 + detail.accumulationShow = detail.arule.is_accumulation
  92 + }
  93 + if (detail.exp_date && detail.exp_date.week_data) {
  94 + let mor = this.hasConsecutiveSelect(detail.exp_date.week_data, '1').rArr.join('、')
  95 + let noon = this.hasConsecutiveSelect(detail.exp_date.week_data, '2').rArr.join('、')
  96 + let nig = this.hasConsecutiveSelect(detail.exp_date.week_data, '3').rArr.join('、')
  97 + if (mor) mor = '早餐:' + mor
  98 + if (noon) noon = '午餐:' + noon
  99 + if (nig) nig = '晚餐:' + nig
  100 + detail.morText = mor;
  101 + detail.noonText = noon;
  102 + detail.nigText = nig;
  103 + }
  104 + detail.checked = false;
  105 + detail.showCpupon = '0';
  106 + detail.cdate = detail.cdate * 1;
  107 + detail.useStime = '';
  108 + detail.useEtime = '';
  109 + let condition = detail.aexpiration || {};
  110 + if (condition.valid_forever === '0' && condition.stime && condition.etime) {
  111 + detail.useStime = condition.stime;
  112 + detail.useEtime = condition.etime;
  113 + }
  114 + if (condition.valid_forever === '1') {
  115 + detail.foreverText = '永久有效';
  116 + }
  117 + if (condition.valid_forever === '0' && condition.today) {
  118 + let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
  119 + detail.useStime = obj.useStime;
  120 + detail.useEtime = obj.useEtime;
  121 + }
  122 + if (condition.valid_forever === '0' && condition.tomorrow) {
  123 + let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
  124 + detail.useStime = obj.useStime;
  125 + detail.useEtime = obj.useEtime;
  126 + }
  127 + if (condition.valid_forever === '0' && condition.sday && condition.eday) {
  128 + let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, parseInt(condition.eday) - 1);
  129 + detail.useStime = obj.useStime;
  130 + detail.useEtime = obj.useEtime;
  131 + }
  132 + if ((detail.useStime > 0 && detail.useEtime > 0) || condition.valid_forever === '1') {
  133 + detail.endDateStr = condition.valid_forever == '1' ? '永久有效' : (util.unixtoTime(detail.useStime, 'YYYY-MM-DD') + '至' + util.unixtoTime(detail.useEtime, 'YYYY-MM-DD'));
  134 + }
  135 + })
  136 + // 过滤已过期的券
  137 + list = list.filter(item => {
  138 + return (this.data.dataStr < (item.useEtime * 1) || item.aexpiration.valid_forever == '1');
  139 + })
  140 + // 判断券是否可用:满足套餐价格门槛的才显示
  141 + let planPrice = parseFloat(this.data.planPrice) || 0;
  142 + list = list.filter(item => {
  143 + let desc = parseFloat(item.desc) || 0;
  144 + return desc == 0 || planPrice >= desc;
  145 + })
  146 + // 相同aid的券合并成一张,用加减号选择张数
  147 + let couponGroup = {};
  148 + let couponList = [];
  149 + list.forEach(item => {
  150 + let key = item.aid ? item.aid : item.activity_id
  151 + if (couponGroup[key]) {
  152 + couponGroup[key].num = (couponGroup[key].num * 1) + 1
  153 + couponGroup[key].activityIds.push(item.activity_id)
  154 + } else {
  155 + item.num = 1
  156 + item.checkedNum = 0
  157 + item.groupKey = key
  158 + item.activityIds = [item.activity_id]
  159 + couponGroup[key] = item
  160 + couponList.push(item)
  161 + }
  162 + })
  163 + list = couponList
  164 + // 单次使用数量限制,0表示不限制,默认0
  165 + list.forEach(item => {
  166 + let useLimit = item.single_use_limit ? (item.single_use_limit * 1) : 0
  167 + item.maxNum = (useLimit > 0 && useLimit < item.num) ? useLimit : item.num
  168 + item.showCpupon = '1'
  169 + item.canCheck = '1'
  170 + item.isOk = '1'
  171 + })
  172 + // 面额大的排在前面
  173 + list.sort((a, b) => (parseFloat(b.price) || 0) - (parseFloat(a.price) || 0))
  174 + console.log('comboBuy couponArr----', list);
  175 + this.setData({
  176 + couponArr: list
  177 + })
  178 + if (this.data.couponSwitch) {
  179 + this.colationData()
  180 + }
  181 + } else {
  182 + this.setData({
  183 + couponArr: [],
  184 + discountPrice: '',
  185 + actualPrice: this.data.planPrice || '0.00',
  186 + })
  187 + }
  188 + })
  189 + },
  190 + // 打开优惠券弹框
  191 + showCouponModal() {
  192 + this.couponModal.showModal()
  193 + },
  194 + // 关闭优惠券弹框
  195 + closeCouponModal() {
  196 + this.couponModal.closeModal()
  197 + },
  198 + // 使用券开关
  199 + switchChange(event) {
  200 + this.setData({
  201 + couponSwitch: event.detail.value,
  202 + })
  203 + if (this.data.couponSwitch) {
  204 + this.colationData()
  205 + } else {
  206 + let list = this.data.couponArr;
  207 + list.forEach(i => {
  208 + i.checkedNum = 0;
  209 + i.showCpupon = '1';
  210 + i.canAdd = '1';
  211 + })
  212 + this.setData({
  213 + couponArr: list,
  214 + finalList: [],
  215 + discountPrice: '',
  216 + actualPrice: this.data.planPrice || '0.00',
  217 + })
  218 + }
  219 + },
  220 + // 加减号选择券的张数
  221 + changeCouponNum(e) {
  222 + let type = e.currentTarget.dataset.type;
  223 + let aid = e.currentTarget.dataset.aid;
  224 + const list = this.data.couponArr
  225 + let item = list.find(i => i.aid == aid)
  226 + if (!item) return
  227 + if (type == 'plus') {
  228 + if (item.canAdd != '1') return
  229 + item.checkedNum = (item.checkedNum * 1) + 1
  230 + }
  231 + if (type == 'minus') {
  232 + if (item.checkedNum <= 0) return
  233 + item.checkedNum = (item.checkedNum * 1) - 1
  234 + }
  235 + this.refreshCouponState()
  236 + },
  237 + // 加减号中间输入框
  238 + numInputChange(e) {
  239 + let aid = e.currentTarget.dataset.aid;
  240 + let val = (e.detail.value || '').replace(/[^\d]/g, '');
  241 + const list = this.data.couponArr
  242 + let item = list.find(i => i.aid == aid)
  243 + if (!item) return
  244 + let maxSelect = this.getMaxSelectNum(item)
  245 + let num = val === '' ? 0 : parseInt(val, 10)
  246 + if (isNaN(num)) num = 0
  247 + if (num > maxSelect) num = maxSelect
  248 + item.checkedNum = num
  249 + this.refreshCouponState()
  250 + },
  251 + // 计算某张券当前最多可以选到的张数
  252 + getMaxSelectNum(item) {
  253 + const list = this.data.couponArr
  254 + let inputValue = parseFloat(this.data.planPrice)
  255 + let descStr = 0
  256 + let val = 0
  257 + list.forEach(i => {
  258 + if (i.checkedNum > 0 && i.aid != item.aid) {
  259 + let d = parseFloat(i.desc) || 0
  260 + if (d > 0) descStr += d * i.checkedNum
  261 + val += parseFloat(i.price) * i.checkedNum
  262 + }
  263 + })
  264 + let itemDesc = parseFloat(item.desc) || 0
  265 + let itemPrice = parseFloat(item.price)
  266 + let maxSelect = item.maxNum
  267 + if (item.accumulationShow != '1' && maxSelect > 1) maxSelect = 1
  268 + if (inputValue > 0) {
  269 + if (itemDesc > 0) {
  270 + let byDesc = Math.floor((inputValue - descStr) / itemDesc)
  271 + if (byDesc < maxSelect) maxSelect = byDesc
  272 + } else {
  273 + if (descStr >= inputValue) {
  274 + maxSelect = 0
  275 + } else {
  276 + let byPrice = Math.floor((inputValue - val) / itemPrice)
  277 + if (byPrice < maxSelect) maxSelect = byPrice
  278 + }
  279 + }
  280 + }
  281 + if (maxSelect < 0) maxSelect = 0
  282 + return maxSelect
  283 + },
  284 + // 根据选择的券张数刷新券的可选状态
  285 + refreshCouponState() {
  286 + const list = this.data.couponArr
  287 + let currentCoupon = '0';
  288 + let inputValue = parseFloat(this.data.planPrice)
  289 + let val = 0;
  290 + let descStr = 0;
  291 + list.forEach(item => {
  292 + if (item.checkedNum > 0) {
  293 + val += parseFloat(item.price) * item.checkedNum
  294 + let itemDesc = parseFloat(item.desc) || 0
  295 + if (itemDesc > 0) {
  296 + descStr += itemDesc * item.checkedNum
  297 + }
  298 + if (item.accumulationShow != '1') {
  299 + currentCoupon = '2'
  300 + } else {
  301 + currentCoupon = '1'
  302 + }
  303 + }
  304 + })
  305 + if (currentCoupon == '0') {
  306 + list.forEach(item => {
  307 + if (item.canCheck == "1") {
  308 + item.showCpupon = '1';
  309 + }
  310 + })
  311 + }
  312 + if (currentCoupon == '2') {
  313 + list.map((item) => {
  314 + if (item.checkedNum > 0) {
  315 + item.showCpupon = '1'
  316 + } else {
  317 + item.showCpupon = '0'
  318 + }
  319 + })
  320 + }
  321 + if (currentCoupon == '1') {
  322 + list.forEach(item => {
  323 + if (item.checkedNum > 0 || (item.accumulationShow == "1" && parseFloat(item.price) <= (inputValue - val) && (((parseFloat(item.desc) || 0) > 0 && (inputValue - descStr) >= parseFloat(item.desc)) || ((parseFloat(item.desc) || 0) === 0 && descStr < inputValue)))) {
  324 + item.showCpupon = '1';
  325 + } else {
  326 + item.showCpupon = '0';
  327 + }
  328 + })
  329 + }
  330 + let finalList = []
  331 + list.forEach(item => {
  332 + if (item.checkedNum > 0) {
  333 + for (let k = 0; k < item.checkedNum; k++) {
  334 + finalList.push({
  335 + ...item,
  336 + activity_id: item.activityIds[k]
  337 + })
  338 + }
  339 + }
  340 + })
  341 + this.updateCanAdd()
  342 + let discountPrice = 0;
  343 + finalList.forEach(i => {
  344 + discountPrice += parseFloat(i.price)
  345 + })
  346 + discountPrice = discountPrice.toFixed(2)
  347 + let actualPrice = (inputValue - discountPrice).toFixed(2)
  348 + if (parseFloat(actualPrice) < 0) actualPrice = '0.00'
  349 + this.setData({
  350 + couponArr: list,
  351 + finalList,
  352 + discountPrice: discountPrice == '0.00' ? '' : discountPrice,
  353 + actualPrice,
  354 + })
  355 + },
  356 + // 计算每张券还能不能继续加
  357 + updateCanAdd() {
  358 + const list = this.data.couponArr
  359 + let inputValue = parseFloat(this.data.planPrice)
  360 + let descStr = 0
  361 + let val = 0
  362 + list.forEach(item => {
  363 + if (item.checkedNum > 0) {
  364 + let itemDesc = parseFloat(item.desc) || 0
  365 + let itemPrice = parseFloat(item.price)
  366 + if (itemDesc > 0) descStr += itemDesc * item.checkedNum
  367 + val += itemPrice * item.checkedNum
  368 + }
  369 + })
  370 + list.forEach(item => {
  371 + item.canAdd = '0'
  372 + let maxSelect = item.accumulationShow == '1' ? item.maxNum : 1
  373 + if (item.showCpupon == '1' && item.checkedNum < maxSelect) {
  374 + let itemDesc = parseFloat(item.desc) || 0
  375 + let itemPrice = parseFloat(item.price)
  376 + if (itemDesc > 0) {
  377 + if (descStr + itemDesc <= inputValue) item.canAdd = '1'
  378 + } else {
  379 + if (descStr < inputValue && val + itemPrice <= inputValue) item.canAdd = '1'
  380 + }
  381 + }
  382 + })
  383 + },
  384 + // 点确认选择
  385 + checkCertificate() {
  386 + this.closeCouponModal()
  387 + let list = this.data.couponArr;
  388 + let price = 0;
  389 + list.forEach(i => {
  390 + if (i.checkedNum > 0) {
  391 + price += parseFloat(i.price) * i.checkedNum
  392 + }
  393 + })
  394 + let planPrice = parseFloat(this.data.planPrice) || 0;
  395 + let actualPrice = (planPrice - price).toFixed(2)
  396 + if (parseFloat(actualPrice) < 0) actualPrice = '0.00'
  397 + price = price.toFixed(2)
  398 + this.setData({
  399 + couponSwitch: price != '0.00',
  400 + discountPrice: price == '0.00' ? '' : price,
  401 + actualPrice,
  402 + })
  403 + },
  404 + // 自动勾选最优惠券组合
  405 + colationData() {
  406 + let list = this.data.couponArr;
  407 + if (!list.length) {
  408 + this.setData({
  409 + discountPrice: '',
  410 + actualPrice: this.data.planPrice || '0.00',
  411 + })
  412 + return
  413 + }
  414 + let obj = this.findBestCoupons(list);
  415 + this.setData({
  416 + couponArr: obj.arr,
  417 + })
  418 + this.refreshCouponState()
  419 + },
  420 + // 最优惠的消费券组合
  421 + findBestCoupons(arr) {
  422 + const amount = parseFloat(this.data.planPrice) || 0;
  423 + const validCoupons = arr.filter(coupon => (coupon.isOk == '1' && parseFloat(coupon.desc) <= amount) && amount >= parseFloat(coupon.price));
  424 + validCoupons.sort((a, b) => parseFloat(b.price) - parseFloat(a.price));
  425 + arr.forEach(item => {
  426 + const isValid = validCoupons.some(validCoupon => validCoupon.activity_id == item.activity_id);
  427 + item.canCheck = isValid ? '1' : '0';
  428 + item.checkedNum = 0;
  429 + item.showCpupon = isValid ? '1' : '0';
  430 + });
  431 + let stackingCoupons = validCoupons.filter(i => i.accumulationShow == '1')
  432 + let list1 = [];
  433 + let list2 = [];
  434 + let finalList = [];
  435 + let selectCount = {};
  436 + stackingCoupons.sort((a, b) => {
  437 + if (a.desc === '0' || a.desc === '') return -1;
  438 + if (b.desc === '0' || b.desc === '') return 1;
  439 + if (parseFloat(b.price) !== parseFloat(a.price)) return parseFloat(b.price) - parseFloat(a.price);
  440 + return parseFloat(b.desc) - parseFloat(a.desc);
  441 + });
  442 + let thresholdDescSum = 0
  443 + let maxThresholdValue = 0
  444 + let thresholdCoupons = stackingCoupons.filter(coupon => (parseFloat(coupon.desc) || 0) > 0)
  445 + thresholdCoupons.sort((a, b) => {
  446 + if (parseFloat(b.desc) !== parseFloat(a.desc)) return parseFloat(b.desc) - parseFloat(a.desc)
  447 + return parseFloat(b.price) - parseFloat(a.price)
  448 + })
  449 + thresholdCoupons.forEach(coupon => {
  450 + let couponDesc = parseFloat(coupon.desc) || 0
  451 + let couponPrice = parseFloat(coupon.price)
  452 + let maxCopies = Math.floor((amount - thresholdDescSum) / couponDesc)
  453 + if (maxCopies > coupon.maxNum) maxCopies = coupon.maxNum
  454 + if (maxCopies > 0) {
  455 + selectCount[coupon.aid] = maxCopies
  456 + thresholdDescSum += couponDesc * maxCopies
  457 + maxThresholdValue += couponPrice * maxCopies
  458 + }
  459 + })
  460 + list1 = stackingCoupons.filter(i => (selectCount[i.aid] || 0) > 0)
  461 + let noDescValue = 0
  462 + let noDescCount = {}
  463 + stackingCoupons.forEach(coupon => {
  464 + let couponDesc = parseFloat(coupon.desc) || 0
  465 + let couponPrice = parseFloat(coupon.price)
  466 + if (couponDesc === 0 && couponPrice > 0) {
  467 + let num = Math.floor((amount - noDescValue) / couponPrice)
  468 + if (num > coupon.maxNum) num = coupon.maxNum
  469 + if (num > 0) {
  470 + noDescCount[coupon.aid] = num
  471 + noDescValue += couponPrice * num
  472 + }
  473 + }
  474 + })
  475 + let maxStackableValue = maxThresholdValue
  476 + if (thresholdDescSum < amount) {
  477 + stackingCoupons.forEach(coupon => {
  478 + let couponDesc = parseFloat(coupon.desc) || 0
  479 + let couponPrice = parseFloat(coupon.price)
  480 + if (couponDesc === 0 && couponPrice > 0) {
  481 + let num = Math.floor((amount - maxStackableValue) / couponPrice)
  482 + if (num > coupon.maxNum) num = coupon.maxNum
  483 + if (num > 0) {
  484 + selectCount[coupon.aid] = num
  485 + maxStackableValue += couponPrice * num
  486 + }
  487 + }
  488 + })
  489 + list1 = stackingCoupons.filter(i => (selectCount[i.aid] || 0) > 0)
  490 + } else if (noDescValue > maxThresholdValue) {
  491 + list1 = stackingCoupons.filter(i => (noDescCount[i.aid] || 0) > 0)
  492 + selectCount = noDescCount
  493 + maxStackableValue = noDescValue
  494 + } else if (noDescValue == maxThresholdValue && noDescValue > 0) {
  495 + let listThreshold = stackingCoupons.filter(i => (selectCount[i.aid] || 0) > 0)
  496 + let listNoDesc = stackingCoupons.filter(i => (noDescCount[i.aid] || 0) > 0)
  497 + let min1 = listThreshold.length > 0 ? Math.min(...listThreshold.map(item => item.useEtime)) : Infinity
  498 + let min2 = listNoDesc.length > 0 ? Math.min(...listNoDesc.map(item => item.useEtime)) : Infinity
  499 + if (min2 < min1) {
  500 + list1 = listNoDesc
  501 + selectCount = noDescCount
  502 + }
  503 + }
  504 + let stackList = list1
  505 + let stackCount = selectCount
  506 + let maxNonStackableValue = 0
  507 + validCoupons.forEach(coupon => {
  508 + if (coupon.accumulationShow != '1') {
  509 + const discountAmount = parseFloat(coupon.price);
  510 + const finalAmount = amount - discountAmount;
  511 + if (finalAmount > 0 || finalAmount == 0) {
  512 + if (maxNonStackableValue < discountAmount) {
  513 + maxNonStackableValue = discountAmount
  514 + list2 = [{ ...coupon }]
  515 + }
  516 + }
  517 + }
  518 + });
  519 + if (maxStackableValue > maxNonStackableValue) {
  520 + finalList = stackList
  521 + } else if (maxStackableValue < maxNonStackableValue) {
  522 + finalList = list2
  523 + stackCount = {}
  524 + if (list2[0]) stackCount[list2[0].aid] = 1
  525 + } else {
  526 + let copiedList1 = JSON.parse(JSON.stringify(stackList));
  527 + let copiedList2 = JSON.parse(JSON.stringify(list2));
  528 + let minList1 = copiedList1.length > 0 ? Math.min(...copiedList1.map(item => item.useEtime)) : Infinity;
  529 + let minList2 = copiedList2.length > 0 ? Math.min(...copiedList2.map(item => item.useEtime)) : Infinity;
  530 + if (minList1 <= minList2) {
  531 + finalList = stackList
  532 + } else {
  533 + finalList = list2
  534 + stackCount = {}
  535 + if (list2[0]) stackCount[list2[0].aid] = 1
  536 + }
  537 + }
  538 + let discountPrice = 0;
  539 + finalList.forEach(coupon => {
  540 + let target = arr.findIndex(obj => obj.aid === coupon.aid || obj.activity_id === coupon.activity_id);
  541 + if (target > -1) {
  542 + arr[target].showCpupon = '1';
  543 + arr[target].checkedNum = stackCount[coupon.aid] || 1;
  544 + discountPrice += parseFloat(coupon.price) * (stackCount[coupon.aid] || 1);
  545 + }
  546 + });
  547 + finalList = []
  548 + arr.forEach(item => {
  549 + if (item.checkedNum > 0) {
  550 + for (let k = 0; k < item.checkedNum; k++) {
  551 + finalList.push({
  552 + ...item,
  553 + activity_id: item.activityIds[k]
  554 + })
  555 + }
  556 + }
  557 + })
  558 + discountPrice = discountPrice.toFixed(2)
  559 + return {
  560 + arr,
  561 + discountPrice,
  562 + finalList,
  563 + };
  564 + },
  565 + // 处理优惠券不可用日期数据
  566 + hasConsecutiveSelect(arr, type) {
  567 + let firstTitle = null;
  568 + let lastTitle = null;
  569 + let rArr = []
  570 + let num = 0
  571 + for (let i = 0; i < arr.length; i++) {
  572 + let str = type == '1' ? arr[i].selectMor : type == '2' ? arr[i].selectNoon : type == '3' ? arr[i].selectNig : '';
  573 + if (str) {
  574 + rArr.push(arr[i].title)
  575 + num++
  576 + if (num == 1) {
  577 + firstTitle = arr[i].title
  578 + }
  579 + if (num >= 5) {
  580 + lastTitle = arr[i].title
  581 + }
  582 + if (num >= 5 && i >= (arr.length - 1)) {
  583 + let fi = rArr.findIndex((item) => {
  584 + return item == firstTitle
  585 + })
  586 + rArr.splice(fi, num, firstTitle + '至' + lastTitle)
  587 + num = 0
  588 + }
  589 + } else {
  590 + if (num < 5) {
  591 + num = 0
  592 + firstTitle = null;
  593 + lastTitle = null;
  594 + } else {
  595 + let fi = rArr.findIndex((item) => {
  596 + return item == firstTitle
  597 + })
  598 + rArr.splice(fi, num, firstTitle + '至' + lastTitle)
  599 + num = 0
  600 + }
  601 + }
  602 + }
  603 + return {
  604 + rArr,
  605 + lastTitle,
  606 + firstTitle
  607 + };
  608 + },
  609 + // 计算免费券有效期的起始、结束日期
  610 + setTimeRange(cdate, startOffset, endOffset) {
  611 + const startDate = new Date((cdate + startOffset * 86400) * 1000);
  612 + startDate.setHours(0, 0, 0, 0);
  613 + let useStime = startDate.getTime() / 1000
  614 + const endDate = new Date((cdate + endOffset * 86400) * 1000);
  615 + endDate.setHours(23, 59, 59, 0);
  616 + let useEtime = endDate.getTime() / 1000
  617 + return { useStime, useEtime };
  618 + },
  619 + // 支付(暂未接入支付流程,先占位)
  620 + submitPay() {
  621 + wx.showToast({
  622 + title: '支付功能开发中',
  623 + icon: 'none',
  624 + })
  625 + },
  626 +
  627 + onReady() {},
  628 + onShow() {},
  629 + onHide() {},
  630 + onUnload() {},
  631 + onPullDownRefresh() {},
  632 + onReachBottom() {},
  633 + onShareAppMessage() {}
  634 +})
  1 +{
  2 + "backgroundTextStyle": "light",
  3 + "navigationBarBackgroundColor": "#fff",
  4 + "navigationBarTextStyle": "black",
  5 + "usingComponents": {
  6 + "nav": "/components/nav/nav",
  7 + "my-modal": "/components/modal/modal"
  8 + }
  9 +}
  1 +<!--pack-cookbook/pages/comboBuy.wxml-->
  2 +<nav>套餐购买</nav>
  3 +<!-- 商家信息 -->
  4 +<view class="sellInfo">
  5 + <image src="{{seller.seller_image}}" mode="aspectFill" />
  6 + <view class="nameInfo font32r">{{seller.sellername}}</view>
  7 +</view>
  8 +<!-- 套餐信息 -->
  9 +<view class="comboCard">
  10 + <view class="priceRow">
  11 + <text class="label font28r">套餐名称</text>
  12 + <view class="valueText font28r">{{details.pname}}</view>
  13 + </view>
  14 + <view class="priceRow" wx:if="{{memberPrice}}">
  15 + <text class="label font28r">菜品原价</text>
  16 + <view class="memberPrice font28r">¥ {{memberPrice}}</view>
  17 + </view>
  18 + <view class="priceRow">
  19 + <text class="label font28r">套餐价格</text>
  20 + <view class="valueText font28r">¥ {{planPrice}}</view>
  21 + </view>
  22 + <view bindtap="showCouponModal" class="priceRow couponsBox colorOrange">
  23 + <view class="couponLeft font28r">选择优惠券</view>
  24 + <view class="couponRight">
  25 + <text wx:if="{{discountPrice && discountPrice!='0.00' && couponSwitch}}">- ¥ {{discountPrice}}</text>
  26 + <text class="noUse font28r" wx:if="{{couponArr.length == 0}}">暂无可用</text>
  27 + <view class="more"></view>
  28 + </view>
  29 + </view>
  30 + <view class="priceRow">
  31 + <text class="label font28r">抵扣后</text>
  32 + <view class="valueText font28r">¥ {{actualPrice}}</view>
  33 + </view>
  34 +</view>
  35 +<view class="bottomBox"></view>
  36 +<!-- 底部支付 -->
  37 +<view class="payBtnBox">
  38 + <view class="total">合计<text>¥ {{actualPrice}}</text></view>
  39 + <view class="payBtn font32r" bindtap="submitPay">支付</view>
  40 +</view>
  41 +<!-- 使用优惠券弹框 -->
  42 +<my-modal id="couponModal" fadeStyle="slideUp" height="{{couponArr.length > 3 ? '80%' : '60%'}}">
  43 + <view slot="modalName" class="titleModal">
  44 + <image bind:tap="closeCouponModal" src="https://qn.colorcun.com/closeImg1.png" mode="aspectFit" />
  45 + <view class="couponTotalText font28r">所有优惠券</view>
  46 + <view bindtap="checkCertificate" class="btn font32r">确认</view>
  47 + </view>
  48 + <view slot="modalContent">
  49 + <view class="infoBox">
  50 + <view class="infoTop">
  51 + <view class="info font28r">本单使用优惠券</view>
  52 + <switch checked="{{couponSwitch}}" bindchange="switchChange" color="#09BB07" class="infoSwitch" />
  53 + </view>
  54 + <view class="infoBottom font24r">选择优惠券后可抵扣套餐价格</view>
  55 + </view>
  56 + <scroll-view class="couponBox" scroll-y="true">
  57 + <view wx:for="{{couponArr}}" data-aid="{{item.aid}}" class="couponItems {{item.showCpupon == '0' ? 'couponNo' : ''}}" wx:key="groupKey">
  58 + <view class="itemLeft">
  59 + <view class="priceText" wx:if="{{item.price}}">
  60 + <view class="icons font24r">¥</view><text class="priceText">{{item.price}}</text>
  61 + </view>
  62 + <view class="icons font20r" wx:if="{{item.desc && item.desc != '0'}}">消费满{{item.desc}}元可用</view>
  63 + <view class="icons font20r" wx:else>无门槛</view>
  64 + </view>
  65 + <view class="itemRight">
  66 + <view class="anameText">
  67 + <view class="anameInfo">
  68 + <view class="names font40r">{{item.aname}}</view>
  69 + <view class="discountText1 font20r">{{item.accumulationShow == '1' ? '可' : '不可'}}叠加</view>
  70 + </view>
  71 + </view>
  72 + <view wx:if="{{item.endDateStr}}" class="font20r bottomTitle">有效日期:<view class="bottom font20r">{{item.endDateStr}}</view>
  73 + </view>
  74 + <view wx:if="{{item.morText || item.noonText || item.nigText}}" class="font20r bottomTitle"><text>不可使用:</text>
  75 + <view class="textBox">
  76 + <view wx:if="{{item.morText}}" class="bottom font20r">{{item.morText}}</view>
  77 + <view wx:if="{{item.noonText}}" class="bottom font20r">{{item.noonText}}</view>
  78 + <view wx:if="{{item.nigText}}" class="bottom font20r">{{item.nigText}}</view>
  79 + </view>
  80 + </view>
  81 + <view wx:if="{{item.exp_date.week_show=='无'}}" class="bottom font20r">无使用时间限制</view>
  82 + </view>
  83 + <view class="rightBox">
  84 + <view class="ownNum font20r">拥有{{item.num}}张</view>
  85 + <view class="numBox">
  86 + <view class="numBtn {{item.checkedNum == 0 ? 'numBtnDisabled' : ''}}" bindtap="changeCouponNum" data-aid="{{item.aid}}" data-type="minus">-</view>
  87 + <input class="numText" type="number" value="{{item.checkedNum}}" data-aid="{{item.aid}}" disabled="{{item.showCpupon == '0'}}" bindinput="numInputChange" />
  88 + <view class="numBtn {{item.canAdd != '1' ? 'numBtnDisabled' : ''}}" bindtap="changeCouponNum" data-aid="{{item.aid}}" data-type="plus">+</view>
  89 + </view>
  90 + </view>
  91 + </view>
  92 + </scroll-view>
  93 + </view>
  94 +</my-modal>
  1 +/* pack-cookbook/pages/comboBuy.wxss */
  2 +page {
  3 + background: #F5F5F5;
  4 +}
  5 +
  6 +/* 商家信息 */
  7 +.sellInfo {
  8 + padding: 56rpx 0 40rpx 0;
  9 + display: flex;
  10 + flex-direction: column;
  11 + align-items: center;
  12 + justify-content: center;
  13 + background: #fff;
  14 +}
  15 +
  16 +.sellInfo image {
  17 + width: 200rpx;
  18 + height: 200rpx;
  19 + margin-bottom: 20rpx;
  20 +}
  21 +
  22 +.sellInfo .nameInfo {
  23 + color: #000000;
  24 + font-family: "PingFang SC";
  25 + font-weight: 500;
  26 +}
  27 +
  28 +/* 套餐信息 */
  29 +.comboCard {
  30 + margin: 20rpx;
  31 + padding: 40rpx;
  32 + background: #fff;
  33 + border-radius: 10rpx;
  34 +}
  35 +
  36 +.priceRow {
  37 + display: flex;
  38 + align-items: center;
  39 + justify-content: space-between;
  40 + margin-bottom: 24rpx;
  41 +}
  42 +
  43 +.priceRow:last-child {
  44 + margin-bottom: 0;
  45 +}
  46 +
  47 +.priceRow .label {
  48 + color: #515151;
  49 + font-family: "PingFang SC";
  50 +}
  51 +
  52 +.valueText {
  53 + color: #000;
  54 + font-family: "PingFang SC";
  55 +}
  56 +
  57 +.memberPrice {
  58 + color: #999;
  59 + text-decoration: line-through;
  60 + font-family: "PingFang SC";
  61 +}
  62 +
  63 +.couponsBox {
  64 + display: flex;
  65 + align-items: center;
  66 + justify-content: space-between;
  67 + color: #999;
  68 + margin-bottom: 24rpx;
  69 + padding: 0;
  70 + background: transparent;
  71 + border: none;
  72 +}
  73 +
  74 +.colorOrange {
  75 + color: #ED7B2F;
  76 +}
  77 +
  78 +.colorOrange .more {
  79 + background-image: url('https://qn.colorcun.com/chevronRight.png');
  80 + background-size: contain;
  81 + background-repeat: no-repeat;
  82 + width: 36rpx;
  83 + height: 32rpx;
  84 + margin-left: 0;
  85 +}
  86 +
  87 +.couponsBox .couponRight {
  88 + display: flex;
  89 + align-items: center;
  90 +}
  91 +
  92 +.noUse {
  93 + font-family: PingFang SC;
  94 + font-weight: 400;
  95 + color: #ED7B2F;
  96 +}
  97 +
  98 +/* 底部支付 */
  99 +.bottomBox {
  100 + padding-bottom: 180rpx;
  101 +}
  102 +
  103 +.payBtnBox {
  104 + position: fixed;
  105 + left: 0;
  106 + bottom: 0;
  107 + height: 160rpx;
  108 + padding: 0 40rpx;
  109 + box-sizing: border-box;
  110 + z-index: 10;
  111 + width: 100%;
  112 + background: #fff;
  113 + display: flex;
  114 + align-items: center;
  115 + justify-content: space-between;
  116 +}
  117 +
  118 +.total {
  119 + display: flex;
  120 + align-items: center;
  121 + color: #000;
  122 + font-family: "PingFang SC";
  123 +}
  124 +
  125 +.total text {
  126 + color: #FD4D59;
  127 + font-family: "PingFang SC";
  128 + font-weight: 600;
  129 + font-size: 44rpx;
  130 + margin-left: 8rpx;
  131 +}
  132 +
  133 +.payBtn {
  134 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
  135 + color: #fff;
  136 + height: 72rpx;
  137 + border-radius: 198rpx;
  138 + font-family: "PingFang SC";
  139 + font-weight: 600;
  140 + padding: 0 80rpx;
  141 + display: flex;
  142 + align-items: center;
  143 + justify-content: center;
  144 +}
  145 +
  146 +/* 优惠券弹框 */
  147 +.mymodal .mymodal-title {
  148 + padding: 0 !important;
  149 +}
  150 +
  151 +.titleModal {
  152 + width: 100%;
  153 + display: flex;
  154 + align-items: center;
  155 + justify-content: space-between;
  156 + padding: 0 32rpx;
  157 +}
  158 +
  159 +.couponTotalText {
  160 + color: #000000;
  161 + font-family: PingFang SC;
  162 + font-weight: 400;
  163 +}
  164 +
  165 +.titleModal image {
  166 + width: 60rpx;
  167 + height: 60rpx;
  168 +}
  169 +
  170 +.btn {
  171 + background: #09BB07;
  172 + border-radius: 10rpx;
  173 + color: #fff;
  174 + text-align: center;
  175 + padding: 10rpx 42rpx;
  176 + height: 48rpx;
  177 + line-height: 48rpx;
  178 +}
  179 +
  180 +.infoBox {
  181 + width: 100%;
  182 + position: absolute;
  183 + box-sizing: border-box;
  184 + left: 0;
  185 + top: 95rpx;
  186 + padding: 28rpx 40rpx 0 40rpx;
  187 + background: #fff;
  188 + z-index: 10;
  189 +}
  190 +
  191 +.infoTop {
  192 + width: 100%;
  193 + display: flex;
  194 + align-items: center;
  195 + justify-content: space-between;
  196 +}
  197 +
  198 +.infoBottom {
  199 + border-bottom: 2rpx solid #dbdbdb;
  200 + color: #696969;
  201 + font-family: PingFang SC;
  202 + font-weight: 400;
  203 + padding: 10rpx 0 30rpx 0;
  204 +}
  205 +
  206 +.info {
  207 + color: #fe6d03;
  208 + font-family: PingFang SC;
  209 + font-weight: 500;
  210 +}
  211 +
  212 +.infoTop switch {
  213 + transform: scale(.9);
  214 +}
  215 +
  216 +.couponBox {
  217 + position: relative;
  218 +}
  219 +
  220 +.couponItems {
  221 + border: 2rpx solid #09bb07;
  222 + margin-bottom: 16rpx;
  223 + border-radius: 20rpx;
  224 + display: flex;
  225 + padding: 20rpx 10rpx;
  226 +}
  227 +
  228 +.couponItems:nth-of-type(1) {
  229 + margin-top: 160rpx;
  230 +}
  231 +
  232 +.itemLeft {
  233 + min-width: 21%;
  234 + display: flex;
  235 + align-items: center;
  236 + flex-direction: column;
  237 + justify-content: center;
  238 + border-right: 2rpx dashed #09BB07;
  239 + padding-right: 10rpx;
  240 + margin-right: 10rpx;
  241 +}
  242 +
  243 +.priceText {
  244 + color: #FD4D59;
  245 + font-weight: 600;
  246 + font-size: 56rpx;
  247 + margin-top: 6rpx;
  248 + display: flex;
  249 + align-items: baseline;
  250 + justify-content: center;
  251 + font-family: PingFang SC;
  252 +}
  253 +
  254 +.icons {
  255 + color: #FD4D59;
  256 + font-size: 20rpx;
  257 + font-weight: 500;
  258 + font-family: PingFang SC;
  259 +}
  260 +
  261 +.anameText {
  262 + display: flex;
  263 + justify-content: space-between;
  264 + margin-bottom: 14rpx;
  265 +}
  266 +
  267 +.anameText .names {
  268 + font-family: PingFang SC;
  269 + font-weight: 600;
  270 + line-height: 48rpx;
  271 + display: -webkit-box;
  272 + word-break: break-all;
  273 + word-wrap: break-word;
  274 + overflow: hidden;
  275 + text-align: left;
  276 +}
  277 +
  278 +.discountText1 {
  279 + color: #fe6d03;
  280 + font-family: PingFang SC;
  281 + font-weight: 500;
  282 + margin: 0 20rpx;
  283 +}
  284 +
  285 +.anameInfo {
  286 + display: flex;
  287 + align-items: center;
  288 + flex-wrap: wrap;
  289 +}
  290 +
  291 +.ownNum {
  292 + text-align: center;
  293 + color: #fe6d03;
  294 + font-family: PingFang SC;
  295 + font-weight: 500;
  296 + flex-shrink: 0;
  297 +}
  298 +
  299 +.textBox {
  300 + width: 90%;
  301 + display: flex;
  302 + flex-direction: column;
  303 +}
  304 +
  305 +.bottomTitle {
  306 + color: #515151;
  307 + font-family: PingFang SC;
  308 + font-weight: 600;
  309 +}
  310 +
  311 +.bottomTitle text {
  312 + flex-shrink: 0;
  313 +}
  314 +
  315 +.bottom {
  316 + font-weight: normal;
  317 +}
  318 +
  319 +.itemRight {
  320 + flex: 1;
  321 +}
  322 +
  323 +.itemRight view {
  324 + display: flex;
  325 + line-height: 36rpx;
  326 + flex-shrink: 0;
  327 +}
  328 +
  329 +.rightBox {
  330 + display: flex;
  331 + flex-direction: column;
  332 + align-items: center;
  333 + justify-content: center;
  334 +}
  335 +
  336 +.numBox {
  337 + display: flex;
  338 + align-items: center;
  339 + justify-content: center;
  340 + margin: 30rpx 10rpx 0 10rpx;
  341 + flex-shrink: 0;
  342 + align-self: center;
  343 +}
  344 +
  345 +.numBtn {
  346 + width: 44rpx;
  347 + height: 44rpx;
  348 + border-radius: 50%;
  349 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
  350 + color: #ffffff;
  351 + font-size: 48rpx;
  352 + font-weight: 600;
  353 + line-height: 44rpx;
  354 + text-align: center;
  355 +}
  356 +
  357 +.numBox .numBtn:first-child {
  358 + line-height: 40rpx;
  359 +}
  360 +
  361 +.numBtnDisabled {
  362 + background: #cccccc;
  363 +}
  364 +
  365 +.numText {
  366 + min-width: 48rpx;
  367 + width: 64rpx;
  368 + height: 44rpx;
  369 + border: 2rpx solid #c8c8c8;
  370 + margin: 0 10rpx;
  371 + text-align: center;
  372 + font-size: 28rpx;
  373 + font-weight: 600;
  374 + color: #333333;
  375 +}
  376 +
  377 +.mymodal .mymodal-content {
  378 + height: 80% !important;
  379 +}
  380 +
  381 +.couponNo {
  382 + border: 2rpx solid #999;
  383 +}
  384 +
  385 +.couponNo .itemLeft {
  386 + border-right: 2rpx dashed #999;
  387 +}
  388 +
  389 +.couponNo .numText {
  390 + border: 2rpx solid #999;
  391 + color: #999;
  392 +}
  393 +
  394 +.couponNo .priceText,
  395 +.couponNo .icons,
  396 +.couponNo .itemRight,
  397 +.couponNo .discountText1,
  398 +.couponNo .bottomTitle,
  399 +.couponNo .ownNum,
  400 +.couponNo .bottom {
  401 + color: #999;
  402 +}
  1 +import util from '../../utils/util';
  2 +import App from '../../utils/api';
  3 +Page({
  4 +
  5 + /**
  6 + * 页面的初始数据
  7 + */
  8 + data: {
  9 + details:{}
  10 + },
  11 +
  12 + /**
  13 + * 生命周期函数--监听页面加载
  14 + */
  15 + onLoad(options) {
  16 + if(options.item){
  17 + let details =JSON.parse(options.item);
  18 + if(details && details.cook_list){
  19 + details.cook_list = JSON.parse(details.cook_list)
  20 + let list = [];
  21 + details.cook_list.forEach(i=>{
  22 + if(i.cookbooklist.length>0){
  23 + i.cookbooklist.forEach(j=>{
  24 + if(j.amountHasOrderList && j.amountHasOrderList.length>0){
  25 + j.amountHasOrderList.forEach(m=>{
  26 + console.log('mmmmmmm-------',m);
  27 + console.log('jjjjjj-------',j);
  28 + list.push({
  29 + image:j.image,
  30 + dishName:j.name,
  31 + amount:m.amount,
  32 + name:m.practiceModel && m.practiceModel.name?m.practiceModel.name:'',
  33 + specs:m.specModel && m.specModel.specs?m.specModel.specs:'',
  34 + price:m.specModel && m.specModel.price?m.specModel.price:'',
  35 + })
  36 + })
  37 + }
  38 + })
  39 + }
  40 + })
  41 + details.list = list
  42 + }
  43 + console.log('options---',details);
  44 + this.setData({
  45 + details
  46 + })
  47 + }
  48 + },
  49 + // 跳转到购买页
  50 + submitOrder(){
  51 + let details = this.data.details;
  52 + console.log('details-------',details);
  53 + let url = util.http_build_query({
  54 + details:JSON.stringify(details)
  55 + }, './comboBuy')
  56 + wx.navigateTo({
  57 + url
  58 + })
  59 + },
  60 + /**
  61 + * 生命周期函数--监听页面初次渲染完成
  62 + */
  63 + onReady() {
  64 +
  65 + },
  66 +
  67 + /**
  68 + * 生命周期函数--监听页面显示
  69 + */
  70 + onShow() {
  71 +
  72 + },
  73 +
  74 + /**
  75 + * 生命周期函数--监听页面隐藏
  76 + */
  77 + onHide() {
  78 +
  79 + },
  80 +
  81 + /**
  82 + * 生命周期函数--监听页面卸载
  83 + */
  84 + onUnload() {
  85 +
  86 + },
  87 +
  88 + /**
  89 + * 页面相关事件处理函数--监听用户下拉动作
  90 + */
  91 + onPullDownRefresh() {
  92 +
  93 + },
  94 +
  95 + /**
  96 + * 页面上拉触底事件的处理函数
  97 + */
  98 + onReachBottom() {
  99 +
  100 + },
  101 +
  102 + /**
  103 + * 用户点击右上角分享
  104 + */
  105 + onShareAppMessage() {
  106 +
  107 + }
  108 +})
  1 +{
  2 + "backgroundTextStyle": "light",
  3 + "navigationBarBackgroundColor": "#fff",
  4 + "navigationBarTextStyle": "white",
  5 + "usingComponents": {
  6 + "nav": "/components/nav/nav"
  7 + }
  8 +}
  1 +<!--pack-cookbook/pages/comboDetails.wxml-->
  2 +<nav>套餐详情</nav>
  3 +<view class="titleBox">
  4 + <view class="leftInfo font32r">{{details.pname}}</view>
  5 + <view class="rightInfo font32r">¥{{details.plan_price}}/{{details.pnum}}人</view>
  6 +</view>
  7 +<view class="centerMain">
  8 + <view class="title">
  9 + <image src="https://qn.colorcun.com/voucherUnion_6.png" mode="" />
  10 + <text class="font32r">菜品</text>
  11 + </view>
  12 + <view class="items" wx:for="{{details.list}}" wx:key="index">
  13 + <view class="news">
  14 + <view class="font24r">{{item.dishName}}</view>
  15 + <view class="font24r">{{item.amount}}{{item.specs}} {{item.name}}<text>原价¥{{item.price}}</text></view>
  16 + </view>
  17 + <image wx:if="{{item.image}}" src="{{item.image}}" mode="widthFix" />
  18 + </view>
  19 +</view>
  20 +<view class="fixed_box">
  21 + <view class="leftPrice">
  22 + <view wx:if="{{details.menu_price}}" class="font24r originalPrice">原价<text>¥{{details.menu_price}}</text></view>
  23 + <view wx:if="{{details.plan_price}}" class="font24r comboPrice">套餐价<text>¥{{details.plan_price}}</text></view>
  24 + </view>
  25 + <button class="font32r btns" bindtap="submitOrder">购买</button>
  26 +</view>
  1 +/* pack-cookbook/pages/comboDetails.wxss */
  2 +page {
  3 + background: #F5F5F5;
  4 +}
  5 +
  6 +.titleBox {
  7 + padding: 40rpx;
  8 + display: flex;
  9 + align-items: center;
  10 + justify-content: space-between;
  11 + background: #fff;
  12 +}
  13 +
  14 +.leftInfo {
  15 + color: #000000;
  16 + font-family: "PingFang SC";
  17 + font-weight: 600;
  18 +}
  19 +
  20 +.rightInfo {
  21 + font-family: "PingFang SC";
  22 + font-weight: 500;
  23 + font-size: 32rpx;
  24 + color: #ff4d11;
  25 +}
  26 +
  27 +.centerMain {
  28 + margin: 14rpx 12rpx;
  29 + background: #fff;
  30 + border-radius: 10rpx;
  31 + padding: 32rpx 32rpx 150rpx 32rpx;
  32 +}
  33 +
  34 +.title {
  35 + display: flex;
  36 + align-items: center;
  37 +}
  38 +
  39 +.title image {
  40 + width: 28rpx;
  41 + height: 28rpx;
  42 +}
  43 +
  44 +.news {
  45 + color: #696969;
  46 + margin: 40rpx 0 12rpx;
  47 + display: flex;
  48 + align-items: center;
  49 + justify-content: space-between;
  50 +}
  51 +
  52 +.news text {
  53 + margin-left: 12rpx;
  54 +}
  55 +
  56 +.items image {
  57 + width: 100%;
  58 +}
  59 +
  60 +.fixed_box {
  61 + position: fixed;
  62 + bottom: 0;
  63 + left: 0;
  64 + height: 160rpx;
  65 + background: #fafafa;
  66 + width: 100%;
  67 + display: flex;
  68 + align-items: center;
  69 + justify-content: space-between;
  70 + padding: 0 40rpx 30rpx 40rpx;
  71 + box-sizing: border-box;
  72 +}
  73 +
  74 +.leftPrice {
  75 + display: flex;
  76 + flex-direction: column;
  77 +}
  78 +
  79 +.leftPrice text{
  80 + margin-left: 8rpx;
  81 +}
  82 +
  83 +.comboPrice text{
  84 + font-size: 32rpx;
  85 +}
  86 +
  87 +.originalPrice {
  88 + text-decoration: line-through;
  89 + color: #696969;
  90 + font-family: "PingFang SC";
  91 + font-weight: 400;
  92 +}
  93 +
  94 +.comboPrice {
  95 + color: #fd4d59;
  96 + font-family: "PingFang SC";
  97 + font-weight: 600;
  98 +}
  99 +
  100 +.comboPrice text {
  101 + font-size: 32rpx;
  102 +}
  103 +
  104 +.btns {
  105 + margin: 0;
  106 + width: 30%;
  107 + border-radius: 42rpx;
  108 + color: #fff;
  109 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
  110 +}
  1 +// pack-cookbook/pages/comboList.js
  2 +import util from '../../utils/util';
  3 +import App from '../../utils/api';
  4 +Page({
  5 +
  6 + /**
  7 + * 页面的初始数据
  8 + */
  9 + data: {
  10 + sid: '',
  11 + uid: '',
  12 + seller: {},
  13 + },
  14 +
  15 + /**
  16 + * 生命周期函数--监听页面加载
  17 + */
  18 + onLoad(options) {
  19 + this.setData({
  20 + sid: options.sid,
  21 + uid: options.uid
  22 + })
  23 + if (options.sid) {
  24 + this.getSellerDetailFun(options.sid)
  25 + }
  26 + },
  27 + // 排菜/套餐列表
  28 + grtPlanCookListFun() {
  29 + App.PlanCook.GetPlanCookList({
  30 + sellerid: this.data.sid,
  31 + uid: this.data.uid,
  32 + }).then(res => {
  33 + let data = res.data.package_list;
  34 + this.setData({
  35 + comboList: data
  36 + })
  37 + })
  38 + },
  39 + // 获取店铺名称
  40 + getSellerDetailFun(sid) {
  41 + App.Customer.GetSellerDetail({
  42 + sid
  43 + }).then(res => {
  44 + let data = res.data;
  45 + this.setData({
  46 + seller: {
  47 + seller_image: data.seller_image,
  48 + sellername: data.sellername,
  49 + sid: data.id
  50 + }
  51 + })
  52 + })
  53 + },
  54 + // 跳转到详情
  55 + gotoComboDetails(e) {
  56 + let items = e.currentTarget.dataset['item'];
  57 + console.log('item-------', items);
  58 + items.seller = this.data.seller;
  59 + let url = util.http_build_query({
  60 + item: JSON.stringify(items)
  61 + }, './comboDetails')
  62 + wx.navigateTo({
  63 + url
  64 + })
  65 + },
  66 +
  67 + // 分享
  68 + sharesetting() {
  69 + console.log(111);
  70 + return {
  71 + title: '点击查看' + this.data.seller.sellername + '套餐排菜',
  72 + path: util.http_build_query({
  73 + sid: this.data.sid
  74 + }, '/pack-cookbook/pages/comboList'),
  75 + imageUrl: this.data.seller.seller_image || 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png',
  76 + }
  77 + },
  78 + /**
  79 + * 生命周期函数--监听页面初次渲染完成
  80 + */
  81 + onReady() {
  82 +
  83 + },
  84 +
  85 + /**
  86 + * 生命周期函数--监听页面显示
  87 + */
  88 + onShow() {
  89 + this.grtPlanCookListFun()
  90 + },
  91 +
  92 + /**
  93 + * 生命周期函数--监听页面隐藏
  94 + */
  95 + onHide() {
  96 +
  97 + },
  98 +
  99 + /**
  100 + * 生命周期函数--监听页面卸载
  101 + */
  102 + onUnload() {
  103 +
  104 + },
  105 +
  106 + /**
  107 + * 页面相关事件处理函数--监听用户下拉动作
  108 + */
  109 + onPullDownRefresh() {
  110 +
  111 + },
  112 +
  113 + /**
  114 + * 页面上拉触底事件的处理函数
  115 + */
  116 + onReachBottom() {
  117 +
  118 + },
  119 +
  120 + /**
  121 + * 用户点击右上角分享
  122 + */
  123 + onShareAppMessage() {
  124 + return this.sharesetting();
  125 + },
  126 + /**
  127 + * 监听用户点击分享到朋友圈按钮的操作
  128 + */
  129 + onShareTimeline() {
  130 + return this.sharesetting();
  131 + },
  132 +})
  1 +{
  2 + "backgroundTextStyle": "light",
  3 + "navigationBarBackgroundColor": "#fff",
  4 + "navigationBarTextStyle": "white",
  5 + "usingComponents": {
  6 + "nav": "/components/nav/nav"
  7 + }
  8 +}
  1 +<!--pack-cookbook/pages/comboList.wxml-->
  2 +<nav>店铺套餐</nav>
  3 +<view class="titleBox">
  4 + <image src="{{seller.seller_image}}" mode="" />
  5 + <view class="nameInfo font32r">{{seller.sellername}}</view>
  6 +</view>
  7 +<view class="comboBox">
  8 + <view class="items" bind:tap="gotoComboDetails" data-item="{{item}}" wx:for="{{comboList}}" wx:key="{{item.id}}">
  9 + <view class="leftBox">
  10 + <view class="names font32r">{{item.pname}}</view>
  11 + <view class="priceBox font32r">¥{{item.plan_price}}/{{item.pnum}}人</view>
  12 + </view>
  13 + <view class="btn font24r">详情</view>
  14 + </view>
  15 +</view>
  16 +<view class="fixed_box">
  17 + <button class="font32r btns btns1" open-type="share">分享</button>
  18 + <button class="font32r btns" bindtap="submitOrder">已购套餐</button>
  19 +</view>
  1 +/* pack-cookbook/pages/comboList.wxss */
  2 +page {
  3 + background: #F5F5F5;
  4 +}
  5 +
  6 +.titleBox {
  7 + background: #fff;
  8 + display: flex;
  9 + align-items: center;
  10 + padding: 32rpx 0 20rpx 32rpx;
  11 + border-bottom: 2rpx solid #ededed;
  12 + margin: 0 20rpx;
  13 +}
  14 +
  15 +.titleBox image {
  16 + width: 60rpx;
  17 + height: 60rpx;
  18 + border-radius: 10rpx;
  19 +}
  20 +
  21 +.nameInfo {
  22 + margin-left: 20rpx;
  23 + color: #000000;
  24 + font-family: "PingFang SC";
  25 + font-weight: 500;
  26 +}
  27 +
  28 +.comboBox {
  29 + display: flex;
  30 + flex-direction: column;
  31 + align-items: center;
  32 + background: #fff;
  33 + padding: 0 20rpx;
  34 +}
  35 +
  36 +.items {
  37 + width: 100%;
  38 + display: flex;
  39 + align-items: center;
  40 + justify-content: space-between;
  41 + box-sizing: border-box;
  42 + padding: 50rpx 32rpx 50rpx 32rpx;
  43 + border-bottom: 2rpx solid #ededed;
  44 +}
  45 +
  46 +.leftBox .names {
  47 + color: #000000;
  48 + font-family: "PingFang SC";
  49 + font-weight: 600;
  50 +}
  51 +
  52 +.priceBox {
  53 + color: #ff4d11;
  54 + font-family: "PingFang SC";
  55 + font-weight: 500;
  56 + margin: 10rpx 0 0 -4rpx;
  57 +}
  58 +
  59 +.btn {
  60 + color: #ffffff;
  61 + font-family: "PingFang SC";
  62 + font-weight: 600;
  63 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
  64 + padding: 4rpx 32rpx;
  65 + border-radius: 198rpx;
  66 +}
  67 +
  68 +.fixed_box {
  69 + position: fixed;
  70 + bottom: 0;
  71 + left: 0;
  72 + height: 160rpx;
  73 + background: #fafafa;
  74 + width: 100%;
  75 + display: flex;
  76 + align-items: center;
  77 + justify-content: space-between;
  78 + padding: 0 40rpx 30rpx 40rpx;
  79 + box-sizing: border-box;
  80 +}
  81 +
  82 +.btns {
  83 + margin: 0;
  84 + width: 45%;
  85 + border-radius: 42rpx;
  86 + color: #fff;
  87 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
  88 +}
  89 +
  90 +.btns1{
  91 + background:#fff;
  92 + color: #ff4d11;
  93 + border: 2rpx solid #ff4d11;
  94 +}