<template>
  <view>
 <view class="house_title">
      <!-- {{ useModel?.houseInfo?.value?.remark || '-' }} -->
      <hs-enum-tag
          :value="useModel?.orderShow?.value?.type"
          :Enums="BillPaymentsTypeEnum"
        />
    </view>
      
    <view class="pay_price">
      <text>¥</text>{{ useModel?.orderShow.value?.amount || '0.00' }}
    </view>
    <view class="pay_title_sub">支付金额</view>
    <view class="pay_type">
      <view class="pay_label">
        <image src="/static/svg/wx_pay.svg" mode="heightFix" />
        <text>微信支付</text>
      </view>
      <uni-icons type="checkbox-filled" size="23" color="#48B338"></uni-icons>
    </view>
    <view class="footer_btn">
      <hs-button
        type="primary"
        size="md"
        :disabled="useModel?.payDisabled?.value"
        :loading="useModel?.payDisabled?.value"
        :loading_label="useModel?.loadingLabel?.value"
        label="立即支付"
        @click="method.onPay"
      />
    </view>
  </view>
</template>
<script lang="ts" setup>
import { onHide, onLoad, onShow, onUnload } from '@dcloudio/uni-app'
import { getCurrentInstance } from 'vue'
import method from './method'
import useModel from './model'
import { BillPaymentsTypeEnum } from '@/gen/Enums'

onLoad(async e => {
  console.log('onLoad', e)
  await getCurrentInstance()?.appContext.config.globalProperties.$onLaunched
  useModel.loadingLabel.value = ''
  useModel.loadingShowNumber.value = 0
  useModel.hideStatus.value = false
  useModel.payDisabled.value = false
  useModel.OrderInfo.value = e
  method?.getShow()
})

onShow(() => {
  if (useModel?.hideStatus?.value) {
    //记录是否跳去第三方支付小程序-取消
    useModel.hideStatus.value = false
    //检查支付状态
    method?.getShow(null)
    method?.loadShow()
  }
  console.log('onShow')
})

onHide(() => {
  if (useModel?.payDisabled?.value) {
    //记录是否跳去第三方支付小程序
    useModel.hideStatus.value = true
  }
})

onUnload(() => {
  useModel.loadingLabel.value = ''
  useModel.loadingShowNumber.value = 0
  useModel.hideStatus.value = false
  useModel.payDisabled.value = false
  clearInterval(useModel.timer.value)
})
</script>
<style lang="scss">
@import './style.scss';
</style>
