<template>
  <view class="myInsurance">
    <view class="myInsuranceCart" v-for="(item, index) in list" :key="index" @click="gopage(item)">
      <view class="">
        <view class="xiangxia"> 承保公司：{{ item.company }} </view>
        <view class="xiangxia"> 保单名称：{{ item.policyName }} </view>
        <view class="xiangxia"> 保单编号：{{ item.policyNumber }} </view>
        <view class="xiangxia">
          保单类型：{{ { AC: '意外险', EM: '雇主险', IN: '工伤险', DS: '第三者责任险' }[item.type] }}
        </view>
        <view class="xiangxia"> 保单金额：{{ item.policyPrice }} </view>
        <view class="xiangxia"> 有效时间：{{ item.startTime.split(' ')[0] }}~{{ item.endTime.split(' ')[0] }} </view>
      </view>
    </view>
    <Loading :loadStatus="loadStatus" :dataList="list" />
  </view>
</template>
<script>
export default {
  data() {
    return {
      loadStatus: 0,
      list: [],
      websitId: ''
    }
  },
  onLoad({ websitId, xzType }) {
    this.websitId = websitId
    uni.showLoading({
      title: '加载中'
    })
    this.loadStatus = 1
    this.$api
      .post(xzType == 'DS' ? '/worker/dsPolicy' : '/worker/policy', { pageNum: 1, pageSize: -1, websitId })
      .then(res => {
        this.list = res?.data?.records
        this.loadStatus = 2
        this.$nextTick(() => {
          uni.hideLoading()
          // setTimeout(() => {
          //   if (this.list.length == 0) {
          //     uni.showModal({
          //       title: '提示',
          //       // 提示文字
          //       content: '保险方案没绑定网点，请联系工作人员！',
          //       // 取消按钮的文字自定义
          //       cancelText: '取消',
          //       // 确认按钮的文字自定义
          //       confirmText: '知道了',
          //       success: function (res) {
          //         if (res.confirm) {
          //           // 执行确认后的操作
          //         } else {
          //           // 执行取消后的操作
          //         }
          //       }
          //     })
          //   }
          // }, 250)
        })
      })
  },
  methods: {
    gopage(item) {
      this.$navToPage({
        url: `/packageEnter/pages/insurance/insuranceContract/index?id=${item.id}&websitId=${this.websitId}`
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.myInsurance {
  box-sizing: border-box;
  padding: 20rpx;
  padding-top: 40rpx;

  .myInsuranceCart {
    width: 100%;
    height: auto;
    box-sizing: border-box;
    padding: 20rpx;
    margin-bottom: 20rpx;
    box-shadow: 2.8px 2.8px 2.2px rgba(0, 0, 0, 0.02), 6.7px 6.7px 5.3px rgba(0, 0, 0, 0.028),
      12.5px 12.5px 10px rgba(0, 0, 0, 0.035), 22.3px 22.3px 17.9px rgba(0, 0, 0, 0.042),
      41.8px 41.8px 33.4px rgba(0, 0, 0, 0.05), 100px 100px 80px rgba(0, 0, 0, 0.07);
    border-radius: 10rpx;

    .myInsuranceCartbuju {
      display: flex;
      justify-content: space-between;
    }

    .xiangxia {
      margin-bottom: 10rpx;
    }
  }
}
</style>
