<template>
  <div class="productdetails">
    <div class="productdetails-main">
      <div class="productdetails-main-container">
        <div class="productdetails-main-top">
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/jdtrademark' }"
              >首页</el-breadcrumb-item
            >
            <el-breadcrumb-item>{{
              productDetails.channel_item_name
            }}</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <div class="productdetails-main-detail">
          <div class="productdetails-left">
            <img :src="productDetails.pic_url" alt="" />
          </div>
          <div class="productdetails-right">
            <h1>{{ productDetails.item_name }}</h1>
            <p v-if="regType == 'FW_GOODS-580010-1'">
              专业知产顾问一对一商标检索分析，提高注册效率，为您优化注册方案，全方位保护
            </p>
            <p v-if="regType == 'FW_GOODS-581978-1'">
              专业知产顾问一对一商标检索分析，提高注册成功率，注册不成功，全额退款！
            </p>
            <div class="priceMsg">
              <div v-if="productPriceList.length != 0">
                <span
                  >总价<b
                    >¥{{ productPriceList[clickedproduct].price * count }}</b
                  ></span
                >
                <span
                  >官費<b
                    >¥{{ productPriceList[clickedproduct].public_expense }}</b
                  ></span
                >
                <span
                  >服务费<b
                    >¥{{ productPriceList[clickedproduct].service_charge }}</b
                  ></span
                >
              </div>
              <p>
                该服务由公司宝提供，<span>发票请到订单中心-发票管理开取</span>
              </p>
            </div>
            <div class="product-service-type">
              <table>
                <tbody>
                  <tr>
                    <td class="td-title">商标注册申请服务项目</td>
                    <td class="td-cont">
                      <ul class="clearfix">
                        <li
                          data-no="PC10064"
                          class="list"
                          :class="{ active: clickedproduct == index }"
                          v-for="(item, index) in productPriceList"
                          :key="index"
                          @click="clickedproduct = index"
                        >
                          {{ item.price_type_name }}
                        </li>
                      </ul>
                    </td>
                  </tr>
                </tbody>
              </table>
            </div>
            <div class="productdetail-count">
              <p>数量</p>
              <el-input-number
                size="mini"
                v-model="count"
                :min="1"
              ></el-input-number>
            </div>
            <div class="bottom-btn">
              <el-button @click="goPlaceOrder()">立即购买</el-button>
              <span><img src="@/assets/imgs/wenti.png" alt="" />咨询客服</span>
            </div>
          </div>
        </div>
        <div class="productdetails-main-space"></div>
        <div class="productdetails-main-bottom-pic">
          <h3><span>产品详情</span><i></i></h3>
          <img :src="productDetails.desc_url" alt="" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getProductDetail } from "@/api/tmOrder.js";
export default {
  data() {
    return {
      // 购买数量 默认为1
      count: 1,
      // 该商标注册方式的详情数据
      productDetails: {},
      // 该商标注册方式的详情数据中的 产品服务价格列表数据
      productPriceList: [],
      // 点击切换的服务项下表
      clickedproduct: 0,
      // 记录注册类型 是 专家辅助申请 还是 担保申请
      regType: ""
    };
  },

  methods: {
    goPlaceOrder() {
      this.$router.push({
        path: "/placeorder",
        query: {
          count: this.count,
          regType: this.regType,
          serviceIndex: this.clickedproduct
        }
      });
    }
  },
  created() {
    this.regType = this.$route.query.channelItemCode;
    // 专家辅助申请 或是 担保申请
    getProductDetail(this.$route.query.channelItemCode).then(res => {
      if (res.status == 0) {
        if (res.data.length == 0) {
          // 服务器端返回的数据为空
          this.$notify({
            title: "警告",
            message: "没有该商品",
            type: "warning"
          });
        } else {
          // 请求数据并装填到productDetails里面
          this.productDetails = res.data[0];
          // console.log("注册申请", this.productDetails);
          this.productPriceList = res.data[0].productPriceList;
          // console.log("服务项", this.productPriceList);
        }
      } else {
        // 服务器端请求失败
        this.$notify.error({
          title: "错误",
          message: res.msg
        });
      }
    });
  },
  mounted() {}
};
</script>

