giveAwhirl.vue 7.51 KB
<template>
	<!-- 试一试 -->
	<view class="giveAwhirl">
		<!-- 画布盒子 -->
		<view class="canvasBox">
			<!-- 后退 -->
			<view class="retreat" @click="retreat">
				<u-icon color="white" size="45" name="arrow-left"></u-icon>
			</view>
			<!-- 卡片 -->
			<view class="canvasBoxCard">
				<uni-transition :mode-class="['fade','zoom-in']" :show="!TorF" :duration="1000"> 
				<!-- 结果物品 -->
				<view class="resultGoods" v-if="!TorF">
					<!-- 恭喜 -->
					<view class="congratulation">
						<image class="congratulationImg" :src="require('@/static/congratulation.png')" mode=""></image>
					</view>
					<!-- 物品信息 -->
					<view class="goodsMsg">
						<!-- 商品图片 -->
						<view class="goods">
							<img class="goodsImg" :src="isGoods[0].productPic" alt="">
						</view>
						<!-- 参数 -->
						<view class="parameter">
							<!-- 标签 -->
							<view class="label">
								SSR至尊款
							</view>
							<!-- 价格-->
							<view class="parameterPrice" v-if="isGoods[0]">
								<p class="parameterName">{{isGoods[0].productName}}</p>
								<p class="parameterReference">参考价¥ {{isGoods[0].productPrice}}</p>
							</view>
						</view>
					</view>
				</view>
				</uni-transition>
				<!-- 惊喜盒子 -->
				<uni-transition :mode-class="['fade','zoom-in']" :show="TorF" :duration="1000"> 
				<view  @tap="$u.throttle(openBox, 2000)" :class="classLiftR" v-if="TorF">
					<image  class="surprisedBoxImg" :src="require('@/static/surprised.png')" mode=""></image>
				</view>
				</uni-transition>
			</view>
			
			<!-- 按钮试一试or来真的 -->
			<uni-transition :mode-class="['fade','zoom-in']" :show="!TorF" :duration="1000"> 
			<view class="btnTry" v-if="!TorF" @click="retreat">
				来真的试一试
			</view>
			</uni-transition>
			<uni-transition :mode-class="['fade','zoom-in']" :show="TorF" :duration="1000"> 
			<view class="btnReally" v-if="TorF">
				请点击魔盒
			</view>
			</uni-transition>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 盒子显示与隐藏
				TorF:true,
				// 上下 左右动画样式
				classLiftR:"surprisedBox"
			};
		},
		methods: {
			// 返回购买页
			retreat() {
				this.$Router.back(1)
			},
			// 打开盒子
			openBox(){
				this.classLiftR="clileftR"
				setTimeout(()=>{
					this.TorF=!this.TorF
				},1000)
				
			}
		},
		//商品
		computed: {
			isGoods() {
				return this.$store.state.pay.commoditys
			}
		}
	}
</script>

