<template name="recommend">
	<!-- 供应商信息 -->
	<view class="recommend clearfix">
		<view class="recommend-empty" v-if="isEmpty">暂无相关推荐商品</view>
		<view class="recommend-list" v-else>
			<view class="row-list" v-for="(pros, idx) in recommendList" :key="idx" @click.stop="navToDetailPage(pros.id)">
				<view class="list-image"><image :src="pros.image" mode=""></image></view>
				<view class="list-name">{{pros.name}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapState,mapMutations} from 'vuex';
	import authorize from '@/common/authorize.js'
	
	export default{
		name:'recommend',
		props:{
			queryProductid: {
				type: Number,
				default: 0
			},
			queryType:{
				type: String,
				default: '0'
			}
		},
		data() {
			return{
				current:0,
				recommendList:[],
				isEmpty:false,
				pageSize:4,
				productID:'',
			}
		},
		created() {
			this.productID = this.queryProductid
			this.infoRecommend(this.queryProductid,this.queryType)
		},
		computed: {
			...mapState(['identity'])
		},
		methods:{
			infoRecommend(id,type){
				this.ProductService.queryProductDetilsRelevant({ productId:id,recommendType:type ? type : 0,identity:this.identity }).then(response =>{
					if( response.data && response.data.length > 0){
						this.isEmpty = false
						this.recommendList = response.data
					}else{
						this.isEmpty = true
					}
				}).catch(error =>{
					this.$util.msg(error.msg,2000)
				})
			},
			//轮播图切换修改背景色
			swiperChange(e) {
				const index = e.detail.current;
				this.current = index;
			},
			navToDetailPage(id) {//跳转商品详情页
				this.$api.navigateTo(`/pages/goods/product?id=${id}`)
			}
		}
	}
</script>

<style lang="scss">	
.recommend{
	background: #F7F7F7;
	width: 100%;
	.recommend-empty{
		width: 702rpx;
		height: 100rpx;
		line-height: 100rpx;
		padding: 0 24rpx;
		font-size: $font-size-28;
		color: #999999;
		text-align: center;
	}
	.recommend-list{
		width: 100%;
		height: auto;
		position: relative;
		box-sizing: border-box;
		padding: 0rpx 24rpx;
		.row-list{
			width: 340rpx;
			height: auto;
			float: left;
			margin-right: 20rpx;
			margin-bottom: 20rpx;
			border-radius: 20rpx;
			background: #FFFFFF;
			&:nth-child(2n){
				margin-right: 0;
			}
			.list-image{
				width: 100%;
				height: 340rpx;
				border-radius: 20rpx 20rpx 0 0;
				image{
					width: 100%;
					height: 340rpx;
					border-radius: 20rpx 20rpx 0 0;
				}
			}	
			.list-name{
				font-size: $font-size-28;
				color: $text-color;
				line-height:88rpx;
				padding: 0 10rpx;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}
		}
	}
	.swiper__recommenddots-box{
		position: absolute;
		bottom: -20rpx;
		left: 0;
		right: 0;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex: 1;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		height: 60rpx;
		background: #FFFFFF;
		.swiper__dots-item{
			width: 8rpx;
			height: 8rpx;
			border-radius: 100%;
			margin-left: 6px;
			background-color:rgba(0,0,0,.3);
		}
		.swiper__dots-long{
			width: 32rpx;
			height: 8rpx;
			border-radius: 4rpx;
			background-color: #000;
			transition: all 0.4s;
		}
	}
}
</style>





















