<template>

	<view style="display: flex;flex-direction: column;height: 100vh;background: -webkit-linear-gradient(left,#FEA65F,#FB9440);">

		<view class="top">
			<NavBar ref="nav" navTitle=" " :showIcon="false" :start-change-height="page.startHeight"
				:end-change-height="page.endHeight">
			</NavBar>
			<view style="display: flex;flex-direction: row;">
				<!-- <view class="btn" @click="bind">
					<image src="https://supervise.yxtsoft.com/lpk/image/binding.png" style="width: 20px;height: 20px;">
					</image>
					<text
						style="height: 45px;line-height: 45px;font-size: 17px;font-weight: 600; text-align: center;color: #FF7100;margin-left: 11px;">绑定新卡</text>
				</view> -->
				<view style="flex: 1;"></view>
				<!-- <text style="color: #fff;margin-top: 60vw; margin-right: 25px;" @click="bind">绑定新卡</text> -->
				<image @click="bind" src="https://supervise.yxtsoft.com/lpk/image/bind2.png"
					style="margin-top: 60vw; margin-right: 25px;width: 20px;height: 20px;">
				</image>
			</view>


		</view>

		<!-- <view
			style="display: flex;flex-direction: column;background: #f0f; height: auto; border-top-left-radius: 25px;border-top-right-radius: 25px;margin-top: -9.1vw;"> -->
		<z-paging ref="paging" v-model="data" :pagingStyle='styleObject' @query="queryList" :refresher-enabled="true" :auto="false">

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

				<!-- 家庭卡-->
				<view v-show="item.type=='1'">

					<view class="item" :class="{ item2: !item.showBtn }">

						<!-- 外边 18px 内边 32px = 50px -->
						<view
							style="padding: 16px;display: flex;flex-direction: row;width: 100%;box-sizing: border-box;">

							<!-- 礼包图标 总60px -->
							<view style="flex-shrink: 0;">
								<image src="https://supervise.yxtsoft.com/lpk/image/home_family.png" mode="aspectFill"
									v-show="item.showBtn" style="width: 50px;height: 50px;margin-right: 10px;" />

								<image src="https://supervise.yxtsoft.com/lpk/image/home_notFamily.png"
									mode="aspectFill" v-show="!item.showBtn"
									style="width: 50px;height: 50px;margin-right: 10px;" />
							</view>

							<view
								style="flex: 1;display: flex;flex-direction: column;box-sizing: border-box;flex-wrap: nowrap;">

								<view style="width: 100%;display: flex;flex-direction: row;">

									<view style="flex: 1;display: flex;flex-direction: column;">
										<text class="_ellipsis"
											style="font-size: 13px;color: #333;width: calc(100vw - 190px);">窖号:{{item.serialNumber}}</text>
										<text lass="_ellipsis"
											style="font-size: 12px;color: #999;margin-top: 5px;width: calc(100vw - 182px);">
											{{item.time}}</text>
									</view>

									<!-- 按钮 24 + 48 = 72px-->
									<view :class="{ showBtn: !item.showBtn }" style="font-size: 12px;color:#fff;flex-shrink: 0;
													border-radius: 15px; height: 30px;padding: 0px 12px;line-height: 30px;box-sizing: border-box;
												 background: -webkit-linear-gradient(left,#FF7405,#FFAD6D);">预约提货</view>
								</view>

								<!-- 蔬菜礼包经典款+状态 -->
								<view style="display: flex;flex-direction: row;align-items: center;margin-top: 5px;">
									<text style="font-size: 15px;color: #FF7100;flex: 1;"> {{item.pname}}</text>
									<text
										style="margin-left: 10px;border-radius: 15px;padding:  3px 10px; font-size: 12px; color: #FF6000;flex-shrink: 0;">
										{{item.state}}</text>
								</view>

								<view v-if="item.list.length>0">
									<view style="height: 10px;"></view>

									<view v-for="(child,pos) in item.list" :key="pos"
										style="display: flex;flex-direction: row;align-items: center;width: calc(100vw - 120px);padding-top: 5px;box-sizing: border-box;">
										<image src="../../static/tck_mx_icon.png" style="width: 9px;height: 9px;">
										</image>
										<view
											style="font-size: 11px;color: #E99D42;padding-left: 5px;flex: 1;overflow: hidden;text-overflow: ellipsis;white-space: nowrap">
											{{child.goodsName}}
										</view>
										<view style="font-size: 11px;color: #E99D42;flex-shrink: 0;margin-left: 23px;">
											{{child.content}}
										</view>
										<view style="font-size: 11px;color: #E99D42;min-width: 60px;text-align: right;padding-left: 5px;">
											{{child.remarks}}
										</view>
									</view>
								</view>

							</view>

						</view>

					</view>

				</view>

				<!-- 亲情卡-->
				<view v-show="item.type=='2'">

					<view class="item3" :class="{ item4: !item.showBtn }">

						<!-- 外边 18px 内边 32px = 50px -->
						<view
							style="padding: 16px;display: flex;flex-direction: row;width: 100%;box-sizing: border-box;">

							<!-- 礼包图标 总60px -->
							<view style="flex-shrink: 0;">
								<image src="https://supervise.yxtsoft.com/lpk/image/home_affection.png"
									mode="aspectFill" v-show="item.showBtn"
									style="width: 50px;height: 50px;margin-right: 10px;" />

								<image src="https://supervise.yxtsoft.com/lpk/image/home_notAffection.png"
									mode="aspectFill" v-show="!item.showBtn"
									style="width: 50px;height: 50px;margin-right: 10px;" />
							</view>

							<view
								style="flex: 1;display: flex;flex-direction: column;box-sizing: border-box;flex-wrap: nowrap;">

								<view style="width: 100%;display: flex;flex-direction: row;">

									<view style="flex: 1;display: flex;flex-direction: column;">
										<text class="_ellipsis"
											style="font-size: 13px;color: #333;width: calc(100vw - 190px);">窖号:{{item.serialNumber}}</text>
										<text lass="_ellipsis"
											style="font-size: 12px;color: #999;margin-top: 5px;width: calc(100vw - 182px);">
											{{item.time}}</text>
									</view>

									<!-- 按钮 24 + 48 = 72px-->
									<view :class="{ showBtn: !item.showBtn }" style="font-size: 12px;color:#fff;flex-shrink: 0;
													border-radius: 15px; height: 30px;padding: 0px 12px;line-height: 30px;box-sizing: border-box;
												 background: -webkit-linear-gradient(left,#FF7405,#FFAD6D);">预约提货</view>
								</view>

								<!-- 蔬菜礼包经典款+状态 -->
								<view style="display: flex;flex-direction: row;align-items: center;margin-top: 5px;">
									<text style="font-size: 15px;color: #FF7100;flex: 1;"> {{item.pname}}</text>
									<text
										style="margin-left: 10px;border-radius: 15px;padding:  3px 10px; font-size: 12px; color: #FF6000;flex-shrink: 0;">
										{{item.state}}</text>
								</view>

								<view v-if="item.list.length>0">
									<view style="height: 10px;"></view>

									<view v-for="(child,pos) in item.list" :key="pos"
										style="display: flex;flex-direction: row;align-items: center;width: calc(100vw - 120px);padding-top: 5px;box-sizing: border-box;">
										<image src="../../static/tck_mx_icon.png" style="width: 9px;height: 9px;">
										</image>
										<view
											style="font-size: 11px;color: #E99D42;padding-left: 5px;flex: 1;overflow: hidden;text-overflow: ellipsis;white-space: nowrap">
											{{child.goodsName}}
										</view>
										<view style="font-size: 11px;color: #E99D42;flex-shrink: 0;margin-left: 23px;">
											{{child.content}}
										</view>
										<view style="font-size: 11px;color: #E99D42;min-width: 60px;text-align: right;padding-left: 5px;">
											{{child.remarks}}
										</view>
									</view>
								</view>


							</view>

						</view>

					</view>

				</view>


				<!-- 企业卡-->
				<view v-show="item.type=='3'">

					<view class="item5" :class="{ item6: !item.showBtn }">

						<!-- 外边 18px 内边 32px = 50px -->
						<view
							style="padding: 16px;display: flex;flex-direction: row;width: 100%;box-sizing: border-box;">

							<!-- 礼包图标 总60px -->
							<view style="flex-shrink: 0;">
								<image src="https://supervise.yxtsoft.com/lpk/image/home_enterprise.png"
									mode="aspectFill" v-show="item.showBtn"
									style="width: 50px;height: 50px;margin-right: 10px;" />

								<image src="https://supervise.yxtsoft.com/lpk/image/home_notEnterprise.png"
									mode="aspectFill" v-show="!item.showBtn"
									style="width: 50px;height: 50px;margin-right: 10px;" />
							</view>

							<view
								style="flex: 1;display: flex;flex-direction: column;box-sizing: border-box;flex-wrap: nowrap;">

								<view style="width: 100%;display: flex;flex-direction: row;">

									<view style="flex: 1;display: flex;flex-direction: column;">
										<text class="_ellipsis"
											style="font-size: 13px;color: #333;width: calc(100vw - 190px);">窖号:{{item.serialNumber}}</text>
										<text lass="_ellipsis"
											style="font-size: 12px;color: #999;margin-top: 5px;width: calc(100vw - 182px);">
											{{item.time}}</text>
									</view>

									<!-- 按钮 24 + 48 = 72px-->
									<view :class="{ showBtn: !item.showBtn }" style="font-size: 12px;color:#fff;flex-shrink: 0;
													border-radius: 15px; height: 30px;padding: 0px 12px;line-height: 30px;box-sizing: border-box;
												 background: -webkit-linear-gradient(left,#FF7405,#FFAD6D);">预约提货</view>
								</view>

								<!-- 蔬菜礼包经典款+状态 -->
								<view style="display: flex;flex-direction: row;align-items: center;margin-top: 5px;">
									<text style="font-size: 15px;color: #FF7100;flex: 1;"> {{item.pname}}</text>
									<text
										style="margin-left: 10px;border-radius: 15px;padding:  3px 10px; font-size: 12px; color: #FF6000;flex-shrink: 0;">
										{{item.state}}</text>
								</view>
								<view v-if="item.list.length>0">
									<view style="height: 10px;"></view>

									<view v-for="(child,pos) in item.list" :key="pos"
										style="display: flex;flex-direction: row;align-items: center;width: calc(100vw - 120px);padding-top: 5px;box-sizing: border-box;">
										<image src="../../static/tck_mx_icon.png" style="width: 9px;height: 9px;">
										</image>
										<view
											style="font-size: 11px;color: #E99D42;padding-left: 5px;flex: 1;overflow: hidden;text-overflow: ellipsis;white-space: nowrap">
											{{child.goodsName}}
										</view>
										<view style="font-size: 11px;color: #E99D42;flex-shrink: 0;margin-left: 23px;">
											{{child.content}}
										</view>
										<view style="font-size: 11px;color: #E99D42;min-width: 60px;text-align: right;padding-left: 5px;">
											{{child.remarks}}
										</view>
									</view>
								</view>

							</view>

						</view>

					</view>

				</view>

			</view>
		</z-paging>

		<!-- </view> -->
	</view>

</template>

<script>
	export default {
		data() {
			return {
				styleObject: {
					'margin-top': '68vw',
					'border-top-left-radius': '25px',
					'border-top-right-radius': '25px',
					'border-bottom-left-radius': '25px',
					'border-bottom-right-radius': '25px',
					'background': '#fff',
					'padding-top': '10px',
					'margin-bottom':"60px"
				},
				page: {
					remarks: '',
					startHeight: 0,
					endHeight: 0
				},
				data: [],
				data2: [],
				currentTab: 0,
			}
		},
		created() {
			this.$bus.$on('order', msg => {
				console.log("aaaaaaaaaaa4", msg)
				this.$refs.paging.reload(true);
			});
		},
		onLoad() {

			let info = uni.getSystemInfoSync();

			this.page.startHeight = info.windowWidth * 0.6
			this.page.endHeight = info.windowWidth * 0.8
		},
		onShow() {
			this.$refs.paging.reload(true);
			if (typeof this.$mp.page.getTabBar === 'function' && this.$mp.page.getTabBar()) {
			  this.$mp.page.getTabBar().setData({
			    selected: 1
			  })
			 
			}
		},
		onUnload() {
			uni.$off('order');
		},
		onPageScroll(res) {
			// 渐变
			this.$refs.nav.defaultColorBgAlpha(res)
		},
		methods: {
			// 分页的请求
			queryList(pageNo, pageSize) {
				let _this = this
				_this.$api.pickUpCardList({
					"current": pageNo,
					"size": pageSize,
					"params": {
						"customerSid": getApp().globalData.sid
					}
				}).then((resp) => {
					// 添加数据源
					this.$refs.paging.complete(resp.records)
				}).catch(e => {
					// 出错了，点击重试
					_this.$refs.paging.complete(false);
				})
			},

			bind() {
				uni.navigateTo({
					url: '/pages/bind/bind_pickUpCard'
				})
				
				// uni.navigateTo({
				// 	url: '/pages/home/myHome'
				// })
			},
			detail(item) {
				console.log("aaa", item);
				if (item.showBtn) {
					// 正常

					if (item.type == '1') {
						console.log("111", item);
						// 家庭卡
						uni.navigateTo({
							url: '/pages/detail/detail_family?sid=' + item.sid
						})
					}

					if (item.type == '2') {
						console.log("222", item);
						// 亲情卡
						uni.navigateTo({
							url: '/pages/detail/detail_affeection?sid=' + item.sid
						})
					}

					if (item.type == '3') {
						console.log("333", item);
						// 企业卡
						uni.navigateTo({
							url: '/pages/detail/detail_enterprise?sid=' + item.sid
						})
					}


				} else {
					// 过期 已完成
					if (item.type == '1') {
						// 家庭卡
						uni.navigateTo({
							url: '/pages/detail/detail_family2?sid=' + item.sid
						})
					}

					if (item.type == '2') {
						// 亲情卡
						uni.navigateTo({
							url: '/pages/detail/detail_affeection2?sid=' + item.sid
						})
					}

					if (item.type == '3') {
						// 企业卡
						uni.navigateTo({
							url: '/pages/detail/detail_enterprise2?sid=' + item.sid
						})
					}
				}

			},
		}
	}
</script>

<style>
	._ellipsis {
		overflow-wrap: break-word;
	}

	.top {
		width: 100vw;
		/* height: 126.66vw; */
		height: 85vw;
		/* 加载背景图 */
		background-image: url(https://supervise.yxtsoft.com/lpk/image/home_bj1.png);
		/* 让背景图基于容器大小伸缩 */
		background-size: 100% 100%;
	}

	.btn {
		/* margin-top: 97.86vw; */
		margin-top: 60vw;
		width: 83%;
		background-color: #FFF;
		border-radius: 45px;
		display: flex;
		/* height: 13vw; */
		flex-direction: row;
		justify-content: center;
		align-items: center;
		/* 加载背景图 */
		/* background-image: url(https://supervise.yxtsoft.com/lpk/image/bindBtn_bj1.png); */
		/* 让背景图基于容器大小伸缩 */
		/* background-size: 100% 100%; */
	}

	.item {
		border-radius: 8px;
		width: calc(100% - 5px);
		background-color: rgba(255, 248, 248, 1);
		color: rgba(16, 16, 16, 1);
		box-shadow: 2px 3px 6px 0px rgba(255, 226, 222, 0.62);
	}

	.item2 {
		/* 加载背景图 */
		/* background-image: url(https://supervise.yxtsoft.com/lpk/image/home_itemBj_lose.png); */
		/* 让背景图基于容器大小伸缩 */
		/* background-size: 100% 100%; */
		/* width: calc(100% - 5px); */

		width: calc(100% - 5px);
		border-radius: 8px;
		background-color: rgba(255, 251, 248, 1);
		color: rgba(16, 16, 16, 1);
		box-shadow: 2px 3px 6px 0px rgba(238, 117, 47, 0.15);
	}

	.item3 {
		/* 加载背景图 */
		/* background-image: url(https://supervise.yxtsoft.com/lpk/image/home_itemBj_affection.png); */
		/* 让背景图基于容器大小伸缩 */
		/* background-size: 100% 100%; */
		/* width: calc(100% - 5px); */

		border-radius: 8px;
		background-color: rgba(255, 254, 249, 1);
		color: rgba(16, 16, 16, 1);
		box-shadow: 2px 3px 6px 0px rgba(224, 218, 168, 0.24);
	}

	.item4 {
		/* 加载背景图 */
		/* background-image: url(https://supervise.yxtsoft.com/lpk/image/home_itemBj_lose.png); */
		/* 让背景图基于容器大小伸缩 */
		/* background-size: 100% 100%; */
		/* width: calc(100% - 5px); */

		width: calc(100% - 5px);
		border-radius: 8px;
		background-color: rgba(255, 251, 248, 1);
		color: rgba(16, 16, 16, 1);
		box-shadow: 2px 3px 6px 0px rgba(238, 117, 47, 0.15);
	}


	.item5 {
		/* 加载背景图 */
		/* background-image: url(https://supervise.yxtsoft.com/lpk/image/home_itemBj_enterprise.png); */
		/* 让背景图基于容器大小伸缩 */
		/* background-size: 100% 100%; */
		/* width: calc(100% - 5px); */

		width: calc(100% - 5px);
		border-radius: 8px;
		background-color: rgba(255, 251, 248, 1);
		color: rgba(16, 16, 16, 1);
		box-shadow: 2px 3px 6px 0px rgba(238, 117, 47, 0.15);
	}

	.item6 {
		/* 加载背景图 */
		/* background-image: url(https://supervise.yxtsoft.com/lpk/image/home_itemBj_lose.png); */
		/* 让背景图基于容器大小伸缩 */
		/* background-size: 100% 100%; */
		/* width: calc(100% - 5px); */

		width: calc(100% - 5px);
		border-radius: 8px;
		background-color: rgba(255, 251, 248, 1);
		color: rgba(16, 16, 16, 1);
		box-shadow: 2px 3px 6px 0px rgba(238, 117, 47, 0.15);
	}


	.showBtn {
		visibility: hidden;
	}

	.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;
	}



	.oragin {}

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