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
+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) {