<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">
						<view class="taocan" :data-id="item.order_pack.id" @click="details(item.order_pack,item.id)">
							<view class="tc_left">
								<text>{{item.order_pack.pack_name}}</text>
							</view>
							<view class="tc_right">
								<view style="width: 100%;">
									<view class="">{{item.order_pack.pack_intro}}</view>
									<!-- <view class="text">{{item.desc}}</view> -->
									<view class="text">
										<view class="">
											图文次数：{{item.order_pack.chat_num}}次
										</view>
										<view class="">
											电话次数：{{item.order_pack.phone_minutes}}次
										</view>
										<view class="">
											门诊次数：{{item.order_pack.appoint_num}}次
										</view>
										<!-- <text style="float: right;color: #FF4F61;font-weight: bold;">¥{{item.order_pack.pack_price/100}}</text> -->
									</view>
								</view>
								<view class="margin-top-xs">
									剩余时长：<u-count-down v-if="current!=1" color="#EEAA3F" separator="zh" :timestamp="item.order_pack.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: '历史服务包'
				}, {
					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 if (this.current == 1) {
					num = 1
				} else {
					num = 3
				}
				console.log(num)
				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, id) {
				let obj = {
					service_pack_id: id,
					guardian_name: data.guardian_name
				}
				console.log(data)
				uni.navigateTo({
					url: "choiceBox?data=" + JSON.stringify(obj)
				})
			}
		}
	}
</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>
