Feat(首页):尖货专题对接完成

This commit is contained in:
lifizer
2024-08-02 23:21:02 +08:00
parent 52b75d0bd3
commit 39ae37b484
3 changed files with 82 additions and 29 deletions
+7
View File
@@ -85,6 +85,13 @@ export function getFestival() {
return request.get('/contentFestival', {}, {login: false})
}
/**
* 尖货专题
* */
export function getContentBest(id) {
return request.get(`/contentBest/${id}`, {}, {login: false})
}
/*
* 非遗文化
* */
+32 -17
View File
@@ -187,7 +187,7 @@
:key="swiperIndex"
>
<image
:src="swiperItem.image"
:src="swiperItem.indexImage"
mode="scaleToFill"
class="swiper-img"
@click="productSwiperItemClickHandle(swiperItem)"
@@ -373,6 +373,7 @@ export default {
_this.bastRightList = []
for (let i = 0; i < data.bastList.length; i++) {
if (i % 2 === 0) {
// 店铺排名
if (i === 4 && data.hotelList.length > 0) {
_this.bastLeftList.push({
type: 'hotel',
@@ -382,23 +383,11 @@ export default {
_this.bastLeftList.push(data.bastList[i])
}
if (i % 2 === 1) {
if (i === 3) {
// 尖货专题
if (i === 3 && data.contentBest.length > 0) {
_this.bastRightList.push({
type: 'swiper',
list: [
{
image: 'http://resource.xdd618.com/19/20240722/1721615384602_入口图8.jpg',
id: 5781
},
{
image: 'http://resource.xdd618.com/19/20240715/1721006994007_微信图片_20240715092549.jpg',
id: 5781
},
{
image: 'http://resource.xdd618.com/19/20240722/1721615384602_入口图8.jpg',
id: 5781
}
]
list: data.contentBest
})
}
_this.bastRightList.push(data.bastList[i])
@@ -428,6 +417,7 @@ export default {
changeOldPopup(state) {
this.isOldUser = state
},
// 民宿专题
goHomeStay(stay) {
if (stay.uniappUrl) {
this.$global.commonJump(stay.uniappUrl)
@@ -446,6 +436,7 @@ export default {
uni.navigateTo({url: '/pkg_product/views/homestay?id=' + stay.id})
}
},
// 节日专题
goFestival() {
uni.navigateTo({url: '/pkg_product/views/festival'})
},
@@ -487,6 +478,7 @@ export default {
this.$global.levelJump(pageLevel, url, params)
}
},
// 千县名品和地标好物
landAndFamousItemClickHandle(item) {
const url = item.url
if (!url) return
@@ -497,11 +489,34 @@ export default {
uni.navigateTo({ url })
}
},
// 店铺排名
hotelItemClickHandle(item) {
uni.navigateTo({ url: `/pagesInn/inn/innHome?id=${item.id}&from=index` })
},
// 尖货专题
productSwiperItemClickHandle(item) {
uni.navigateTo({url: '/pkg_product/views/homestay?id=' + item.id})
// 类型:1-专题页 2-商品详情 3-时令尝鲜
const type = item.type
if (type === 1) {
uni.navigateTo({ url: `/pkg_product/views/festival?id=${item.id}&from=index&theme=best` })
}
// 链接到特定页面
if (type === 2 && item.uniappUrl) {
this.$global.commonJump(stay.uniappUrl)
return
}
// 商品详情
if (type === 2 && item.productId) {
this.$yrouter.push({
path: '/pages/shop/GoodsCon/index',
query: {
id: item.productId
}
})
}
if (type === 3) {
uni.navigateTo({ url: '/pkg_product/views/seasonList' })
}
},
setTopHandle() {
uni.pageScrollTo({
+43 -12
View File
@@ -16,7 +16,7 @@
mode="widthFix"
/>
<view
v-for="(content,cIndex) in contents"
v-for="(content, cIndex) in contents"
:key="cIndex"
class="section"
>
@@ -35,7 +35,7 @@
:class="cIndex === 0 ? 'span12' : 'span8'"
:src="item.image"
mode="scaleToFill"
@click="goGoods(item.id)"
@click="goGoods(item.id || item.linkId)"
/>
</view>
</view>
@@ -44,8 +44,11 @@
</view>
</template>
<script>
// 节日专题
import { getFestival } from '@/api/product'
/**
* 节日专题&尖货推荐初始模板
* options.theme:best-尖货,''-节日
*/
import { getFestival, getContentBest } from '@/api/product'
import { pageListenMixins } from '@/mixins/pageListenMixins'
export default {
name: 'FestivalPage',
@@ -54,16 +57,44 @@ export default {
return {
isLoad: false,
topImage: '',
contents: [],
pageKeyId: Object.freeze('appContentFestival')
contents: {},
pageKeyId: ''
}
},
onLoad() {
getFestival().then(({data}) => {
this.isLoad = true
this.topImage = data.topImage
this.contents = data.contents
})
onLoad(options) {
const theme = options.theme || ''
const id = options.id
// 尖货
if (theme === 'best') {
this.pageKeyId = `appContentBest_id_${id}`
getContentBest(id).then(({data}) => {
this.isLoad = true
const contents = []
if (data.templateProperties) {
const temp = data.templateProperties
// 第一页图片
this.topImage = temp.page1Image
// 第二页数据
contents.push({
backgroundImage: temp.page2BackgroundImage,
products: temp.page2Links
})
// 第三页数据
contents.push({
backgroundImage: temp.page3BackgroundImage,
products: temp.page3Links
})
}
this.contents = contents
})
} else {
this.pageKeyId = 'appContentFestival'
getFestival().then(({data}) => {
this.isLoad = true
this.topImage = data.topImage
this.contents = data.contents
})
}
},
methods: {
goGoods(id) {