<template>
	<view style="padding-bottom:220rpx;">
		<!-- 发票信息 -->
		<view class="box flex justify-center">
			<view class="box-con flex justify-center">
				<view class="box-con-c">
					<view class="box-con-c-item flex justify-between align-center">
						<view class="box-con-c-item-l flex align-center">
							发票抬头
							<text style="color: red;font-size: 32rpx;margin-top: 20rpx;margin-left: 10rpx;">*</text>
						</view>
						<view class="box-con-c-item-r">
							<u-input v-model="taitou" input-align="right" type="text" placeholder="例:西安XXX有限公司" />
						</view>
					</view>
					<view class="box-con-c-item flex justify-between align-center">
						<view class="box-con-c-item-l flex align-center">
							纳税人识别号
							<text style="color: red;font-size: 32rpx;margin-top: 20rpx;margin-left: 10rpx;">*</text>
						</view>
						<view class="box-con-c-item-r">
							<u-input v-model="shibiehao" input-align="right" type="text" placeholder="请填写纳税人识别号" />
						</view>
					</view>
					<view class="box-con-c-item flex justify-between align-center">
						<view class="box-con-c-item-l flex align-center">
							发票类型
						</view>
						<view class="box-con-c-item-r">
							<u-input v-model="types" :disabled="true" input-align="right" type="text"
								placeholder="请填写发票类型" />
						</view>
					</view>
					<view class="box-con-c-item flex justify-between align-center">
						<view class="box-con-c-item-l flex align-center">
							发票内容
						</view>
						<view class="box-con-c-item-r">
							<u-input v-model="contents" input-align="right" type="text" placeholder="请填写发票内容" />
						</view>
					</view>
					<view class="box-con-c-item flex justify-between align-center">
						<view class="box-con-c-item-l flex align-center">
							发票金额
							<text style="color: red;font-size: 32rpx;margin-top: 20rpx;margin-left: 10rpx;">*</text>
						</view>
						<view class="box-con-c-item-r">
							<text style="color: #346EF6;">{{price}}元</text>
						</view>
					</view>
					<view class="box-con-c-item flex justify-between align-center">
						<view class="box-con-c-item-l flex align-center">
							注册地址
						</view>
						<view class="box-con-c-item-r">
							<u-input v-model="address" input-align="right" type="text" placeholder="请填写注册地址" />
						</view>
					</view>
					<view class="box-con-c-item flex justify-between align-center">
						<view class="box-con-c-item-l flex align-center">
							注册电话
						</view>
						<view class="box-con-c-item-r">
							<u-input v-model="zcphone" input-align="right" type="text" placeholder="请填写注册电话" />
						</view>
					</view>
					<view class="box-con-c-item flex justify-between align-center">
						<view class="box-con-c-item-l flex align-center">
							开户银行
						</view>
						<view class="box-con-c-item-r">
							<u-input v-model="yh" input-align="right" type="text" placeholder="请填写开户银行" />
						</view>
					</view>
					<view class="box-con-c-item flex justify-between align-center">
						<view class="box-con-c-item-l flex align-center">
							银行账号
						</view>
						<view class="box-con-c-item-r">
							<u-input v-model="yhzh" input-align="right" type="text" placeholder="请填写银行账号" />
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 收件人信息 -->
		<view class="info flex justify-center">
			<view class="info-box">
				收件人信息
			</view>
		</view>
		<view class="box flex justify-center">
			<view class="box-con flex justify-center">
				<view class="box-con-c">
					<view class="box-con-c-item flex justify-between align-center">
						<view class="box-con-c-item-l flex align-center">
							接收电子邮件
							<text style="color: red;font-size: 32rpx;margin-top: 20rpx;margin-left: 10rpx;">*</text>
						</view>
						<view class="box-con-c-item-r">
							<u-input v-model="email" input-align="right" type="text" placeholder="用于向你发送电子发票" />
						</view>
					</view>
					<view class="box-con-c-item flex justify-between align-center">
						<view class="box-con-c-item-l flex align-center">
							接收手机号
							<text style="color: red;font-size: 32rpx;margin-top: 20rpx;margin-left: 10rpx;">*</text>
						</view>
						<view class="box-con-c-item-r">
							<u-input v-model="phone" input-align="right" type="number" maxlength="11"
								placeholder="订单记录通过短信发送" />
						</view>
					</view>

				</view>
			</view>
		</view>

		<!-- 确认开票 -->
		<view class="btn flex justify-center">
			<view class="btn-box flex justify-center align-center" @click="submit">
				提交
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				zcphone: '',
				yh: '',
				yhzh: '',
				email: '',
				phone: '',
				address: '',
				types: '电子发票',
				contents: '',
				taitou: '',
				shibiehao: '',
				indentNumber: '',
				type: '',
				price: 0,
			};
		},
		onLoad(e) {
			this.price = e.price
			this.indentNumber = e.indentNumber

		},
		methods: {
			//提交
			submit() {
				if (this.taitou == '') {
					uni.showToast({
						title: '请输入发票抬头',
						icon: 'none'
					})
					return
				}
				if (this.shibiehao == '') {
					uni.showToast({
						title: '请输入纳税人识别号',
						icon: 'none'
					})
					return
				}
				if (this.email == '') {
					uni.showToast({
						title: '请输入接收电子邮件',
						icon: 'none'
					})
					return
				}
				if (this.phone == '') {
					uni.showToast({
						title: '请输入接收手机号',
						icon: 'none'
					})
					return
				}
				// let invoiceContent =
				// 	`<p><em>发票抬头:${this.taitou}</em></p>`+`<p><em>纳税人识别号:${this.shibiehao}</em></p>`+`${this.address!=''?'<p><em>注册地址:'+this.address+'</em></p>':''}`+`${this.zcphone!=''?'<p><em>注册电话:'+this.zcphone+'</em></p>':''}`+`${this.yh!=''?'<p><em>开户银行:'+this.yh+'</em></p>':''}`+`${this.yhzh!=''?'<p><em>银行账号:'+this.yhzh+'</em></p>':''}`
				
				let data = {
					indentNumber: this.indentNumber,
					userType: 1,
					invoiceType: 1,
					invoiceTitle: this.contents,
					invoiceMoney: this.price,
					userEmail: this.email,
					userPhone: this.phone,
					invoiceHeader:this.taitou,
					taxPayerNumber:this.shibiehao,
					bankAddress:this.address,
					bankPhone:this.zcphone,
					bankDeposit:this.yh,
					bankNumber:this.yhzh
				}
				this.$Request.postJson("/app/invoice/applyInvoice", data).then(res => {
					if (res.code == 0) {
						uni.showToast({
							title: '提交成功!'
						})
						setTimeout(() => {
							uni.navigateBack()
						}, 1000)
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		width: 100%;
		height: auto;
		margin-top: 20rpx;

		.box-con {
			width: 686rpx;
			height: 100%;
			background-color: #ffffff;
			border-radius: 16rpx;

			.box-con-c {
				width: 646rpx;
				height: 100%;
			}

			.box-con-c-item {
				width: 100%;
				height: 100rpx;
				border-bottom: 1rpx solid #f2f2f2;

				.box-con-c-item-l {
					width: 240rpx;
					height: 100%;
				}
			}
		}
	}

	.info {
		width: 100%;
		height: auto;
		margin-top: 20rpx;

		.info-box {
			width: 686rpx;
			color: #999999;
			padding-left: 20rpx;
		}
	}

	.btn {
		width: 100%;
		position: fixed;
		bottom: 0rpx;
		height: 200rpx;
		background-color: #ffffff;

		.btn-box {
			width: 686rpx;
			height: 100rpx;
			border-radius: 50rpx;
			background-color: #346EF6;
			color: #ffffff;
			margin-top: 40rpx;
		}
	}
</style>
