为了账号安全,请及时绑定邮箱和手机立即绑定

【备战春招】第11天首页拼团秒杀砍价促销活动组件开发

标签:
小程序

课程章节: 3-6 首页拼团秒杀砍价促销活动组件开发
课程讲师: CRMEB

课程内容:
1、首先创建拼团秒杀组件promotion.vue

<template>
	<view class="promotion">
		<view class="promotion-container">
			<view class="left">
				<navigator :url="list.imgList.list[0].info[3]" hover-class="none">
					<image :class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="list.imgList.list[0].img" mode=""></image>
				</navigator>
			</view>
			<view class="right">
				<navigator :url="list.imgList.list[1].info[3]" hover-class="none">
					<image :class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="list.imgList.list[1].img" mode=""></image>
				</navigator>
				<navigator :url="list.imgList.list[2].info[3]" hover-class="none">
					<image :class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="list.imgList.list[2].img" mode=""></image>
				</navigator>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			list: {
				type: Object,
				default: () => {}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.promotion {

		&-container {
			display: flex;
			height: 260rpx;
			padding: 30rpx;
			justify-content: space-between;
		}

		.left {
			image {
				width: 260rpx;
				height: 260rpx;
			}
		}

		.right {
			display: flex;
			flex-direction: column;
			justify-content: ;

			image {
				width: 416rpx;
				height: 124rpx;

			}
		}
	}
</style>

2、在index.vue中应用,再在comments 中注册,在template中使用,并获取数据

<template>
	<view class="home">
		<view class="home-container">
			<Banner :list='swiperData'></Banner>
			<SubCategory :list='menusData'></SubCategory>
			<Promotion :list="promotionData"></Promotion>
		</view>
	</view>
</template>

<script>
	import Banner from './components/Banner.vue'
	import SubCategory from '/components/SubCategory.vue';
	import Promotion from 'components/Promotion.vue'
	export default {
		comments:{
			Banner,
			SubCategory,
			Promotion
		},
		data(){
			return {
				swiperData:{},
				menusData:{},
				promotionData
			}
		},
		onLoad() {
			this._getHomeData()
		},
		methods:{
			async _getHomeData(){
				const {status,data,msg} = await homeDataApi()
				if(status === this.API_STATUS_CODE.SUCCESS){
					console.log(status,data,msg)
					this.swiperData = data.swiperBg.default
					this.menusData = data.menus.default
					this.promotionData = data.activity.default
					
					app._initTabBar(data.tabBar.default)
				}else{
					uni.showToast({
						icon:'none',
						title:'首页数据获取失败,请刷新重试',
						duration:3000
					})
				}
			}
		}
	}
</script>

<style>
</style>
点击查看更多内容
1人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消