buyFreeCoupon.js 26.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702
// pack-activity/pack/buyFreeCoupon.js
import util from '../../utils/util';
import App from '../../utils/api';
Page({
    /**
     * 页面的初始数据
     */
    data: {
        options: {},
        available: '1', //输入金额够优惠券最低消费1  不够0
        couponArr: [], //所有券列表
        dataStr: Date.now() * 1 / 1000,
        discountPrice: '', //优惠价格
        actualPrice: '', //实付价格
        inputValue: '', //输入的金额
        canSolt: {}, //当前时间是哪个餐段、节假日
    },
    sid: '', //扫码进入带的参数商家id
    couponModal: '',
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.couponModal = this.selectComponent("#couponModal");
        if (options.sid) {
            this.sid = options.sid
            this.getSellerDetailFun(options.sid)
        }
    },
    // 打开优惠券弹框
    showCouponModal() {
        this.couponModal.showModal()
    },
    // 关闭优惠券弹框
    closeCouponModal() {
        this.couponModal.closeModal()
    },
    // 获取店铺名称
    getSellerDetailFun(sid) {
        App.Customer.GetSellerDetail({
            sid
        }).then(res => {
            let data = res.data;
            this.setData({
                seller: {
                    seller_image: data.seller_image,
                    sellername: data.sellername,
                    sid: data.id
                }
            })
            // 判断当前时间餐段、节假日
            this.getSellerDailyFun(data.daily)
        })
    },
    // 获取所有优惠券列表
    getCoupon() {
        App.Activity.ActivityListByOpenid({
            sellerid: this.sid
        }).then(res => {
            if (res.ret == 200 && res.data && res.data.length > 0) {
                let list = res.data
                list.forEach(detail => {
                    detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
                    detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
                    detail.arule = detail.arule ? util.determine(detail.arule) : '';
                    if (detail.arule) {
                        detail.accumulationShow = detail.arule.is_accumulation
                    }
                    if (detail.exp_date && detail.exp_date.week_data) {
                        let noon = this.hasConsecutiveSelect(detail.exp_date.week_data, '1').rArr.join('、')
                        let nig = this.hasConsecutiveSelect(detail.exp_date.week_data, '2').rArr.join('、')
                        if (noon) noon = '午餐:' + noon
                        if (nig) nig = '晚餐:' + nig
                        detail.noonText = noon;
                        detail.nigText = nig;
                    }
                    detail.checked = false;
                    detail.showCpupon = '0';
                    detail.cdateText = util.unixtoTime(detail.cdate, 'YYYY-MM-DD')
                    detail.endDateStr = util.unixtoTime(detail.stime, 'YYYY-MM-DD') + '至' + util.unixtoTime(detail.etime, 'YYYY-MM-DD')
                })
                list.sort((a, b) => {
                    return (a.etime * 1) - (b.etime * 1)
                })
                let couponArr = list
                this.setData({
                    couponArr
                })
            }
        })
    },
    // 勾选券
    checkboxChange(e) {
        console.log('checkbox发生change事件,携带value值为:', e.detail.value)
        const list = this.data.couponArr
        const values = e.detail.value
        let arr = []
        let currentCoupon = '0'; //没选券 为0  可叠加券1  不可叠加券2
        for (let i = 0, lenI = list.length; i < lenI; ++i) {
            list[i].checked = false
            for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
                if (list[i].activity_id === values[j]) {
                    arr.push({
                        ...list[i]
                    })
                    list[i].checked = true
                    if (list[i].accumulationShow == '1') {
                        currentCoupon = '1'
                    } else {
                        currentCoupon = '2'
                    }
                    break
                }
            }
        }
        console.log('没选券 为0  可叠加券1  不可叠加券2', currentCoupon);
        //没选券 所有可选的打开 
        if (currentCoupon == '0') {
            list.forEach(item => {
                if (item.canCheck == "1") {
                    item.showCpupon = '1';
                }
            })
        }
        //选的不可叠加券  其他所有的可叠加券都不可选 
        if (currentCoupon == '2') {
            list.forEach(item => {
                if (item.accumulationShow == "1") {
                    item.showCpupon = '0';
                }
            })
        }
        //选的可叠加券  其他所有的不可叠加券都不可选 
        if (currentCoupon == '1') {
            list.forEach(item => {
                if (item.accumulationShow == "0") {
                    item.showCpupon = '0';
                }
            })
        }
        this.setData({
            couponArr: list
        })
    },
    // 输入金额
    bindKeyInput(e) {
        console.log('输入金额,bindchange携带value值为:', e.detail.value);
        let list = this.data.couponArr;
        // 所有的券重置
        list.forEach(i => {
            i.checked = false;
            i.showCpupon = '0'
        })
        this.setData({
            inputValue: e.detail.value,
            couponArr: list
        })

        this.colationData()
    },
    // 点确认选择
    checkCertificate() {
        this.closeCouponModal()
        let list = this.data.couponArr;
        list = list.filter(i => {
            return i.checked
        })
        let price = 0;
        list.forEach(i => {
            price += i.price * 1
        })
        console.log('优惠金额----', price);
        let val = this.data.inputValue * 1;
        let actualPrice = val - price.toFixed(2)
        price = price.toFixed(2)
        this.setData({
            discountPrice: price,
            actualPrice: actualPrice > 0 ? actualPrice : 0.1,
        })
        console.log('点确认选择后', list);
    },
    // 处理显示券可用、不可用的列表
    async colationData() {
        let list = this.data.couponArr;
        list = await this.filterCoupons(list);
        let obj = await this.findBestCoupons(list);
        list = obj.arr
        console.log('处理过后的券数据', list);
        list.sort((a, b) => b.canCheck - a.canCheck);
        list.sort((a, b) => b.showCpupon - a.showCpupon);
        this.setData({
            couponArr: list,
            finalList: obj.finalList
        })
    },
    // 付款
    confirmPayment() {
        let actualPrice = this.data.actualPrice
        if (actualPrice <= 0) {
            return
        }
        App.PayOnline.CombineTransactionsByNewActivity({
            sellerid: this.data.seller.sid,
            price: actualPrice,
        }).then(res => {
            console.log('付款信息', res.data);
            if (res.ret != '200') {
                wx.showToast({
                    title: res.msg,
                    duration: 1000,
                    icon: 'none',
                })
            }
            if (res.ret == '200') {
                wx.requestPayment({
                    timeStamp: res.data.timeStamp + '',
                    nonceStr: res.data.nonceStr,
                    package: res.data.package,
                    signType: res.data.signType,
                    paySign: res.data.paySign,
                    success(ress) {
                        if (ress.errMsg == 'requestPayment:ok') {
                            this.writeOff()
                            console.log('支付成功', ress);
                            wx.showToast({
                                title: '支付成功',
                                duration: 1000,
                                icon: 'none',
                            })
                        }
                        console.log('支付失败', ress);
                        wx.showToast({
                            title: '支付失败,请重新下单',
                            duration: 1000,
                        })
                    },
                    fail(ress) {
                        console.log('支付失败', ress);
                        wx.showToast({
                            title: '支付失败,请重新下单',
                            duration: 1000,
                            icon: 'none',
                        })
                    },
                })
            }
        })
    },
    // 核销所勾选的券
    writeOff() {
        console.log('勾选的券', this.data.finalList);
        if (this.data.finalList.length > 0) {
            let str = this.data.finalList.map(item => item.activity_id).join(',');
            console.log('核销所勾选的券传参', str);
            App.Activity.SetActivityStatus({
                id: str,
            }).then(res => {
                if (res.ret == '200') {
                    console.log('核销成功', str);
                }
            })
        }
    },
    // 判断券开启、有效期结束时间、领取后有效天数、领取当天可用、不可用日期
    filterCoupons(list) {
        const currentDate = new Date();
        currentDate.setHours(0, 0, 0, 0);
        list.forEach(coupon => {
            const startUseDate = new Date(currentDate);
            let endUseDate = new Date(currentDate);
            const couponDate = new Date(coupon.cdate * 1000);
            if (coupon.arule.is_same_day) {
                startUseDate.setDate(couponDate.getDate() - 1);
            } else {
                startUseDate.setDate(couponDate.getDate());
            }
            // 券领取天数为0或者为空 默认券可使用最晚时间是券有效期截止时间
            if (coupon.aexpiration == '0' || coupon.aexpiration == '') {
                let date = new Date(coupon.etime * 1000);
                endUseDate = date
            } else {
                endUseDate.setDate(couponDate.getDate() + parseInt(coupon.aexpiration));
            }
            // 今天不是领取当日,但在有效天数内 && 今天是领取当日且可用 && 在有效天数内 && 券是开启状态
            const isUseDate = (currentDate > startUseDate && currentDate < endUseDate) &&
                (this.data.dataStr < (coupon.etime * 1) && coupon.is_open == '1')
            let obj = this.data.canSolt
            let selectedValue = true;
            let str = true
            if (coupon.exp_date && coupon.exp_date.week_data && coupon.exp_date.week_data.length > 0) {
                let today = new Date(); // 获取今天是星期几(0-6,0表示周日)
                let dayOfWeek = today.getDay();
                let arr = coupon.exp_date.week_data
                let todayArr = arr[dayOfWeek];
                let legalHolidayValue = arr[arr.length - 1];
                if (obj.can === "晚餐") {
                    selectedValue = todayArr.selectNig;
                } else if (obj.can === "午餐") {
                    selectedValue = todayArr.selectNoon;
                } else if (obj.can === "早餐") {
                    selectedValue = todayArr.selectMor;
                }
                selectedValue = !selectedValue
                console.log(coupon.aname, coupon.exp_date.week_show, `今天是 ${todayArr.title},选择值为: ${selectedValue}`);
                // 根据 isshow 判断法定假日是否可用
                if (obj.isshow === "1") {
                    if (obj.can === "晚餐") {
                        str = legalHolidayValue.selectNig;
                    } else if (obj.can === "午餐") {
                        str = legalHolidayValue.selectNoon;
                    } else if (obj.can === "早餐") {
                        str = legalHolidayValue.selectMor;
                    }
                    str = !str
                }
                console.log(coupon.aname, '法定节假期', `,选择值为: ${str}`);
            }
            let availableDate = true;
            if (str || selectedValue) {
                availableDate = true
            }
            if (!str || !selectedValue) {
                availableDate = false
            }
            if ((str && !selectedValue) || (!str && selectedValue)) {
                availableDate = false
            }
            coupon.isOk = isUseDate && (availableDate || coupon.exp_date.week_show == '无') ? '1' : '0'; //是否在可用时间内 1可使用 2不可使用
            endUseDate.setHours(23, 59, 59, 999); // 设置时间为23:59:59.999
            const timestamp = Math.floor(endUseDate.getTime() / 1000);
            let c = coupon.etime * 1
            coupon.expirationDate = Math.min(timestamp, c);
        });
        return list
    },
    // 最优惠的消费券组合(消费要求为无门槛 或者 满足优惠券使用金额 && 勾选最优的、最早到期的)
    findBestCoupons(arr) {
        console.log('勾选最优的之前', arr);
        let inputValue = this.data.inputValue;
        const amount = parseFloat(inputValue);
        const validCoupons = arr.filter(coupon => (coupon.isOk == '1' && parseFloat(coupon.desc) <= amount));
        arr.forEach(item => {
            const isValid = validCoupons.some(validCoupon => validCoupon.activity_id == item.activity_id);
            item.canCheck = isValid ? '1' : '0'; // 如果在 validCoupons 中,设置 canCheck 为 1,否则为 0
        });
        console.log('可以勾选的券 && 满足付款条件的券', validCoupons);
        let list1 = []; // 可叠加的优惠券组合
        let list2 = []; // 最优惠的不可叠加的优惠券
        let finalList = []; //最终用的优惠券组合
        // 计算可叠加的组合
        let remainingValue = inputValue; // 剩余金额
        let totalDiscount = 0; // 总优惠金额
        // 尝试组合可叠加的优惠券
        validCoupons.forEach(coupon => {
            if (coupon.accumulationShow === '1') {
                const discountAmount = parseInt(coupon.price);
                if (remainingValue > 0) {
                    list1.push(coupon);
                    totalDiscount += discountAmount; // 累加优惠金额
                    remainingValue -= discountAmount; // 减少应付金额
                }
            }
        });
        // 检查可叠加组合是否有效
        if (remainingValue < 0) {
            list1 = []; // 如果剩余金额小于0,清空可叠加列表
        }
        // 重置剩余金额,用于不可叠加的优惠券
        remainingValue = inputValue;
        // 遍历有效优惠券,寻找不可叠加的优惠券
        validCoupons.forEach(coupon => {
            if (coupon.accumulationShow === '0') {
                const discountAmount = parseInt(coupon.price);
                // 计算实际支付金额
                const finalAmount = inputValue - discountAmount;
                // 确保实际支付金额不小于0,并且是最优惠的
                if (finalAmount >= 0) {
                    if (!list2.length || discountAmount > parseInt(bestCoupon.price)) {
                        list2.push({
                            ...coupon
                        }); // 更新最优惠的不可叠加券
                    }
                }
            }
        });
        console.log('可叠加的优惠券组合', list1);
        console.log('不可叠加的优惠券', list2);
        // 计算两个列表的最大优惠值
        let maxStackableValue = list1.reduce((total, coupon) => total + coupon.price, 0);
        let maxNonStackableValue = list2.reduce((total, coupon) => total + coupon.price, 0);

        // 比较两个最大值并输出结果
        if (maxStackableValue > maxNonStackableValue) {
            console.log(`可叠加优惠券组合的最大优惠值更高: ${maxStackableValue}`);
            finalList = list1
        } else if (maxStackableValue < maxNonStackableValue) {
            console.log(`不可叠加券的最大优惠值更高: ${maxNonStackableValue}`);
            finalList = list2
        } else {
            console.log(`两者的优惠值相同: ${maxStackableValue}`);
            let copiedList1 = JSON.parse(JSON.stringify(list1));
            let copiedList2 = JSON.parse(JSON.stringify(list2));
            let minList1 = copiedList1.length > 0 ? Math.min(...copiedList1.map(item => item.expirationDate)) : Infinity;
            let minList2 = copiedList2.length > 0 ? Math.min(...copiedList2.map(item => item.expirationDate)) : Infinity;
            // 判断最小的 expirationDate 是在 list1 还是 list2
            if (minList1 <= minList2) {
                console.log('最小的在 list1 中', list1);
                finalList = list1
            } else {
                console.log('最小的在 list2 中', list2);
                finalList = list2
            }
        }
        console.log('选中的券组合', finalList);
        let discountPrice = 0;
        // 更新选中的优惠券
        finalList.forEach(coupon => {
            let target = arr.find(obj => obj.activity_id === coupon.activity_id);
            if (target) {
                target.showCpupon = 1;
                target.checked = true;
                discountPrice += coupon.price * 1; // 使用 parseFloat 确保类型正确
            }
            console.log('选中的券', {
                ...coupon
            });
        });
        discountPrice = discountPrice.toFixed(2)
        console.log('总优惠金额:', discountPrice);
        let actualPrice = (amount - discountPrice).toFixed(2);
        console.log('实际支付金额:', actualPrice);
        this.setData({
            discountPrice,
            actualPrice: actualPrice > 0 ? actualPrice : '0.1', // 确保实际支付金额不小于0.01
        });
        return {
            arr,
            finalList, // 返回可叠加和不可叠加的优惠券组合
        };
    },
    // 处理优惠券不可用日期数据
    hasConsecutiveSelect(arr, type) {
        let firstTitle = null;
        let lastTitle = null;
        let rArr = []
        let num = 0
        for (let i = 0; i < arr.length; i++) {
            let str = type == '1' ? arr[i].selectNoon : arr[i].selectNig
            if (str) {
                rArr.push(arr[i].title)
                num++
                if (num == 1) {
                    firstTitle = arr[i].title
                }
                if (num >= 5) {
                    lastTitle = arr[i].title
                }
                if (num >= 5 && i >= (arr.length - 1)) {
                    let fi = rArr.findIndex((item) => {
                        return item == firstTitle
                    })
                    rArr.splice(fi, num, firstTitle + '至' + lastTitle)
                    num = 0
                }
            } else {
                if (num < 5) {
                    num = 0
                    firstTitle = null;
                    lastTitle = null;
                } else {
                    let fi = rArr.findIndex((item) => {
                        return item == firstTitle
                    })
                    rArr.splice(fi, num, firstTitle + '至' + lastTitle)
                    num = 0
                }
            }
        }
        return {
            rArr,
            lastTitle,
            firstTitle
        };
    },
    // 判断当前时间餐段、节假日
    getSellerDailyFun(lunchDis) {
        let lunchDinnerList = [];
        if (lunchDis.morning) {
            lunchDinnerList.push({
                can: "早餐",
                solt: 1,
                class: "morning",
            })
        }
        if (lunchDis.noon) {
            lunchDinnerList.push({
                can: "午餐",
                solt: 2,
                class: "dinner",
            })
        }
        if (lunchDis.night) {
            lunchDinnerList.push({
                can: "晚餐",
                solt: 3,
                class: "lunch",
            })
        }
        const currentTime = new Date().toLocaleTimeString('en-US', {
            hour12: false,
            hour: '2-digit',
            minute: '2-digit'
        });
        let obj = this.checkTimeInInterval(currentTime, lunchDis, lunchDinnerList);
        //节假日数组
        var holidays = [
            '2025-1-1', // 元旦
            '2025-1-28', // 春节
            '2025-1-29', // 春节
            '2025-1-30', // 春节
            '2025-1-31', // 春节
            '2025-2-1', // 春节
            '2025-2-2', // 春节
            '2025-2-3', // 春节
            '2025-2-4', // 春节
            '2025-4-4', //清明
            '2025-4-5', //清明
            '2025-4-6', //清明
            '2025-5-1', // 劳动节
            '2025-5-2', // 劳动节
            '2025-5-3', // 劳动节
            '2025-5-4', // 劳动节
            '2025-5-5', // 劳动节
            '2025-5-31', // 端午节
            '2025-6-1', // 端午节
            '2025-6-2', // 端午节
            '2025-10-1', // 国庆节、中秋节
            '2025-10-2', // 国庆节、中秋节
            '2025-10-3', // 国庆节、中秋节
            '2025-10-4', // 国庆节、中秋节
            '2025-10-5', // 国庆节、中秋节
            '2025-10-6', // 国庆节、中秋节
            '2025-10-7', // 国庆节、中秋节
            '2025-10-8', // 国庆节、中秋节
        ];
        //周末上班日期数组
        var nWeekend = [
            '2025-1-26', //春节调整
            '2025-2-8', //春节调整
            '2025-4-27', //五一调整
            '2025-9-28', //国庆调整
            '2025-10-11', //国庆调整
        ];
        var curdate = new Date();
        curdate.setTime(curdate.getTime() + 4 * 24 * 60 * 60 * 1000);
        var year = curdate.getFullYear();
        var month = curdate.getMonth() + 1;
        var date = curdate.getDate();
        var formattedDate = year + "-" + month + "-" + date;
        obj.isshow = '0'
        //该日期同时满足2个条件即为节假日:1.在节假日数组内或在周末. 2.不在周末上班日期数组
        if ((holidays.indexOf(formattedDate) >= 0 || (curdate.getDay() == 0 || curdate.getDay() == 6)) && nWeekend.indexOf(formattedDate) < 0) {
            obj.isshow = '1'
        } else {
            obj.isshow = '0'
        }
        console.log('不可用日期信息:餐段、节假日', obj);
        if (obj && obj.can && obj.solt) {
            this.setData({
                canSolt: {
                    ...obj
                }
            })
        }
        this.getCoupon()
    },
    // 传参currentTime 当前时间 例16:51 lunchDis 餐段 {morning: "07:00-10:00",night: "16:00-21:00",noon: "11:00-14:30"}
    // 判断当前时间餐段
    checkTimeInInterval(currentTime, lunchDis, lunchDinnerList) {
        const [currentHour, currentMinute] = currentTime.split(':');
        const [morningHour2, morningMinute2] = lunchDis.morning ? lunchDis.morning.split("-")[1].split(':') : [0, 0];
        const [noonHour1, noonMinute1] = lunchDis.noon ? lunchDis.noon.split("-")[1].split(':') : [0, 0];
        const [noonHour2, noonMinute2] = lunchDis.noon ? lunchDis.noon.split("-")[1].split(':') : [0, 0];
        const [nightHour1, nightMinute1] = lunchDis.night ? lunchDis.night.split("-")[1].split(':') : [0, 0];
        const currentTimestamp = new Date().setHours(currentHour, currentMinute, 0, 0); //当前时间
        const time1 = (morningHour2 && morningMinute2) ? new Date().setHours(morningHour2, morningMinute2, 0, 0) : ''; //早餐截止时间
        const time2 = (noonHour1 && noonMinute1) ? new Date().setHours(noonHour1, noonMinute1, 0, 0) : ''; //午餐开始时间
        const time3 = (noonHour2 && noonMinute2) ? new Date().setHours(noonHour2, noonMinute2, 0, 0) : ''; //午餐截止时间
        const time4 = (nightHour1 && nightMinute1) ? new Date().setHours(nightHour1, nightMinute1, 0, 0) : ''; //晚餐开始时间
        // 1个餐段
        if (lunchDinnerList.length == 1) {
            return {
                solt: lunchDinnerList[0].solt,
                can: lunchDinnerList[0].can
            };
        }
        // 2个餐段(早,午)(早,晚)(午,晚)
        if (lunchDinnerList.length == 2) {
            let obj1 = lunchDinnerList[0];
            let obj2 = lunchDinnerList[1];
            let timeA1 = obj1.solt == 1 ? time1 : time2;
            let timeA2 = obj2.solt == 2 ? time2 : time4;
            if (currentTimestamp < timeA1) { // 在早餐/午餐截止时间之前
                return obj1.solt == 1 ? {
                    solt: 1,
                    can: '早餐'
                } : {
                    solt: 2,
                    can: '午餐'
                };
            } else if (currentTimestamp > timeA1 && currentTimestamp < timeA2) { //在早餐/午餐截止时间之后 && 午餐/晚餐开始时间之前
                return obj2.solt == 2 ? {
                    solt: 2,
                    can: '午餐'
                } : {
                    solt: 3,
                    can: '晚餐'
                };
            } else if (currentTimestamp > timeA2) { //在午餐/晚餐截止时间之后
                return obj1.solt == 1 ? {
                    solt: 1,
                    can: '早餐'
                } : {
                    solt: 2,
                    can: '午餐'
                };
            }
        }
        // 3个餐段(早,午,晚)
        if (lunchDinnerList.length == 3) {
            if (currentTimestamp < time1) { //当前时间 在早餐截止时间之前
                return {
                    solt: 1,
                    can: '早餐'
                };
            } else if (currentTimestamp > time1 && currentTimestamp < time2) { //在早餐截止时间之后 && 午餐开始时间之前
                return {
                    solt: 2,
                    can: '午餐'
                };
            } else if (currentTimestamp > time3 && currentTimestamp < time4) { //在午餐截止时间之后 && 晚餐开始时间之前
                return {
                    solt: 3,
                    can: '晚餐'
                };
            } else {
                return {
                    solt: 3,
                    can: '晚餐'
                };
            }
        }
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})