PlayNav.vue 1.8 KB
<template>
	<view class="play_list">
		<view v-for="(item, index) in navList" :key="index" :class="{active: index === current}" class="play_item"  @click="toggle(item.id,index)">
			<text>{{ item.title }}</text>
			<image class="bg_nav" :src="item.bgImg" mode="widthFix"></image>
		</view>
	</view>
</template>

<script>
	import bg1 from '@/static/homeImg/bg_1.png'
	import bg2 from '@/static/homeImg/bg_2.png'
	import bg3 from '@/static/homeImg/bg_3.png'
	export default {
		data() {
			return {
				current: 0,
				navList: [
					{ id: 1, title: '狼人杀', bgImg: bg1},
					{ id: 2, title: '剧本杀', bgImg: bg2},
					{ id: 3, title: '密室逃脱', bgImg: bg3}
				]
			}
		},
		methods: {
			toggle(id, index){
				this.current = index
				this.$emit('playName', id)
			}
		}
	}
</script>

<style lang="scss" scoped>
.play_list{
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	min-height: 100rpx;
	margin: 20rpx 0;
	.play_item{
		position: relative;
		width: 200rpx;
		height: 80rpx;
		text-align: center;
		line-height: 80rpx;
		color: #fff;
		font-size: 28rpx;
		background: linear-gradient( 45deg, #966CFF 0%, #C3ACFF 59%);
		border-radius: 12rpx;
		transition: all .3s ease;
		&:nth-child(2){
			.bg_nav{
				width: 96rpx;
				right: -11%;
			}
		}
		&:nth-child(3){
			.bg_nav{
				width: 78rpx;
				right: -8%;
			}
		}
		.bg_nav{
			position: absolute;
			top: 0;
			right: -20%;
			width: 135rpx;
		}
		&.active{
			width: 250rpx;
			height: 100rpx;
			line-height: 100rpx;
			font-weight: 500;
			font-size: 36rpx;
			.bg_nav{
				transform: scale(1.5);
				top: 20rpx;
				right: -32rpx;
			}
		}
		&:nth-child(2) {
			background: linear-gradient( 45deg, #FF9B8A 0%, #FFCBC2 68%);
		}
		&:nth-child(3) {
			background: linear-gradient( 45deg, #75ACFF 0%, #A0C6FF 57%);
		}
	}
}
</style>