Feat:趣游-轮播图按地区显示

This commit is contained in:
LinCyJang
2026-01-31 16:04:42 +08:00
parent cf4d198682
commit 2abd6533ba
2 changed files with 60 additions and 8 deletions
+4
View File
@@ -191,6 +191,10 @@ export function getHotelTypeList() {
}); });
} }
export function getHotelBanner(params) {
return request.get("/hotelBanner", params);
}
/** /**
* 店铺详情海报 * 店铺详情海报
* @param id 店铺ID int * @param id 店铺ID int
+56 -8
View File
@@ -84,7 +84,7 @@
class="img" class="img"
/> />
</view> </view>
<view v-if="currType.carousel" class="slider-wrap"> <view v-if="hotelBanner.length" class="slider-wrap">
<swiper <swiper
indicatorDots="true" indicatorDots="true"
indicator-color="rgba(255, 255, 255, .3)" indicator-color="rgba(255, 255, 255, .3)"
@@ -94,12 +94,12 @@
style="height: 330rpx;" style="height: 330rpx;"
> >
<block <block
v-for="(item, bannerIndex) in currType.carousel" v-for="(item, bannerIndex) in hotelBanner"
:key="bannerIndex" :key="bannerIndex"
> >
<swiper-item> <swiper-item>
<view class="swiper-item" @click="typeBannerItemClick(item)"> <view class="swiper-item" @click="typeBannerItemClick(item)">
<image :src="item.carouselImage" class="img" /> <image :src="item.bannerImage" class="img" />
</view> </view>
</swiper-item> </swiper-item>
</block> </block>
@@ -121,7 +121,7 @@
</view> </view>
<view class="body" v-else> <view class="body" v-else>
<view class="v12-justify-between v12-align-center"> <view class="v12-justify-between v12-align-center">
<text class="v12-font-bold" v-if="currType.carousel">推荐</text> <text class="v12-font-bold" v-if="hotelBanner.length">推荐</text>
<view class="v12-dark1-text v12-font-28 v12-align-center" @click="handleRefresh"> <view class="v12-dark1-text v12-font-28 v12-align-center" @click="handleRefresh">
<u-icon name="reload"></u-icon> <u-icon name="reload"></u-icon>
换一换 换一换
@@ -170,7 +170,8 @@
</view> </view>
</template> </template>
<script> <script>
import { getHotelList, getHotelTypeList, getAncientTownIcon, getAncientTownList } from "@/api/inn.js" import { getHotelList, getHotelTypeList, getAncientTownIcon, getAncientTownList, getHotelBanner } from "@/api/inn.js"
import { fetchCity } from "@/api/wenwan"
import { getCurAddress, getLocation } from "@/utils/common" import { getCurAddress, getLocation } from "@/utils/common"
import FunHotelItem from './components/HotelItem' import FunHotelItem from './components/HotelItem'
import { pageListenMixins } from '@/mixins/pageListenMixins' import { pageListenMixins } from '@/mixins/pageListenMixins'
@@ -202,7 +203,10 @@ export default {
isNext: false, isNext: false,
townConfig: {}, townConfig: {},
townList: [], townList: [],
randomSeed: null randomSeed: null,
hotelBanner: [],
goodCityId: '',
cityOptions: []
} }
}, },
computed: { computed: {
@@ -223,8 +227,12 @@ export default {
this.fetchList(random, this.randomSeed) this.fetchList(random, this.randomSeed)
} }
}, },
onLoad() { onLoad(options) {
this.currType = {} this.currType = {}
if (options && options.city) {
this.goodCityId = options.city
}
this.initGoodCity()
getHotelTypeList().then(({data}) => { getHotelTypeList().then(({data}) => {
this.typeList = data this.typeList = data
this.currType = this.typeIndex === -1 ? {} : data[this.typeIndex] this.currType = this.typeIndex === -1 ? {} : data[this.typeIndex]
@@ -246,7 +254,9 @@ export default {
watch: { watch: {
cityName: { cityName: {
handler(value) { handler(value) {
if(value) { if (value) {
this.updateGoodCityId()
this.fetchHotelBanner()
this.search() this.search()
} }
}, },
@@ -445,6 +455,26 @@ export default {
this.townConfig = res.data this.townConfig = res.data
}) })
}, },
initGoodCity() {
fetchCity(2).then(({ data }) => {
const group = data && data.group ? data.group : []
const list = []
group.forEach(item => {
if (item.city && item.city.length) {
list.push(...item.city)
}
})
this.cityOptions = list
this.updateGoodCityId()
})
},
updateGoodCityId() {
if (!this.cityOptions.length || !this.cityName) return
const found = this.cityOptions.find(item => item.cityName === this.cityName)
if (found) {
this.goodCityId = found.id || found.cityId || this.goodCityId
}
},
goCity() { goCity() {
uni.navigateTo({ uni.navigateTo({
url: `/pages/chose-city/chose-city?type=2&city=${this.cityName}` url: `/pages/chose-city/chose-city?type=2&city=${this.cityName}`
@@ -531,6 +561,24 @@ export default {
uni.hideLoading() uni.hideLoading()
}) })
}, },
fetchHotelBanner() {
if (!this.goodCityId) {
return
}
const params = {
goodCityId: this.goodCityId
}
getHotelBanner(params).then(res => {
const { success, data } = res
if (success && data) {
if (Array.isArray(data.hotelBanner)) {
this.hotelBanner = data.hotelBanner
} else if (Array.isArray(data)) {
this.hotelBanner = data
}
}
})
},
typeBannerItemClick(item) { typeBannerItemClick(item) {
if (!item.hotelId) return if (!item.hotelId) return
uni.navigateTo({ url: `/pagesInn/inn/innHome?id=${item.hotelId}` }) uni.navigateTo({ url: `/pagesInn/inn/innHome?id=${item.hotelId}` })