<template>
	<view class="contentColumnC">
		<view class="contentColumnC" style="width:700rpx;background-color: white;">
			<view class="contentInRowL sizeSpace">
				<text class="ztextfontB2">费用明细</text>
			</view>
			<view class="contentInRowS sizeSpace">
				<view class="contentInRowL" style="align-items:center;">
					<text class="textfontB3">总费用：</text>
					<text style="font-size: 50rpx;font-weight: bold;">{{XChengObj.amount}}</text>
					<text class="textfontB3">元</text>
				</view>
				<!-- <view class="contentInRowR">
					<text class="textfontB3">支付宝支付</text>
					<uni-icons></uni-icons>
				</view> -->
			</view>
			<!-- <view class="contentInRowL sizeSpace">
				<text class="textfontB3" style="color:darkgray;width: 660rpx;">预估价不含附加费，本次行程产生高速费12元，与预估相比正常，且无其他附加费用</text>
			</view> -->
			<view class="contentInRowS sizeSpace">
				<text class="textfontB3">起步费</text>
				<text class="textfontB3">{{qibuf}}元</text>
			</view>
			<view class="contentInRowS sizeSpace">
				<text class="textfontB3">里程费</text>
				<text class="textfontB3">{{XChengObj.fare}}元</text>
			</view>
			<view class="contentInRowS sizeSpace">
				<text class="textfontB3">其他费用</text>
				<text class="textfontB3">{{getqitafy()}}元</text>
			</view>
			<!-- <view class="contentInRowS sizeSpace">
				<text class="textfontB3">优惠券</text>
				<text class="textfontB3">0元</text>
			</view> -->
			<view class="contentColumnC bottomViewBt">
				<text class="quxiaoBt" @click="quzhifu">去支付</text>
			</view>
		</view>
	</view>
</template>

<script>
import api from "@/pages/api/api.js"
	export default {
		name:"dachejiesuan",
		props: {
			XChengObj:'',
			qibuf:0
		},
		data() {
			return {
				
			};
		},
		methods:{
			getqitafy(){
				var qt =  this.XChengObj.amount*1-this.XChengObj.fare*1-this.qibuf*1;
				if(qt<=0){
					qt=0;
				}
				return qt.toFixed(2);
			},
			quzhifu(){
				uni.showToast({
					title:'模拟支付完成',//that.i18n('api.wangluoshibai'),
					icon: 'none',
					duration: 2500
				})
				var data = {
					id:this.XChengObj.id,
					state:4
				}
				this.SetTxorder(data,0);
			},
			
			SetTxorder(data,index){
				api('SetTxorder',data,res=>{
					console.log('SetTxorder------',res)
					if(res.data.code==200){
						this.pushMsg(this.XChengObj.driver.cid,this.XChengObj.user.phone,'乘客支付了');
						uni.showToast({
							title:'修改成功',//that.i18n('api.wangluoshibai'),
							icon: 'none',
							duration: 2500
						})
						this.$emit('EZfSelect',1);
					}
					else{
						uni.showToast({
							title:'修改失败',//that.i18n('api.wangluoshibai'),
							icon: 'none',
							duration: 2500
						})
					}
				},failc=>{
					//console.log('getTaxiPrices----',failc)
					uni.showToast({
						title:'网络错误',//that.i18n('api.wangluoshibai'),
						icon: 'none',
						duration: 2500
					})
				})
			},
			pushMsg(cid,phone,msg){//消息推送
				var time=new Date();
				var n,y,r,h,m,s;
				n=time.getFullYear();
				y=time.getMonth()+1;
				r=time.getDate();
				h=time.getHours();
				m=time.getMinutes();
				s=time.getSeconds();
				
				var timsStr = n+'-'+y+'-'+r+' '+h+':'+m+':'+s;
				var payloadData={
					rcuser:'尾号：'+phone.slice(-4),
					time:timsStr,
					msg:msg,
					type:1
				}
				api('pushMsgQS',{
					cid:cid,
					title:'您有新消息了',
					content:msg,
					payload:payloadData
				},res=>{
					
				},failc=>{
					//console.log('getadvertis----',failc)
				})
			},
			getVNPay(){
				var language = uni.getStorageSync('language');
				var lg;
				if(language=='yuenan'){
					lg='vi';
				}
				else{
					lg='en';
				}
				
				api('VNPay',{
					orderid:this.XChengObj.ddId,
					amount:this.XChengObj.amount,
					language:lg
				},res=>{
					if(res.data.code!=200){
						uni.showToast({
						    title: res.data.msg,
						    icon: 'none',
						    duration: 3500
						})
						return;
					}
					uni.navigateTo({
						url:'/pages/OrderList/buy/Zhifuyemian?url='+ encodeURIComponent(JSON.stringify(res.data.data))+'&ddid='+this.XChengObj.ddId
					})
				},failc=>{
					//console.log('getadvertis----',failc)
				})
			},
		},
	}
</script>

<style>
.sizeSpace{
	width:660rpx;
	margin-top: 20rpx;
	align-items: center;
}
.bottomViewBt{
	margin-top: 40rpx;
	width:580rpx;
}

.quxiaoBt{
	margin-top: 30rpx;
	margin-bottom: 30rpx;
	padding-left: 50rpx;
	padding-right: 50rpx;
	font-size: 32rpx;
	font-weight: bold;
	line-height: 60rpx;
	border-radius: 30rpx;
	text-align: center;
	background-color: #E86E48;
	color: white;
}

.querenBt{
	margin-top: 30rpx;
	margin-bottom: 30rpx;
	padding-left: 50rpx;
	padding-right: 50rpx;
	font-size: 32rpx;
	font-weight: bold;
	border: 1rpx solid darkgray;
	line-height: 60rpx;
	border-radius: 30rpx;
	text-align: center;
	background-color: white;
	color: #1A1A1A;
}
</style>