<template>
  <cc-root-view>
    <view class="index_content">
      <MyHeaderTitle />
      <hs-empty v-if="useModel?.loadingPage?.value && !useModel?.pageRole?.value?.length" text="暂无权限"
        iconName="no_jurisdictio" />
      <cc-scroll-loading v-else :meta="useModel?.metaData?.value" @load="method?.loadMore">
        <template v-for="i in useModel?.pageRole?.value || []" :key="i?.key">
          <MyShowData v-if="i?.key === 'date'" />
          <MyClassIfication v-if="i?.key === 'jingangarea'" :item="i?.children" />
          <MyToDeDone v-if="i?.key === 'to_do_details'" />
        </template>
      </cc-scroll-loading>
    </view>
  </cc-root-view>
</template>
<script setup lang="ts">
import getUser from '@/common/libraries/userUserLogin'
import { onShareAppMessage, onShareTimeline, onShow } from '@dcloudio/uni-app'
import { getCurrentInstance } from 'vue'
import MyClassIfication from './components/Classification.vue'
import MyHeaderTitle from './components/HeaderTitle.vue'
import MyShowData from './components/ShowData.vue'
import MyToDeDone from './components/ToDeDone.vue'
import method from './method'
import useModel from './model'


// const headleSendSms = async () => {
//   console.log("发送短信")
//   const res = await wx.cloud.callFunction({
//     name: 'sendSms',  // 你的云函数名
//     data: {
//       phone: "+8615014056191",
//       code: "123"
//     }
//   })
//   console.log(res)
// }


onShow(async () => {
  await getCurrentInstance()?.appContext.config.globalProperties.$onLaunched
  method?.getPageRole()
  if (getUser?.getLoginStatus()) {
    useModel.formData.value.page = 1
    useModel.listData.value = []
    method?.getCountGridHouse()
    method?.getCompanyEmployeeBacklogs()
    method?.getIndexCount()
  } else {
    useModel.userData.value = undefined
    useModel.listData.value = []
    useModel.metaData.value = { total: 0 }
  }
})

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

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