<template>
  <div class="app-container">
    <main id="main">

      <!--==========================
        Marketplace Section
      ============================-->
      <section id="services">
        <div class="container cportal console">

          <h3>工作台</h3>

          <div class="row row10">
            <div class="col-lg-4">
              <div class="box wow fadeInLeft">
                <div class="icon svgImg"><img src="@/assets/pic/row10.png" alt=""></div>
                <div class="content">
                  <h4 class="title">我的测试工具</h4>
                  <p class="description">
                    <i><span>{{toolCount}}</span></i>
                  </p>
                  <ul>
                    <li style="margin-top: 6px;"><a href="javascript:void(-1)" @click="toMarket">查看工具市场</a></li>
                    <li style="margin-top: 6px;color: #ffffff;">|</li>
                    <li style="margin-top: 6px;"><a href="javascript:void(-1)" @click="toMyTool">查看我的工具</a></li>
                  </ul>
                </div>
              </div>
            </div>

            <div class="col-lg-4">
              <div class="box wow fadeInLeft">
                <div class="icon svgImg"><img src="@/assets/pic/row10.png" alt=""></div>
                <div class="content">
                  <h4 class="title">本周我的测试项目</h4>
                  <p class="description">
                    <i><span>{{taskCount}}</span></i>
                  </p>
                  <ul>
                    <li style="margin-top: 6px;"><a href="javascript:void(-1)" @click="toMyTool">查看我的工具</a></li>
                    <li style="margin-top: 6px;color: #ffffff;">|</li>
                    <li style="margin-top: 6px;"><a href="javascript:void(-1)" @click="toMyTask">查看测试项目</a></li>
                  </ul>
                </div>
              </div>
            </div>

          </div>

        </div>
      </section>
    </main>
  </div>
</template>

<script>
  import {listNews} from "@/api/cms/cms";
  import {listMyTools} from "@/api/my/my";
  import {getMyWeekTask} from "@/api/my/my";

  export default {
  name: "index",
  data() {
    return {
      // 版本号
      version: "3.4.0",
      toolCount: 0,
      taskCount: 0,
      news:[],
      // 查询参数
      queryParam: {
        taskType:undefined,
        projectName:undefined,
        status:undefined,
        pageNum: 1,
        pageSize: 10
      }
    };
  },
  methods: {
    goTarget(href) {
      window.open(href, "_blank");
    },
    toMarket(){
      this.$router.push({ path: "/market/market" });
    },
    toMyTool(){
      this.$router.push({ path: "/testmanage/myTool" });
    }
    ,
    toMyTask(){
      this.$router.push({ path: "/testmanage/myTask" });
    }
  },
  created(){
    // listNews().then(res=>{
    //   this.news = res.data;
    // })
    this.loading = true;
    listMyTools().then(response => {
      if (response.data != null) {
        let validTools = response.data.filter(function (item) {
          return item.status == 0;
        })
        this.toolCount = validTools.length;
        this.loading = false;
      }
    });
    getMyWeekTask(this.queryParam).then(response => {
      if (response.myWeekTask != null)
        this.taskCount = response.myWeekTask.length;
    })
  }
};
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>

