<template>
	<view class="liet">
		<view class="title">
			<u-icon name="close" @click="close()"></u-icon>
			<view class="font-thirty-two font-color3" style="margin: 0 auto; font-weight: 600;">
				商品数量
			</view>
		</view>
		<view class="border" style="padding-top: 80rpx;">
			<!-- <view class="font-twenty font-color3" style="margin: 20rpx 0 50rpx;">
				商品折扣
			</view> -->
			<!-- <u-input v-model="value" :type="type" :border="border" /> -->
			<!-- <input type="number" v-model="value"  placeholder="请输入数字" /> -->
			<input v-model="value" class="input" border="true" height="100" placeholder="请输入数量" />
		</view>
		<view class="footer11">
			<button type="default" class="btn" @click="submit">确认</button>
			<button type="default" class="btnClose" @click="close">返回</button>
		</view>
		<u-toast ref="uToast" />
	</view>
	
</template>

<script>
	export default{
		data(){
			return{
				value:'',
				type: 'number',
				money: null,
				index: null,
				goodsRatePrice: null,
				flag: false,
			}
		},
		methods:{
			close(){
				this.$emit('close')
			},
			shows(money,goodsRatePrice,index){
				this.flag = false;
				this.money = money;
				this.index = index;
				this.goodsRatePrice = goodsRatePrice;
			},
			show(){
				this.flag = true;
			},
			submit(){
				if(this.value === ''){
					this.$refs.uToast.show({
						title: '请输入数量!',
						type: 'default',
					})
				}else{
					if(this.$u.test.number(this.value)){
						console.log(this.value)
						this.$emit('add', this.value,this.money, this.goodsRatePrice,this.index);
						this.close();
					}else{
						this.$refs.uToast.show({
							title: '必须是数字,请重新输入!',
							type: 'default',
						})
					}
				}
				// const num = /^[0-9]*$/;
				// if (num.test(this.value)) {
				// 	this.$emit('add', this.value);
				// 	this.close()
				// }else{
				// 	this.$refs.uToast.show({
				// 		title: '必须是数字,请重新输入!',
				// 		type: 'default',
				// 	})
				// }
			}
		}
	}
</script>

<style lang="scss" scoped>
	.input{
		width: calc(100% - 30rpx);
		height: 100rpx;
		border: 2rpx solid #333333;
		border-radius: 24rpx;
		padding-left: 30rpx;
	}
	.liet{
		padding: 30rpx;
		background: #fff;
		min-height: 100vh;
	}
	.title {
		display: flex;
		align-items: center;
		text-align: center;
		.close {
			width: 50rpx;
			height: 50rpx;
		}
	}
	
	.border {
		border: 2rpx #E0E0E0 solid;
		border-left: none;
		border-right: none;
		margin: 30rpx 0;
	
		.area {
			height: 250rpx;
		}
	}
	.footer11{
		display: flex;
		justify-content: space-between;
	}
	.btnClose{
		width: 330rpx;
		margin: 50rpx auto;
		color: #2E4F1C;
		background: #fff;
		border-radius: 48rpx;
		border: 2rpx #2E4F1C solid;
	}
	.btn {
		width: 330rpx;
		margin: 50rpx auto;
		color: #ffffff;
		background: #2E4F1C;
		border-radius: 48rpx;
	}
</style>
