<template>
	<view class="container cashier">
		<cu-custom :navbar-data='nvabarData'></cu-custom>
		<view class="container-cash clearfix" :style="{marginTop:CustomBar+'px'}">
			<view class="container-wrapper">
				<view class="cash-icon">
					<text class="iconfont" :class="payStatus ? 'icon-wancheng' : 'icon-shibai'"></text>
				</view>
				<view class="cash-text">
					<text>{{ successText }}</text>
				</view>
			</view>
			<view class="container-amount">
				<view class="amount-label">支付金额</view>
				<view class="amount-money">￥{{ amuntMoney | NumFormat }}</view>
			</view>
			<view class="container-button">
				<view class="btn btn-home" v-if="payBtnStatus" @click="toAgainPay">继续下一笔支付</view>
				<view class="btn btn-home" v-else @click="this.$api.switchTabTo('/pages/tabBar/home/index')">回到首页</view>
				<view class="btn btn-open" @click="details">查看订单</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				orderId:0,
				nvabarData: {		//顶部自定义导航
					haveBack:false,
					haveHome:true,
					showCapsule:1, // 是否显示左上角图标  1表示显示  0表示不显示,
					showSearch: 0,
					title: '支付结果',  // 导航栏 中间的标题
					textLeft:this.$store.state.isIphone
				},
				payType:'',
				payStatus:true,
				payBtnStatus:false,
				amuntMoney:0,
				successText:'订单支付失败',
				isIphoneX:this.$store.state.isIphoneX,
				CustomBar:this.CustomBar,// 顶部导航栏高度
				mapStateArr:[11,12,13,21,22,23,111]
				
			}
		},
		filters:{
			NumFormat(value) {
			    //处理金额
			    if (value) {
			        return Number(value).toFixed(2)
			    } else {
			        return '0.00'
			    }
			}
		},
		onLoad(option) {
			this.initData(option)
		},
		methods:{
			initOrderInfo() {
			    this.orderInfo = uni.getStorageSync('orderInfo')
			    uni.removeStorageSync('orderInfo')
			},
			initData(option){
				const data = JSON.parse(option.data)
				this.orderId = data.data.orderId
				this.payType = data.data.type
				this.amuntMoney = data.data.payAmount
				if(this.payType == 'success'){
					this.payStatus = true
					this.successText = '订单支付成功'
				}else{
					this.payStatus = false
					this.successText = '订单支付失败'
				}
				this.PayOrderCheckoutCounter(this.orderId)
			},
			PayOrderCheckoutCounter(orderId){//初始化支付信息
				this.PayService.PayOrderCheckoutCounter({ orderId : orderId }).then(response =>{
					this.isRepuest = true
					const status = response.data.order.status //主订单状态
					this.mapStateArr.forEach(value => {
						if(status === value){
							this.payBtnStatus = true
						}
					})
				}).catch(error =>{
					this.$util.msg(error.msg,2000)
				})
			},
			toAgainPay(){
				this.$api.reLaunch(`/pages/user/order/order-pay-list?orderId=${this.orderId}`)
			},
			details(){
				this.$api.reLaunch('/pages/user/order/order-details?type=share&orderId='+this.orderId)
			}
		},
		onShow() {
			
		}
	}
</script>

<style lang="scss">
	page{
		height: auto !important;
	}
	.container-cash{
		width: 100%;
		.container-wrapper{
			width:100%;
			height: auto;
			padding: 120rpx 24rpx 0 24rpx;
			box-sizing: border-box;
			.cash-icon{
				width: 100%;
				height: 90rpx;
				text-align: center;
				.iconfont{
					font-size: 80rpx;
					&.icon-wancheng{
						color:#00BE6F ;
					}
					&.icon-shibai{
						color:#F94B4B ;
					}
				}
			}
			.cash-text{
				width: 100%;
				height: 90rpx;
				text-align: center;
				font-size: $font-size-28;
				color: $text-color;
				line-height: 90rpx;
				padding-bottom: 40rpx;
			}
		}
		.container-amount{
			width: 100%;
			height: 130rpx;
			box-sizing: border-box;
			padding: 0 24rpx;
			margin-bottom: 24rpx;
			font-size: $font-size-28;
			color: #333333;
			line-height: 90rpx;
			border-top: 20rpx solid #F7F7F7;
			border-bottom: 20rpx solid #F7F7F7;
			.amount-label{
				float: left;
				font-weight: bold;
			}
			.amount-money{
				float: right;
				text-align: right;
			}
		}
		.container-button{
			width: 100%;
			box-sizing: border-box;
			padding: 80rpx 75rpx;
			.btn{
				width: 100%;
				height: 90rpx;
				border-radius: 50rpx;
				line-height: 90rpx;
				box-sizing: border-box;
				text-align: center;
				font-size: $font-size-26;
				color: #FFFFFF;
				margin: 24rpx 0;
				&.btn-open{
					background:#FFFFFF;
					border: 1px solid $color-system;
					color: $color-system;
				}
				&.btn-home{
					background:$btn-confirm;
				}
			}
		}
	}
</style>
