<template>
  <div class="pageContent planDescription">
    <NavBar title="任务详情" @on-click-left="$router.back()"></NavBar>
    <div class="bannar radius">
      <div class="image">
        <img src="@/assets/development/images/banner2.png" alt="" />
      </div>
    </div>
    <div class="content" v-if="detail">
      <div v-if="detail.status === 1 || detail.status === 2">
        <div class="gap"></div>
        <div class="max-title">离完成任务解锁奖励</div>
        <div class="max-title">又近了一步！</div>
        <div class="gap"></div>
        <div class="text center">
          你今天整体状态优秀，身体压力状态较小，能很好应对今 日工作生活中的挑战，请继续保持优秀状态。相信自己，
          你一定可以实现你的目标！
        </div>
        <div class="gap"></div>
        <div class="progress">
          <div class="bg" width="100%"></div>
          <div class="text" :style="`left:${detail.taskData.progress}%;`">{{ detail.taskData.finishCount }}</div>
        </div>
        <div class="gap"></div>
      </div>
      <div class="gap"></div>
      <div class="mid-title center" v-if="detail.status === 3">未开始</div>
      <div class="mid-title center" v-else-if="detail.status === 0">未解锁</div>
      <div class="mid-title center" v-else>{{detail.completionDesc}}</div>
      <div class="gap"></div>
      <div class="mid-title">目标</div>
      <div class="text">{{ detail.target }}</div>
      <div class="gap"></div>
      <div class="mid-title">目标解释</div>
      <div class="text">{{ detail.targetDesc }}</div>
      <div class="gap"></div>
      <div class="mid-title">任务</div>
      <div class="text" v-for="(item, index) in tasks" :key="index">{{ item }}</div>
    </div>
  </div>
</template>

<script>
import NavBar from '@/components/NavBar';
import develeopMent from '@/api/development';
export default {
  components: {
    NavBar
  },
  data() {
    return {
      id: 1,
      detail: null,
      progress: 50
    };
  },
  computed: {
    tasks() {
      return this.detail ? this.detail.taskDesc.split('\r\n') : [];
    }
  },
  mounted() {
    let id = this.$route.params.id;
    if (id) {
      this.id = id;
    } else {
      this.$toast('参数错误');
      setTimeout(() => {
        this.$router.back();
      }, 2000);
      return
    }
    this.initData();
  },
  methods: {
    async initData() {
      let re = await develeopMent.LevelDetail({
        levelId: this.id
      });
      if (re) {
        if (re.succeed) {
          this.detail = re.data;
        } else {
          this.$toast(re.message);
        }
      }
    }
  }
};
</script>

<style scoped lang="scss">
@import './include.scss';
.max-title {
  font-size: 50px;
  font-weight: bold;
  text-align: center;
}
.mid-title {
  font-size: 30px;
}
.min-title {
  font-size: 26px;
}
.title {
  font-size: 24px;
}
.text {
  font-size: 24px;
  color: gray;
}
.center {
  text-align: center;
}
.planDescription {
  padding-top: 130px;

  .bannar {
    overflow: hidden;
    position: relative;
    width: 75%;
    min-height: 200px;
    margin: 0 auto;
  }

  .content {
    width: 100%;
    padding: 0px 40px;

    .progress {
      position: relative;
      width: 100%;

      .bg {
        left: 0;
        top: 0px;
        height: 30px;
        border-radius: 20px;
        background: #29943a;
        z-index: 1;
      }
      .text {
        position: absolute;
        top: 0px;
        bottom: 0;
        width: 60px;
        height: 60px;
        line-height: 60px;
        color: #fff;
        font-size: 34px;
        text-align: center;
        border-radius: 50%;
        margin: auto;
        margin-left: -30px;
        background: black;
        z-index: 2;
      }
    }
  }
}
</style>
