equityPage.js 22.2 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 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794
// pages/equity/index.js
import { IMG_URL } from '~/utils/imageBase.js'
import { checkLoginEnvironment } from '~/utils/loginEnvironmentCheck'
import { get4SStoreList } from '~/store/index'
import { checkDailyReport } from '~/store/ModalToQueueControl'
import api from '~/api/api.js'
import dayjs from 'dayjs'
import {
  merchantMode,
  waitinputorder,
  staffDailyReportDetailWeeklyList,
  staffDailyReportMerchantValid,
  quotationRecording,
  isBusinessSchoolEnableCurrentUser,
  deliveryTargetInfo,
  orderStaffValid
} from '../../api'
import { getBusinessSchoolScene } from '~/store/index'
import carLifeApi from '../../carEquityApi'

import {
	fetchServiceCenterUnread,
	resolveFirstUnreadNotice
} from '../../services/serviceCenterNoticeService.js'
import { enqueueServiceNoticePopup } from '~/utils/serviceNoticePopupHandler.js'
import { AI_ROUTES } from '~/router/routeAliases.js'
import {
	loadAbnormalFlowTipState,
	dismissAbnormalFlowTip,
	openAbnormalFlowTransactionPopup
} from '../../../tabIndex/services/abnormalFlowTipService.js'
import {
	shouldSkipStaffOrderValid,
	markStaffOrderValidChecked
} from '../../services/staffOrderValidService.js'

