comboBuy.js 25 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
// pack-cookbook/pages/comboBuy.js
import util from '../../utils/util';
import App from '../../utils/api';
Page({

    /**
     * 页面的初始数据
     */
    data: {
        sid: '',
        details: {}, //上页面传入的套餐信息
        seller: {}, //商家信息
        couponArr: [], //本套餐可用的优惠券列表
        finalList: [], //勾选的券列表
        planPrice: '', //套餐价格
        memberPrice: '', //菜品原价
        discountPrice: '', //优惠金额
        actualPrice: '', //抵扣后价格
        couponSwitch: true, //本单使用优惠券开关
        dataStr: Date.now() * 1 / 1000,
    },
    couponModal: '',

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        console.log('comboBuy options----', options);
        this.couponModal = this.selectComponent("#couponModal");
        let details = {};
        if (options.details) {
            details = JSON.parse(options.details);
        }
        let planPrice = details.plan_price || '';
        let memberPrice = details.member_price || details.menu_price || '';
        if (planPrice !== '') {
            planPrice = parseFloat(planPrice).toFixed(2);
        }
        if (memberPrice !== '') {
            memberPrice = parseFloat(memberPrice).toFixed(2);
        }
        this.setData({
            details,
            planPrice,
            memberPrice,
            actualPrice: planPrice || '0.00',
        })
        let sid = (details.seller && details.seller.sid) || options.sid || '';
        if (sid) {
            this.setData({
                sid
            })
            if (details.seller) {
                this.setData({
                    seller: details.seller
                })
            }
            this.getSellerDetailFun(sid)
        }
    },
    // 获取商家名称、照片
    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.getCoupon()
        })
    },
    // 获取所有优惠券,只展示本套餐可用的
    getCoupon() {
        if (!this.data.sid) return;
        App.Activity.ActivityListByOpenid({
            sellerid: this.data.sid
        }).then(res => {
            if (res.ret == 200 && res.data && res.data.length > 0) {
                let list = res.data;
                list.forEach(detail => {
                    detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
                    detail.arule = detail.arule ? util.determine(detail.arule) : '';
                    detail.expiration_date = detail.expiration_date ? util.determine(detail.expiration_date) : '';
                    detail.aexpiration = detail.aexpiration ? util.determine(detail.aexpiration) : '';
                    if (detail.arule) {
                        detail.accumulationShow = detail.arule.is_accumulation
                    }
                    if (detail.exp_date && detail.exp_date.week_data) {
                        let mor = this.hasConsecutiveSelect(detail.exp_date.week_data, '1').rArr.join('、')
                        let noon = this.hasConsecutiveSelect(detail.exp_date.week_data, '2').rArr.join('、')
                        let nig = this.hasConsecutiveSelect(detail.exp_date.week_data, '3').rArr.join('、')
                        if (mor) mor = '早餐:' + mor
                        if (noon) noon = '午餐:' + noon
                        if (nig) nig = '晚餐:' + nig
                        detail.morText = mor;
                        detail.noonText = noon;
                        detail.nigText = nig;
                    }
                    detail.checked = false;
                    detail.showCpupon = '0';
                    detail.cdate = detail.cdate * 1;
                    detail.useStime = '';
                    detail.useEtime = '';
                    let condition = detail.aexpiration || {};
                    if (condition.valid_forever === '0' && condition.stime && condition.etime) {
                        detail.useStime = condition.stime;
                        detail.useEtime = condition.etime;
                    }
                    if (condition.valid_forever === '1') {
                        detail.foreverText = '永久有效';
                    }
                    if (condition.valid_forever === '0' && condition.today) {
                        let obj = this.setTimeRange(detail.cdate, 0, parseInt(condition.today) - 1);
                        detail.useStime = obj.useStime;
                        detail.useEtime = obj.useEtime;
                    }
                    if (condition.valid_forever === '0' && condition.tomorrow) {
                        let obj = this.setTimeRange(detail.cdate, 1, condition.tomorrow * 1);
                        detail.useStime = obj.useStime;
                        detail.useEtime = obj.useEtime;
                    }
                    if (condition.valid_forever === '0' && condition.sday && condition.eday) {
                        let obj = this.setTimeRange(detail.cdate, parseInt(condition.sday) - 1, parseInt(condition.eday) - 1);
                        detail.useStime = obj.useStime;
                        detail.useEtime = obj.useEtime;
                    }
                    if ((detail.useStime > 0 && detail.useEtime > 0) || condition.valid_forever === '1') {
                        detail.endDateStr = condition.valid_forever == '1' ? '永久有效' : (util.unixtoTime(detail.useStime, 'YYYY-MM-DD') + '至' + util.unixtoTime(detail.useEtime, 'YYYY-MM-DD'));
                    }
                })
                // 过滤已过期的券
                list = list.filter(item => {
                    return (this.data.dataStr < (item.useEtime * 1) || item.aexpiration.valid_forever == '1');
                })
                // 判断券是否可用:满足套餐价格门槛的才显示
                let planPrice = parseFloat(this.data.planPrice) || 0;
                list = list.filter(item => {
                    let desc = parseFloat(item.desc) || 0;
                    return desc == 0 || planPrice >= desc;
                })
                // 相同aid的券合并成一张,用加减号选择张数
                let couponGroup = {};
                let couponList = [];
                list.forEach(item => {
                    let key = item.aid ? item.aid : item.activity_id
                    if (couponGroup[key]) {
                        couponGroup[key].num = (couponGroup[key].num * 1) + 1
                        couponGroup[key].activityIds.push(item.activity_id)
                    } else {
                        item.num = 1
                        item.checkedNum = 0
                        item.groupKey = key
                        item.activityIds = [item.activity_id]
                        couponGroup[key] = item
                        couponList.push(item)
                    }
                })
                list = couponList
                // 单次使用数量限制,0表示不限制,默认0
                list.forEach(item => {
                    let useLimit = item.single_use_limit ? (item.single_use_limit * 1) : 0
                    item.maxNum = (useLimit > 0 && useLimit < item.num) ? useLimit : item.num
                    item.showCpupon = '1'
                    item.canCheck = '1'
                    item.isOk = '1'
                })
                // 面额大的排在前面
                list.sort((a, b) => (parseFloat(b.price) || 0) - (parseFloat(a.price) || 0))
                console.log('comboBuy couponArr----', list);
                this.setData({
                    couponArr: list
                })
                if (this.data.couponSwitch) {
                    this.colationData()
                }
            } else {
                this.setData({
                    couponArr: [],
                    discountPrice: '',
                    actualPrice: this.data.planPrice || '0.00',
                })
            }
        })
    },
    // 打开优惠券弹框
    showCouponModal() {
        this.couponModal.showModal()
    },
    // 关闭优惠券弹框
    closeCouponModal() {
        this.couponModal.closeModal()
    },
    // 使用券开关
    switchChange(event) {
        this.setData({
            couponSwitch: event.detail.value,
        })
        if (this.data.couponSwitch) {
            this.colationData()
        } else {
            let list = this.data.couponArr;
            list.forEach(i => {
                i.checkedNum = 0;
                i.showCpupon = '1';
                i.canAdd = '1';
            })
            this.setData({
                couponArr: list,
                finalList: [],
                discountPrice: '',
                actualPrice: this.data.planPrice || '0.00',
            })
        }
    },
    // 加减号选择券的张数
    changeCouponNum(e) {
        let type = e.currentTarget.dataset.type;
        let aid = e.currentTarget.dataset.aid;
        const list = this.data.couponArr
        let item = list.find(i => i.aid == aid)
        if (!item) return
        if (type == 'plus') {
            if (item.canAdd != '1') return
            item.checkedNum = (item.checkedNum * 1) + 1
        }
        if (type == 'minus') {
            if (item.checkedNum <= 0) return
            item.checkedNum = (item.checkedNum * 1) - 1
        }
        this.refreshCouponState()
    },
    // 加减号中间输入框
    numInputChange(e) {
        let aid = e.currentTarget.dataset.aid;
        let val = (e.detail.value || '').replace(/[^\d]/g, '');
        const list = this.data.couponArr
        let item = list.find(i => i.aid == aid)
        if (!item) return
        let maxSelect = this.getMaxSelectNum(item)
        let num = val === '' ? 0 : parseInt(val, 10)
        if (isNaN(num)) num = 0
        if (num > maxSelect) num = maxSelect
        item.checkedNum = num
        this.refreshCouponState()
    },
    // 计算某张券当前最多可以选到的张数
    getMaxSelectNum(item) {
        const list = this.data.couponArr
        let inputValue = parseFloat(this.data.planPrice)
        let descStr = 0
        let val = 0
        list.forEach(i => {
            if (i.checkedNum > 0 && i.aid != item.aid) {
                let d = parseFloat(i.desc) || 0
                if (d > 0) descStr += d * i.checkedNum
                val += parseFloat(i.price) * i.checkedNum
            }
        })
        let itemDesc = parseFloat(item.desc) || 0
        let itemPrice = parseFloat(item.price)
        let maxSelect = item.maxNum
        if (item.accumulationShow != '1' && maxSelect > 1) maxSelect = 1
        if (inputValue > 0) {
            if (itemDesc > 0) {
                let byDesc = Math.floor((inputValue - descStr) / itemDesc)
                if (byDesc < maxSelect) maxSelect = byDesc
            } else {
                if (descStr >= inputValue) {
                    maxSelect = 0
                } else {
                    let byPrice = Math.floor((inputValue - val) / itemPrice)
                    if (byPrice < maxSelect) maxSelect = byPrice
                }
            }
        }
        if (maxSelect < 0) maxSelect = 0
        return maxSelect
    },
    // 根据选择的券张数刷新券的可选状态
    refreshCouponState() {
        const list = this.data.couponArr
        let currentCoupon = '0';
        let inputValue = parseFloat(this.data.planPrice)
        let val = 0;
        let descStr = 0;
        list.forEach(item => {
            if (item.checkedNum > 0) {
                val += parseFloat(item.price) * item.checkedNum
                let itemDesc = parseFloat(item.desc) || 0
                if (itemDesc > 0) {
                    descStr += itemDesc * item.checkedNum
                }
                if (item.accumulationShow != '1') {
                    currentCoupon = '2'
                } else {
                    currentCoupon = '1'
                }
            }
        })
        if (currentCoupon == '0') {
            list.forEach(item => {
                if (item.canCheck == "1") {
                    item.showCpupon = '1';
                }
            })
        }
        if (currentCoupon == '2') {
            list.map((item) => {
                if (item.checkedNum > 0) {
                    item.showCpupon = '1'
                } else {
                    item.showCpupon = '0'
                }
            })
        }
        if (currentCoupon == '1') {
            list.forEach(item => {
                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)))) {
                    item.showCpupon = '1';
                } else {
                    item.showCpupon = '0';
                }
            })
        }
        let finalList = []
        list.forEach(item => {
            if (item.checkedNum > 0) {
                for (let k = 0; k < item.checkedNum; k++) {
                    finalList.push({
                        ...item,
                        activity_id: item.activityIds[k]
                    })
                }
            }
        })
        this.updateCanAdd()
        let discountPrice = 0;
        finalList.forEach(i => {
            discountPrice += parseFloat(i.price)
        })
        discountPrice = discountPrice.toFixed(2)
        let actualPrice = (inputValue - discountPrice).toFixed(2)
        if (parseFloat(actualPrice) < 0) actualPrice = '0.00'
        this.setData({
            couponArr: list,
            finalList,
            discountPrice: discountPrice == '0.00' ? '' : discountPrice,
            actualPrice,
        })
    },
    // 计算每张券还能不能继续加
    updateCanAdd() {
        const list = this.data.couponArr
        let inputValue = parseFloat(this.data.planPrice)
        let descStr = 0
        let val = 0
        list.forEach(item => {
            if (item.checkedNum > 0) {
                let itemDesc = parseFloat(item.desc) || 0
                let itemPrice = parseFloat(item.price)
                if (itemDesc > 0) descStr += itemDesc * item.checkedNum
                val += itemPrice * item.checkedNum
            }
        })
        list.forEach(item => {
            item.canAdd = '0'
            let maxSelect = item.accumulationShow == '1' ? item.maxNum : 1
            if (item.showCpupon == '1' && item.checkedNum < maxSelect) {
                let itemDesc = parseFloat(item.desc) || 0
                let itemPrice = parseFloat(item.price)
                if (itemDesc > 0) {
                    if (descStr + itemDesc <= inputValue) item.canAdd = '1'
                } else {
                    if (descStr < inputValue && val + itemPrice <= inputValue) item.canAdd = '1'
                }
            }
        })
    },
    // 点确认选择
    checkCertificate() {
        this.closeCouponModal()
        let list = this.data.couponArr;
        let price = 0;
        list.forEach(i => {
            if (i.checkedNum > 0) {
                price += parseFloat(i.price) * i.checkedNum
            }
        })
        let planPrice = parseFloat(this.data.planPrice) || 0;
        let actualPrice = (planPrice - price).toFixed(2)
        if (parseFloat(actualPrice) < 0) actualPrice = '0.00'
        price = price.toFixed(2)
        this.setData({
            couponSwitch: price != '0.00',
            discountPrice: price == '0.00' ? '' : price,
            actualPrice,
        })
    },
    // 自动勾选最优惠券组合
    colationData() {
        let list = this.data.couponArr;
        if (!list.length) {
            this.setData({
                discountPrice: '',
                actualPrice: this.data.planPrice || '0.00',
            })
            return
        }
        let obj = this.findBestCoupons(list);
        this.setData({
            couponArr: obj.arr,
        })
        this.refreshCouponState()
    },
    // 最优惠的消费券组合
    findBestCoupons(arr) {
        const amount = parseFloat(this.data.planPrice) || 0;
        const validCoupons = arr.filter(coupon => (coupon.isOk == '1' && parseFloat(coupon.desc) <= amount) && amount >= parseFloat(coupon.price));
        validCoupons.sort((a, b) => parseFloat(b.price) - parseFloat(a.price));
        arr.forEach(item => {
            const isValid = validCoupons.some(validCoupon => validCoupon.activity_id == item.activity_id);
            item.canCheck = isValid ? '1' : '0';
            item.checkedNum = 0;
            item.showCpupon = isValid ? '1' : '0';
        });
        let stackingCoupons = validCoupons.filter(i => i.accumulationShow == '1')
        let list1 = [];
        let list2 = [];
        let finalList = [];
        let selectCount = {};
        stackingCoupons.sort((a, b) => {
            if (a.desc === '0' || a.desc === '') return -1;
            if (b.desc === '0' || b.desc === '') return 1;
            if (parseFloat(b.price) !== parseFloat(a.price)) return parseFloat(b.price) - parseFloat(a.price);
            return parseFloat(b.desc) - parseFloat(a.desc);
        });
        let thresholdDescSum = 0
        let maxThresholdValue = 0
        let thresholdCoupons = stackingCoupons.filter(coupon => (parseFloat(coupon.desc) || 0) > 0)
        thresholdCoupons.sort((a, b) => {
            if (parseFloat(b.desc) !== parseFloat(a.desc)) return parseFloat(b.desc) - parseFloat(a.desc)
            return parseFloat(b.price) - parseFloat(a.price)
        })
        thresholdCoupons.forEach(coupon => {
            let couponDesc = parseFloat(coupon.desc) || 0
            let couponPrice = parseFloat(coupon.price)
            let maxCopies = Math.floor((amount - thresholdDescSum) / couponDesc)
            if (maxCopies > coupon.maxNum) maxCopies = coupon.maxNum
            if (maxCopies > 0) {
                selectCount[coupon.aid] = maxCopies
                thresholdDescSum += couponDesc * maxCopies
                maxThresholdValue += couponPrice * maxCopies
            }
        })
        list1 = stackingCoupons.filter(i => (selectCount[i.aid] || 0) > 0)
        let noDescValue = 0
        let noDescCount = {}
        stackingCoupons.forEach(coupon => {
            let couponDesc = parseFloat(coupon.desc) || 0
            let couponPrice = parseFloat(coupon.price)
            if (couponDesc === 0 && couponPrice > 0) {
                let num = Math.floor((amount - noDescValue) / couponPrice)
                if (num > coupon.maxNum) num = coupon.maxNum
                if (num > 0) {
                    noDescCount[coupon.aid] = num
                    noDescValue += couponPrice * num
                }
            }
        })
        let maxStackableValue = maxThresholdValue
        if (thresholdDescSum < amount) {
            stackingCoupons.forEach(coupon => {
                let couponDesc = parseFloat(coupon.desc) || 0
                let couponPrice = parseFloat(coupon.price)
                if (couponDesc === 0 && couponPrice > 0) {
                    let num = Math.floor((amount - maxStackableValue) / couponPrice)
                    if (num > coupon.maxNum) num = coupon.maxNum
                    if (num > 0) {
                        selectCount[coupon.aid] = num
                        maxStackableValue += couponPrice * num
                    }
                }
            })
            list1 = stackingCoupons.filter(i => (selectCount[i.aid] || 0) > 0)
        } else if (noDescValue > maxThresholdValue) {
            list1 = stackingCoupons.filter(i => (noDescCount[i.aid] || 0) > 0)
            selectCount = noDescCount
            maxStackableValue = noDescValue
        } else if (noDescValue == maxThresholdValue && noDescValue > 0) {
            let listThreshold = stackingCoupons.filter(i => (selectCount[i.aid] || 0) > 0)
            let listNoDesc = stackingCoupons.filter(i => (noDescCount[i.aid] || 0) > 0)
            let min1 = listThreshold.length > 0 ? Math.min(...listThreshold.map(item => item.useEtime)) : Infinity
            let min2 = listNoDesc.length > 0 ? Math.min(...listNoDesc.map(item => item.useEtime)) : Infinity
            if (min2 < min1) {
                list1 = listNoDesc
                selectCount = noDescCount
            }
        }
        let stackList = list1
        let stackCount = selectCount
        let maxNonStackableValue = 0
        validCoupons.forEach(coupon => {
            if (coupon.accumulationShow != '1') {
                const discountAmount = parseFloat(coupon.price);
                const finalAmount = amount - discountAmount;
                if (finalAmount > 0 || finalAmount == 0) {
                    if (maxNonStackableValue < discountAmount) {
                        maxNonStackableValue = discountAmount
                        list2 = [{ ...coupon }]
                    }
                }
            }
        });
        if (maxStackableValue > maxNonStackableValue) {
            finalList = stackList
        } else if (maxStackableValue < maxNonStackableValue) {
            finalList = list2
            stackCount = {}
            if (list2[0]) stackCount[list2[0].aid] = 1
        } else {
            let copiedList1 = JSON.parse(JSON.stringify(stackList));
            let copiedList2 = JSON.parse(JSON.stringify(list2));
            let minList1 = copiedList1.length > 0 ? Math.min(...copiedList1.map(item => item.useEtime)) : Infinity;
            let minList2 = copiedList2.length > 0 ? Math.min(...copiedList2.map(item => item.useEtime)) : Infinity;
            if (minList1 <= minList2) {
                finalList = stackList
            } else {
                finalList = list2
                stackCount = {}
                if (list2[0]) stackCount[list2[0].aid] = 1
            }
        }
        let discountPrice = 0;
        finalList.forEach(coupon => {
            let target = arr.findIndex(obj => obj.aid === coupon.aid || obj.activity_id === coupon.activity_id);
            if (target > -1) {
                arr[target].showCpupon = '1';
                arr[target].checkedNum = stackCount[coupon.aid] || 1;
                discountPrice += parseFloat(coupon.price) * (stackCount[coupon.aid] || 1);
            }
        });
        finalList = []
        arr.forEach(item => {
            if (item.checkedNum > 0) {
                for (let k = 0; k < item.checkedNum; k++) {
                    finalList.push({
                        ...item,
                        activity_id: item.activityIds[k]
                    })
                }
            }
        })
        discountPrice = discountPrice.toFixed(2)
        return {
            arr,
            discountPrice,
            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].selectMor : type == '2' ? arr[i].selectNoon : type == '3' ? 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
        };
    },
    // 计算免费券有效期的起始、结束日期
    setTimeRange(cdate, startOffset, endOffset) {
        const startDate = new Date((cdate + startOffset * 86400) * 1000);
        startDate.setHours(0, 0, 0, 0);
        let useStime = startDate.getTime() / 1000
        const endDate = new Date((cdate + endOffset * 86400) * 1000);
        endDate.setHours(23, 59, 59, 0);
        let useEtime = endDate.getTime() / 1000
        return { useStime, useEtime };
    },
    // 支付(暂未接入支付流程,先占位)
    submitPay() {
        wx.showToast({
            title: '支付功能开发中',
            icon: 'none',
        })
    },

    onReady() {},
    onShow() {},
    onHide() {},
    onUnload() {},
    onPullDownRefresh() {},
    onReachBottom() {},
    onShareAppMessage() {}
})