<style scoped>
.back {
  background: #ffffff;
}
.wapper {
  max-width: 1200px;
  margin: 0 auto;
}
.main {
  width: 930px;
  height: 370px;
  background: #e0e0e0;
  border-radius: 8px;
}
.card-img-box {
  width: 260px;
  margin-left: 10px;
}
.card-img {
  width: 260px;
  height: 180px;
  background: #e0e0e0;
  border-radius: 8px;
}
.margin-bottom {
  margin-bottom: 10px;
}
.nav-item {
  width: 276px;
  height: 100px;
  background: #ffffff;
  border: 1px solid #eeeeee;
  border-radius: 8px;
}
.nav-item:hover {
  background: #ffffff;
  border: 1px solid #efefef;
}
.nav-img {
  width: 50px;
  height: 50px;
  margin: 10px auto 3px auto;
  display: block;
}
.top-title {
  margin-top: 30px;
  font-size: 26px;
  font-family: Microsoft JhengHei;
  font-weight: bold;
  color: #000000;
  line-height: 44px;
}
.info-icon {
  width: 32px;
  height: 32px;
  margin-right: 10px;
}
.time-item {
  width: 25%;
}
#baidu-map {
  width: 400px;
  height: 196px;
  background: #ffffff;
  border-radius: 8px;
}
</style>
<template>
  <div class="back">
    <div class="wapper">
      <q-breadcrumbs gutter="none">
        <q-breadcrumbs-el label="Home" />
        <q-breadcrumbs-el label="Components" />
        <q-breadcrumbs-el label="Breadcrumbs" />
      </q-breadcrumbs>

      <div class="flex">
        <img
          class="main"
          src="https://imgfile.oytour.com/Upload/DMC/202110131151571540000000139.jpeg"
        />
        <div class="card-img-box">
          <img
            class="card-img margin-bottom"
            src="https://imgfile.oytour.com/Upload/DMC/202110131151571540000000139.jpeg"
          />
          <img
            class="card-img"
            src="https://imgfile.oytour.com/Upload/DMC/202110131151571540000000139.jpeg"
          />
        </div>
      </div>

      <div class="flex justify-between">
        <div v-for="item in navList" :key="item.img" class="nav-item">
          <img
            class="nav-img"
            :src="require(`../../assets/img/${item.img}.png`)"
          />
          <div class="f16 bold text-center">{{ item.title }}</div>
        </div>
      </div>
      <div class="top-title">TOP榜单</div>
      <div>本地销量最好的商品</div>
      <div class="flex justify-between mt">
        <topCard v-for="item in 4" :key="item" />
      </div>
      <div class="top-title">最新推荐</div>
      <div>已售出商品的最新榜單</div>
      <div class="flex justify-between mt">
        <likeCard v-for="item in 4" :key="item" />
      </div>
      <div class="top-title">關於東京</div>
      <div class="flex justify-between">
        <div style="width: 720px">
          虽然曾历战火，京都之美仍然遗世独立。只要亲身到访，你就会发现京都把日本的「侘寂」美学诠释得有多淋漓尽致。
          作为日本艺妓发源地，值得你深入认识这个古典的文艺世界。花一个早晨在岚山的竹林里静思，学习正宗怀石料理，或是到金阁寺体验宁谧自在。伏见稻荷大社也是另一个必到景点，那著名的鸟居隧道，仿佛引领你进入仙境。
        </div>
        <div>
          <div id="baidu-map"></div>
        </div>
      </div>
      <div class="top-title">當地天氣</div>
      <div>
        <div class="flex">
          <div class="time-item" v-for="item in 4" :key="item">
            <div class="f16">12月-2月</div>
            <div class="f26 bold">-12° -17°</div>
          </div>
        </div>
        <div class="flex mt">
          <div class="flex time-item">
            <img
              class="info-icon"
              :src="require(`../../assets/img/info-time.png`)"
            />
            <div>
              <div class="f16 bold">時區</div>
              <div>-12° -17°</div>
            </div>
          </div>
          <div class="flex time-item">
            <img
              class="info-icon"
              :src="require('../../assets/img/info-currency.png')"
            />
            <div>
              <div class="f16 bold">貨幣</div>
              <div>-12° -17°</div>
            </div>
          </div>
          <div class="flex time-item">
            <img
              class="info-icon"
              :src="require(`../../assets/img/info-ele.png`)"
            />
            <div>
              <div class="f16 bold">電壓</div>
              <div>-12° -17°</div>
            </div>
          </div>
          <div class="flex time-item">
            <img
              class="info-icon"
              :src="require(`../../assets/img/info-time.png`)"
            />
            <div>
              <div class="f16 bold">旅遊時間</div>
              <div>-12° -17°</div>
            </div>
          </div>
        </div>
      </div>
      <nearCity />
    </div>
  </div>
</template>
<script>
import topCard from "./components/top-card.vue";
import likeCard from "./components/like-card.vue";
import nearCity from "./components/near-city.vue";
export default {
  components: { topCard, likeCard, nearCity },
  data() {
    return {
      navList: [
        {
          title: "觀光行程",
          img: "nav-map",
        },
        {
          title: "景點門票",
          img: "nav-ticket",
        },
        {
          title: "住宿",
          img: "nav-hotal",
        },
        {
          title: "交通",
          img: "nav-trip",
        },
      ],
    };
  },
  mounted() {
    this.createMap();
    this.addMarker();
    this.addLabel()
  },
  methods: {
    createMap() {
      if (!BMapGL) {
        return;
      }
      let map = new BMapGL.Map("baidu-map"); // 创建地图实例
      let point = new BMapGL.Point(116.404, 39.915); // 创建点坐标
      map.centerAndZoom(point, 15); // 初始化地图，设置中心点坐标和地图级别
      this.map = map;
    },
    addMarker() {
      let icon = require(`../../assets/img/info-time.png`);
      var myIcon = new BMapGL.Icon(icon, new BMapGL.Size(23, 25), {
        // 指定定位位置。
        // 当标注显示在地图上时，其所指向的地理位置距离图标左上
        // 角各偏移10像素和25像素。您可以看到在本例中该位置即是
        // 图标中央下端的尖角位置。
        anchor: new BMapGL.Size(10, 25),
        // 设置图片偏移。
        // 当您需要从一幅较大的图片中截取某部分作为标注图标时，您
        // 需要指定大图的偏移位置，此做法与css sprites技术类似。
        // imageOffset: new BMapGL.Size(0, 0 - 25)   // 设置图片偏移
      });
      let point = new BMapGL.Point(116.404, 39.915); // 创建点坐标
      // 创建标注对象并添加到地图
      var marker = new BMapGL.Marker(point, { icon: myIcon });
      this.map.addOverlay(marker);
    },
    addLabel() {
      var point = new BMapGL.Point(116.404, 39.915);
      var content = "label";
      var label = new BMapGL.Label(content, {
        // 创建文本标注
        position: point, // 设置标注的地理位置
        offset: new BMapGL.Size(10, -80), // 设置标注的偏移量
      });
      this.map.addOverlay(label); // 将标注添加到地图中
      label.addEventListener("click", function () {
        alert("您点击了标注");
      });
      label.setStyle({
        // 设置label的样式
        color: "#000",
        fontSize: "30px",
        border: "2px solid #1E90FF",
      });
    },
  },
};
</script>