<template>
	<view>
		<view class="block">
			<view class="content">
				<view class="orderinfo">
						<view class="nominal">订单信息:</view>
						<view class="order-info" v-for="row in rdata.shop_db" v-bind:key="rdata.id">
							<view class="left">
								<image :src="row.picurl"></image>
							</view>
							<view class="right">
								<view class="name">
									{{row.full_title}}
								</view>
								<!-- <view class="spec">{{row.spec}}</view> -->
								<view class="price-number">
									￥<view class="price">{{row._price}}</view>
									x<view class="number">{{row._num}}</view>
								</view>
							</view>
							
						</view>
					<view class="row">
						<view class="nominal">订单金额:</view><view class="text">{{rdata.totalmoney}}元</view>
					</view>
				</view>
			</view>
		</view>
		<view class="row2">
			<view class="nominal">开票信息:</view>
			<view class="nominal">
				<radio-group @change="radioChange">
				<label class="radio"><radio value="1" />普票</label>
				<label class="radio"><radio value="2" checked/>专票</label>
				</radio-group>
			</view>
		</view>
		<!-- 开票信息 -->
		<view class="addr" @tap="selectInvoice" style="margin-top: 2px;">		
			<view class="right" v-if="invoiceinfo.id" >
				<view class="tel-name"  >
						<view class="name">
							{{invoiceinfo.name}}
						</view>
						<view class="tel">
							{{invoiceinfo.duty_paragraph}}
						</view>
					</view>
					<view class="addres">
						{{invoiceinfo.address}}
						<!-- {{recinfo.address.region.label}}
						{{recinfo.address.detailed}} -->
					</view>
				</view>
				<view class="right" v-else>
					请选择发票信息
				</view>
		</view>
		<view class="pay">
			<view class="btn" @tap="upApply()">提交</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				amount:0,
				orderName:'',
				paytype:'alipay',//支付类型
				imageValue:[],
				rdata:{},
				count:1,
				name:'file',
				url:'',
				filepath:null,
				invoiceinfo:{},
				if_invoice:2
			};
		},
		onLoad(e) {
			// this.amount = parseFloat(e.amount).toFixed(2);
			
			uni.getStorage({
				key:'paymentOrder',
				success: (e) => {
					// if(e.data.shop_db.length>1){
					// 	this.orderName = '多商品合并支付'
					// }else{
					// 	this.orderName = e.data.shop_db[0].title;
					// }
					this.rdata = e.data
				}
			})
			
			
		},
		onShow(){
			uni.getStorage({
				key: 'selectInvoice',
				success: (e) => {
					this.invoiceinfo = e.data;
				}
			})
		},
		methods:{
			radioChange(e){
				this.if_invoice = e.detail.value
			},
			doDeposit(){
				//模板模拟支付，实际应用请调起微信/支付宝
				uni.showLoading({
					title:'支付中...'
				});
				setTimeout(()=>{
					uni.hideLoading();
					uni.showToast({
						title:'支付成功'
					});
					setTimeout(()=>{
						uni.redirectTo({
							url:'../../pay/success/success?amount='+this.amount
						});
					},300);
				},700)
			},
			select(e){
				this.filepath = e.tempFilePaths[0]
			},
			selectInvoice(){
				uni.navigateTo({
					url: '../user/invoice/invoice?type=select'
				})
			},
			upApply(){
				if(this.invoiceinfo.id){
					let data = {
						if_invoice:this.if_invoice,
						invoice:this.invoiceinfo.id
					}
					this.$u.api.tjkp(this.rdata.id,data).then(res=>{
						uni.showToast({
							title:'提交成功',
							icon:'none'
						})
						uni.navigateBack({
							
						})
					})
				}else{
					uni.showToast({
						title:'请选择发票信息',
						icon:'none'
					})
				}
			},
		}
	}
</script>

<style lang="scss">
	.row2{
		padding:20upx;
	}
	.addr {
		width: 95%;
		padding: 20upx;
		margin: 30upx auto 20upx auto;
		box-shadow: 0upx 5upx 20upx rgba(0, 0, 0, 0.1);
		border-radius: 20upx;
		display: flex;
	
		.icon {
			width: 80upx;
			height: 80upx;
			display: flex;
			align-items: center;
	
			image {
				width: 60upx;
				height: 60upx;
			}
		}
	
		.tel-name {
			width: 100%;
			display: flex;
			font-size: 32upx;
	
			.tel {
				margin-left: 40upx;
			}
		}
	
		.addres {
			width: 100%;
			font-size: 26upx;
			color: #999;
		}
	}
.block{
		width: 94%;
		padding: 0 3% 40upx 3%;
		.title{
			width: 100%;
			font-size: 34upx;
		}
		.content{
			.nominal{
				color:gray;
			}
			.orderinfo{
				width: 100%;
				border-bottom: solid 1upx #eee;
				.order-info{
					width: 100%;
					display: flex;
					margin-top: 4upx;
					.left{
						flex-shrink: 0;
						width: 25vw;
						height: 20vw;
						image{
							width: 25vw;
							height: 20vw;
							border-radius: 10upx;
						}
					}
					.right{
						width: 100%;
						margin-left: 10upx;
						position: relative;
						.name{
							width: 100%;
							font-size: 28upx;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
							overflow: hidden;
						}
						.spec{
							color: #a7a7a7;
							font-size: 22upx;
				
						}
						.price-number{
							position: absolute;
							bottom: 0;
							width: 100%;
							display: flex;
							justify-content: flex-end;
							font-size: 22upx;
							color: #333;
							display: flex;
							align-items: flex-end;
							.price{
								font-size: 24upx;
								margin-right: 5upx;
							}
							
						}
					}
				}
			}
			.pay-list{
				width: 100%;
				border-bottom: solid 1upx #eee;
				.row{
					width: 100%;
					height: 120upx;
					display: flex;
					align-items: center;
					.left{
						width: 100upx;
						flex-shrink: 0;
						display: flex;
						align-items: center;
						image{
							width: 80upx;
							height: 80upx;
						}
					}
					.center{
						width: 100%;
						font-size: 30upx;
					}
					.right{
						width: 100upx;
						flex-shrink: 0;
						display: flex;
						justify-content: flex-end;
					}
				}
			}
		}
	}
	.pay{
		margin-top: 20upx;
		width: 100%;
		display: flex;
		justify-content: center;
		flex-wrap: wrap;
		.btn{
			width: 70%;
			height: 80upx;
			border-radius: 80upx;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #fff;
			background-color: #f06c7a;
			box-shadow: 0upx 5upx 10upx rgba(0,0,0,0.2);
		}
		.tis{
			margin-top: 10upx;
			width: 100%;
			font-size: 24upx;
			display: flex;
			justify-content: center;
			align-items: baseline;
			color: #999;
			.terms{
				color: #5a9ef7;
			}
		}
	}
</style>
