<template>
	<view
		style="padding: 12px; padding-bottom: 0;"
		:style="{
			'background-color': goodsInfo.backgroundColor,
			'background-image': goodsInfo.backgroundPicUrl,
			'border-color': goodsInfo.goodsStyle == 2 ? 'rgb(226, 226, 226)' : ''
		}"
	>
		<u-row gutter="24">
			<u-col span="6" v-for="(item, gli) in goodList" :key="gli">
				<view
					class="good-two"
					@click="openGood(item)"
					:style="{
						border: goodsInfo.goodsStyle == 2 ? '1px solid rgb(226, 226, 226)' : '',
						background: goodsInfo.goodsStyle == 1 || goodsInfo.goodsStyle == 2 ? '#FFF' : ''
					}"
				>
					<!-- <view class="tips" v-if="goodsInfo.showGoodsTag"><image :src="goodsInfo.goodsTagPicUrl" mode="widthFix" style="width:100%" /></view> -->
					<view class="img-box">
						<view class="img-show">
							<image
								style="
									  width: 100%;
									  height: 100%;
									  border-radius: 10rpx 10rpx 0 0;
									"
								mode="aspectFill"
								:src="item.picUrl"
							/>
						</view>
					</view>
					<view class="good-info" v-if="imgModel==false">
						<view class="good-name" v-if="goodsInfo.showGoodsName">{{ item.name }}</view>
						<view class="good-price-info"  v-if="goodsInfo.showsubtitle">
							<span class="price" >{{ item.subtitle }}</span>
							
						</view>
					</view>
				</view>
			</u-col>
		</u-row>
		<auth v-if="showAuth" @changeuserinfo="reloadUserinfo" @gbAuth="gbAuth"></auth>
	</view>
</template>
<script>

import auth from '@/components/auth/index.vue';
export default {
	components: {
		auth
	},
	props: ['goodList', 'goodsInfo'],
	data() {
		return {
			mainColor: '',
			activeKey: 0,
			showSku: false,
			showAuth: false,
			u: {},
			imgModel:false
		};
	},
	created() {
		this.mainColor = this.$uiConfig.mainColor;
		if(this.goodsInfo.showGoodsName==false && this.goodsInfo.showsubtitle ==false){
			this.imgModel=true
		}
	},
	methods: {
		openGood(item) {
			
			this.u = uni.getStorageSync('mall_UserInfo');
			if (!this.u) {
				this.u = {
					nickName: '未登录',
					avatarUrl: ''
				};
				this.showAuth = true;
			} else {
				uni.navigateTo({ url: '/pages/school/courseList?GoodsId=' + item.id });
				// uni.navigateTo({ url: '/pages/school/articleList' });
			}
		},
		reloadUserinfo() {
			this.u = uni.getStorageSync('mall_UserInfo');
			// this.showAuth = false;
		},
		//关闭登录窗口
		gbAuth() {
			this.showAuth = false;
		}
	}
};
</script>

<style>
.good-two {
	position: relative;
	margin-bottom: 12px;
	border: 1rpx solid transparent;
	border-radius: 10rpx;
	overflow: hidden;
	/* padding-bottom: 10rpx; */
}
.good-two .tips {
	width: 64rpx;
	height: 64rpx;
	position: absolute;
	top: 0;
	left: 0;
	z-index: 4;
}
.good-two .img-box {
	width: 100%;
	height: 0;
	padding-top: 54%;
	position: relative;
}
.good-two .img-box .img-show {
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	right: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}
.good-two .guding {
	position: relative;
}
.good-two .guding .img-box {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	top: 0;
}
.good-two .good-info {
	padding: 6rpx;
	margin-top: -5px;
	padding-bottom: 0;
}
.good-two .good-info .good-name {
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	margin: 3px 0;
	font-size: 13px;
	height: 37px;
}
.good-two .good-info .good-price-info {
	display: flex;
}
.good-two .good-info .good-price-info .price {
	color: #999999;
	/* flex: 1; */
	font-size: 11px;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
}
.good-two .good-info .good-price-info .buy {
	width: 24px;
	text-align: right;
}
</style>
