<template>
  <div class="brandreg">
    <div>
      <div class="brand">
        <div>
          <div class="brand-title">商标注册申请</div>
          <div class="brand-text">
            <span>
              <img
                src="../../../assets/imgs/dui.png"
                style="margin-right: 10px;"
                alt
              />
              诚信商家
            </span>
            <span>
              <img
                src="../../../assets/imgs/dui.png"
                style="margin-right: 10px;"
                alt
              />
              1v1专业服务
            </span>
            <span>
              <img
                src="../../../assets/imgs/dui.png"
                style="margin-right: 10px;"
                alt
              />
              省钱省心省力
            </span>
          </div>

          <!-- 轮播部分 -->
          <div class="brandreg-swiper">
            <div class="swiper-container">
              <div class="swiper-wrapper">
                <div
                  class="swiper-slide"
                  v-for="(item, index) in dataList"
                  :key="index"
                  @mouseenter="addActive(index, $event)"
                  :class="{ 'swiper-slide-enter': index == current }"
                >
                  <div
                    class="brandreg-swiper-hearder"
                    :class="{
                      'brandreg-swiper-hearder-enter': index == current
                    }"
                  >
                    <div>
                      <div>
                        <img :src="item.icon_url" alt />
                      </div>
                      <div>{{ item.item_name }}</div>
                    </div>
                  </div>
                  <div
                    class="brandreg-swiper-content"
                    :class="{
                      'brandreg-swiper-content-button-enter': index == current
                    }"
                  >
                    <ul>
                      <li
                        v-for="(t, i) in JSON.parse(item.product_desc).desc"
                        :key="i + t"
                      >
                        <div>
                          <img src="../../../assets/imgs/dbx.png" alt />
                        </div>
                        <div>{{ t }}</div>
                      </li>
                    </ul>
                    <div>
                      <div>
                        <sup>￥</sup>
                        <span>{{ item.price }}</span
                        >/件
                      </div>
                      <div
                        class="brandreg-swiper-content-button"
                        @click="goOwnBuyPage(index)"
                      >
                        立即购买
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// 注册信息数据请求
import { getRegInfo } from "@/api/tmOrder.js";

export default {
  data() {
    return {
      dataList: [],
      showArrows: false,
      current: 1
    };
  },
  mounted() {
    getRegInfo().then(res => {
      // 请求数据并装填到datalist里面
      console.log(res.data);
      this.dataList = res.data;
    });
  },
  methods: {
    /*swiper区域添加class */
    addActive(index, event) {
      this.current = index;
    },
    // 点击购买去相应的购买页面
    goOwnBuyPage(index) {
      if (index == 0) {
        location.href =
          "https://oauth2.jdcloud.com/authorize?response_type=token&redirect_uri=https://tm.plus.jdcloud.com/jdtm/getUser&state=selftmreg&client_id=9491577327154697";
      }
      if (index == 1) {
        location.href = "https://market.jdcloud.com/service/details/582208";
      }
      if (index == 2) {
        location.href = "https://market.jdcloud.com/service/details/582207";
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.brandreg {
  > div {
    width: 1200px;
    margin: 30px auto;
    .brand {
      width: 100%;
      > div {
        width: 1200px;
        margin: 0 auto;
        > div {
          width: 1200px;
        }
      }
    }
  }
}
.brand-title {
  width: 100%;
  text-align: center;
  font-size: 28px;
  font-family: MicrosoftYaHei;
  font-weight: 400;
  color: rgba(51, 51, 51, 1);
  line-height: 100px;
}

.brand-text {
  font-size: 14px;
  font-family: MicrosoftYaHei;
  font-weight: 400;
  color: rgba(153, 153, 153, 1);
  text-align: center;
  display: flex;
  justify-content: center;
  > span:not(:nth-child(1)) {
    margin-left: 45px;
  }
  > span {
    display: flex;
    align-items: center;
    > img {
      width: 13px;
      height: 9px;
    }
    h5 {
      font-size: 14px;
      font-weight: 400;
      color: rgba(153, 153, 153, 1);
    }
  }
}

/* 轮播 */
.brandreg-swiper {
  position: relative;
  margin-top: 22px;
  .swiper-container {
    width: 1203px;
    // height: 380px;
    padding-left: 3px;
    .swiper-wrapper {
      display: flex;
      align-items: flex-end;
      .swiper-slide {
        width: 400px !important;
        box-sizing: border-box;
        // height: 370px;
        text-align: center;
        margin-right: 0 !important;
        transition: all 0.1s;
        box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
        border-radius: 1px;
      }
    }
  }
}

/* 移入之后的高亮样式 */
.brandreg-swiper .swiper-slide-enter {
  height: 370px;
}
.brandreg-swiper .brandreg-swiper-hearder-enter {
  height: 80px;
  background: #32b6e7;
  color: #fff;
  font-size: 18px;
  line-height: 80px;
}
.brandreg-swiper .brandreg-swiper-content-button-enter {
  .brandreg-swiper-content-button {
    background: #32b6e7;
    border: 1px solid #32b6e7;
    color: #fff;
    cursor: pointer;
  }
}

/* 轮播卡片头部图文 */
.brandreg-swiper-hearder {
  font-size: 16px;
  height: 70px;
  background: #2f3353;
  color: #fff;
  > div {
    width: 100%;
    height: 100%;
    line-height: 70px;
    > div {
      display: inline-block;
    }
    > div:nth-child(1) {
      width: 39px;
      height: 39px;
      margin-right: 15px;
      > img {
        width: 100%;
        height: 100%;
        margin-top: 15px;
      }
    }
  }
}

/* 轮播卡片中部li数据渲染 */
.brandreg-swiper-content {
  ul {
    height: 145px;
    box-sizing: border-box;
    padding: 30px 26px 0;

    li {
      display: flex;
      align-items: center;
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFangSC;
      font-weight: 400;
      color: rgba(67, 67, 67, 1);
      margin-bottom: 15px;

      > div:nth-child(1) {
        width: 14px;
        /* height: 16px; */
        margin-right: 14px;
        margin-left: 41px;

        > img {
          width: 100%;
          height: 100%;
        }
      }
    }

    li:nth-last-child(1) {
      padding-bottom: 30px;
      border-bottom: 1px solid #ededef;
    }
  }

  > div > div:nth-child(1) {
    font-size: 16px;
    margin-top: 15px;
    font-family: PingFangSC-Regular, PingFangSC;
    font-weight: 400;
    color: rgba(223, 0, 130, 1);

    > span {
      font-size: 36px;
    }
  }
}

/* 轮播卡片底部立即购买按钮 */
.brandreg-swiper-content-button {
  width: 364px;
  height: 46px;
  border-radius: 1px;
  line-height: 46px;
  border: 1px solid rgba(0, 136, 199, 1);
  margin: 21px auto 0;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFangSC;
  font-weight: 400;
  color: rgba(0, 136, 199, 1);
  margin-bottom: 10px;
}
</style>
