<template>
  <div class="wrapper" v-if="vipList[1]">
    <div class="title">开发者会员</div>
    <div class="subtitle">提高接单效率 鼓励优质开发者</div>
    <div class="content">
      <div class="explain">
        <div class="explain-title">权益内容</div>
        <div class="explain-content">
          <p>确认接单次数<img src="@/assets/img/vip/icon_explain.png" alt=""></p>
          <p>同时接单数量<img src="@/assets/img/vip/icon_explain.png" alt=""></p>
          <p>Ping(接单意愿)权重
            <el-tooltip class="item" effect="dark" content="程序员列表、搜索结果页、兼职推荐开发者会员每天最多可ping5次" placement="top-end">
              <img src="@/assets/img/vip/icon_explain.png" alt="" title="">
            </el-tooltip>
          </p>
          <p>资质认证申请<img src="@/assets/img/vip/icon_explain.png" alt=""></p>
          <p>平台服务费减免<img src="@/assets/img/vip/icon_explain.png" alt=""></p>
        </div>
      </div>
      <div class="ordinary">
        <div class="ordinary-title">普通开发者</div>
        <div class="ordinary-avatar">
          <img src="@/assets/img/vip/ordinary_avatar.png" alt="">
        </div>
        <div class="ordinary-content">
          <p>每月最多确认接单{{vipList[3].devAcceptTimes}}次</p>
          <p>仅1单</p>
          <p>普通权重</p>
          <p>无折扣</p>
          <p>无减免</p>
        </div>
      </div>
      <div class="developer">
        <div class="developer-title">
          <img src="@/assets/img/vip/developer_title.png" alt="">
        </div>
        <div class="developer-avatar">
          <img src="@/assets/img/vip/ordinary_avatar.png" alt="">
        </div>
        <div class="developer-content">
          <p>不限次数</p>
          <p>会员+认证自由工作者可接{{vipList[1]['accept_count']}}单</p>
          <p>比普通权重高30%</p>
          <p>低至3-6折</p>
          <p>整包项目减免{{vipList[1]['project_reduction_rate']}}%、云端项目减免{{vipList[1]['job_reduction_rate']}}%</p>
        </div>
        <div class="developer-price-wrapper">
          <div class="developer-price"><span>￥{{vipList[1]['monthly_real_price']}}</span>/月</div>
          <div class="original-price">原价￥{{vipList[1]['monthly_origin_price']}}/月</div>
        </div>
        <div class="developer-btn" @click="clickPay('dev')">立即开通</div>
      </div>
    </div>
    <div class="tips">
      <div class="tips-title">说明</div>
      <div class="tips-content">
        <p>1.最低支持购买3个月，每个月按31天算；</p>
        <p>2.开通会员即代表您已同意<span>《程序员客栈会员服务条款》</span>；</p>
        <p> 3.如有任何问题，欢迎咨询在线客服，或拨打热线：0571-28120931 转1</p>
      </div>
    </div>
    <buy-dialog
      :handleClose="handleClose"
      :buyDialog="buyDialog"
      :gotoPay="gotoPay"
      :type="type"
      :item="item"
      :vipDetail="vipDetail"
      :pricePrefix="pricePrefix"
    ></buy-dialog>
  </div>

</template>

<script>
    import buyDialog from "@/components/type/vip/buy-dialog";

    export default {
        data() {
            return {
                buyDialog: false,
                pricePrefix: "",
                type: "dev", // com: 企业会员, dev: 开发者会员
                vipList: [],
                vipDetail: {},
                item: {}
            };
        },
        async mounted() {
            await this.getList();
            await this.getVipDetail();
        },
        components: {
            buyDialog
        },
        computed: {},
        methods: {
            async getList() {
                let extraHeaders = {};
                if (this.deviceType === "ios") {
                    extraHeaders = this.getSign();
                }
                let res = await this.$axios.$post(`/api/vip/getList`, extraHeaders);
                this.vipList = res.data;
            },
            /**
             * 点击支付
             */
            clickPay(type) {
                this.type = type;
                this.item = this.vipList[1];
                this.buyDialog = true;
            },
            handleClose() {
                this.buyDialog = false;
            },
            gotoPay(number) {
                const item = this.item;
                location.href = `/vip/pay?product_id=${item.id}&number=${number}&next=/type/vip/`;
            },
            // 点击会员计划
            clickProject(index) {
                let vip = this.vipList[index];
                window.open(recommend.seo_uri);
            },
            async getVipDetail() {
                let res = await this.$axios.$post("/api/vip/get_vip_user_detail");
                this.vipDetail = res && res.data ? res.data : {};
            }
        }
    }
</script>

