<template>
	<view class="content">
		<image class="yearImg" src="https://cdn.douhuofalv.com/images/2023/04/17/80a076d77afdbe716e29f2ea56f9b103.png" mode="widthFix"></image>
		<view class="list">
			<view class="title">
				<view class="title-name"><text>企业法律咨询服务包</text></view>
				<view class="title-text">legal advice</view>
			</view>
			<view class="item" :class="{active : item.is_open}" v-for="(item, index) in synthesisArr" :key="index">
				<view class="endedAt" v-if="item.is_open">
					<view class="endedAt-time">到期时间：{{item.service_user.ended_at}}</view>
				</view>
				<view class="top">
					<view class="top-title">{{item.title}}</view>
					<view class="top-btn" :class="{'hide': item.button_status === 3}" @click="onBuy(index)">
						<text v-if="item.button_status === 0">购买</text>
						<text v-if="item.button_status === 1">续费</text>
						<text v-if="item.button_status === 2">支付</text>
						<text v-if="item.button_status === 3">审核中</text>
						<text v-if="item.button_status === 4">被驳回</text>
					</view>
				</view>
				<view class="range">
					<view class="range-label">
						<view class="range-label-title">面相群体：</view>
						<view class="range-label-text">
							{{item.audiences}}
						</view>
					</view>
					<view class="range-label">
						<view class="range-label-title">咨询收费：</view>
						<view class="range-label-text">
							{{item.price}}元/年
						</view>
					</view>
					<view class="range-label scope" v-if="index == 0">
						<view class="range-label-title">服务范围：</view>
						<view class="range-label-text">
							<text v-for="(items, scopeIndex) in item.scope" :key="scopeIndex">{{scopeIndex + 1}}、{{items}}</text>
						</view>
					</view>
				</view>
				<view class="shape" v-if="index >= 1">
					<view class="shapeBack"></view>
					<view class="shapeCont">
						<view class="shapeWhite">
							<view class="shapeWhite-title">
								服务范围
							</view>
							<view class="shapeWhite-label" v-for="(items, scopeIndex) in item.scope" :key="scopeIndex">
								{{scopeIndex + 1}}、{{items}}
							</view>
							<image class="shapeWhite-back" src="https://cdn.douhuofalv.com/images/2023/04/17/893b41e87c2bdfca62c4936a880c79cd.png" mode="widthFix"></image>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<image class="yearBttom" src="https://cdn.douhuofalv.com/images/2023/04/17/fc4cad00a630e3d69b3f486e9d2937e9.png" mode="widthFix"></image>
	</view>
</template>

