<template>
	<view>
		<view class="tui-actionsheet-mask" :class="[show?'tui-mask-show':'']" @tap="handleClickMask"></view>
		<view class="tui-actionsheet-class tui-actionsheet" :class="[show?'tui-actionsheet-show':'']">
			<view class="tui-tips" :style="{fontSize:size+'rpx',color:color}" v-if="tips">
				{{tips}}
			</view>
			<view :class="[isCancel?'tui-operate-box':'tui-operate-boxN']">
				<slot></slot>
			</view>
			<view v-if="showbotom">
				<view class="tui-actionsheet-btn tui-actionsheet-cancel" hover-class="tui-actionsheet-hover"
					:hover-stay-time="150" v-if="isCancel" @tap="handleClickCancel(1)">{{$t("order.wancheng")}}</view>
			</view>
			
		</view>
	</view>
</template>
 
<script>
	export default {
		name: "tuiActionsheet",
		props: {
			//点击遮罩 是否可关闭
			maskClosable: {
				type: Boolean,
				default: true
			},
			//显示操作菜单
			show: {
				type: Boolean,
				default: false
			},
			//菜单按钮数组，自定义文本颜色，红色参考色：#e53a37
			itemList:{},
			//提示文字
			tips: {
				type: String,
				default: ""
			},
			//提示文字
			acttips: {
				type: String,
				default:''
			},
			//提示文字颜色
			color: {
				type: String,
				default: "#9a9a9a"
			},
			//提示文字大小 rpx
			size: {
				type: Number,
				default: 26
			},
			//是否需要取消按钮
			isCancel: {
				type: Boolean,
				default: true
			},
			//是否需要底部按钮
			showbotom: {
				type: Boolean,
				default: true
			},
			
		},
		watch: {
			show(val){
				if(val){
					// 背景不可滚动
					//document.body.style.overflow='hidden';
				}
				else{
					// 背景可滚动
					//document.body.style.overflow='';
				}
			}
		},
		methods: {
			handleClickMask() {
				if (!this.maskClosable) return;
				this.handleClickCancel(0);
			},
			handleClickItem(e) {
				if (!this.show) return;
				const dataset = e.currentTarget.dataset;
				this.$emit('click', {
					index: dataset.index
				});
			},
			
			selectGuige(index,name){
				this.$emit('EselectGuige',index,name);
			},
			
			handleClickCancel(type) {
				if(type==1){
					this.$emit('ClickCancel');
				}
				this.$emit('chooseCancel');
			}
		}
	}
</script>
 
<style>
	.tui-actionsheet {
		width:750upx;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 9999;
		visibility: hidden;
		transform: translate3d(0, 100%, 0);
		transform-origin: center;
		transition: all 0.3s ease-in-out;
		background: #eaeaec;
		min-height: 100rpx;
	}
 
	.tui-actionsheet-show {
		transform: translate3d(0, 0, 0);
		visibility: visible;
	}
 
	.tui-tips {
		width:750upx;
		padding: 30rpx 60rpx;
		box-sizing: border-box;
		text-align: center;
		background: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
	}
 
	.tui-operate-box {
		padding-bottom: 12rpx;
		max-height: 80vh;
		overflow: scroll;
	}
	.tui-operate-boxN {
		max-height: 80vh;
		overflow: scroll;
	}
 
	.tui-actionsheet-btn {
		width:750upx;
		height: 100rpx;
		background: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
		text-align: center;
		font-size: 36rpx;
		position: relative;
	}
 
	.tui-btn-last {
		padding-bottom: env(safe-area-inset-bottom);
	}
 
	.tui-actionsheet-divider::before {
		content: '';
		width:750upx;
		border-top: 1rpx solid #d9d9d9;
		position: absolute;
		top: 0;
		left: 0;
		-webkit-transform: scaleY(0.5);
		transform: scaleY(0.5);
	}
 
	.tui-actionsheet-cancel {
		color: #1a1a1a;
		padding-bottom: env(safe-area-inset-bottom);
	}
 
	.tui-actionsheet-hover {
		background: #f7f7f9;
	}
 
	.tui-actionsheet-mask {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.6);
		z-index: 9996;
		transition: all 0.3s ease-in-out;
		opacity: 0;
		visibility: hidden;
	}
 
	.tui-mask-show {
		opacity: 1;
		visibility: visible;
	}
	
	.skuViewCt{
		display: flex;
		flex-direction: column;
		justify-content:center;
		width: 100%;
		margin-top: 10rpx;
	}
	
	.contensbgg{
		display: flex;
		flex-wrap: wrap;
		justify-content:flex-start;
		align-items:center;
	}
	
	.guigeleixing{
		font-size: 26rpx;
		line-height: 40rpx;
		height: 40rpx;
		color: black;
		font-weight: bold;
	}
	.youhuixinxi{
		margin: 8rpx;
		padding: 4rpx;
		font-size: 26rpx;
		line-height: 54rpx;
		height: 54rpx;
		border: 2rpx solid lightgray;
		border-radius: 8rpx;
	}
	.xz{
		background-color: #ff0000;
	}
	
</style>