<style lang="scss">
.productdetails {
  width: 100%;
  .productdetails-main {
    width: 100%;
    min-height: 786px;
  }
}
.productdetails-main-container {
  max-width: 1190px;
  padding: 0 20px;
  margin: 0 auto;
  .productdetails-main-top {
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #cecece;
  }
  .productdetails-main-detail {
    width: 100%;
    display: flex;
    padding: 20px 0;
    .productdetails-left {
      display: block;
      width: 400px;
      height: 340px;
      border: 1px solid rgba(207, 207, 207, 1);
      margin-right: 40px;
      img {
        display: block;
        width: 400px;
        height: 340px;
      }
    }
    .productdetails-right {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: space-evenly;
      h1 {
        font-size: 20px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: rgba(51, 51, 51, 1);
        line-height: 36px;
        margin-bottom: 5px;
        color: #333;
        font-weight: 700;
        font-size: 24px;
      }
      p {
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(153, 153, 153, 1);
        line-height: 20px;
      }
      .priceMsg {
        width: 100%;
        padding: 15px 17px;
        background: #f3f7fd;
        margin-bottom: 20px;
        margin-top: 12px;
        margin: 15px 0;
        div {
          width: 100%;
          margin-bottom: 12px;
          span {
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(153, 153, 153, 1);
            line-height: 17px;
            margin-right: 40px;
            b {
              font-size: 23px;
              color: #ff5b00;
              margin-left: 20px;
            }
          }
        }
        p {
          font-size: 12px;
          font-family: PingFangSC-Light, PingFang SC;
          font-weight: 300;
          color: rgba(153, 153, 153, 1);
          line-height: 17px;
          span {
            color: #3071fe;
          }
        }
      }
      // 商标注册服务类型：专家辅助申请 担保申请
      .product-service-type {
        .td-title {
          color: #888;
          width: 165px;
          text-align: left;
        }
        .td-cont {
          .list {
            display: inline-block;
            margin: 5px 0;
            color: #666;
            height: 30px;
            line-height: 30px;
            padding: 0 12px;
            border: solid 1px #ccc;
            border-radius: 2px;
            cursor: pointer;
            margin-right: 15px;
            position: relative;
            font-size: 14px;
          }
          .list.active {
            color: #fc461e;
            border: solid 0.9px #fc461e;
          }
          .clearfix:after {
            content: "";
            display: block;
            clear: both;
            height: 0;
            visibility: hidden;
          }
        }
      }
      .productdetail-count {
        display: flex;
        align-items: center;
        margin-bottom: 15px;
        p {
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: rgba(153, 153, 153, 1);
          line-height: 20px;
          margin-right: 12px;
        }
      }
      .bottom-btn {
        display: flex;
        align-items: center;
        button {
          width: 128px;
          height: 36px;
          background: rgba(48, 113, 254, 1);
          border: 1px solid rgba(48, 113, 254, 1);
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          line-height: 20px;
          padding: 0;
          border-radius: 0;
          margin-right: 10px;
          span {
            color: rgba(255, 255, 255, 1);
          }
        }
        span {
          display: flex;
          justify-content: center;
          align-items: center;
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: rgba(48, 113, 254, 1);
          line-height: 20px;
          cursor: pointer;
          img {
            display: inline-block;
            width: 16px;
            margin-right: 7px;
          }
        }
      }
    }
  }
  .productdetails-main-space {
    width: 107px;
    height: 3px;
    background-color: #2f95fc;
    margin-top: 30px;
  }
  .productdetails-main-bottom-pic {
    width: 1190px;
    min-height: 800px;
    border: 1px solid #ededed;
    h3 {
      width: 1190px;
      background-color: #f1f1f1;
      margin: 0;
      height: 30px;
      border-top: 1px solid #ededed;
      span {
        display: inline-block;
        width: 107px;
        height: 30px;
        line-height: 30px;
        text-align: center;
        font-size: 14px;
        color: #666;
        background-color: #fff;
        border: none;
        vertical-align: top;
      }
      i {
        display: inline-block;
        width: 1091px;
        height: 28px;
        border: 1px solid #eee;
      }
    }
    img {
      display: block;
      width: 1190px;
    }
  }
}
</style>
