<template>
	<view class="content">
		<view class="good-list">
			<view class="good" v-for="item in list" @click="navTo('/pages/goods_details/index?id=' + (type == 1 ? item.product_id :item.product.id))" :style="{'height': type == 1 ? '450rpx': '500rpx'}">
				<image :src="type == 1?item.image : item.slider_image" mode="" class="good-image"></image>
				<view class="good-name ">
					<view class="clamp" v-if="type !=1">
						{{item.store_name}}
					</view>
					<view class="clamp" v-else>
						{{item.card_name}}
					</view>
				</view>
				<view class="time-wrap" v-if="type != 1">
					<view class="time" v-if="item.product.keyword">
						时间:{{item.product.keyword}}
					</view>
				</view>
				<view class="good-price">
					<view class="price" v-if="type != 1">
						￥{{item.product.price}}
					</view>
					<view class="price" v-else>
						￥{{item.card_price}}
					</view>
					<view class="xl" v-if="type != 1 &&item.product.ot_price*1 > item.product.price ">
						￥{{item.product.ot_price}}
					</view>
					<!-- <view class="xl" v-if="type == 1 && item.card_price ">
						￥{{item.card_price}}
					</view> -->
				</view>
			</view>
		</view>
		<view v-if="list.length == 0 && loadingType=='nomore'">
			<emptyPage title="暂无订单信息~"></emptyPage>
		</view>
	</view>
</template>

<script>
	import {
		getServeItem,
		getSeverCardList
	} from "@/api/store.js"
	import emptyPage from '@/components/emptyPage.vue';
	export default {
		components: {
			emptyPage
		},
		data() {
			return {
				list: [],
				type: 0,
				page: 1,
				limit: 100,
				loadingType: 'loadmore'
			}
		},
		onLoad(opt) {
			if (opt.type) {
				this.type = opt.type
			}
			
		},
		onShow() {
			this.getList()
		},
		onReachBottom() {
			// this.getList()
		},
		onReady() {

		},
		methods: {
			navTo(url) {
				uni.navigateTo({
					url
				});
			},
			getList() {
				let that = this;
				let getList;
				if (that.loadingType == 'loading' || that.loadingType == 'nomore') {
					return
				}
				that.loadingType = 'loading'
				if (that.type == 0) {
					getList = getServeItem
				}else {
					getList = getSeverCardList
				}
				getList({
					page: that.page,
					pageSize: that.limit,
					service_card_id: 0
				}).then(res => {
					console.log(res)
					let arr = res.data.list
					that.list = that.list.concat(arr)
					console.log(that.list)
					that.page++
					if (arr.length == that.limit) {
						that.loadingType = 'loadmore'
					} else {
						that.loadingType = 'nomore'
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.gq-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
		// justify-content: space-between;
		padding: 20rpx 0 20rpx 20rpx;
	}

	.gq-item {
		margin: 0 0 20rpx 14rpx;
		width: 227rpx;
		// height: 425rpx;
		background: #FFFFFF;
		box-shadow: 0px 5rpx 5rpx 0px rgba(35, 24, 21, 0.06);
		border-radius: 10rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-between;
		padding: 15rpx 14rpx;

		.gq-logo {
			width: 182rpx;
			height: 192rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			margin-bottom: 20rpx;

			image {
				width: 182rpx;
				height: 192rpx;
				background-color: #eee;
			}
		}

		.store-name {
			padding-top: 10rpx;
			text-align: center;
			width: 100%;
			font-size: 26rpx;
			font-weight: 500;
			color: #262261;
			overflow: hidden;
		}

		.info {
			width: 100%;
			display: flex;
			padding: 5rpx 0;

			.info-tit {
				font-size: 18rpx;
				flex-shrink: 0;
			}

			.info-val {
				flex-grow: 1;
				text-align: center;
				font-size: 20rpx;
				width: 140rpx;
				border-bottom: 1px #C7C7C7 solid;
			}
		}

	}

	.good-list {
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		padding: 20rpx 28rpx;

		.good {
			width: 336rpx;
			height: 500rpx;
			background: #FFFFFF;
			box-shadow: 0px 0px 6rpx 0px rgba(0, 0, 0, 0.1);
			border-radius: 14rpx;
			margin-bottom: 20rpx;
			position: relative;

			.good-image {
				width: 336rpx;
				height: 336rpx;
				background-color: #eee;
				border-radius: 14rpx 14rpx 0 0;
			}

			.good-name {
				font-size: 28rpx;
				font-weight: bold;
				color: #333333;
				padding: 0 20rpx;
			}

			.good-key {
				font-size: 22rpx;
				font-weight: 500;
				color: #999999;
				padding-left: 20rpx
			}

			.time {
				padding: 5rpx 10rpx;
				border: 1px solid #ff6973;
				color: #ff6973;
				display: inline-block;
				margin: 10rpx 0;
				margin-left: 20rpx;
			}

			.good-price {
				display: flex;
				width: 336rpx;
				justify-content: flex-start;
				align-items: flex-end;
				font-size: 28rpx;
				font-weight: bold;
				color: #ff6973;
				position: absolute;
				bottom: 20rpx;
				padding: 0 20rpx;

				.xl {
					padding-left: 10rpx;
					font-size: 20rpx;
					font-weight: bold;
					color: #999999;
					text-decoration: line-through;
				}
			}
		}
	}
	.clamp {
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
</style>