<template>
	<view class="content">
		<view class="good-list">
			<view class="good" v-for="item in list" @click="navTo('/pagesT/unit/itemdetail?id=' + item.id)">
				<image :src="item.image" mode="" class="good-image"></image>
				<view class="good-name ">
					<view class="clamp">
						{{item.name}}
					</view>
				</view>
				<!-- <view class="good-key">
					鸿运开来 为成功喝彩
				</view> -->
				<view class="time-wrap">
					<view class="time">
						时间:{{item.service_time}}分钟
					</view>
					
				</view>
				<view class="good-price">
					<view class="price">
						¥{{item.price}}
					</view>
					<view class="xl">
						<!-- 销量:{{item.sales}} -->
					</view>
				</view>
			</view>
		</view>
		<!-- <view class="gq-list">
			<view class="gq-item" v-for="item in list" @click="navTo('/pagesT/unit/itemdetail?id=' + item.id)">
				<view class="gq-logo">
					<image :src="item.image" mode="" class=""></image>
				</view>

				<view class="info">
					<view class="info-tit">
						名称:
					</view>
					<view class="info-val clamp">
						{{item.name}}
					</view>
				</view>
				<view class="info">
					<view class="info-tit">
						价格:
					</view>
					<view class="info-val clamp">
						{{item.price}}
					</view>
				</view>
				<view class="info">
					<view class="info-tit">
						服务时间:
					</view>
					<view class="info-val clamp">
						{{item.service_time}}分钟
					</view>
				</view>
				<view class="info">
					<view class="info-tit">
						可预约:
					</view>
					<view class="info-val clamp">
						是
					</view>
				</view>
				<view class="info">
					<view class="info-tit">
						可下单:
					</view>
					<view class="info-val clamp">
						是
					</view>
				</view>
			</view>
		</view> -->
		<u-loadmore :status="loadingType" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				type: '',
				page: 1,
				limit: 100,
				loadingType: 'loadmore'
			}
		},
		onLoad(opt) {
			this.getList()
		},
		onShow() {

		},
		onReachBottom() {
			this.getList()
		},
		onReady() {

		},
		methods: {
			navTo(url) {
				// console.log(this.hasLogin)
				// return
				if (!this.$store.state.hasLogin) {
					// #ifdef APP-PLUS
					uni.reLaunch({
						url: '/pagesT/public/wxLogin'
					});
					// #endif
					// #ifdef MP-WEIXIN
					uni.reLaunch({
						url: '/pagesT/binding/bindInfo'
					});
					//#endif
					// #ifdef H5
					uni.navigateTo({
						url: '/pagesT/public/wxLogin?loginType=2'
					});
					// #endif
				} else {
					uni.navigateTo({
						url
					});
				}
			},
			getList() {
				let that = this
				if (that.loadingType == 'loading' || that.loadingType == 'nomore') {
					return
				}
				that.loadingType = 'loading'
				this.$u.api.getItemList({
					page: that.page,
					pageSize: that.limit
				}).then(res => {
					console.log(res)
					that.list = that.list.concat(res.data)
					console.log(that.list)
					that.page++
					if (res.data.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: space-between;
				font-size: 28rpx;
				font-weight: bold;
				color: #ff6973;
				position: absolute;
				bottom: 20rpx;
				padding: 0 20rpx;

				.xl {
					font-size: 20rpx;
					font-weight: bold;
					color: #999999;
				}
			}
		}
	}
</style>