index.js 2.77 KB
import { discoveryApi  } from "~/api/index"
Page({
  data: {
    showCarFlag: false,
    currentChannel: {
      id: 6
    }
  },
  onShow() {
    // let {
    //   merchantId
    // } = this.data
    // const merchantInfo = wx.p.storage.get('merchant_info')
    // let newMerchantId = merchantInfo.merchantId

    // if (newMerchantId != merchantId && newMerchantId ) {
    //   this.setData({
    //     merchantId: newMerchantId
    //   })
    //   this.getDiscoverInfo(newMerchantId, 6)
    // }
    // this.getDiscoverInfo(merchantInfo.merchantId, 6)
    this.getComponentPage().onShow && this.getComponentPage().onShow()
    const FIRST = wx.p.storage.get('first_enter_miniprograme')
    this.setData({
      showStore:!FIRST
    })
  },

  // getDiscoverInfo(merchantId, channel) {
  //   discoveryApi.getDiscoverConfig({
  //     merchantId
  //   }).then(res => {
  //     if (res && res.length) {
  //       // console.log(JSON.stringify(res), channel);
  //       this.handlerDiscoverSetting(JSON.stringify(res), channel)
  //     }
  //   })
  // },
  // 处理发现配置数据
  // handlerDiscoverSetting(query, channel) {
  //   const list = JSON.parse(query)
  //   let {
  //     currentChannel,
  //     curTabIndex
  //   } = this.data
  //   if (list && list.length) {
  //     if (channel) {
  //       list.forEach((el, index) => {
  //         if (el.channelType == channel) {
  //           curTabIndex = index
  //           currentChannel = el
  //         }
  //       })
  //     } else {
  //       currentChannel = list[0]
  //     }
  //     // this.computeBannerHeight(list.length)
  //   }
  //   this.setData({
  //     currentChannel,
  //   })
  // },
  // 计算高度
  // computeBannerHeight(len) {
  //   let query = wx.createSelectorQuery().in(this)
  //   query
  //     .select('.banner_wrapper')
  //     .boundingClientRect(res => {
  //       this.setData({
  //         'heightInfo.bannerH': res.height
  //       })
  //     })
  //     .exec()
  //   query
  //     .select('.tab_wrapper')
  //     .boundingClientRect(react => {
  //       if (len == 1) {
  //         this.setData({
  //           'heightInfo.tabH': 20
  //         })
  //       } else {
  //         this.setData({
  //           'heightInfo.tabH': react.height
  //         })
  //       }
  //     })
  //     .exec()
  // },
  //隐藏购物车
  // showShoppingCarFn(e) {
  //   this.setData({
  //     showCarFlag: e.detail != 2
  //   })
  // },
  navbarReady(e) {
    let { height } = e.detail;
    this.setData({
      navBarHeight: height,
      user_box_style: `padding-top:${height}px`,
    });
  },
  getComponentPage() {
    return this.selectComponent(`#currentChannel_6`)
  },
  freshMerchant(){
    this.onShow()
  },
  onShareAppMessage(){},
  onLoad(){
    this.shareTitle = "甄选专区"
  }
})