<template>
	<view>
		<view class="border-bottom p-fixed left0 right0 zIndex">
			<view class="p-relative">
				<u-tabs name="label" :list="list" :current="current" @change="change" :gutter='50'>
				</u-tabs>
				<view v-if="list.length > 4" class="p-absolute d-flex j-center a-center right0 top0 bg-color-white" style="width: 50rpx;height: 88rpx;z-index: 1000000000;"
				 @click.stop='maskState = !maskState'>
					<u-icon name="arrow-down-fill" size="28"></u-icon>
				</view>
				<view v-if="maskState">
					<view class=" d-flex f-wrap a-center" style="background-color: #fff;width: 750rpx;z-index: 100000000000;">
						<view v-for="(item,index) in list" :key='index' style="margin: 0 50rpx;height: 80rpx;line-height: 80rpx;"
						 @click.stop="change(index)" :class="current == index?'select-color':''">
							{{item.label}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-if="maskState" @click.stop="maskState = false" class="p-fixed left0 right0 bottom0" style="background: rgba(0,0,0,.2);z-index: 10;"
		 :style="'height:'+windowHeight+'px'"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				windowHeight: 0,
				maskState: false
			};
		},
		props: {
			list: {
				type: Array,
				default: () => []
			},
			current: {
				type: [String, Number],
				default: -1
			}
		},
		created() {
			try {
				const res = uni.getSystemInfoSync();
				this.windowHeight = res.windowHeight
			} catch (e) {}
		},
		methods: {
			change(index) {
				this.maskState = false
				this.$emit('change',index, this.list[index].value)
			}
		}
	}
</script>

<style scoped>
	.select-color {
		color: #2979ff;
	}
</style>
