<template>

	<z-paging ref="paging" v-model="data" @query="queryList" :auto='true'>

		<view @click="bind"
			style="background: #f1f2f3;width: 100%;height: 35px;line-height: 35px;text-align: center;color: red;">
			绑定新卡</view>

		<view style="display: flex;flex-direction: column;padding-top: 10px;">

			<view v-for="(item,index) in data" style="display: flex;flex-direction: column;align-items: center;"
				:class="item.showBtn==true?'oragin':'gray'" @click="detail(item.sid)">
				<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>

			<uni-popup ref="inputDialog" type="dialog">
				<uni-popup-dialog ref="inputClose" mode="input" title="绑定新卡" :value="page.remarks" placeholder="请输入卡号"
					@confirm="dialogInputConfirm"></uni-popup-dialog>
			</uni-popup>
		</view>

	</z-paging>

</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) {
				console.log(pageNo);
				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() {
				this.$refs.inputDialog.open()
			},
			detail(sid) {
				uni.navigateTo({
					url: '/pages/card/card_detail?sid=' + sid
				})
			},
			booking(sid) {
				uni.navigateTo({
					url: '/pages/card/card_booking?sid=' + sid
				})
			}
		}
	}
</script>

<style>
	.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>