<template>
	<view class="container">
		<view class="content">
			<image class="close" src="../../static/close-gray.png" mode="" @click="close()"></image>
			<view class="title">请输入支付密码</view>
			<view class="subTitle">您即将支付</view>
			<view class="integral">{{integral}}<text>积分</text></view>
			<validCode ref="pwd" :maxlength="6" :isPwd="true" @finish="getPwd" @inputChange="inputChange"></validCode>
			<view @click="submit()" class="buy-bottom" :style="{'background-color':btnActive?'#FF0520':''}">确认支付</view>
		</view>
	</view>
</template>

<script>
	import validCode from '../validCode/validCode'
	export default {
		name:"setPwdAlert",
		components: {validCode},
		data() {
			return {
				pwd: '',
			};
		},
		computed: {
			btnActive() {
				return this.pwd.length === 6
			}
		},
		props: {
			closeName: {
				type: String
			},
			integral: {
				type:String
			}
		},
		methods: {
			getPwd(e) {
				this.pwd = e
			},
			inputChange(e) {
				this.pwd = e
			},
			submit() {
				if (!this.btnActive) {
					return
				}
				this.$emit('pwdSubmit', this.pwd)
				this.close()
			},
			close() {
				this.pwd = ''
				this.$refs.pwd.clear()
				this.$parent[this.closeName] = false
			}
		}
	}
</script>

<style lang="scss" scoped>
.container {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba($color: #000000, $alpha: 0.7);
	z-index: 99999;
	.content {
		margin: 50% 55rpx;
		border-radius: 16rpx;
		background-color: #FFFFFF;
		padding: 48rpx 40rpx;
		// width: 640rpx;
		position: relative;
		.close {
			position: absolute;
			top: 24rpx;
			right: 24rpx;
			height: 36rpx;
			width: 36rpx;
		}
		.title {
			font-size: 32rpx;
			font-weight: bolder;
			color: #333333;
			line-height: 44rpx;
			text-align: center;
		}
		.subTitle {
			margin-top: 24rpx;
			font-size: 32rpx;
			color: #666666;
			line-height: 44rpx;
			text-align: center;
		}
		.integral {
			margin-top: 32rpx;
			margin-bottom: 48rpx;
			font-size: 60rpx;
			color: #FF0520;
			font-weight: bolder;
			text-align: center;
			text {
				font-size: 40rpx;
			}
		}
		.buy-bottom {
			margin-top: 96rpx;
			border-radius: 40rpx;
			height: 80rpx;
			width: 560rpx;
			background-color: rgba($color: #FF0520, $alpha: 0.5);
			line-height: 82rpx;
			text-align: center;
			color: #FFFFFF;
			font-size: 32rpx;
			z-index: 99999;
			margin-bottom: 32rpx;
		}
	}
}
</style>
