index.js 23.4 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 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823
// tabWorkOrder/pages/index/index.js
import api from './api'
import order_mixins from './order_mixins.js'
import { buildBoutiqueCustomerDailyListDisplay } from '../createOrder/services/customerDailyFields.helpers.js'
import {
  LOW_PRICE_ORDER_EDIT_MESSAGE,
  shouldBlockLowPriceOrderEdit
} from '~/utils/workOrderLowPrice.helpers.js'
const IMG_URL =
  'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
let timeoutId
import {
  checkDailyReport,
  checkStudyTask,
  checkOrderLockGate
} from '~/store/ModalToQueueControl'
Page({
  /**
   * 页面的初始数据
   */
  data: {
    IMG_URL,
    ...order_mixins.data,
    showIcon1: true, // 初始显示图标
    // showIcon2: true, // 初始隐藏第二个图标
    activeIndex: 0,
    orderObj: [
      {
        label: '销售顾问',
        arr: ['merchantName', 'employeeName']
      },
      {
        label: '转化人员',
        arr: ['sellerMerchantName', 'sellerName']
      },
      {
        label: '工单编号',
        key: 'orderCode'
      },
      {
        label: '工单时间',
        key: 'orderTime'
      }
    ],
    searchObj: {},
    pageNum: 1,
    keyword: '',
    list: [],
    tabIndex: 0,
    tabList: ['全部', '待跟进', '已升级', '战败'],
    tabListTemplate: ['全部', '待跟进', '已升级', '战败'],
    isMake: true,
    selectType: 1,
    isSettingExpiredTraffic: false, // 是否启用流量失效
    isScan: false // 是否扫码核销
  },
  // 创建一个动画实例
  // createAnimation: function () {
  //   const animation = wx.createAnimation({
  //     duration: 300, // 动画持续时间,单位毫秒
  //     timingFunction: 'ease', // 缓动函数,这里使用了默认的缓动效果
  //   });
  //   const iconAnimation = this.selectComponent('#iconAnimation'); // 获取animation组件的实例
  //   console.log(iconAnimation);
  //   animation.translateY(0).step(); // 初始状态
  //   iconAnimation.animationData = animation.export();
  //   this.setData({
  //     animationData: animation.export(),
  //   });

  //   return animation;
  // },
  selectType(e) {
    let { type } = e.currentTarget.dataset
    console.log(e, e.currentTarget.dataset, type)
    this.setData({
      selectType: type
    })
  },
  // 确定是否要显示
  showSelectType({ scene = '', item = {} }, scan = false) {
    let { isSettingExpiredTraffic } = this.data
    this.setData({ isScan: scan })
    // 当切换门店后,不支持录入失效客户工单,将selectType置为1录入工单
    if ((!isSettingExpiredTraffic || scan) && this.data.selectType == 3) {
      this.setData({
        selectType: 1
      })
    }
    wx.$modal(
      this,
      {
        show: true,
        title: '请选择录单入口',
        tabTitleShow: false,
        success: res => {
          // 跳转新增订单页面 并带特定参数
          let { orderInfo, selectType } = this.data
          console.log(item, 'showSelectType')
          if (selectType == 1) {
            wx.$router.go('tabWorkOrder.createOrder', {
              scene,
              ...item
            })
          } else {
            wx.$router.go('tabWorkOrder.defeatOrder', {
              scene,
              ...item,
              isExpiredTraffic: selectType == 3
            })
          }
        },
        error: () => {}
      },
      '#modal2'
    )
  },
  onPageScroll: function (e) {
    const { scrollTop } = e.detail
    // const animation = this.createAnimation(); // 创建动画实例
    // 滚动时隐藏第一个图标,显示第二个图标
    this.setData({
      showIcon1: false,
      showIcon2: true
    })
    // 清除之前的定时器
    if (timeoutId) {
      clearTimeout(timeoutId)
    }

    // 设置一个定时器,在滚动停止后一定时间后恢复两个图标的显示状态
    timeoutId = setTimeout(() => {
      this.setData({
        showIcon1: true,
        showIcon2: false
      })
    }, 1000) // 在这里设置等待的时间,单位是毫秒
  },
  navbarReady(e) {
    // console.log(e)
    let navBarHeight = e.detail.height
    // console.log('123', navBarHeight)
    this.setData({
      navBarHeight
    })
  },
  tabClick(e) {
    let { searchObj } = this.data
    delete searchObj.statusList
    this.setData({
      tabIndex: e.detail,
      searchObj
    })
    this.search()
  },
  input(e) {
    let { value } = e.detail
    value = wx.$util.replaceEmoji(value)
    this.setData({
      keyword: value
    })
  },
  clear() {
    this.setData({
      keyword: ''
    })
    this.search()
  },
  back() {
    this.setData({
      show_confirm: false
    })
    wx.showTabBar()
  },
  showConfirm() {
    this.setData({
      showRendering: true,
      show_confirm: true
    })
    wx.hideTabBar()
  },

  /**
   * 处理关联工单列表跳转,并在进入已有工单编辑页前拦截低价单。
   *
   * @param {Object} e 小程序点击事件
   * @returns {Promise<void|false>} 低价或权限门禁拦截时返回 false
   */
  async jump(e) {
    // 订单状态 1 待跟进, 2 不升级, 3 待支付,4 已支付,6 已评价 ,9 已撤销 , 10 已关闭 , 11 已失效
    // constructionFlag 施工标识(Y:已施工;N||null:未施工)
    // failureFlag 订单失效状态(Y:已失效,N:未失效)
    // console.log(e.currentTarget.dataset)

    // return
    let { item, name } = e.currentTarget.dataset
    if (shouldBlockLowPriceOrderEdit(item, name)) {
      wx.$util.showToast(LOW_PRICE_ORDER_EDIT_MESSAGE)
      return false
    }
    // console.log(item, name)
    // wx.$router.go('constructionOrderDetail', item)
    let {
      userInfo,
      isMake,
      userInfo: { userType }
    } = this.data
    // console.log(status)
    // console.log(item.constructionFlag)
    // if (name == 'createOrder' || name == 'premiumUpgrade') {
    if (name == 'createOrder' || name == 'premiumUpgrade') {
      if (userInfo.merchantType && !wx.$hasPermission?.isSuper?.(userInfo) && isMake) {
        // 校验是否填写昨日日报
        let staffCheck = await checkDailyReport()
        if (staffCheck) return false
        // 校验学习中心开单限制
        let staffStudyTask = await checkStudyTask()
        if (staffStudyTask) return false
        // 校验异常订单
        let lockCheck = await checkOrderLockGate()
        if (lockCheck) return false
        // 是微信支付直接跳转确认页面
        if (userType == 2 && item?.selectPayType == 1) {
          wx.$router.go('tabWorkOrder.confirmOrder', item)
        } else if (userType == 2) {
          item
            ? this.showSelectType({ item })
            : wx.$router.go('tabWorkOrder.' + name, item)
        } else {
          wx.$util.showNoAccess()
        }
      } else {
        wx.$util.showNoAccess()
      }
      // 已支付加已施工
    } else if (item.constructionFlag == 'Y' && item.status != 10) {
      wx.$router.go('tabWorkOrder.constructionOrderDetail', item)
    } else {
      wx.$router.go('tabWorkOrder.' + name, item)
    }
  },
  async scan() {
    let that = this
    // 校验是否填写昨日日报
    let staffCheck = await checkDailyReport()
    if (staffCheck) return false
    // 校验学习中心开单限制
    let staffStudyTask = await checkStudyTask()
    if (staffStudyTask) return false
    // 校验异常订单
    let lockCheck = await checkOrderLockGate()
    if (lockCheck) return false
    wx.scanCode({
      success(res) {
        let { result } = res
        that.showSelectType({ scene: result }, true)
        // console.log(result)
        // wx.$router.go("tabWorkOrder.createOrder", {
        //   scene: result,
        // });
      },
      fail(err) {
        console.log(err)
      }
    })
  },
  // 查看全部商品
  showAllGoodsList(e) {
    let { item } = e.currentTarget.dataset
    let { list } = this.data
    list.forEach(val => {
      val?.forEach(subVal => {
        if (subVal.id == item.id)
          subVal.showAllGoodsListFlag = !subVal?.showAllGoodsListFlag
      })
    })
    this.setData({
      list
    })
  },
  async delBtn(e) {
    // 校验是否填写昨日日报
    let staffCheck = await checkDailyReport()
    if (staffCheck) return false
    // 校验学习中心开单限制
    let staffStudyTask = await checkStudyTask()
    if (staffStudyTask) return false
    // 校验异常订单
    let lockCheck = await checkOrderLockGate()
    if (lockCheck) return false
    let _this = this
    // let { list } = this.data
    // index, ind
    let {
      item: { orderCode }
    } = e.currentTarget.dataset

    wx.showModal({
      title: '',
      content: '是否取撤销该工单?',
      confirmText: '是',
      confirmColor: '#347BFF',
      cancelText: '否',
      success(res) {
        if (res.confirm) {
          _this.showLoading('取消中...')
          _this.repeal(orderCode)
        }
      }
    })
    // list[index][ind]['confirmIndex'] = true
    // this.setData({
    //   list
    // })
  },
  // 撤销该工单
  async repeal(orderCode) {
    // 校验是否填写昨日日报
    let staffCheck = await checkDailyReport()
    if (staffCheck) return false
    // 校验学习中心开单限制
    let staffStudyTask = await checkStudyTask()
    if (staffStudyTask) return false
    // 校验异常订单
    let lockCheck = await checkOrderLockGate()
    if (lockCheck) return false
    let _this = this
    api
      .revokeOrder({
        orderCode
      })
      .then(_res_ => {
        let { code, message } = _res_
        if (code == 0) {
          // wx.$util.showToast('操作成功')
          wx.showToast({
            title: '操作成功',
            icon: 'success'
          })
          setTimeout(() => {
            _this.search()
          }, 500)
        } else {
          wx.$util.showToast(message)
        }
      })
  },

  touchE: function (e) {
    // console.log(e)
    var that = this
    // console.log(e.changedTouches.length)
    // debugger
    let { item: li } = e.currentTarget.dataset
    // console.log(!li.repeal)
    if (!li.repeal) return
    if (e.changedTouches.length == 1) {
      //手指移动结束后触摸点位置的X坐标
      var endX = e.changedTouches[0].clientX
      //触摸开始与结束,手指移动的距离
      var disX = that.data.startX - endX
      // console.log(disX)
      var delBtnWidth = that.data.delBtnWidth
      //如果距离小于删除按钮的1/2,不显示删除按钮
      var txtStyle =
        disX > delBtnWidth / 2 ? 'left:-' + delBtnWidth + 'rpx' : 'left:0'

      //获取手指触摸的是哪一项
      var index = e.currentTarget.dataset.index
      var ind = e.currentTarget.dataset.ind
      var list = that.data.list
      list[index][ind].txtStyle = txtStyle
      // console.log(list)
      //更新列表的状态
      that.setData({
        list: list
      })
    }
  },
  //手指触摸动作开始 记录起点X坐标
  async touchstart(e) {
    // console.log(e)

    // 权限控制 员工不能删除 和没选具体门店的管理员也不能
    // canRemark 处理不是员工并且只有一个店的情况
    // let { userInfo, canRemark, dataDateStr, today } = this.data
    // // (userInfo.userType != 2 || userInfo.isSuper) && (userInfo.subLoginUser.merchantId != userInfo.merchantId || canRemark)
    // let canDelete = userInfo.subLoginUser.merchantId != userInfo.merchantId || canRemark

    //开始触摸时 重置所有删除
    this.data.list.forEach(item => {
      // console.log(item)
      item.forEach(function (v, i) {
        if (v.isTouchMove)
          //只操作为true的
          v.isTouchMove = false
        v.confirmIndex = false
      })
    })

    this.setData({
      startX: e.changedTouches[0].clientX,
      startY: e.changedTouches[0].clientY,
      list: this.data.list
    })
  },
  //滑动事件处理
  async touchmove(e) {
    if (!this.data.isMake) {
      return
    }
    // console.log(e)
    // if (condition) {
    // }
    // let { userInfo } = this.data
    let { item: li } = e.currentTarget.dataset
    // console.log(!li.repeal)
    if (!li.repeal) return
    // let userType = !userInfo.isSuper && userInfo.merchantType
    // let orderType = userInfo.userType == 1 && li.status != 9 && li.status != 1 && li.selectPayType != 3 && li.selectPayType != 1
    // // 权限检验
    // // console.log(!userType || !orderType)
    // if (!userType || !orderType) return

    var that = this,
      index = e.currentTarget.dataset.index, //当前索引
      ind = e.currentTarget.dataset.ind, //当前索引
      startX = that.data.startX, //开始X坐标
      startY = that.data.startY, //开始Y坐标
      touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标
      touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标
      //获取滑动角度
      angle = that.angle(
        {
          X: startX,
          Y: startY
        },
        {
          X: touchMoveX,
          Y: touchMoveY
        }
      )
    // console.log(that.data.list[index])
    that.data.list[index].forEach(function (v, i) {
      v.isTouchMove = false
      //滑动超过30度角 return
      if (Math.abs(angle) > 30) return
      if (i == ind) {
        if (touchMoveX > startX)
          //右滑
          v.isTouchMove = false
        //左滑
        else v.isTouchMove = true
      }
    })
    //更新数据
    that.setData({
      list: that.data.list
    })
  },
  /**
   * 计算滑动角度
   * @param {Object} start 起点坐标
   * @param {Object} end 终点坐标
   */
  angle: function (start, end) {
    var _X = end.X - start.X,
      _Y = end.Y - start.Y
    //返回角度 /Math.atan()返回数字的反正切值
    return (360 * Math.atan(_Y / _X)) / (2 * Math.PI)
  },

  init(userInfo) {},
  search() {
    wx.$orderListRefresh = false
    let { searchObj, userInfo } = this.data
    let merchantId
    // 判断是不是超管 && !userInfo.isSuper
    // ,不是只能筛选当前4s店的
    if (!searchObj.merchantId) {
      merchantId = userInfo?.shopMerchantId
      this.setData({
        ['searchObj.merchantId']: merchantId
      })
    }
    console.log(userInfo)
    console.log('search', merchantId)
    this.setData({
      list: [],
      pageNum: 1,
      flag: false,
      nothing: false
    })
    this.getWorkList()
    this.getStatByStatus()
  },
  getWorkList() {
    //
    // console.log('getWorkList', this.showLoading)
    // this.showLoading('加载中...')
    // 解决loading只能有一个的兼容问题
    this.showLoading && this.showLoading('加载中...')
    let { searchObj, pageNum, keyword, tabIndex, userInfo, status } = this.data
    let obj = {
      keyword,
      pageNum,
      ...searchObj
    }

    // 待跟进状态需要特殊处理避免带出已关闭
    if ([2, 3].includes(tabIndex)) {
      let target = {
        1: 'R',
        2: 'Y',
        3: 'N'
      }
      obj.upgradeFinishFlag = target[tabIndex]
    } else if (tabIndex == 1) {
      obj.statusList = [1]
    }

    // console.log(obj.sourceList && obj.statusList[0] == 'Y')
    if (
      (obj.statusList && obj.statusList[0] == 'Y') ||
      (obj.statusList && obj.statusList[0] == 'N')
    ) {
      obj.constructionFlag = obj.statusList[0]
      delete obj.statusList
    }
    api.getWorkPackageGoodsList(obj).then(res => {
      wx.$util.hideLoading()
      // console.log('工单', obj, res)
      let { code, data, errId, message } = res
      let total = 0
      let list = []
      if (code == 0) {
        // 这个是用来判断哪些用户可以撤销的
        let userType =
          (!wx.$hasPermission?.isSuper?.(userInfo) && userInfo.merchantType) ||
          (wx.$hasPermission?.isNotMentor?.(userInfo) && !wx.$hasPermission?.canViewRecruit?.(userInfo))
        // let userType = true

        data.list.map(e => {
          e.customerDailyDisplay = buildBoutiqueCustomerDailyListDisplay(e)
          if (e.orderTime)
            e.orderTime = new Date(e.orderTime).format('yyyy-MM-dd hh:mm:ss')
          e.subOrderList.map(i => {
            i.totalPrice = Number(wx.$util.decimal(i.totalPrice, 2)).toFixed(2)
          })
          e.total_price = e.totalPrice
          e.totalPrice = Number(wx.$util.decimal(e.totalPrice, 2)).toFixed(2)
          // && e.status != 1 待跟进现在也能撤销
          let orderType =
            (userInfo.userType == 1 || userInfo.userType == 2) &&
            e.status != 9 &&
            ![1, 3, 4].includes(e.selectPayType)
          // let orderType = userInfo.userType !== 1 && e.status != 9 && e.status != 1 && e.selectPayType != 3 && e.selectPayType != 1
          // console.log(userType);
          // console.log(orderType);
          e.repeal = userType && orderType
          // 处理subOrderList 商品为空的情况
          e.subOrderList = e.subOrderList.filter(item => item.merchantGoodsId)

          e.packageGoodsList?.forEach(item => {
            item.packageGoodsOrderList.forEach(g => {
              g.price = g.totalPrice
                ? Number(g.totalPrice) / Number(g.number)
                : g.upgradePrice
            })
            item.goodsList = item.packageGoodsOrderList
            item.price = item.goodsList.reduce((prev, cur) => {
              return prev + Number(cur.totalPrice) / Number(cur.number)
            }, 0)
            item.count = item.goodsList.length ? item.goodsList[0].number : 1
            let total = item.price * item.count
            item.totalPrice = wx.$util.decimal(total, 2)
          })
          if (e.packageGoodsList && e.packageGoodsList.length) {
            e.subOrderList = e.subOrderList.concat(e.packageGoodsList)
          }

          // e.subOrderList = e.subOrderList.filter(item => item.id)

          // 处理显示订单右上角文字
          // console.log(status[e.status])
          // console.log(' status[e.status]', status[e.status])
          let text = status[e.status].text
          let color = status[e.status].color
          let background = status[e.status].background
          // 不是订单失效状态优先显示已施工
          if (![9, 11, 12].includes(e.status) && e.constructionFlag == 'Y') {
            text = '已施工'
            color = '#347BFF'
            background = '#F3F7FC'
          }
          e.statusText = text
          e.statuscolor = color
          e.statusbackground = background
          // 商品是否包含太阳膜
          e.isFilmOrder =
            e.subOrderList?.findIndex(subE => subE?.upgradeGoodsType == 1) > -1
        })
        list = data.list
        total = data.total
      } else {
        if (errId != '-5003') wx.$util.showToast(message)
      }
      if (total != 0) {
        this.setData({
          [`list[${pageNum - 1}]`]: list
        })
      }
      this.setData({
        total,
        flag: true,
        triggered: false
      })
    })
  },
  getStatByStatus() {
    let { searchObj, keyword, tabList, tabListTemplate } = this.data
    if (
      (searchObj.statusList && searchObj.statusList[0] == 'Y') ||
      (searchObj.statusList && searchObj.statusList[0] == 'N')
    ) {
      searchObj.constructionFlag = searchObj.statusList[0]
      delete searchObj.statusList
    }
    api
      .statByStatus({
        ...searchObj,
        keyword
      })
      .then(result => {
        // console.log(result)
        let { data, code } = result
        if (code == 0) {
          const labelList = [
            'totalCount',
            'waitUpgradeCount',
            'upgradedCount',
            'notUpgradeCount'
          ]
          // tabList: ['全部', '待跟进', '已升级', '战败']
          labelList.map((item, index) => {
            tabList[index] = {
              text: tabListTemplate[index],
              count: data[item] ? data[item] : 0
            }
          })
          this.setData({
            tabList
          })
        }
      })
      .catch(err => {
        console.log(err)
      })
  },
  // test() {
  //   console.log('test')
  //   // debugger

  //   let orderCode = deleteList.splice(0, 1).join('')
  //   orderCode &&
  //     api
  //       .revokeOrder({
  //         orderCode
  //       })
  //       .then(_res_ => {
  //         let { code } = _res_
  //         console.log(_res_)
  //         if (code == 0) {
  //           // wx.$util.showToast('操作成功')
  //           wx.showToast({
  //             title: '操作成功',
  //             icon: 'success'
  //           })
  //           this.test()
  //         } else {
  //           wx.setStorageSync('errorCode', orderCode)
  //           wx.setStorageSync('waitCode', list)
  //         }
  //       })
  //       .catch(error => {
  //         console.log(error)
  //         wx.setStorageSync('errorCode', orderCode)
  //         wx.setStorageSync('waitCode', list)
  //       })
  // },
  onRoute(options) {
    // console.log('activeIndex' in options);
    if ('activeIndex' in options) {
      // let { searchObj } = this.data
      // delete searchObj.inviteStatus
      this.setData({
        activeIndex: options.activeIndex
        // searchObj.inviteStatusList
      })
    }
    let { searchObj } = this.data
    let userInfo = wx.$util.getUserInfo()
    searchObj.merchantId = ''
    this.setData({
      userInfo: {
        ...userInfo,
        merchantType:
          userInfo?.merchantAccountList.includes('6') ||
          userInfo?.merchantAccountList.includes('8')
      },
      searchObj
    })
    if (wx.$orderListRefresh) {
      // 清空筛选条件 搜索条件
      this.setData(
        {
          searchObj: {},
          keyword: ''
        },
        () => {
          this.search()
          this.getCreateOrderSetting()
        }
      )
    }
    //  if (wx.$refresh ) {
    //   this.search()
    //   // this.getStatByPeriod()
    //   // this.getiIviteRecord()
    //  }
    // console.log(options,'options');
  },
  // 获取轻改录单配置是否启用流量失效
  getCreateOrderSetting() {
    let userInfo = wx.$util.getUserInfo()
    let merchantType =
      userInfo?.merchantAccountList.includes('6') ||
      userInfo?.merchantAccountList.includes('8')
    if (
      merchantType &&
      !wx.$hasPermission?.canViewViolation?.(userInfo) &&
      userInfo?.userType == 2 &&
      userInfo?.shopMerchantId
    ) {
      api
        .getServiceBaseInfo({ merchantId: userInfo?.shopMerchantId })
        .then(res => {
          this.setData({
            isSettingExpiredTraffic: res?.data?.trafficExpireFlag == 'Y'
          })
        })
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // this.test()
    let userInfo = wx.$util.getUserInfo()
    this.setData({
      isMake: !(
        wx.$hasPermission?.canSelectMultiStore?.(userInfo)
      )
    })
    this.getCreateOrderSetting()
    // this.tabClick()
    console.log(11111)
    this.search()
  },

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

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

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

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

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

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},
  scrollonReachBottom() {
    let { total, pageNum } = this.data
    wx.$util.onReachBottom(
      {
        total,
        pageNum
      },
      res => {
        this.getWorkList()
        this.getStatByStatus()
      }
    )
  },
  /**
   * 监听 TabBar 切换点击
   */
  // onTabItemTap(item) {
  //   console.log(item, 'item')
  // },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {}
})