<template>

	<view style="display: flex;flex-direction: column;">

		<view class="top">

			<view class="btn" @click="bind">
				<image src="@/static/binding.png" style="width: 20px;height: 20px;"></image>
				<text
					style="line-height: 35px;font-size: 18px; text-align: center;color: #FE6B00;margin-left: 10px;">绑定新卡</text>
			</view>

		</view>

		<view style="display: flex;flex-direction: column;
				background-color: #fff;
				height: 50vh; z-index: 100;
				border-top-left-radius: 25px;border-top-right-radius: 25px;margin-top: -20px;">
			<z-paging ref="paging" use-page-scroll v-model="data" @query="queryList" :auto='true' hight="30px"
				:autoHeight='false'>



				<view v-for="(item,index) in data" :key="index"
					style="display: flex;flex-direction: column;align-items: center;margin-top: 10px; "
					:class="item.showBtn==true?'oragin':'gray'" @click="detail(item)">


					<!-- 	<view
						style="display: flex;flex-direction: column;border:  1px solid #e29a68;width: 90%;border-radius: 20rpx;margin-top: 8px;">

						<view class="use">
							<image style="width: 70rpx;height: 70rpx;position: absolute;right: 40px;"
								src="../../static/card_line.png"></image>
							<image src="../../static/gift.png" style="width: 30px;height: 30px;padding-left: 6px;">
							</image>
							<view style="flex: 1;display: flex;flex-direction: column;z-index: 1;">
								<view style="font-size: 14px;padding: 2px;padding-left: 5px;padding-top: 7px;">
									{{item.name}}
								</view>
								<view style="font-size: 12px;padding-left: 5px;padding-bottom: 6px;">{{item.time}}
								</view>
							</view>

							<view v-if="item.showBtn" @click.stop="booking(item.sid)"
								style="flex-shrink: 0;padding: 9px;font-size: 13px;z-index: 1;font-weight: 600;">预约提货
							</view>
						</view>
						<view
							style="width: 100%;text-align: center;padding-top: 20px;border-bottom-left-radius: 20rpx;border-bottom-right-radius: 20rpx;background-color: #fdf0ee;">
							<view style="font-size: 16px;color: red;">{{item.pname}}</view>
							<view class="bottom"
								style="padding-bottom: 10px;border-bottom-left-radius: 10px;border-bottom-right-radius: 10px;font-size: 12px;margin-top: 10px;color: #666;width: 100%;">
								{{item.state}}
							</view>
						</view>
					</view> -->


					<view class="item" :class="{ item2: !item.showBtn }"
						style="display: flex;flex-direction: row;width: 85%; margin-left: 10px; margin-right: 10px;  padding: 16px; ">

						<view style="display: flex;flex-direction: row; align-items: center; flex: 1;">

							<image src="@/static/pack.png" mode="aspectFill" v-show="item.showBtn"
								style="width: 50px;height: 50px;margin-right: 10px;" />
								
								<image src="@/static/pack2.png" mode="aspectFill"  v-show="!item.showBtn"
									style="width: 50px;height: 50px;margin-right: 10px;" />

							<view style="display: flex;flex-direction: column;margin-right: 10px; ">

								<text style="font-size: 12px;color: #333;"> {{item.name}}</text>
								<text style="font-size: 12px;color: #999;margin-top: 5px;"> {{item.time}}</text>

								<view style="display: flex;flex-direction: row;align-items: center;margin-top: 5px;">
									<text style="font-size: 12px;color: #FF7100;"> {{item.pname}}</text>
									<text
										style="border: 1px #FED4B3 solid;margin-left: 10px;border-radius: 15px;padding:  3px 10px; font-size: 13px; color: #FF6000;">
										{{item.state}}</text>

								</view>
							</view>

						</view>
						<view style="font-size: 12px;color:#fff;
							border-radius: 15px; height: 18px;padding: 3px 8px;
						 background: -webkit-linear-gradient(left,#FF7405,#FFAD6D);">预约提货</view>
					</view>


				</view>

			</z-paging>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				page: {
					remarks: ''
				},
				data: [],
			}
		},
		onLoad() {
			uni.$on("order", (e) => {
				// 相当与下拉刷新
				this.$refs.paging.reload(true);
			})

		},
		onUnload() {
			uni.$off('order');
		},
		methods: {
			// 分页的请求
			queryList(pageNo, pageSize) {
				let _this = this
				_this.$api.cardList({
					"current": pageNo,
					"size": pageSize,
					"params": {
						"customerSid": getApp().globalData.sid
					}
				}).then((resp) => {
					// 添加数据源
					this.$refs.paging.complete(resp.records)
				}).catch(e => {
					// 出错了，点击重试
					_this.$refs.paging.complete(false);
				})
			},
			dialogInputConfirm(val) {
				// 网络请求 绑定
			},
			bind() {
				uni.navigateTo({
					url: '/pages/card/card_bind'
				})
			},
			detail(item) {

				if (item.state == '失效') {
					// 记录
					uni.navigateTo({
						url: '/pages/card/card_record?sid=' + item.sid
					})
				} else {
					// 详情
					uni.navigateTo({
						url: '/pages/card/card_detail?sid=' + item.sid
					})
				}

			},
			booking(sid) {
				uni.navigateTo({
					url: '/pages/card/card_booking?sid=' + sid
				})
			}
		}
	}
</script>

<style>
	.top {
		width: 100%;
		height: 60vh;
		/* 加载背景图 */
		background-image: url(../../static/OIP-C.jpg);
		/* 让背景图基于容器大小伸缩 */
		background-size: cover;
	}

	.btn {
		margin-top: 45vh;
		width: 83%;
		margin-left: 30px;
		margin-right: 30px;
		background-color: #FFF;
		border-radius: 20px;
		display: flex;
		height: 40px;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}

	.item {
		/* 加载背景图 */
		background-image: url(../../static/card_item.png);
		/* 让背景图基于容器大小伸缩 */
		background-size: cover;
	}
	
	.item2 {
		/* 加载背景图 */
		background-image: url(../../static/card_item2.png);
		/* 让背景图基于容器大小伸缩 */
		background-size: cover;
	}

	.use {
		display: flex;
		flex-direction: row;
		border-top-left-radius: 20rpx;
		border-top-right-radius: 20rpx;
		color: #FFF;
		align-items: center;
		background: linear-gradient(89.8deg, rgba(218, 51, 33, 1) -3.76%, rgba(237, 113, 53, 0) 300.05%);
	}

	.gray {
		filter: grayscale(100%);
		-webkit-filter: grayscale(100%);
		transition: filter 0.2s;
	}

	.bottom {
		/* 加载背景图 */
		background-image: url(../../static/card_bg1.png);
		/* 让背景图基于容器大小伸缩 */
		background-size: cover;
	}

	.oragin {}

	uni-page-body,
	page {
		background: #FFFFFF;
	}
</style>