<style lang="scss" scope>
  .wrapper {
    overflow: hidden;
  }

  .title {
    margin-top: 54px;
    line-height: 45px;
    text-align: center;
    font-weight: 600;
    font-size: 32px;
    color: #222222;
  }

  .subtitle {
    margin-top: 4px;
    line-height: 22px;
    text-align: center;
    font-size: 16px;
    color: #999999;
  }

  .content {
    margin: 49px auto 0;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .explain {
    overflow: hidden;
    width: 304px;
    height: 606px;
    border-radius: 2px;
    background-color: #FFFFFF;
    border: 1px solid #D6DBE3;
    box-shadow: 0px 4px 20px 0px rgba(0, 21, 53, 0.05);
    text-align: center;
  }

  .explain-title {
    margin-top: 45px;
    line-height: 28px;
    font-weight: 600;
    font-size: 20px;
    color: #8E5B15;
  }

  .explain-content {
    overflow: hidden;
    line-height: 20px;
    font-size: 14px;
    color: #222222;
  }

  .explain-content p:nth-child(1) {
    margin-top: 125px;
  }

  .explain-content p:nth-child(2) {
    margin-top: 30px;
  }

  .explain-content p:nth-child(3) {
    margin-top: 30px;
  }

  .explain-content p:nth-child(4) {
    margin-top: 30px;
  }

  .explain-content p:nth-child(5) {
    margin-top: 30px;
  }

  .explain-content p {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .explain-content img {
    margin-left: 5px;
    width: 13px;
    height: 13px;
  }

  .ordinary {
    overflow: hidden;
    width: 315px;
    height: 606px;
    border-radius: 2px;
    background-color: #FFFFFF;
    border: 1px solid #D6DBE3;
    box-shadow: 0px 4px 20px 0px rgba(0, 21, 53, 0.05);
    text-align: center;
  }

  .ordinary-title {
    margin-top: 45px;
    line-height: 28px;
    font-weight: 600;
    font-size: 20px;
    color: #666666;
  }

  .ordinary-avatar {
    margin: 16px auto 0;
    width: 66px;
    height: 66px;
  }

  .ordinary-avatar img {
    width: 100%;
    height: 100%;
  }

  .ordinary-content {
    overflow: hidden;
    line-height: 20px;
    font-size: 14px;
    color: #666666;
  }

  .ordinary-content p:nth-child(1) {
    margin-top: 43px;
  }

  .ordinary-content p:nth-child(2) {
    margin-top: 30px;
  }

  .ordinary-content p:nth-child(3) {
    margin-top: 30px;
  }

  .ordinary-content p:nth-child(4) {
    margin-top: 30px;
  }

  .ordinary-content p:nth-child(5) {
    margin-top: 30px;
  }

  .developer {
    overflow: hidden;
    width: 326px;
    height: 606px;
    border-radius: 2px;
    background-color: #FFF9ED;
    border: 1px solid #C89A29;
    box-shadow: 0px 4px 20px 0px rgba(199, 160, 61, 0.13);
    text-align: center;
  }

  .developer-title {
    margin-top: 47px;
  }

  .developer-title img {
    width: 156px;
    height: 23px;
  }

  .developer-avatar {
    margin: 19px auto 0;
    width: 66px;
    height: 66px;
  }

  .developer-avatar img {
    width: 100%;
    height: 100%;
  }

  .developer-content {
    overflow: hidden;
    line-height: 20px;
    font-weight: 600;
    font-size: 14px;
    color: #9E733A;
  }

  .developer-content p:nth-child(1) {
    margin-top: 43px;
  }

  .developer-content p:nth-child(2) {
    margin-top: 30px;
  }

  .developer-content p:nth-child(3) {
    margin-top: 30px;
  }

  .developer-content p:nth-child(4) {
    margin-top: 30px;
  }

  .developer-content p:nth-child(5) {
    margin-top: 30px;
  }

  .developer-price-wrapper {
    margin-top: 52px;
    display: flex;
    justify-content: center;
  }

  .developer-price {
    font-size: 15px;
    color: #222222;
  }

  .developer-price span {
    line-height: 40px;
    font-weight: 600;
    font-size: 28px;
    color: #222222;
  }

  .original-price {
    margin-top: 15px;
    margin-left: 5px;
    line-height: 17px;
    font-size: 12px;
    color: #666666;
    text-decoration: line-through;
  }

  .developer-btn {
    margin: 21px auto 0;
    width: 195px;
    height: 44px;
    background-color: #D4AB4C;
    line-height: 44px;
    text-align: center;
    font-weight: 500;
    font-size: 14px;
    color: #0E0E0E;
    cursor: pointer;
  }

  .tips {
    margin-top: 38px;
  }

  .tips-title {
    line-height: 20px;
    font-weight: 600;
    font-size: 14px;
    color: #666666;
  }

  .tips-content {
    margin-top: 3px;
    line-height: 28px;
    font-size: 14px;
    color: #919AA7;
  }

  .tips-content span {
    color: #308EFF;
  }
</style>
