<template>
	<page-meta :page-style="'overflow:'+(popShow?'hidden':'visible')"></page-meta>
	<view class="bg">
		<image v-if="headImg" :src="showImg(headImg)" class="topImg" mode="widthFix"></image>
		
		<view class="main-container">
			<view class="coupon-box" v-for="(prize,prizeIndex) in prizeList" :key="prizeIndex"
			:style="{'background-image':`url(${prize.backgroundImg})`}">
				<view class="flex-between" style="flex-wrap: wrap;" v-if="prize.isCoupon">
					<image :class="['coupon-img','coupon-img'+i]" v-for="(item,i) in couponList" :key="i"
					:src="item.img" @click="getCoupon(item)" mode="widthFix"></image>
				</view>
				<view class="w-full" v-else @click="gotoPath(prize.path)">
					<image style="width: 100%;height: 262rpx;" :src="prize.img" mode="widthFix"></image>
				</view>
				
				<view class="rule flex-center" v-if="prize.isCoupon" @click="showRule(item)">
					活动规则
					<image src="https://static.ticket.sz-trip.com/uploads/20251015/d63427138ebdec9e4a780736c0cece2c.png"></image>
				</view>
			</view>
			
			
			<view class="type-container" :style="{'background-image':`url(${typeList[typeIndex].backgroundImg})`}">
				<view :class="['type-item','type-item'+i,typeIndex==i?'active':'']" @click="typeIndex=i"
				v-for="(item,i) in typeList" :key="i">{{item.title}}</view>
			</view>
			<view class="product-container">
				<view class="row-product"  @click="gotoDetailByType(item)" :key="index"
					v-for="(item,index) in typeList[typeIndex].list.slice(0,typeList[typeIndex].viewNum)">
					<image class="img" :src="showImg(item.headimg)" mode="aspectFill"></image>
					<view class="content flex-column">
						<view class="title text-overflowRows">{{item.title}}</view>
						<!-- <view class="tags"  v-if="item.display_tags">
							<view class="tag" v-for="(tag,tagI) in item.display_tags.split(',')" :key="tagI">{{tag}}</view>
						</view> -->
						<view class="flex-between">
							<view >
								<text class="price">{{item.price/100}}</text>
								<text class="old-price" v-if="item.market_price">{{item.market_price/100}}</text>
							</view>
							<view class="btn">
								<image style="width: 100%;height: 100%;border-radius: 50%;" mode="aspectFill"
								src="https://static.ticket.sz-trip.com/uploads/20251015/06d55a0ce76555ad9d65e8574af0b016.png"></image>
							</view>
						</view>
					</view>
					
				</view>
			
				<image class="view-more" src="https://static.ticket.sz-trip.com/uploads/20250923/e121513a65fda74f822c660cda703e9a.png"
				v-if="typeList[typeIndex].list.length>0&&typeList[typeIndex].viewNum<=6"  mode="heightFix"
				@click="typeList[typeIndex].viewNum=999"></image>
			</view>

			<!-- <image style="width: 100%;" mode="widthFix" src="https://static.ticket.sz-trip.com/uploads/20251015/b75309eedd49e02b518d5eeeca19855e.png"></image> -->
				
			<image class="bottom-img" src="https://static.ticket.sz-trip.com/uploads/20251015/cf1381e1c826b6cad95a8344c7125def.png"></image>
			<image @click="returnTop" v-show="showGoTop" class="back-img" 
			src="https://static.ticket.sz-trip.com/uploads/20251015/82d48498bdf14ded3061bec9defa5138.png"></image>
			
		</view>
		
		<uni-popup ref="popup" type="center" mask-background-color="rgba(0,0,0,0.6)" @change="changPopShow">
			<view class="flex-column flex-center">
				<image style="width: 636rpx;" mode="widthFix" src="https://static.ticket.sz-trip.com/uploads/20251015/bcfccc761d5f48589a92d83cf2ad89f5.png"></image>
				
				<image @click="$refs.popup.close()" style="width: 53rpx;height: 53rpx;margin-top: 40rpx;" 
				src="https://static.ticket.sz-trip.com/uploads/20251015/d89694d06c3aa5e418aca43822d14042.png"></image>
			</view>
		</uni-popup>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				headImg: '',
				
				prizeList: [
					{
						backgroundImg: "https://static.ticket.sz-trip.com/uploads/20251015/1de2e7b5d2c81859da64a03c08a2abab.png",
						isCoupon: true,
						ruleImg: "https://static.ticket.sz-trip.com/uploads/20251015/bcfccc761d5f48589a92d83cf2ad89f5.png",
					},
					{
						backgroundImg: "https://static.ticket.sz-trip.com/uploads/20251015/869d6ad6500513201a42b2f05d315281.png",
						img: "https://static.ticket.sz-trip.com/uploads/20251015/94f1e10dc0f45347a243481d28044a52.png",
						path: "/subPackages/activity/dzxConSeasonNH"
					},
					{
						backgroundImg: "https://static.ticket.sz-trip.com/uploads/20251015/b57675474d037bfe3c141a73e22a1514.png",
						img:"https://static.ticket.sz-trip.com/uploads/20251015/54710ff93860f871f533d6affcf4b7fc.png",
						path: "/subPackages/activity/dzxConSeasonPrize"
					},
				],
				couponList: [
					{id: null, img: "https://static.ticket.sz-trip.com/uploads/20251015/9b516a020e2783787f7a95156d1ae1f9.png"},
					{id: null, img: "https://static.ticket.sz-trip.com/uploads/20251015/8321d506adeaeb4b84d5e2cbfb113870.png"},
					{id: null, img: "https://static.ticket.sz-trip.com/uploads/20251015/26099ebefdf08e2b60c5ee41c22ffeb9.png"},
					{id: null, img: "https://static.ticket.sz-trip.com/uploads/20251015/a300c6a3b39bdc8d4a8801bfde9efa9f.png"},
					{id: null, img: "https://static.ticket.sz-trip.com/uploads/20251015/7c1c2b9b20a5ec9dc5693a2f34429d36.png"},
				],
				isReceive: true,
				typeIndex: 0,
				typeList: [
					{
						id: 116,title: "正宗好蟹",viewNum:6, list: [],
						backgroundImg: "https://static.ticket.sz-trip.com/uploads/20251016/cf772d70307dccb70fbc6221174144f9.png",
					},
					{
						id: 117,title: "秋冬进补",viewNum:6, list: [],
						backgroundImg: "https://static.ticket.sz-trip.com/uploads/20251016/6be24679dbfec9efc8703627c764aa3d.png",
					},
					{
						id: 118,title: "时令甄选",viewNum:6, list: [],
						backgroundImg: "https://static.ticket.sz-trip.com/uploads/20251016/c92d5c63f216b27ce77522e17e06f1d6.png",
					},
					{
						id: 119,title: "苏韵文创",viewNum:6, list: [],
						backgroundImg: "https://static.ticket.sz-trip.com/uploads/20251016/339be8cc94d8b21c192c5911fa73de70.png",
					},
				],
				showGoTop: false,
				popShow: false,
			}
		},
		onLoad(option) {
			
		},
		onReady() {
			this.getHeadImg(2401)
			this.getGoods()
		},
		methods: {
			changPopShow (e) {
				this.popShow = e.show
			},
			getHeadImg (id) {
				this.Post({id},'/api/multimedia/detail').then(res => {
					this.headImg = res.data.head_img
					uni.setNavigationBarTitle({
						title:res.data.title
					})
					if (res.data.company_name) {
						res.data.company_name.split(',').forEach((item, index) => {
							this.couponList[index].id = item
						})
					}
				});	
			},
			showRule (item) {
				this.$refs.popup.open()
			},
			
			// 产品列表
			getGoods() {
				for(let p of this.typeList) {
					this.Post({
						tag_id: p.id,
						offset: 0,
					    limit: 999,
					},'/api/product/get_product_by_tag_subject').then(res => {
						if (res.data.list.length < p.viewNum) {
							p.viewNum = 999
						}
						p.list = res.data.list
						console.log(p)
					})
				}
			
			},
			getCoupon(item) {
				if (!this.isReceive) {
					uni.showToast({
						title: "短时间内请勿重复点击！",
						icon: 'none'
					})
					return;
				}
				this.isReceive = false
				setTimeout(() => {this.isReceive = true}, 3000)
				this.Post({
					ids: item.id,
					is_all: 1,
				},"/api/coupon/getNewCouponsByActivitiesIds").then(res => {
					if (res) {
						uni.showToast({
							title: res.data,
							icon: 'none'
						})
					}
				})
			},
			

			viewDetail(item) {
				this.gotoDetailByType(item)
			},
			returnTop(){
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 200,
				})
			},
		},
		onPageScroll(res) {
			this.showGoTop = res.scrollTop > 200 ? true : false;
		}
	}
