<style>
	.jz_ReserTop {
		width: 100%;
		min-height: 300rpx;
		box-shadow: 0px 2px 15px 0px rgba(76, 76, 76, 0.13);
		background-color: #fff;
		border-bottom-left-radius: 60rpx;
		border-bottom-right-radius: 60rpx;
		padding: 40rpx;
	}

	.jz_ReserTitle {
		color: #111111;
		font-weight: bold;
		font-size: 36rpx;
	}

	.jz_ReserIn {
		color: #999999;
		font-size: 24rpx;
	}

	.jz_ReseQue {
		color: #DFBE6E;
		font-size: 24rpx;
		padding-top: 30rpx;
		border-top: 1px solid #E7E7E7;
		margin-top: 20px;
	}

	.jz_ReseQue img {
		width: 16px;
		height: 14px;
		position: relative;
		top: 2px;
		margin-right: 5px;
	}

	.jz_ReseOrder {
		padding: 40rpx;
	}

	.jz_ReDix {
		display: flex;
		align-items: center;
		margin-bottom: 10px;
	}

	.jz_RedixTitle {
		width: 90px;
		flex-shrink: 0;
	}

	.jz_OrderDiv {
		position: fixed;
		width: 90%;
		height: 100rpx;
		background-color: #fff;
		margin: auto;
		bottom: 20px;
		padding: 20rpx;
		left: 40rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-shadow: 0px 10px 30px 0px rgba(36, 36, 36, 0.2);
		border-radius: 16px;
		z-index: 999;
	}

	.jz_OrderReNow {
		width: 150rpx;
		height: 80rpx;
		background-color: #111111;
		text-align: center;
		line-height: 80rpx;
		color: #fff;
		font-weight: bold;
		font-size: 28rpx;
		border-radius: 16rpx;
	}
