SideSelectPopup.js 1.79 KB
// components/SideSelectPopup/SideSelectPopup.js
import constantData from '../../pages/constant/data'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean,
      value: false,
      observer: function (n) {
        if (n) {
          wx.$util.pointRecord(31)
          let userInfo = wx.$util.getUserInfo() || {}
          let storageSelectedSceneType = userInfo.selectedSceneType
          this.setData({storageSelectedSceneType})
          let { sceneList } = this.data
          let openSceneArr = userInfo?.openSceneArr || []
          // 获取开通业务场景
          let arr = sceneList.filter(v => openSceneArr.includes(v.sceneType))
          this.setData({
            sceneList: arr
          })
        }
      }
    },
    hasTabBar: {
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    sceneList: constantData.sceneList,
    storageSelectedSceneType: ''
  },

  /**
   * 组件的方法列表
   */
  methods: {
    closeMenu(){
      this.setData({
        show:false
      })
    },
    showTabBar() {
      if (this.data.hasTabBar) wx.showTabBar({animation: true})
    },
    hideTabBar() {
      if (this.data.hasTabBar) wx.hideTabBar({animation: true})
    },
    selectScene(e) {
      let { scene,item } = e.currentTarget.dataset
      let { sceneList, storageSelectedSceneType } = this.data
      if (scene == storageSelectedSceneType) return this.closeMenu()
      wx.$router.reLaunch(constantData?.pageUrl[scene])
      sceneList.map(i => (i.actived = false))
      wx.$util.setUserInfo({ ...wx.$util.getUserInfo(), selectedSceneType: scene })
      wx.$util.pointRecord(item.recordId)
    },
    goMineCenter() {
      wx.$util.pointRecord(5)
      wx.$router.redirectTo('pages.sceneIndex')
    }
  }
})