<template>
	<view class="picture">
		<view class="section" v-for="(item,index) in productList" :key="index" @click="navigaitionTo(item)">
			<image :src="item.adsImage" mode="widthFix"></image>
		</view>
	</view>
</template>

<script>
export default{
	data(){
		return{
			productList:[]
		}
	},
	props:{
		pageData: {
			type: Object
		},
		userIdentity: {
			type: Number
		},
		flag:{
			type:Boolean,
			default:false
		}
	},
	created() {
		this.initData(this.pageData);
	},
	watch: {
		pageData: {
			handler: function(el) {
				//监听对象的变换使用 function，箭头函数容易出现this指向不正确
				this.pageData = el
				this.initData(this.pageData)
			},
			deep: true
		}
	},
	methods:{
		initData(data){
			if(this.flag){
				this.productList = data.floorImageList;
			}else{
				this.productList = data.floorImageList.slice(0,2);
			}
			
		},
		navigaitionTo(item){
			console.log(item);
			if(item.link){
				uni.navigateTo({
					url:`/h5/pages/article/path?link=${item.link}`
				})
			}
		}
	}
}
</script>

<style lang="scss">
.picture{
	width: 100%;
	.section{
		margin-bottom: 24rpx;
		width: 702rpx;
		height: 360rpx;
		overflow: hidden;
		border-radius: 16rpx;
		image{
			width: 702rpx;
			height: 360rpx;
		}
		&:first-child{
			margin-top: 0;
		}
	}
}
</style>