</style>
<template>
	<view class="jz_Reserve">
		<view class="jz_ReserTop">
			<view class="jz_ReserTitle">
				{{currentPriceInfo.title}}
			</view>
			<view class="jz_ReserIn" style="margin:33rpx 0 18rpx 0">
				{{currentPriceInfo.startCityName}}出发 {{currentPriceInfo.startDate}}
			</view>
			<view class="jz_ReseQue">
				<img src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/CustomizedCar/zuanshi.png" />即时确认：本产品付款后可快速确认，放心期待您的旅行
			</view>
		</view>
		<view class="jz_ReseOrder">
			<view class="jz_ReDix">
				<view class="jz_RedixTitle">成人：</view>
				<u-number-box v-model="orderMsg.ManNum" :input-width="300" :input-height="60" @change="changeMan()"></u-number-box>
			</view>
			<view class="jz_ReDix">
				<view class="jz_RedixTitle">儿童不占床：</view>
				<u-number-box v-model="orderMsg.ChirdNoBedNum" :input-width="300" :input-height="60" @change="changeChirdNoBedNum()"></u-number-box>
			</view>
			<view class="jz_ReDix">
				<view class="jz_RedixTitle">儿童占床：</view>
				<u-number-box v-model="orderMsg.ChirdNeedBedNum" :input-width="300" :input-height="60" @change="changeChirdNeedBedNum()"></u-number-box>
			</view>
			<view class="jz_ReDix">
				<view class="jz_RedixTitle">婴儿：</view>
				<u-number-box v-model="orderMsg.BabyNum" :input-width="300" :input-height="60" @change="changeBabyNum()"></u-number-box>
			</view>
		</view>
		<view class="jz_OrderDiv">
			<view style="color:#FF3166;font-weight:bold;">
				<text style="font-size:22rpx;">¥</text>
				<text style="font-size:40rpx;margin:0 20rpx 0 5rpx;">{{price}}</text>
				<text style="color:#6E6E6E;font-size:24rpx;">共计{{total}}人</text>
			</view>
			<view style="display:flex;margin-top:-2px;">
				<view class="jz_OrderReNow" @click="goPay()">下单</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				pageTitle: '订单填写',
				orderMsg: {
					ManNum: 0, //成人
					ChirdNoBedNum: 0, //儿童不占床
					ChirdNeedBedNum: 0, //儿童占床
					BabyNum: 0, //婴儿
					ChirdNum: 0, //儿童数量
				},
				price: 0,
				currentPriceInfo: {},
				total: 0,
				YSeatNum:0,
				ESeatNum: 0,
				FSeatNum: 0,
				sumSeat:0,
				userInfo:{}
			};
		},
		created() {},
		onLoad(option) {
			if (option.currentPriceInfo) {
				this.currentPriceInfo = JSON.parse(decodeURIComponent(option.currentPriceInfo))
			}
		},
		methods: {
			//改变成人
			changeMan(e) {
				this.orderMsg.ManNum = e.value;
				this.calcMoney();
			},
			//改变儿童不占床
			changeChirdNoBedNum(e) {
				this.orderMsg.ChirdNoBedNum = e.value;
				this.calcMoney();
			},
			//改变儿童占床
			changeChirdNeedBedNum(e) {
				this.orderMsg.ChirdNeedBedNum = e.value;
				this.calcMoney();
			},
			//改变婴儿
			changeBabyNum(e) {
				this.orderMsg.BabyNum = e.value;
				this.calcMoney();
			},
			//计算价格
			calcMoney() {
				var price=0;
				if(this.$utils.getretailer()){
					price = this.currentPriceInfo.b2BMemberPrice;
				}else{
					price = this.currentPriceInfo.b2CMemberPrice;
				}
				this.orderMsg.ChirdNum = parseInt(this.orderMsg.ChirdNoBedNum) + parseInt(this.orderMsg.ChirdNeedBedNum);
				//计算总人数
				this.total = parseInt(this.orderMsg.ManNum) + parseInt(this.orderMsg.ChirdNum);
				this.sumSeat = this.total;

				let money = price * this.orderMsg.ManNum
				money += price * this.orderMsg.ChirdNum
				money += this.currentPriceInfo.babyChargePrice * this.orderMsg.ChirdNeedBedNum
				money += this.currentPriceInfo.babyPrice * this.orderMsg.BabyNum
				money += this.currentPriceInfo.childNeedPrice * this.orderMsg.ChirdNeedBedNum
				if (this.orderMsg.ChirdNoBedNum > 0) {
					money -= this.currentPriceInfo.childNoNeedPrice * this.orderMsg.ChirdNoBedNum
				}
				this.price = money

			},
			//去支付
			goPay() {
				this.userInfo = uni.getStorageSync('mall_UserInfo');
				this.basedataObj = uni.getStorageSync('basedata').mall;
				var CustomerId = 0;
				var ContactName = '';
				var ContactMobile = '';
				var CustomerType = 3;
				var price=0;
				if(this.$utils.getretailer()){
					CustomerId =  this.basedataObj.virtualB2BCustomerId;
					CustomerType = 1;
					price = this.currentPriceInfo.b2BMemberPrice;
				}else{
					ContactName =  this.basedataObj.virtualB2CCustomerName;
					ContactMobile = this.basedataObj.virtualB2CCustomerTel;
					price = this.currentPriceInfo.b2CMemberPrice;
				}
				let msg = {
					OrderId: 0,
					TCID: this.currentPriceInfo.tcid,
					CustomerType: CustomerType,
					GroupType: 1,
					ContactName: ContactName,
					ContactMobile: ContactMobile,
					CustomerId: CustomerId,
					DepartureCityId: 262,
					IsIntermodal: 2,
					Unit_Price: price,
					TC_Price: price,
					ManNum: this.orderMsg.ManNum,
					ChirdNum: this.orderMsg.ChirdNum,
					ChirdNeedBedNum: this.orderMsg.ChirdNeedBedNum,
					BabyNum: this.orderMsg.BabyNum,
					OldPeopleNum: 0,
					SingleRoomNum: 0,
					PreferPrice: this.price,
					YSeatNum: this.total,
					ESeatNum: 0,
					FSeatNum: 0,
					Commission: 0, //todo 提成
					ClientSource: 2,
					BrandId: 0,
					TradeWay: 0,
					PlatformOrder: '',
					GuestNum: this.orderMsg.ManNum + this.orderMsg.ChirdNum,
					IsChildrenTour: this.currentPriceInfo.isSupportChildren,
					IsBirdDiscount: this.zaoniao > 0 ? 1 : 2,
					PredictRoomNum: 1,
					BigRoomNum: 0,
					TripleRoomNum: 0,
					TradeDate: this.currentPriceInfo.startDate,
					CostType: 0,
					MinOrderPrice: 0,
					Remarks: '',
					VisaNum: this.orderMsg.ManNum + this.orderMsg.ChirdNum,
					SafeNum: this.orderMsg.ManNum + this.orderMsg.ChirdNum,
					AirticketNum: 0,
					ReturnArriveCityId: 262,
					IsReturnIntermodal: 2,
					GoCityTime: '',
					BackCityTime: '',
					ScenicRefundArr: [],
					CommissionSharePeople: 0,
					CommissionShareMoney: 0,
					OrderSource: 2,
					MiniAppUserId:this.userInfo.UserId
				}
				this.apipost("sellorder_post_SetOrderInfoForB2B", msg,
					res => {
						if (res.resultCode == 1) {
							let data = res.data;
							data.CoverImg = this.currentPriceInfo.CoverImg;
							let myData = JSON.stringify(data);
							uni.navigateTo({
								url: "/pages/jiuzhai/jz_SureOrder?orderData="+encodeURIComponent(myData)
							});
						} else {

						}
					},
					null
				);
			}
		}

	};
</script>
