<template>
	<view class="main">
		<uni-icons type="minus-filled" size="20" color="#A67A54" @click="numReduce"></uni-icons>
		<!-- <text class="buy-select">{{number}}</text> -->
		<u-input
		  v-model="number"
		  type="number"
		  height="40"
		  :placeholder="placeholder"
		  :clearable="false"
		  :disabled="isDisabled"
		  input-align="center"
		  :custom-style="{width:'45px'}"/>
		<uni-icons type="plus-filled" size="20" color="#A67A54" @click="numPlus"></uni-icons>
	</view>
</template>

<script>
	export default {
		props: {
			isDisabled: {
				default: false
			},
			placeholder: {
				default: ''
			},
			step: {
				default: 1
			},
			minNum: {
				default: 0.01
			}
		},
		data() {
			return {
			    number: 1,
			}
		},
		methods: {
			numPlus() {
			    this.number = Number(this.number) + Number(this.step)
				this.$emit('getNum',this.number);
			},
			numReduce() {
			    if ((Number(this.number) - Number(this.step)) >= Number(this.minNum)) {
				    this.number = Number(this.number) - Number(this.step)
			    }
				this.$emit('getNum',this.number);
			}
		}
	}
</script>

<style>
</style>
<style lang="less" scoped>
	.main {
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}
</style>
