|
@@ -1,7 +1,8 @@
|
|
|
<script setup lang="ts">
|
|
|
-import ModelList from "@/assets/data/Model/index";
|
|
|
+import ModelList, { baseURL } from "@/assets/data/Model/index";
|
|
|
import { ModelType } from "@/types/Model/index";
|
|
|
import getNumNoRepeat from "@/utils/tool";
|
|
|
+import restaurantList, { hotelList } from "@/assets/data/recommend/index";
|
|
|
import Swiper from "swiper";
|
|
|
import "swiper/swiper-bundle.css";
|
|
|
import { nextTick } from "vue";
|
|
@@ -22,15 +23,14 @@ const goVr = (code: string) => {
|
|
|
};
|
|
|
|
|
|
// 美食的两个随机推荐
|
|
|
-const recommendFoodIndexs = ref([]);
|
|
|
+const recommendFoods = ref([]);
|
|
|
// 酒店的两个随机推荐
|
|
|
-const recommendHotelIndexs = ref([])
|
|
|
+const recommendHotels = ref([]);
|
|
|
|
|
|
const lastY = ref(0);
|
|
|
const bottomHeight = ref("50%");
|
|
|
// 手指滑动
|
|
|
const touchMove = (event: any) => {
|
|
|
- console.log("查看随机数", recommendFoodIndexs, recommendHotelIndexs);
|
|
|
// 左右切换为 X 即可
|
|
|
let currentY = event.changedTouches[0].pageY;
|
|
|
let ty = currentY - lastY.value;
|
|
@@ -51,19 +51,43 @@ const handletouchstart = (event: any) => {
|
|
|
// 当前轮播下标
|
|
|
const swiperActiveIndex = ref(0);
|
|
|
|
|
|
+const itRecommend = () => {
|
|
|
+ // 产生推荐的随机数
|
|
|
+ let recommendFoodIndexs = getNumNoRepeat(
|
|
|
+ currentScene.value.recommend.food.length - 1,
|
|
|
+ 2
|
|
|
+ );
|
|
|
+ const recommendHotelIndexs = getNumNoRepeat(
|
|
|
+ currentScene.value.recommend.hotel.length - 1,
|
|
|
+ 2
|
|
|
+ );
|
|
|
+ console.log(typeof recommendFoodIndexs);
|
|
|
+
|
|
|
+ if (recommendFoodIndexs && recommendHotelIndexs) {
|
|
|
+ // 获取推荐信息——美食
|
|
|
+ recommendFoodIndexs.forEach((index: number) => {
|
|
|
+ const res = restaurantList.find((item: any) => {
|
|
|
+ return item.id == currentScene.value.recommend.food[index];
|
|
|
+ });
|
|
|
+ recommendFoods.value.push(res);
|
|
|
+ });
|
|
|
+ // 获取推荐信息——酒店
|
|
|
+ recommendHotelIndexs.forEach((index: number) => {
|
|
|
+ const res = hotelList.find((item: any) => {
|
|
|
+ return item.id == currentScene.value.recommend.hotel[index];
|
|
|
+ });
|
|
|
+ recommendHotels.value.push(res);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ console.log(recommendFoods.value, recommendHotels.value);
|
|
|
+};
|
|
|
+
|
|
|
onMounted(async () => {
|
|
|
await nextTick(() => {
|
|
|
currentScene.value = ModelList.find((item: ModelType) => {
|
|
|
return item.code === route.query.code;
|
|
|
});
|
|
|
- recommendFoodIndexs.value = getNumNoRepeat(
|
|
|
- currentScene.value.recommend.food.length,
|
|
|
- 2
|
|
|
- );
|
|
|
- recommendHotelIndexs.value = getNumNoRepeat(
|
|
|
- currentScene.value.recommend.hotel.length,
|
|
|
- 2
|
|
|
- );
|
|
|
+ itRecommend();
|
|
|
});
|
|
|
|
|
|
var swiper = new Swiper(".mySwiper", {
|
|
@@ -159,24 +183,38 @@ onMounted(async () => {
|
|
|
<div class="bottom-recommend-content">
|
|
|
<!-- 食物 -->
|
|
|
<div class="content-item">
|
|
|
- <div class="item">
|
|
|
- <img src="@/assets/img/map/recommend/1/food/1(1).jpg" alt="" />
|
|
|
- <div>同庆楼</div>
|
|
|
- </div>
|
|
|
- <div class="item">
|
|
|
- <img src="@/assets/img/map/recommend/1/food/2(1).jpg" alt="" />
|
|
|
- <div>荣悦荟洋房海鲜火锅(滨江店)</div>
|
|
|
+ <div
|
|
|
+ class="item"
|
|
|
+ v-for="(item, index) in recommendFoods"
|
|
|
+ :key="item.id"
|
|
|
+ >
|
|
|
+ <img
|
|
|
+ :src="baseURL + '/image/service/food/' + item.coverName"
|
|
|
+ alt=""
|
|
|
+ />
|
|
|
+ <div>{{ item.name }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 酒店 -->
|
|
|
<div class="content-item">
|
|
|
- <div class="item">
|
|
|
+ <!-- <div class="item">
|
|
|
<img src="@/assets/img/map/recommend/1/hotel/2(1).jpg" alt="" />
|
|
|
<div>MS美宿艺术品酒店</div>
|
|
|
</div>
|
|
|
<div class="item">
|
|
|
<img src="@/assets/img/map/recommend/1/hotel/3(1).jpg" alt="" />
|
|
|
<div>芜湖奇士商务酒店</div>
|
|
|
+ </div> -->
|
|
|
+ <div
|
|
|
+ class="item"
|
|
|
+ v-for="(item, index) in recommendHotels"
|
|
|
+ :key="item.id"
|
|
|
+ >
|
|
|
+ <img
|
|
|
+ :src="baseURL + '/image/service/hotel/' + item.coverImg"
|
|
|
+ alt=""
|
|
|
+ />
|
|
|
+ <div>{{ item.name }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -400,6 +438,7 @@ onMounted(async () => {
|
|
|
text-overflow: ellipsis;
|
|
|
overflow: hidden;
|
|
|
white-space: nowrap;
|
|
|
+ margin-top: 0px;
|
|
|
}
|
|
|
}
|
|
|
}
|