<template>
  <van-nav-bar
      title="消息通知"
      left-arrow
      @click-left="onClickLeft"
  />
  <div class="msg-area">
    <div class="single-msg" v-for="(item, index) in msgList" :key="index">
      <div class="msg-lef">{{ item.ifCareerAppointText }}</div>
      <div class="msg-rig">
        <div class="rig-tit">
          {{ item.mealName }}
          <span class="inner-badge">{{ item.ifCancelText }}</span>
        </div>
        <div class="rig-content">
          <span v-if="item.ifCancelText == '待体检'">
            您好，您于{{ item.phyAppontTime }}预约的位于{{ item.hospitalName }}的体检即将进行，请您按时到达！
          </span>
          <span v-if="item.ifCancelText == '已取消'">
            您好，您于{{ item.cancelTime }}取消了位于{{ item.hospitalName }}的体检，特此通知。
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">

  import { fetchMsg } from '../../api/MsgNotice'
  import { ref, onMounted } from 'vue'

  const msgList = ref<any[]>([])
  
  const onClickLeft = () => {
    history.back()
  }

  // 获取体检信息
  const getMsg = () => {
    fetchMsg({
      token: localStorage.getItem('token')
    }).then((res: any) => {
      msgList.value = res.data.obj
    }).catch((err: any) => {
      console.log(err)
    })
  }

  onMounted(() => {
    getMsg()
  })

</script>

<style scoped lang="scss">
  .msg-area{
    width: 95%;
    margin: 0.15rem auto;
    box-sizing: border-box;
    padding: 0.15rem 0;
    .single-msg{
      width: 100%;
      height: 3rem;
      margin-bottom: 0.2rem;
      border: 1px solid #d7d7d7;
      display: flex;
      .msg-lef{
        width: 10%;
        height: 100%;
        background-color: #8fc7c7;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        padding-left: 0.2rem;
        font-size: 18px;
      }
      .msg-rig{
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        .rig-tit, .rig-content{
          width: 100%;
          height: 24%;
          display: flex;
          align-items: center;
          font-size: 18px;
          box-sizing: border-box;
          padding: 0 0.15rem;
          .inner-badge{
            box-sizing: border-box;
            padding: 0.1rem;
            background-color: #ff7026;
            font-size: 14px;
            color: #fff;
            margin-left: 0.2rem;
            border-radius: 0.2rem;
            font-weight: normal;
          }
        }
        .rig-tit{
          color: #ff1c1e;
          font-weight: bold;
          padding-top: 0.2rem;
        }
        .rig-content{
          height: 60%;
          font-size: 16px;
          line-height: 22px;
        }
      }
    }
  }
</style>