<template>
  <div class="docContainer">
    <div style="position:relative;">
      <img @click="goPage('notice')" width="30" src="../assets/images/msg.png" class="msg">
      <span v-if="new_notice" class="red"></span>
      <img src="../assets/images/infobg.png" alt="" width="100%" style="">
      <div class="docinfo">
        <img class="docavatar" src="../assets/images/doch1.jpg" width="60rem" height="60rem" />
        <p class="docname">{{doctorInfo.name}} 医生,您好!</p>
      </div>
    </div>
    <div class="content">
      <div class="footer">
        <!-- <div class="csbtn" @click="goPage('/regpatinfo')">新病例信息录入</div> -->
        <div class="csbtn" @click="regNew">新病例信息录入</div>
        <div class="jbbtn" @click="goPage('patcaselist')">历史病例管理</div>
        <div class="jbbtn" @click="logout">退出登录</div>
        <div class="usageInfo" @click="goPage('agreedoc?type=1')">使用说明</div>
      </div>
    </div>
  </div>
</template>

<script>
  import {
    Field,
    MessageBox,
    Toast,
    Popup
  } from 'mint-ui'

  export default {
    name: 'Index',
    components: {
      Field,
      MessageBox,
      Toast,
      Popup
    },
    data() {
      return {
        doctorInfo: {},
        new_notice:0
      }
    },
    methods: {
      goPage(path) {
        this.$router.push(path)
      },
      logout() {
        window.localStorage.removeItem('token')
        window.localStorage.removeItem('authinfo')
        window.location.reload()
      },
      getData() {
        this.$api.getAccountInfo().then(res => {
          if (!res.data.code) {
            this.doctorInfo = res.data.data
            localStorage.setItem("authinfo",JSON.stringify(this.doctorInfo));
          }
        })
      },
      getNotice(){
          this.$api.get_patient_doctor_notice_new().then(res=>{
            if (!res.data.code) {
              if(res.data.data.total>0){
                this.new_notice=1
              }
            }
          })
      },
      regNew() {
        this.$api.getPatientDoingCase({
          doctor_id: this.doctorInfo.id
        }).then(res => {
          if(res.data.code == 0){
            this.$router.push("regpatinfo")
          }
          
          // if (res.data.code == 0 && res.data.data.id) {
          //   MessageBox ({
          //     title: '提示',
          //     message: '您有一个病例未完成',
          //     showCancelButton: true,
          //     confirmButtonText: "继续录入",
          //     cancelButtonText: "重新录入",
          //     cancelButtonClass: "docIndexCancelBtn",
          //     confirmButtonClass: "confirmButtonClass"
          //   }, action => {
          //     console.log(action)
          //     if (action == "confirm") {
          //       this.$router.push({
          //         path: "/diagcalc",
          //         query: {
          //           id: res.data.data.id,
          //           patid: res.data.data.patient_id
          //         }
          //       })
          //     } else {
          //       this.$router.push("regpatinfo")
          //     }
          //   });
          // } else {
          //   this.$router.push("regpatinfo")
          // }
        })
      }
    },
    created() {
      this.getData()
      this.getNotice()
    }
  }

</script>

<style lang="scss">
  .docContainer {
    .bgcolor {
      width: 100%;
      height: 10rem;
      // border:1px solid red;
      position: absolute;
      /* z-index:-1; */
      background: #016AFA;
    }
    .msg{
      position: absolute;
      right: 10px;
      top: 10px;
      z-index: 9;
    }
    .red{
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: red;
        position: absolute;
        top: 13px;
        right: 15px;
        z-index: 10;
      }
    .bgimg {
      width: 100%;
      height: 24.8rem;
      // border:1px solid red;
      /* top: 10rem; */
      position: absolute;
      /* z-index:-1; */
      background-image: url("../assets/images/infobg.png");
      background-size: 100% 100%;
    }

    .docinfo {
      position: absolute;
      top: 30%;
      left: 0;
      right: 0;

      .docavatar {
        border-radius: 60rem;
      }

      .docname {
        color: #fff;
        margin: 0.1rem;
      }

      z-index:3;
    }

    .footer {
      margin-bottom: 2rem;

      .usageInfo {
        width: 6rem;
        height: 2.4rem;
        line-height: 2.4rem;
        border-radius: 1rem;
        background: #595758;
        color: #fff;
        margin: 2rem 1rem;
      }

    }

  }

  .docIndexCancelBtn {
    font-size: 24px;
    /* color: red !important; */
  }


</style>