</script>

<style lang="scss" scoped>
	.bg {
		width: 750rpx;
		min-height: 100vh;
		padding-bottom: 30rpx;
		background-image: url("https://static.ticket.sz-trip.com/uploads/20251015/306f4e5db6cc77c111c73f78acecad18.png");
		background-size: 100% auto;
		background-repeat: repeat-y; /* 竖向重复 */
		background-position: bottom; /* 从底部开始显示 */
	}
	
	.topImg {
		width: 100%;
	}
	.main-container{
		width: 100%;
		margin-top: -1610rpx;
		padding: 0 17rpx 60rpx;
	}
	.coupon-box{
		width: 100%;
		position: relative;
		padding: 95rpx 12rpx 3rpx;
		background-size: 100% 100%;
		background-repeat: no-repeat;
		margin-bottom: 30rpx;
		.rule{
			width: 165rpx;
			height: 49rpx;
			background: #63C083;
			border-radius: 35rpx 35rpx 35rpx 35rpx;
			font-weight: 400;
			font-size: 27rpx;
			color: #FFFFFF;
			position: absolute;
			top: 12rpx;
			right: 0;
			image{
				width: 20rpx;
				height: 20rpx;
				margin-left: 5rpx;
				margin-top: 1rpx;
			}
		}
		
		.coupon-img{
			width: 160rpx;
			height: 190rpx;
			margin-bottom: 15rpx;
		}
		.coupon-img4{
			width: 100%;
			height: 196.67rpx;
			margin-bottom: 10rpx;
		}
	}
	
	.row-product{
		width: 100%;
		height: 240rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 27rpx 0rpx rgba(177,177,177,0.25);
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		border: 1rpx solid #F4F4F4;
		padding: 20rpx 22rpx;
		display: flex;
		margin-bottom: 13rpx;
		.img{
			width: 200rpx;
			height: 100%;
			border-radius: 20rpx;
			flex-shrink: 0;
		}
		.content{
			width: 100rpx;
			flex: 1;
			justify-content: space-between;
			padding: 0 0 0rpx 13rpx;
		}
		.price{
			font-weight: 500;
			font-size: 39rpx;
			color: #FF0000;
			&::before{
				content: "￥";
				font-size: 27rpx;
			}
			// &::after{
			// 	content: "起";
			// 	font-size: 24rpx;
			// }
		}
		.old-price{
			font-weight: 400;
			font-size: 29rpx;
			color: #B1B1B1;
			text-decoration-line: line-through;
			margin-left: 13rpx;
			&::before{
				content: "￥";
			}
		}
		.btn{
			width: 53.33rpx;
			height: 53.33rpx;
			border-radius: 50%;
			overflow: hidden;
		}
	}
	.title{
		font-weight: 400;
		font-size: 31rpx;
		color: #000000;
	}
	.tags{
		width: 100%;
		display: flex;
		overflow: hidden;
		.tag{
			font-weight: 500;
			font-size: 24rpx;
			height: 38rpx;
			line-height: 38rpx;
			color: #4C9BB4;
			padding: 0rpx 6rpx;
			border-radius: 5rpx;
			border: 1px solid #4C9BB4;
			margin-right: 13rpx;
		}
	}
	.view-more{
		height: 24rpx;
		margin: 31rpx auto 0;
		position: relative;
		z-index: 2;
		display: block;
	}

	.type-container{
		display: flex;
		// padding: 24rpx 34rpx 0;
		height: 324rpx;
		background-size: 100% 100%;
		position: relative;
		.type-item{
			font-weight: 500;
			font-size: 28rpx;
			color: #FFFFFF;
			text-align: left;
			height: 80rpx;
			// background-color: rgba(0,0,0,0.5);
			opacity: 0;
			flex: 1;
			&.active{
				// font-weight: bold;
				// font-size: 33rpx;
				// color: #000000;
				// text-shadow: 
				// -3px -3px 0 #fff,  /* 左上白边 */
				// 3px -3px 0 #fff,   /* 右上白边 */
				// -3px 3px 0 #fff,   /* 左下白边 */
				// 3px 3px 0 #fff,    /* 右下白边 */
				// 0px 3px 3px rgba(255,119,0,0.25);
				// text-stroke: 3px #FFFFFF;
				
			}
		}
		// .type-item0{
		// 	width: 180rpx;
		// }
		// .type-item1{
		// 	width: 170rpx;
		// }
		// .type-item2{
		// 	width: 170rpx;
		// }
	}
	
	.product-container{
		margin-top: -210rpx;
		padding:0 21rpx 34rpx 27rpx;
		position: relative;
		background: #FFFEFF;
		border-radius: 0rpx 0rpx 35rpx 35rpx;
	}
	
	.column-product{
		width: 340rpx;
		height: 497rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		padding: 6rpx;
		overflow: hidden;
		margin-bottom: 16rpx;
		.img{
			width: 327rpx;
			height: 327rpx;
			border-radius: 13rpx 13rpx 0rpx 0rpx;
		}
		.content{
			width: 100%;
			flex: 1;
			height: 150rpx;
			justify-content: space-between;
			padding: 4rpx 10rpx;
		}
		.price{
			font-weight: bold;
			font-size: 28rpx;
			color: #E62525;
			&::before{
				content: "￥";
			}
		}
		.btn{
			width: 100rpx;
			height: 40rpx;
			background: #FF9838;
			border-radius: 20rpx;
			font-weight: bold;
			font-size: 27rpx;
			color: #FFFFFF;
			line-height: 40rpx;
			text-align: center;
		}
	}
	
	.bottom-img{
		width: 123.95rpx;
		height: 103.06rpx;
		margin: 74rpx auto 0;
		display: block;
	}
	.back-img{
		position: fixed;
		width: 66rpx;
		height: 66rpx;
		bottom: 66rpx;
		right: 26rpx;
	}
</style>