<template>
	<view class="container">
		<u-tabs :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
		<view style="width: 100vw;height: auto;background-color: #f6f6f6;">
			<view style="width: 100%;height: 100%;">
				<view v-for="(item,index) in serviceList" :key="index">
					<view class="card flex justify-center" v-for="itm,idx in item.order_pack" :key="idx">
						<view class="taocan" :data-id="item.id" @click="details(item.order_pack[idx])">
							<view class="tc_left">
								<text>{{itm.pack_name}}</text>
							</view>
							<view class="tc_right">
								<view style="width: 100%;">
									<view class="text">{{itm.pack_intro}}</view>
									<!-- <view class="text">{{item.desc}}</view> -->
									<view class="text">
										<text style="text-align: left;">时长:{{itm.effective_days}}天</text>
										<text style="float: right;color: #FF4F61;font-weight: bold;">¥{{itm.pack_price/100}}</text>
									</view>
								</view>
								<view class="margin-top-xs">
									剩余时长：<u-count-down v-if="current!=1" color="#EEAA3F" separator="zh" :timestamp="itm.end_time-miao"></u-count-down><text
									 v-else>已结束</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-empty text="暂无数据" :show="show" mode="order" margin-top="250"></u-empty>
		<view class="cu-tabbar-height"></view>
		<view class="cu-tabbar-height"></view>
	</view>
</template>

<script>
	export default {
		onLoad() {
			this.getserviceList()
		},
		onShow() {
			this.miao = parseInt(new Date().getTime() / 1000)
		},
		data() {
			return {
				list: [{
					name: '服务中服务包'
				}, {
					name: '历史服务包'
				}, ],
				current: 0,
				serviceList: [],
				miao: "",
				pageindex: 1,
				show: false
			}
		},
		methods: {
			change(index) {
				this.current = index;
				this.pageindex = 1
				this.serviceList = []
				this.getserviceList()
			},
			getserviceList: async function() {
				let num = 0
				if (this.current == 0) {
					num = 2
				} else {
					num = 1
				}
				let res = await this.$request.post("/api/v1/order/orderList", {
					page: this.pageindex,
					list_type: 1,
					product_type: 6,
					is_pack_expire: num
				})
				console.log(res)
				if (res.status == 0) {
					if (this.pageindex > res.data.last_page) {
						uni.showToast({
							title: "没有更多了",
							icon: "none"
						})
					} else {
						this.serviceList = this.serviceList.concat(res.data.data)
						this.pageindex++
					}
				}
				if (this.serviceList.length == 0) {
					this.show = true
				} else {
					this.show = false
				}
			},
			details(data) {
				console.log(data)
				// uni.navigateTo({
				// 	url: "choiceBox?data=" + JSON.stringify(data)
				// })
			}
		}
	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		height: 100%;
		background-color: #F6F6F6;
	}

	.card {
		width: 100%;
		height: auto;
		margin-top: 20rpx;

		// background-image: url(../../static/服务包.png);
		.taocan {
			width: 710rpx;
			height: 230rpx;
			position: relative;
			display: flex;
			border-radius: 10rpx;
			background: radial-gradient(circle at right top, transparent 15rpx, #ffffff 0) top left / 152rpx 51% no-repeat,
				radial-gradient(circle at right bottom, transparent 15rpx, #ffffff 0) bottom left /152rpx 51% no-repeat,
				radial-gradient(circle at left top, transparent 15rpx, #ffffff 0) top right /560rpx 51% no-repeat,
				radial-gradient(circle at left bottom, transparent 15rpx, #ffffff 0) bottom right /560rpx 51% no-repeat;
			filter: drop-shadow(0rpx 2rpx 12rpx 0rpx rgba(0, 0, 0, 0.04));
		}
	}

	.tc_left {
		display: flex;

		justify-content: center;
		align-items: center;
		width: 152rpx;

		text {
			font-size: 30rpx;
			font-weight: bold;
		}
	}

	.tc_right {
		display: flex;
		flex-direction: column;
		justify-content: center;
		width: 550rpx;
		padding: 0 20rpx;
		font-size: 26rpx;

		.text {
			padding: 10rpx 0rpx;
			width: 100%;
		}
	}
</style>
