confirm.vue 2.5 KB
<template>
	<view class="confirmWrap">
		<view class="confirm">
			<view class="confirmTitle">
				{{title}}
			</view>
			<view class="inpNumWrap">
				<view class="inpNum" v-if="handleType == 'inpNum'">
					<input type="number" v-model="price" placeholder="请输入金额"/>
				</view>
				<view class="inpTxtArea" v-if="handleType == 'inpTxtArea'">
					<textarea placeholder="请输入理由" v-model="remark"/>
				</view>
			</view>
			
			<view class="confirmBtnList">
				<view class="confirmBtn" @click="cancel">
					取消
				</view>
				<view class="confirmBtn" @click="confirm" style="color: #35655f;">
					确定
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				price:'',
				remark:''
			}
		},
		props:{
			title:{
				type:String
			},
			handleType:{
				type:String
			}
		},
		methods:{
			confirm(){
				if(this.handleType == 'inpNum'){
					if(this.price == ''){
						uni.showToast({
							title:'请输入金额',
							icon:'none'
						})
						return
					}
					this.$emit('confirm',{price:this.price})
				}
				if(this.handleType == 'inpTxtArea'){
					if(this.remark == ''){
						uni.showToast({
							title:'请输入理由',
							icon:'none'
						})
						return
					}
					this.$emit('confirm',{remark:this.remark})
				}
			},
			cancel(){
				this.$emit('cancel')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.confirmWrap{
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 1;
		background: rgba(0,0,0,0.5);
		display: flex;
		align-items: center;
		justify-content: center;
		.confirm{
			background: #fff;
			width: 622rpx;
			border-radius: 30rpx;
			.confirmTitle{
				padding: 50rpx 48rpx;
				font-size: 32rpx;
				text-align: center;
			}
			.inpNumWrap{
				padding: 16rpx 48rpx 80rpx 48rpx;
				.inpNum{
					width: 100%;
					height: 80rpx;
					background: #f7f8fa;
					border-radius: 16rpx;
					display: flex;
					align-items: center;
					padding:0 20rpx;
					input{width: 100%;}
				}
				.inpTxtArea{
					width: 526rpx;
					height: 280rpx;
					background: #f7f8fa;
					border-radius: 16rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					textarea{width: 500rpx;height: 260rpx;}
				}
			}
			.confirmBtnList{
				border-top: 2rpx solid #ebedf0;
				display: flex;
				height: 95rpx;
				.confirmBtn{
					flex: 1;
					text-align: center;
					line-height: 95rpx;
					border-right: 2rpx solid #ebedf0;
				}
				.confirmBtn:nth-of-type(2){border-right: none;}
			}
		}
	}
</style>