<template>
  <view class="home_page">
    <hs-all-page-bg />
    <view class="home_page_content">
      <MyPageHeadTitle />
      <MyPageBanner />
      <MyClassification />
      <MyNewsList />
      <MyAiInput />
      <MyTabs />
      <MyModalServer />
      <MyOfficialAccount />
    </view>
  </view>
</template>

<script setup lang="ts">
import { onLoad, onPageScroll, onShareAppMessage, onShareTimeline, onShow } from '@dcloudio/uni-app'
import { ref, reactive, getCurrentInstance } from 'vue'
import MyNewsList from './components/NewsList.vue'
import MyPageHeadTitle from './components/PageHeadTitle.vue'
import MyPageBanner from './components/PageBanner.vue'
import MyClassification from './components/Classification.vue'
import MyAiInput from './components/AiInput.vue'
import { useWeAppAuthStore } from '@/common'
import MyModalServer from './components/ModalServer.vue'
import useModel from './model'
import MyTabs from './components/Tabs.vue'
import MyOfficialAccount from './components/OfficialAccount.vue'
import getLoginStatus from '@/common/libraries/userUserLogin'
import method from './method'
const auth = useWeAppAuthStore()
// 生命周期
onLoad(async e => {
  await getCurrentInstance()?.appContext.config.globalProperties.$onLaunched
  console.log('页面加载', auth?.data)
})

onPageScroll(e => {
  useModel.scrollTop.value = e.scrollTop
})

onShow(async e => {
  await getCurrentInstance()?.appContext.config.globalProperties.$onLaunched
  useModel.user.value = auth?.data?.user
  useModel.pageConfig.value = auth?.data?.config?.companyConfig?.config_value || {}
  console.log('页面显示')
  if (getLoginStatus?.getLoginStatus()) {
    method?.getCountBills()
  }
  if (auth?.data.house_register) {
    console.log('house_register', auth?.data.house_register)
    auth?.getIsHouseExist()
  } else {
    useModel.countBills.value = 0
  }
  // 可以在这里刷新数据
})

onShareAppMessage(() => {
  return {
    title: '',
    path: '/pages/index/index'
  }
})
onShareTimeline(() => {
  return {
    title: '',
    path: '/pages/index/index'
  }
})
</script>

<style lang="scss">
@import './style.scss';
</style>