<script>
	import { yearSynthList } from '@/apis/interfaces/synthesis'
	export default {
		data() {
			return {
				synthesisArr: [],  //企业-年费服务包列表
			}
		},
		
		created() {
			this.yearServe();
		},
		
		methods: {
			// 年费服务包列表
			yearServe(){
				yearSynthList({
					type: 2
				}).then(res => {
					console.log(res)
					this.synthesisArr = res
				}).catch(err => {
					uni.showToast({
						title: err.message,
						icon : 'none'
					})
				})
			},
			// 购买企业服务包
			onBuy(index){
				let obj = this.synthesisArr[index]
				switch (obj.button_status){
					case 3:
						uni.showToast({
							title: '打款凭证审核中，请耐心等待',
							icon : 'none'
						})
						break;
					case 4:
						uni.showModal({
							title		: '审核被驳回',
							content		: '驳回原因：' + obj.service_order.offline_pays.remark,
							showCancel	: false,
							success		: modalRes => {
								if(modalRes.confirm){
									this.$Router.push({
										name	: 'BankPay',
										params	: {
											payId	 	: obj.service_order.offline_pays.offline_pay_id,
											type	 	: 'edit',
											orderId		: obj.service_order.order_id,
											orderType	: obj.service_order.order_type.replace(/\\/g, '-'),
											price		: obj.price
										}
									})
								}
							}
						})
						break;
					default:
						this.$Router.push({
							name: 'StandWrite',
							params: {
								serveId: obj.synthesis_service_id
							}
						})
						break;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100vw;
		background-color: #121d4c;
	}
	
	.yearImg,
	.yearBttom{
		width: 100%;
		display: block;
	}
	
	.list {
		padding: 30rpx;
		box-sizing: border-box;
		background-color: #121d4c;
		.title {
			margin-bottom: 40rpx;
			display: flex;
			height: 80rpx;
			line-height: 80rpx;
			.title-name {
				flex: 1;
				text {
					padding: 0 70rpx 0 30rpx;
					font-size: 36rpx;
					background-image: -webkit-linear-gradient(40deg,#f1c593, #fef9f2);
					display: inline-block;
					color: #2c3c66;
					font-weight: 600;
					position: relative;
					&:after {
						position: absolute;
						content: '';
						right: 0;
						top: 0;
						width: 0;
						height: 0;
						border-width: 40rpx;
						border-style: solid;
						border-color: transparent #121d4c transparent transparent;
					}
				}
			}
			.title-text {
				font-size: 36rpx;
				text-transform: uppercase;
				background-image: -webkit-linear-gradient(top,#86716b, #8e8f9c);
				-webkit-background-clip:text; 
				-webkit-text-fill-color:transparent;
			}
		}
		.item {
			background-color: #002088;
			border-radius: 20rpx;
			padding: 30rpx;
			box-sizing: border-box;
			margin-bottom: 30rpx;
			position: relative;
			&.active {
				padding-top: 70rpx;
			}
			.endedAt {
				position: absolute;
				top: 0;
				left: 0;
				display: inline-block;
				color: #2c3c66;
				width: 100%;
				text-align: center;
				.endedAt-time {
					background-image: -webkit-linear-gradient(40deg,#f1c593, #fef9f2);
					margin: 0 auto;
					display: inline-block;
					padding: 0 20rpx;
					line-height: 52rpx;
					font-size: 26rpx;
					border-radius: 0 0 5rpx 5rpx;
					color: #582700;
				}
			}
			.top {
				display: flex;
				font-weight: 600;
				line-height: 54rpx;
				margin-bottom: 20rpx;
				.top-title {
					font-size:36rpx;
					background-image: -webkit-linear-gradient(top,#fdf6ca, #e29c68); 
					-webkit-background-clip:text; 
					-webkit-text-fill-color:transparent;
					flex: 1;
				}
				.top-btn {
					background-image: -webkit-linear-gradient(top,#fff8da,#f3c796);
					color: #582700;
					padding: 0 30rpx;
					border-radius: 50rpx;
					font-size: 30rpx;
					box-shadow: 0 8rpx 6rpx rgba(0, 0, 0, .3);
				}
			}
			.range {
				color: #ffffff;
				font-size: 28rpx;
				.range-label {
					line-height: 40rpx;
					padding: 10rpx 0;
					display: flex;
					.range-label-title {
						width: 160rpx;
					}
					.range-label-text {
						width: calc(100% - 160rpx);
						text {
							display: block;
							margin-bottom: 20rpx;
							&:last-child {
								margin-bottom: 0;
							}
						}
					}
				}
			}
			
			.shape {
				position: relative;
				margin-top: 30rpx;
				font-size: 28rpx;
				.shapeBack {
					background-color: #0d245b;
					height: 20rpx;
					width: 100%;
					border: 4rpx solid #e8c595;
					border-radius: 80rpx;
				}
				.shapeCont {
					padding: 0 30rpx;
					box-sizing: border-box;
					margin-top: -18rpx;
					.shapeWhite {
						background-color: #ffffff;
						border-radius: 0 0 20rpx 20rpx;
						padding: 40rpx 30rpx 30rpx;
						box-sizing: border-box;
						color: #0e2660;
						position: relative;
						&::after {
							position: absolute;
							content: '';
							top: 0;
							left: 0;
							width: 100%;
							height: 20rpx;
							background-image: -webkit-linear-gradient(top, #a7a8ad, transparent);
						}
						.shapeWhite-title {
							font-size: 38rpx;
							margin-bottom: 20rpx;
						}
						.shapeWhite-label {
							padding: 10rpx 0;
							line-height: 44rpx;
						}
						.shapeWhite-back {
							width: 85%;
							position: absolute;
							right: 0;
							bottom: 0;
						}
					}
				}
			}
		}
		
	}
</style>