<style lang="scss" scoped>
	* {
		margin: 0;
		padding: 0;
	}
	// 上下抖动动画
	@keyframes upDown{
		0% {
			transform: translateY(0);
		}
		25%{
			transform: translateY(-20rpx);
		}
		50% {
			transform: translateY(0);
		}
		75%{
			transform: translateY(-20rpx);
		}
		100%{
			transform: translateY(0rpx);
		}
	}
	// 上下抖动动画
	@keyframes leftR{
		0% {
			transform: rotateZ(0);
		}
		25%{
			transform: rotateZ(15deg);
		}
		50% {
			transform: rotateZ(-15deg);
		}
		75%{
			transform: rotateZ(15deg);
		}
		100%{
			transform: rotateZ(-15deg);
		}
	}
	.clileftR{
		width: 384rpx;
		height: 353rpx;
		animation: leftR 0.4s infinite;
		transform: rotateZ(0deg);
		.surprisedBoxImg{
			width: 384rpx;
			height: 353rpx;
		}
	}
	
	.giveAwhirl {
		width: 100vw;
		height: 100vh;
		background-image: url("~@/static/showbgd.png");
		background-repeat: no-repeat;
		background-size: cover;
		display: flex;
		justify-content: center;

		//画布盒子
		.canvasBox {
			width: 100vw;
			height: 100vh;
			display: flex;
			align-items: center;
			position: relative;
			flex-direction: column;
			// 后退
			.retreat {
				padding: 15rpx;
				background-color: rgba(0, 0, 0, 0.7);
				position: absolute;
				display: flex;
				align-items: center;
				justify-content: center;
				top: var(--status-bar-height);
				left: 50rpx;
			}
			// 卡片
			.canvasBoxCard{
				width: 680rpx;
				height: 900rpx;
				background-image: url("~@/static/kapian.png");
				background-repeat: no-repeat;
				background-size: contain;
				margin-top: 250rpx;
				border-radius: 30rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				margin-bottom: 40rpx;
				// 开出结果
				.resultGoods{
					width: 500rpx;
					height: 650rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: space-between;
					// 恭喜
					.congratulation{
						width: 450rpx;
						height: 70rpx;
						.congratulationImg{
							width: 450rpx;
							height: 70rpx;
						}
					}
					// 物品信息
					.goodsMsg{
						width: 450rpx;
						height: 550rpx;
						display: flex;
						flex-direction: column;
						align-items: center;
						justify-content: space-between;
						// 商品图片
						.goods{
							width: 450rpx;
							height: 350rpx;
							display: flex;
							align-items: center;
							justify-content: center;
							.goodsImg{
								width: 200rpx;
								height: 300rpx;
								background-color: seagreen;
							}
						}
						// 参数
						.parameter{
							width: 500rpx;
							height: 200rpx;
							display: flex;
							justify-content: flex-start;
							flex-direction: column;
							// 标签
							.label{
								width: 160rpx;
								height: 50rpx;
								background: linear-gradient(55deg, #03EBF1 0%, #C3FDFF 34%, #F8C6E7 69%, #FFFEE1 100%);
								border-radius: 10rpx;
								text-align: center;
								line-height: 50rpx;
								font-weight: 700;
							}
							.parameterPrice{
								margin-top: 20rpx;
								width: 370rpx;
								height: 130rpx;
								border: 1px solid black;
								border-radius: 30rpx;
								background-image: url("@/static/rightB.png");
								background-position: right bottom;
								background-color: white;
								background-repeat: no-repeat;
								background-size: 90rpx 80rpx;
								padding: 10rpx 13rpx;
								.parameterName{
									font-size: 16px;
									font-weight: 600;
									overflow: hidden;
									text-overflow: ellipsis;
									white-space: nowrap;
								}
								.parameterReference{
									width: 220rpx;
									height: 40rpx;
									border-radius: 40rpx;
									font-size: 14px;
									color: white;
									background-color: #1F64E8;
									margin-top: 12rpx;
									line-height: 40rpx;
									font-weight: 600;
									text-align: center;
									padding: 8rpx 8rpx;
									white-space: nowrap;
								}
							}
						}
					}
				}
				
				// 惊喜盒子
				.surprisedBox{
					width: 384rpx;
					height: 353rpx;
					animation: upDown 3s infinite;
					transform: translateY(0);
					.surprisedBoxImg{
						width: 384rpx;
						height: 353rpx;
					}
				}
			}
			// 按钮 来真的
			.btnTry{
				width: 420rpx;
				height: 100rpx;
				background: linear-gradient(129deg, #ffcdb0 15%, #F72934 100%);
				line-height: 100rpx;
				text-align: center;
				font-size: 20px;
				color: white;
				font-weight: 700;
				text-shadow: 0px 0px 10px rgba(127,1,1,0.5000);
			}
			// 按钮  试一试
			.btnReally{
				width: 420rpx;
				height: 100rpx;
				background: linear-gradient(129deg, #ffcdb0 15%, #F72934 100%);
				line-height: 100rpx;
				text-align: center;
				font-size: 20px;
				color: white;
				font-weight: 700;
				text-shadow: 0px 0px 10px rgba(127,1,1,0.5000);
				
			}
		}

	}
</style>