<template>
	<view class="content">
		<view class="success-title">{{payResult == 1 ? '开通成功' : (payResult == 0 ? '待支付' : '开通失败')}}</view>
		<view class="success-icon">
			<u-icon name="clock-fill" :color="mainColor" size="156" v-if="payResult == 0"></u-icon>
			<u-icon name="checkmark-circle-fill" color="#19be6b" size="156" v-else-if="payResult == 1"></u-icon>
			<u-icon name="close-circle-fill" color="#fa3534" size="156" v-else-if="payResult == 2"></u-icon>
		</view>
		<view class="success-text">{{payResult == 1 ? '恭喜您!开通会员成功!' : (payResult == 0 ? '请支付该订单!' : '支付失败!无法开通会员!')}}</view>
		<view class="success-text">订单号:{{orderId}}</view>
		<view class="handle-fix-box">
			<u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="goBack()">返回</u-button>
		</view>
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	const NET = require('@/utils/request')
	const API = require('@/config/api')
	export default {
		computed: {
			...mapGetters([
				'mainColor',
				'customStyle',
			])
		},
		data() {
			return {
				orderId: '',
				payResult: '0',
			}
		},
		onLoad(options) {
			this.orderId = options.id
			NET.request(API.getPayResult, {
				oderNo: this.orderId
			}, 'POST').then(res => {
				this.payResult = res.data.status
			}).catch(error => {
				this.$refs.uTips.show({
						title: error.message,
					type: 'warning',
				})
			})
		},
		onReady() {},
		methods: {
			//  返回
			goBack() {
				uni.navigateBack()
			},
		},
	}
</script>

<style>
	page {
		width: 100%;
		height: 100%;
		position: relative;
	}
</style>
<style lang="scss" scoped>
	@import "@/static/css/themes.scss";
	.content {
		width: 100%;
		float: left;
		padding: 0 15px 60px 15px;
		box-sizing: border-box;

		.success-title {
			width: 100%;
			height: 64px;
			float: left;
			line-height: 48px;
			font-size: 28px;
			text-align: center;
		}

		.success-icon {
			width: 100%;
			float: left;
			text-align: center;
			margin-bottom: 20px;
		}

		.success-text {
			width: 100%;
			height: 20px;
			float: left;
			line-height: 20px;
			font-size: 12px;
			text-align: center;
		}
	}
</style>