<template>
	<view>
		<ujp-navbar :title="title" :is-back="false" ></ujp-navbar>
		<view class="paySuccess">
			<u-icon :name="detail.payStatus==20?'chenggong':'close-circle-fill'" custom-prefix="custom-icon" size="180" :color="detail.payStatus==20?'#00B962':'#ff9800'"></u-icon>
			
			<view class="title oldTextjp" oldstyle="font-size: 20px;" v-if="detail.type=='1'">{{detail.payStatusStr}}</view>
			<view class="title oldTextjp" oldstyle="font-size: 20px;" v-if="detail.type=='2'" >开通{{detail.payStatus==20?'成功':'失败'}}</view>
			
			<view class="payPrice">
				<font>{{detail.totalFee?detail.totalFee.toFixed(2):0}}</font><span>元</span>
			</view>
			<p class="oldTextjp2" oldstyle="font-size: 16px;"  >{{detail.payNameStr}}</p>
		
			
		</view>
		<view class="paySuccess-btn" v-if="detail.type=='1'">
			<u-button class="success-btn1 oldTextjp2" oldstyle="font-size: 18px;" shape="circle" type="" @click="rechargeContinue">
				<span>继续充值</span>
			</u-button>
			
			
			<u-button class="success-btn2 oldTextjp2" oldstyle="font-size: 18px;"
			 v-if="detail.recordId&&detail.payStatus==20"
			 shape="circle" type="success" @click="chargeLook2">
				<span>前往充电中</span>
			</u-button>
			<u-button class="success-btn2 oldTextjp2" oldstyle="font-size: 18px;"
			 v-else-if="charge"
			 shape="circle" type="success" @click="chargeLook">
				<span>前往充电</span>
			</u-button>
			
			
			<u-button class="success-btn2 oldTextjp2" oldstyle="font-size: 18px;"
			 v-else
			 shape="circle" type="success" @click="balanceLook">
				<span>查看余额</span>
			</u-button>
		</view>
		<view class="paySuccess-btn" v-if="detail.type=='2'">
			
			<u-button class="success-btn1 oldTextjp2" v-if="detail.payStatus!=20" oldstyle="font-size: 18px;" shape="circle" type="" @click="getInfo">
				<span>刷新</span>
			</u-button>
			
			<u-button class="success-btn2 oldTextjp2" oldstyle="font-size: 18px;" shape="circle" type="" @click="userindex">
				<span>返回</span>
			</u-button>
			
			
		</view>
		<view class="discounts" style="padding:0 18px;margin-top: 20px;" v-if="bannerList.length" >
			<u-swiper bg-color="#fff" :img-mode="'scaleToFill'" height="160" :list="bannerList"  mode="none"  @click="clickBanner"
				:name="'picUrl'">
			</u-swiper>
		</view>
	</view>
</template>

<script>
	import * as API from '@/apis/finance.js'
	import * as newsApi from '@/apis/news.js'
	
	export default {
		data() {
			return {
				detail: {},
				id: "",
				charge:false,
				chargeObj:{},
				title:'充值结果',
				bannerList:[],
			}
		},
		onLoad(op) {
			if(op.id){
				this.id=op.id
				this.getInfo();
			}
			var obj=this.carhelp.getGunIdCharge();
			if(obj){
				this.charge=true
				this.chargeObj=obj
			}
			this.getBannerInfo("recharge-end")
		},
		onReady() {
			
		},
		methods: {
			clickBanner(index){
				var mod= this.bannerList[index]
				
				if(mod.linkUrl.indexOf('http')==0){
				    window.location=mod.linkUrl;
				}
				else if(mod.linkUrl.indexOf('#/')==0){
					if(mod.linkUrl.indexOf("?")==-1){
						mod.linkUrl+='?';
					}
				    //window.location=mod.linkUrl;
					var url=mod.linkUrl.split("#")[1]
					//window.location = mod.clickUrl;
					uni.navigateTo({
						url: url
					})
				}
				else if(mod.linkUrl=='#'||mod.linkUrl==''){
				
				}
				else{
					uni.navigateTo({
						url:mod.linkUrl
					})
				}
				
			},
			getBannerInfo(code){
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				newsApi.getBannerInfo(code).then((res) => {
					uni.hideLoading();
					this.bannerList =res.data;
					
					// document.getElementsByClassName("uni-swiper-wrapper")[0].parentNode.style="background-color: rgb(255, 255, 255); height: 300px;"
				 }).catch(error => {
						uni.showToast({
						
							title: error,icon: "none"
						})
				})
			},
			getInfo() {
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				API.accountDetail({
					outOrderNo: this.id
				}).then((res) => {
					uni.hideLoading()

					this.detail = res.data.orderInfo;
					if(this.detail.type=='2'){
						this.title='开通会员'
					}
					
				}).catch(error => {
					uni.showToast({
						title: error,
						icon: "none"
					})
				})
			},
			userindex() {
				uni.redirectTo({
					url: '/pages/user/index'
				})
			},
			rechargeContinue() {
				uni.redirectTo({
					url: '/pages/user/finance/recharge'
				})
			},
			chargeLook2(){
			 	
				uni.redirectTo({
					url:"/pages/searchPile/chargeProcess/dcCharging?id=" + this.detail.recordId
				})
				
			},
			chargeLook(){
				
				uni.redirectTo({
					url:'/pages/searchPile/chargeProcess/charge?isback=1&deviceNo='+this.chargeObj.deviceNo+"&gun="+this.chargeObj.channelNo+"&carNumber="+this.chargeObj.carNumber
				})
				
			},
			balanceLook() {
				uni.redirectTo({
					url: '/pages/user/finance/balance'
				})
			}
		}
	}
</script>
<style>
	page {
		background-color: #fff;
	}
</style>
<style lang="scss" scoped>
	.paySuccess {
		text-align: center;
		padding: 50px 0;

		.title {
			font-size: 20px;
			margin-top: 20px;
		}

		.payPrice {
			display: flex;
			align-items: flex-end;
			justify-content: center;

			font {
				font-size: 36px;
				line-height: 36px;
			}

			margin-top: 20px;
		}

		p {
			color: #999;
			margin-top: 4px;
		}
	}

	.paySuccess-btn {
		display: flex;
		justify-content: space-between;
		padding: 0 40px;
	}

	.success-btn1 {
		color: #BBBBBB !important;
		background-color: #fff !important;
		flex: 0.4;

		span {
			color: #333;
		}
	}

	.success-btn2 {
		background-color: #00B962 !important;
		flex: 0.4;
		border-color: #00B962 !important;
		color: #fff !important;
	}
</style>
