<!--
  Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.

  https://www.mall4j.com/

  未经允许，不可做商业用途！

  版权所有，侵权必究！
-->

<template>
  <view class="Mall4j">
    <feature
      ref="featureIndexRef"
      :page-load="pageLoad"
      :page-id="renovationId"
      :shop-id="shopId"
      :page-scorll-top="pageScorllTop"
      @page-loaded="pageLoaded"
    />
    <shop-tabbar
      v-if="homeStatus == 1 && shopId!=='0'"
      style="position:fixed;bottom:0;width:100%;left:0;right:0;"
      :renovation-id="renovationId"
      :shop-id="shopId"
    />
  </view>
</template>

<script setup>
const pageLoad = ref(false)
const renovationId = ref('') // 页面id
const shopId = ref('')
const pageScorllTop = ref(0) // 页面滚动距离
const homeStatus = ref(0) // 是否为主页
onLoad((options) => {
  if (options.renovationId) {
    renovationId.value = options.renovationId
  }
  if (options.shopId) {
    shopId.value = options.shopId
  }
})
onPageScroll(function (e) {
  pageScorllTop.value = e.scrollTop
})
/**
 * 页面上拉触底事件的处理函数
 */
const featureIndexRef = ref(null)
onReachBottom(() => {
  featureIndexRef.value?.getNextPage()
})

// 页面加载回调
const pageLoaded = (e) => {
  uni.setNavigationBarTitle({
    title: e.detail.title
  })
  pageLoad.value = false
  homeStatus.value = e.detail.homeStatus
}

</script>
