<template>
  <div class="services_shop-container">
    <div class="services_shop-carousel">
      <el-carousel height="400px">
        <el-carousel-item
          v-for="(banner, index) in banners"
          :key="'banner_' + index"
        >
          <img :src="banner" width="100%" />
        </el-carousel-item>
      </el-carousel>
      <ul class="services_shop-info">
        <template v-for="(item, index) in servicesShopInfo">
          <li class="info_item" :key="'info_' + index">
            <div class="left-contianer">
              <img :src="item.icon" width="100%" />
            </div>
            <div class="right-container">
              <p v-text="item.name"></p>
              <p>
                <span v-text="item.value"></span>
                <span v-text="item.unit"></span>
              </p>
            </div>
          </li>
          <li
            class="info_line"
            :key="'line_' + index"
            v-if="index + 1 < servicesShopInfo.length"
          ></li>
        </template>
      </ul>
    </div>

    <!-- 热门数据 -->
    <shop-list
      name="热门数据"
      to="/shop/data_service_list"
      detail-path="/shop/sjfwDetail/"
      :data="hot_datas"
    ></shop-list>

    <!-- 精品地图 -->
    <shop-list
      name="精品地图"
      to="/shop/space_time_service_list"
      detail-path="/shop/skfwDetail/"
      :data="map_datas"
    ></shop-list>

    <!-- 综合应用 -->
    <shop-list
      name="综合应用"
      to="/shop/comprehensive_app_list"
      detail-path="/shop/zhfwDetail/"
      :data="comprehensive_datas"
    ></shop-list>
  </div>
</template>

<script>
import shopList from "@/components/shop-list";

export default {
  components: {
    shopList,
  },
  data: () => ({
    banners: null,
    servicesShopInfo: null,
    hot_datas: [],
    map_datas: [],
    comprehensive_datas: [],
  }),
  methods: {
    init() {
      this.$http
        .get("/static/serviceshop.json")
        .then((response) => {
          let data = response.body;
          let servicesShopInfo = [
            {
              name: "服务总数",
              value: "",
              unit: "万",
              icon: require("@/assets/imgs/shop_ic_fuwuzs.png"),
            },
            {
              name: "用户总数",
              value: "",
              unit: "万",
              icon: require("@/assets/imgs/shop_ic_yonghuzs.png"),
            },
            {
              name: "接入机构",
              value: "",
              unit: "",
              icon: require("@/assets/imgs/shop_ic_jierujg.png"),
            },
            {
              name: "接入系统",
              value: "",
              unit: "万",
              icon: require("@/assets/imgs/shop_ic_jieruxt.png"),
            },
            {
              name: "服务请求次数",
              value: ".2",
              unit: "亿",
              icon: require("@/assets/imgs/shop_ic_fuwuzs.png"),
            },
          ];

          this.banners = data.banners;
          this.servicesShopInfo = servicesShopInfo.map((item) => {
            let temp = data.servicesShopInfo.find((v) => v.name === item.name);

            return {
              ...item,
              value: temp && temp.value,
            };
          });
          this.hot_datas = data.hot_datas;
          this.map_datas = data.map_datas;
          this.comprehensive_datas = data.comprehensive_datas;
        })
        .catch(function(error) {
          console.log(error);
        });
    },
  },
  mounted() {
    this.init();
  },
};
</script>

<style scoped>
.services_shop-container {
  max-width: 1200px;
  margin: -157px auto 20px;
}
.services_shop-carousel {
  border-radius: 10px;
  overflow: hidden;
}

.services_shop-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 5px;
  background-color: #fff;
}
.services_shop-info > .info_item {
  flex-grow: 1;
  display: inline-flex;
  justify-content: space-between;
  align-items: center;
  height: 125px;
  padding: 10px 10px;
  margin: 0 15px;
  box-sizing: border-box;
}
.services_shop-info .left-container {
  width: 45px;
  flex-shrink: 0;
}
.services_shop-info .right-container {
  flex-grow: 1;
  padding: 0 1.5em;
}
.services_shop-info .right-container > p {
  font-size: 16px;
  color: #58617a;
  line-height: 32px;
  text-align: right;
  position: relative;
  box-sizing: border-box;
}
.services_shop-info .right-container > p:nth-child(2) > span:nth-child(1) {
  font-family: Arial;
  font-size: 24px;
  font-weight: bold;
  color: #242c43;
}
.services_shop-info .right-container > p:nth-child(2) > span:nth-child(2) {
  position: absolute;
  top: 0;
  right: -1.2em;
}
.services_shop-info > .info_line {
  height: 64px;
  border: 1px solid #f2f3f4;
}
</style>

<style>
.services_shop-carousel .el-carousel__button {
  width: 30px;
  height: 5px;
  opacity: 1;
  border-radius: 2px;
}
.services_shop-carousel .is-active .el-carousel__button {
  background-color: #e56600;
}
</style>
