<template>
	<div class="module-item-goods" :style="!module.base.m ? 'margin-top:0' : ''" v-if="shopList.length>0">
		<div class="item-goods-con" :style="style">
			<moduleBg :base="module.base" />
			<moduleTwtit :type="module.type" :title="module.title" v-if="module.title.s" />
			<div class="item-goods-style1 style2" :class="module.base.s == 1 ? 'style2' : ''">
				<div class="item" v-for="(item, index) in shopList" :key="index"
					@click="$util.openYyGoods(shopList,index)">
					<div class="pic">
						<img :src="url+item.thumb" alt="" />
					</div>
					<div class="c" style="padding: 0 5px;">
						<div class="tit" v-if="module.base.t.s">
							<moduleText :text="module.base.t" :name="item.name" />
						</div>
						<div class="price" v-if="module.base.sjg || module.base.sgm">
							<template v-if="module.base.sjg">
								<span>
									<b>￥{{ item.price }}</b>
								</span>
								<span v-if="item.type == 2">
									<b>{{ item.priceDescribe }}</b>
								</span>
							</template>
							<template v-if="module.base.sgm">
								<!-- <button >预约</button>  -->
								<button class="yy_button flex-center" size="mini" type="danger">预约</button>
							</template>
						</div>
					</div>
				</div>
				<div class="noadd" v-if="shopList.length == 0">
					暂无预约商品
				</div>
			</div>
		</div>
	</div>
</template>
<script>
	import moduleBg from './bg.vue';
	import moduleText from './text.vue';
	import moduleTwtit from './twtit.vue';
	export default {
		props: ['module'],
		components: {
			moduleBg,
			moduleText,
			moduleTwtit
		},
		data() {
			return {
				url: getApp().globalData.URL,
				shopList: [],
			};
		},

		computed: {
			style() {
				if (this.module.base.fc != '') {
					return `color:${this.module.base.fc}`;
				}
			}
		},

		mounted() {
			this.getGoodsList();
		},

		methods: {
			//获取商品列表
			getGoodsList() {
				var shopList = [];
				// console.log(this.module, "获取商品列表")
				this.$http.request('template/yygoods_lists', {
					store_id: this.$store.state.store_id,
					controller: "admin",
					page: 1,
					limit: 6,
				}, "", "", "").then(t => {
					if (t.code == 200) {
						for (let i of t.data) {
							shopList.push({
								name: i.name,
								price: i.price,
								thumb: i.cover_pic,
								id: i.id
							})
						}
						this.module.list = shopList;
						this.shopList= shopList;
					} else {
						this.shopList= [];
						this.module.list = shopList;	
					}
				})
			},
		},
	};
</script>

<style>
	@import url("./goods.css");
	.yy_button{
		color: #FFF;border-radius: 40px;background-color: #F56C6C; border-color: #F56C6C;
	}
	
	.module-item-goods {
		margin-top: 10px;
	}

	.scroll-true {
		white-space: nowrap;
		overflow-x: auto;
	}

	.scroll-true .item {
		display: inline-block;
		width: 30%;
		margin-right: 10px;
	}

	.el-scrollbar__wrap {
		overflow-y: hidden;
	}

	.pic_img {
		width: 106px;
		height: 106px;
	}

	.item-goods-style1 {
		position: relative;
		padding: 20rpx 0;
	}

	.noadd {
		position: relative;
		color: #999;
	}
</style>
