crowdFundingPage.js 3.71 KB
// pages/equity/index.js
import { get4SStoreList } from '~/store/index'
import { waitinputorder } from '../../api'
const app = getApp()
let time = null
Page({
  /**
   * 页面的初始数据
   */
  data: {
    tabBarList: [
      {
        name: '首页',
        iconPath: '/images/tab-home.png',
        selectedIconPath: '/images/tab-home-active.png'
      },
      {
        name: '活动管理',
        iconPath: '/images/tab-date.png',
        selectedIconPath: '/images/tab-date-active.png'
      },
      {
        name: '个人中心',
        iconPath: '/images/tab-mine.png',
        selectedIconPath: '/images/tab-mine-active.png'
      }
    ],
    tabIndex: 0,
    pageShow: [true, false, false],
    navBarHeight: 0,
    showPicker: false,
    userInfo: {},
    selectStroeIndex: 0,
    shopSideSelectPopup: false,
    mode: 1,
    tipsProps: false,
    waitInputCount: 0,
    isStaff: false,
    storeRange: []
    // hasMode:true
  },
  init(userInfo) {
    this.setData({ userInfo })
    this.get4SStoreList()
    // this.test()
  },
  get4SStoreList() {
    let userInfo = wx.$util.getUserInfo()
    let params = {
      merchantId: userInfo?.isSuper ? '' : userInfo?.merchantId,
      staffUUID: userInfo?.isSuper ? '' : userInfo?.uuid,
      scene: 3
    }
    get4SStoreList(params).then(result => {
      if (!result?.length) {
        userInfo.shopMerchantId = null
        userInfo.default4SStoreInfo_crowdFunding = {}
        userInfo.shopMerchantName = null
        userInfo.sceneType = null
        wx.$util.setUserInfo(userInfo)
        return wx.$router.reLaunch('pages.accountItems')
      }
      if (result?.length && userInfo?.isSuper) {
        let obj = {
          ...userInfo,
          default4SStoreInfo_crowdFunding: {
            merchantId: result[0]?.merchantId,
            merchantName: result[0]?.merchantName
          }
        }
        if (!userInfo?.default4SStoreInfo_crowdFunding || !Object.keys(userInfo?.default4SStoreInfo_crowdFunding).length) {
          wx.$util.setUserInfo(obj)
          this.setData({
            userInfo: obj
          })
        }
      }
      this.setData({
        storeRange: result || [],
        showPage: true
      })
    })
  },

  changeTabBar(e) {
    let tabIndex = e.detail
    wx.$eventbus.emit('page_show')
    this.setData({
      [`pageShow[${tabIndex}]`]: true,
      tabIndex
    })
    this.initList()
  },

  initList() {
    let { tabIndex } = this.data
    this.selectComponent(`#page-${tabIndex}`)?.onLoad && this.selectComponent(`#page-${tabIndex}`).onLoad()
  },

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

  navbarReady(e) {
    let navBarHeight = e.detail.height
    this.setData({
      navBarHeight
    })
  },
  onRoute(options) {
    // console.log(options,'options');
    if (options&&options.tabIndex) {
      this.changeTabBar({detail:options.tabIndex})
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {},

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

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

    // let { tabIndex } = this.data
    // this.selectComponent(`#page-${tabIndex}`)?.onLoad && this.selectComponent(`#page-${tabIndex}`).onLoad()
  },

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

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

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

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

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