<template>
	<view >
		<swiper class="screen-swiper square-dot margin-sm" style="height: 260rpx;min-height: 268rpx;"
			:indicator-dots="true" :circular="true" :autoplay="true" interval="5000" duration="500">
			<swiper-item  v-for="(item,index) in adsList" :key="index">
				<u-image  @click="jump(item)" style="width: 100%;height: 268rpx;" :src="item.url"
					mode="aspectFill"></u-image>
			</swiper-item>
		</swiper>
		<goods :goodsList="goodsList" :activityId="activityId"></goods>
		<view style="height: 50rpx;">
			
		</view>
	</view>
</template>

<script>
	import goods from "@/components/goods/goods.vue"
	import {
		wx_launch
	} from "../../common/utils/wx_launch.js"; // 引入公共js文件
	export default {
		components: {
			goods
		},
		props: {
			activityId: {
				type: String,
				default: '',
			}
		},
		data() {
			return {
				goodsList: [],
				adsList: [],
				appletList: []
			}
		},
		created() {
			this.fetchGoodsList();
			this.fetchAds()
		},
		methods: {
			async fetchAds() {
				let res = await this.$u.api.pointsGoods.ads({
					activityId: this.activityId
				})
				this.adsList = res.records;
			},
			fetchGoodsList() {
				this.$u.api.pointsGoods.list({
					activityId: this.activityId
				}).then(res => {
					this.goodsList = res.records;
				})
			},
			jump(item) {
				if (item.type==0) {
					window.location.href=item.path
					return
				}
				uni.navigateTo({
					url: '/pages/web-view/web-view?url=' + item.path
				})
			}
		}
	}
</script>

<style>

</style>