const app = getApp()
let time = null
var util = require('~/utils/timeFormat/time-utils.js')
let modalQueue = []
Page({
  /**
   * 页面的初始数据
   */
  data: {
    navStyle: 'background-color: rgba(0,0,0,0);box-shadow:none;',
    tabBarList: [
      {
        name: '首页',
        iconPath: IMG_URL + 'images/tab-home.png',
        selectedIconPath: IMG_URL + 'images/tab-home-active.png'
      },
      {
        name: '工单管理',
        iconPath: IMG_URL + 'images/tab-order.png',
        selectedIconPath: IMG_URL + 'images/tab-order-active.png'
      },
      {
        name: '权益提单',
        iconPath: IMG_URL + 'images/tab-equity.png',
        selectedIconPath: IMG_URL + 'images/tab-equity-active.png'
      },
      {
        name: '营销素材',
        iconPath: IMG_URL + 'images/tab-material.png',
        selectedIconPath: IMG_URL + 'images/tab-material-active.png'
      },
      {
        name: '个人中心',
        iconPath: IMG_URL + 'images/tab-mine.png',
        selectedIconPath: IMG_URL + 'images/tab-mine-active.png'
      }
    ],
    tipsPropsConfig: {
      tipsText: '该门店产生异常订单,请点击补录!',
      showTips: true,
      type: 2,
      typeText: '补录订单'
    },
    tabIndex: 0,
    pageShow: [true, false, false, false, false],
    navBarHeight: 113.5,
    showPicker: false,
    userInfo: {},
    selectStroeIndex: 0,
    shopSideSelectPopup: false,
    mode: null,
    tipsProps: false,
    waitInputCount: 0,
    isStaff: false,
    abnormalFlowTips: { show: false, count: 0, tipsText: '' },
    storeRange: [],
    showPage: false,
    invoiceOrderInfo: {},
    serviceCenterUnreadNum: 0
    // hasMode:true
  },
  async navigator(e) {
    // 校验是否填写昨日日报
    let staffCheck = await checkDailyReport(true)
    if (staffCheck) return false
    let { selectOutTradeNoArr } = e.detail
    let { mode, paymentMethod } = this.data
    this.closeSwitchPopup()
    selectOutTradeNoArr &&
      wx.$router.go(
        mode ? 'createOrderCarQuotationSimple' : 'createOrderCarQuotation',
        {
          selectOutTradeNoArr,
          paymentMethod
        }
      )
  },
  tipsEvent() {
    this.setData({
      tipsProps: !this.data.tipsProps
    })
  },
  closeSwitchPopup() {
    this.setData({
      tipsProps: false
    })
  },
  // 检测一下是否能微信端小程序登录
  checkAgreeClient(loginUserObj) {
    const yqMerchantId = loginUserObj?.merchantId
    return checkLoginEnvironment({
      yqMerchantId,
      getYqStoreConfig: params => api.getYqStoreConfig(params),
      onBlocked: message => {
        wx.hideLoading()
        this.addModalToQueue(
          '温馨提示',
          message,
          '知道了',
          false,
          5,
          res => {
            if (res.confirm) {
              wx.$router.reLaunch('pages.accountItems')
            }
          }
        )
      }
    })
  },
  async checkDailyRecport() {
    let { tabIndex } = this.data
    let userInfo = wx.$util.getUserInfo()
    const isStaff = app.globalData.isStaff
    let eventRequest = []
    // isStaff &&
    //   tabIndex == 0 &&
    //   eventRequest.push(this.staffDailyReport(wx.$util.getUserInfo()));
    if (tabIndex == 0 && !wx.$hasPermission?.canViewViolation?.(userInfo))
      eventRequest.push(this.checkAgreeClient(wx.$util.getUserInfo()))
    return new Promise(resolve => {
      Promise.all(eventRequest).then(() => {
        resolve()
      })
    })
  },
  checkDeliveryTarget() {
    return new Promise(resolve => {
      let userInfo = wx.$util.getUserInfo()
      let currentDate = new Date()
      // toISOString 方法会丢失时区 导致与北京时间差八小时
      let hour = currentDate.getHours() + 8
      currentDate.setHours(hour)
      // 格式化日期为"yyyy-mm-dd"
      let formattedDate = currentDate.toISOString().split('T')[0]
      // 驻店负责人 loginRoleOnSelectMerchant 跟随门店配置是否是驻店负责人
      if (app.globalData.isStaff && userInfo.loginRoleOnSelectMerchant == 4) {
        deliveryTargetInfo({
          merchantId: userInfo?.shopMerchantId,
          targetDate: formattedDate
        }).then(res => {
          let { code, data } = res
          if (code == 0) {
            if (!data) {
              if (wx.__HAS_NOTLOGIN_MODAL || wx.$hasPermission?.canSelectMultiStore?.(userInfo))
                return false
              this.addModalToQueue(
                '交车目标',
                '您有未填写的交车目标,请点击前往',
                '前往填写',
                true,
                2,
                res => {
                  if (res.confirm) {
                    wx.$router.go('packageEquity.deliveryTarget', {})
                  }
                }
              )
            }
          }
          resolve()
        })
      } else {
        resolve()
      }
    }).catch(err => {
      resolve()
    })
  },
  /**
   * 查询门店权益模式并下发给子组件 `mode`。
   * 仅在页面 `onLoad` 调用一次;Tab 切换不再重复请求 `merchant.mode`。
   * @returns {Promise<void>}
   */
  getMerchant4SMode() {
    return new Promise(resolve => {
      const userInfo = wx.$util.getUserInfo()
      let storeInfo = userInfo?.default4SStoreInfo || {}
      if (
        !app?.globalData?.isStaff ||
        !storeInfo?.merchantId
      ) {
        this.setData({ mode: -1 })
        resolve()
        return
      }
      merchantMode({ merchantId4s: storeInfo?.merchantId })
        .then(result => {
          let { data, code } = result
          if (code == 0 && data?.mode != null) {
            const isStaff = app.globalData.isStaff && data.mode != -1
            this.setData({
              mode: data.mode,
              isStaff
            })
          } else {
            this.setData({
              mode: -1
            })
            if (wx.$hasPermission?.canSelectMultiStore?.(userInfo))
              return false
            this.addModalToQueue(
              '温馨提示',
              '未配置权益规则,请联系客服处理。',
              '确定',
              false,
              1,
              () => {}
            )
          }
          resolve()
        })
        .catch(err => {
          this.setData({ mode: -1 })
          resolve()
        })
    })
  },
  init(userInfo) {
    // console.log(8989)
    this.setData({
      userInfo
    })
    if (!wx.$hasPermission?.canViewViolation?.(userInfo)) {
      this.get4SStoreList()
    } else {
      this.setData({ showPage: true })
    }
    this.getIsBusinessSchoolEnableCurrentUser()
    // this.test()
  },
  getIsBusinessSchoolEnableCurrentUser() {
    // 判断是不是超管 是默认开启工资绩效 不是查询对应园区
    // let userInfo = wx.$util.getUserInfo()
    let { userInfo } = this.data
    // let enableBusinessSchool = userInfo?.isSuper ? true : false
    if (wx.$hasPermission?.isSuper?.(userInfo)) {
      this.setData({
        enableBusinessSchool: true
      })
    } else {
      getBusinessSchoolScene({})
        .then(res => {
          // console.log(res, "res");
          // let { code, data } = res
          // if (code == 0) {
          this.setData({
            enableBusinessSchool: res
          })
          // }
        })
        .catch(err => {
          console.log(err)
        })
    }
  },
  get4SStoreList() {
    let userInfo = wx.$util.getUserInfo()
    let params = {
      merchantId:
        wx.$hasPermission?.canSelectMultiStore?.(userInfo)
          ? ''
          : userInfo?.merchantId,
      staffUUID:
        wx.$hasPermission?.canSelectMultiStore?.(userInfo)
          ? ''
          : userInfo?.uuid,
      scene: 0
    }
    get4SStoreList(
      params,
      wx.$hasPermission?.canSelectMultiStore?.(userInfo)
    ).then(result => {
      let userInfo = wx.$util.getUserInfo()
      if (!result?.length) {
        userInfo.shopMerchantId = null
        userInfo.default4SStoreInfo = {}
        userInfo.shopMerchantName = null
        userInfo.sceneType = null
        wx.$util.setUserInfo(userInfo)
        return wx.$router.reLaunch('pages.accountItems')
      }
      if (result?.length && wx.$hasPermission?.canSelectMultiStore?.(userInfo)) {
        if (result[0]?.merchantName !== '全部' && result[0]?.merchantId) {
          result.unshift({ merchantName: '全部' })
        }
        let obj = {
          ...userInfo
          // default4SStoreInfo: {
          //   merchantId: result[0]?.merchantId,
          //   merchantName: result[0]?.merchantName,
          // },
        }
        if (
          !userInfo?.default4SStoreInfo ||
          !Object.keys(userInfo?.default4SStoreInfo).length
        ) {
          wx.$util.setUserInfo(obj)
          this.setData({
            userInfo: obj
          })
        }
      }
      this.setData({
        storeRange: result || [],
        showPage: true
      })
    })
  },

  showStorePicker() {
    this.setData({
      showPicker: true
    })
  },

  /**
   * 底部 Tab 切换:更新 tabIndex、懒挂载标记 pageShow[N],触发父页 initList。
   * 子 Tab 业务数据由各子组件 `properties.show` observer 刷新,不在此手动 onLoad。
   * @param {{ detail: number }} e - tabIndex
   */
  changeTabBar(e) {
    // let { pageShow } = this.data,
    // wx.__HAS_NOREPORT_MODAL = false
    // wx.__HAS_NOTARGET_MODAL = false
    // console.log(e.detail)
    wx.__HAS_SHOW_MODAL = false
    let tabIndex = e.detail
    // console.log(pageShow[tabIndex])
    this.setData({
      [`pageShow[${tabIndex}]`]: true,
      tabIndex,
      staffUuid: ''
    })
    const showPageNum = [1, 2]
    showPageNum.includes(tabIndex) && wx.$eventbus.emit('page_show') // 初始化tab底部条没有的问题
    this.initList()
  },
  checkTask() {
    return new Promise(resolve => {
      const userInfo = wx.$util.getUserInfo()
      const merchantId = userInfo?.merchantId
      const time = wx.getStorageSync('aiTime')
      if (time == new Date().format('yyyy-MM-dd')) {
        resolve()
        return
      }
      wx.setStorageSync('aiTime', new Date().format('yyyy-MM-dd'))
      const params = {
        currentPage: 1,
        sparringStatus: 0,
        tryCount: 2,
        taskState: 2,
        pageSize: 1,
        yqMerchantId: merchantId
      }
      carLifeApi
        .getSparringPage(params)
        .then(res => {
          const { list = [] } = res.data
          if (list.length) {
            if (wx.__HAS_NOTLOGIN_MODAL || wx.$hasPermission?.canSelectMultiStore?.(userInfo))
              return false
            this.addModalToQueue(
              '对练任务提醒',
              '您有未完成的对练任务,点击前往完成',
              '前往完成',
              true,
              3,
              res => {
                if (res.confirm) {
                  const {
                    task: { aiType, promptOnOff },
                    staff: { id, tryCount }
                  } = list[0]
                  wx.$router.go(
                    `${AI_ROUTES.exerciseList}?staffid=${id}&tryCount=${tryCount}&roleType=${aiType}&promptOnOff=${promptOnOff}`
                  )
                }
              }
            )
          }
          resolve()
        })
        .catch(() => {
          resolve()
        })
    })
  },
  /**
   * 开单预警:调用 `order.staff.valid`,必要时入队弹窗。
   * 仅由 `initList` 在 tabIndex===0 时调用;当日缓存见 staffOrderValidService。
   * @returns {Promise<void>}
   */
  checkStaffOrderStatus() {
    return new Promise(resolve => {
      const userInfo = wx.$util.getUserInfo()
      const dateStaffPop = wx.$storage.get('dateStaffPop') || {}
      const isStaff = app.globalData.isStaff
      if (!isStaff) {
        resolve()
        return
      }
      if (shouldSkipStaffOrderValid(dateStaffPop, userInfo)) {
        resolve()
        return
      }
      orderStaffValid({
        sceneType: userInfo.sceneType
      })
        .then(result => {
          if (result.data) {
            if (
              !wx.__HAS_NOTLOGIN_MODAL &&
              !wx.$hasPermission?.canSelectMultiStore?.(userInfo)
            ) {
              this.addModalToQueue(
                '开单预警',
                '您已超过三天未开单',
                '确定',
                false,
                1,
                () => {
                  this.showNextModal()
                }
              )
            }
          }
          wx.$storage.set(
            'dateStaffPop',
            markStaffOrderValidChecked(dateStaffPop, userInfo)
          )
          resolve()
        })
        .catch(() => {
          resolve()
        })
    })
  },
  checkAbnormalOrderLocal() {
    return new Promise(resolve => {
      let abnormalOrderPop = wx.$storage.get('abnormalOrderPop')
      let userInfo = wx.$util.getUserInfo()
      let nowDate = new Date().format('yyyy-MM-dd')
      let { sceneType } = userInfo
      let merchantId = userInfo?.default4SStoreInfo?.merchantId
      let dayBoolean = abnormalOrderPop?.date && nowDate == abnormalOrderPop?.date
      let flag = abnormalOrderPop?.[sceneType]?.[merchantId]

      api
        .abnormalOrderLock()
        .then(res => {
          if (!res.data?.abnormalOrderNum) {
            resolve(false)
            return
          }
          if (dayBoolean && flag) {
            resolve(true)
            return
          }
          this.addModalToQueue(
            '异常订单提醒',
            `存在 ${res.data.abnormalOrderNum}条异常订单未处理,请尽快处理!`,
            '确认',
            false,
            0,
            () => {
              this.showNextModal()
            }
          )
          wx.$storage.set('abnormalOrderPop', {
            date: nowDate,
            [sceneType]: {
              ...(abnormalOrderPop?.[sceneType] || {}),
              [merchantId]: true
            }
          })
          resolve(true)
        })
        .catch(() => {
          resolve(false)
        })
    })
  },
  addModalToQueue(
    title,
    content,
    confirmText,
    showCancel,
    priority,
    eventCallback,
    isShowNext
  ) {
    if (modalQueue.findIndex(val => val.content == content) < 0)
      modalQueue.push({
        title,
        content,
        confirmText,
        showCancel,
        priority,
        eventCallback,
        isShowNext
      })
    modalQueue.sort((a, b) => a.priority - b.priority)
  },
  showNextModal() {
    let _this = this
    if (modalQueue.length === 0) return
    if (wx.__HAS_SHOW_MODAL) return
    const modalInfo = modalQueue.pop()
    wx.__HAS_SHOW_MODAL = true
    wx.showModal({
        title: modalInfo.title,
        content: modalInfo.content,
        showCancel: modalInfo.showCancel,
        cancelColor: '#292D33',
        confirmText: modalInfo.confirmText,
        confirmColor: '#347BFF',
        success: function (res) {
          wx.__HAS_SHOW_MODAL = false
          if (res.cancel || modalInfo.isShowNext) _this.showNextModal()
          modalInfo.eventCallback(res)
        }
      })
  },
  /**
   * Tab 切换 / 页面 onShow 时的父页任务队列(弹窗链、交付目标等)。
   * 不刷新子 Tab 列表/看板;不调用 `getMerchant4SMode`。
   * Tab0 额外:开单预警、异常单、服务中心公告(员工)。
   * @returns {Promise<void>}
   */
  async initList() {
	  let {tabIndex} =  this.data
	  const isStaff = app.globalData.isStaff;

    let eventRequest = [
      // this.checkDailyRecport(),
      this.checkDeliveryTarget()
    ]
    // Tab0 专属弹窗/检查,避免 Tab1–4 切换误打 order.staff.valid 等接口
    if (tabIndex === 0) {
      eventRequest.push(this.checkStaffOrderStatus())
      eventRequest.push(this.checkAbnormalOrderLocal())
    }
	  if (isStaff && tabIndex === 0) {
		  eventRequest.push(this.checkServiceNotice());
	  }
	  Promise.all(eventRequest).then(() => {
		  wx.__HAS_SHOW_MODAL = false
		  this.showNextModal()
	  })
  },
  /**
   * 侧边切换 4S 店后刷新(SideSelectPopup.eventCallback 调用,对齐 tabIndex.initData)。
   * 重建菜单(含动态日报三入口)并刷新 Tab0 看板/待办/接待。
   * @param {Object} [data] - selectMerchantScene 返回,可含 subLoginUser
   */
  async initData(data) {
    const userInfo = wx.$util.getUserInfo()
    if (data?.subLoginUser) {
      userInfo.subLoginUser = data.subLoginUser
      wx.$util.setUserInfo(userInfo)
    }
    this.setData({ userInfo })
    await this.getMerchant4SMode()
    const home = this.selectComponent('#page-0')
    if (home?.onStoreSwitched) {
      await home.onStoreSwitched({ mode: this.data.mode })
    }
    const { tabIndex } = this.data
    if (tabIndex > 0) {
      const tab = this.selectComponent(`#page-${tabIndex}`)
      tab?.refreshOnShow?.()
    }
    loadAbnormalFlowTipState(this)
  },
  back() {
    if (this.data.staffUuid) {
      return wx.$router.back()
    }
    wx.$router.reLaunch('pages.sceneIndex')
  },

  showMenuPopup() {
    this.setData({
      shopSideSelectPopup: true
    })
  },

	navbarReady(e) {
		let navBarHeight = e.detail.height
		this.setData({
			navBarHeight
		})
	},
	setTime() {
		let _this = this
		time = setTimeout(() => {
			// console.log(_this.getWaitOrder)
			// 2025-8月版本,隐藏补录入口
			// _this.getWaitOrder();
		}, 10 * 1000)
	},
	// 10s轮询一次待补录
	getWaitOrder() {
		let { isStaff, mode } = this.data
		// console.log('isStaff', isStaff)
		// let thisPage = wx.$router.getPageInstance()
		// console.log(thisPage.route, ' thisPage.route')
		// thisPage.route == 'tabIndex/pages/index/index' &&
		time && clearTimeout(time) //解决切换门店时 需要清除计时器
		if (isStaff && mode) {
			waitinputorder()
				.then(result => {
					// console.log(result)
					let { code, data } = result
					this.setTime()
					if (code == 0) {
						this.setData({
							waitInputCount: data.waitInputCount
						})
					}
				})
				.catch(err => {})
		}
	},
	async checkServiceNotice() {
		const unread = await fetchServiceCenterUnread()
		this.setData({ serviceCenterUnreadNum: Number(unread) || 0 })

		const candidate = await resolveFirstUnreadNotice()
		if (!candidate) return

		try {
			enqueueServiceNoticePopup(this, candidate)
		} catch (err) {
			console.error('[checkServiceNotice] enqueue failed', err)
		}
	},
	onRoute(options) {
		wx.__HAS_SHOW_MODAL = false
		if (options && options.tabIndex) {
			this.changeTabBar({
				detail: options.tabIndex
			})
			//判断是否是从超管话术质检带过来的参数
			if (options.staffUuid && options.tabIndex == 1)
				this.setData({
					staffUuid: options.staffUuid
				})
		} else {
			if (options && options.tabIndex && options.tabIndex != 0) {
				return
			}
		}
	},
	/**
	 * 页面首屏:拉门店 mode(仅此一次)、处理深链 tabIndex、注册 eventbus。
	 * 子 Tab 业务初始化改由各自 `show` observer,不在此 onLoad 子组件。
	 * @param {Object} [options] - 路由参数,可含 tabIndex
	 */
	onLoad(options) {
		this.getMerchant4SMode()
		if (options && options.tabIndex) {
			this.changeTabBar({
				detail: options.tabIndex
			})
		}
		wx.$eventbus.on('switch_tab', () => {
			let e = {
				detail: 3
			}
			this.changeTabBar(e)
		})
		wx.$receptionLoaded = false
		// console.log(options, 'onLoad')
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady() {},

  /**
   * 页面显示:跑父页 initList;若仍在 Tab0 则补刷 home(子页返回时 show 不变,observer 不触发)。
   */
  onShow() {
    this.initList()
    const selectInvoiceObj = getApp().globalData.selectInvoiceObj
    this.setData({
      invoiceOrderInfo: selectInvoiceObj?.isOpen
        ? selectInvoiceObj.codeInfo
        : {}
    })
    delete getApp().globalData?.selectInvoiceObj // 使用后清除
    loadAbnormalFlowTipState(this)
  },
  /** 关闭异常流水吸底提醒(当前登录周期) */
  onAbnormalFlowTipClose() {
    dismissAbnormalFlowTip(this)
  },
  /** 异常流水吸底「去处理」:打开选流水弹窗 */
  onAbnormalFlowTipAction() {
    openAbnormalFlowTransactionPopup(this)
  },

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide() {
		time && clearTimeout(time)
		let { tabIndex } = this.data
		this.selectComponent(`#page-${tabIndex}`)?.onHide &&
		this.selectComponent(`#page-${tabIndex}`).onHide()
	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload() {
		time && clearTimeout(time)
		let { tabIndex } = this.data
		this.selectComponent(`#page-${tabIndex}`)?.onUnload &&
		this.selectComponent(`#page-${tabIndex}`).onUnload()
	},

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

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

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage() {},
	// closeScreen() {
	//   this.selectComponent("#page-1").back();
	// },
	// 筛选确认
	searchScreen(obj) {
		console.log(obj)
		let { tabIndex } = this.data
		this.selectComponent(`#page-${tabIndex}`)?.searchScreen &&
		this.selectComponent(`#page-${tabIndex}`).searchScreen(obj)
	},

  // 筛选页面返回
  containerBack() {
    let { tabIndex } = this.data
    this.selectComponent(`#page-${tabIndex}`)?.back &&
      this.selectComponent(`#page-${tabIndex}`).back()
  }
})