<template>
	<view class="app">
		<view class="header" :style="{'background': data.color}">
			<image :src="page.icon" class="success-image"></image>
			<view class="success-title">支付成功</view>
			<view class="hr"></view>
		</view>
		<view class="info-box">
			<view class="info-amount" :style="{'color': data.color}">¥ {{ data.price }}</view>
			<view class="left-circle"></view>
			<view class="right-circle"></view>
			<view class="info-main">
				<view class="info-cell">
					<view class="left">订单编号</view>
					<view class="right">{{ data.orderId }}</view>
				</view>
				<view class="info-cell" v-if="!(page.createTime == undefined||page.createTime=='')">
					<view class="left">下单时间</view>
					<view class="right">{{page.createTime}}</view>
				</view>
				<view class="info-cell">
					<view class="left">支付方式</view>
					<view class="right">{{ data.pay }}</view>
				</view>
				<view class="info-cell" v-if="!(page.payTime == undefined||page.payTime=='')">
					<view class="left">支付时间</view>
					<view class="right">{{page.payTime}}</view>
				</view>
			</view>
		</view>
		<view v-if="!(data.order_url==undefined||data.order_url==null)" class="button-query"
			:style="{'background': data.color}" @click="queryOrder">查看订单
		</view>
		<view class="footer-hr"></view>
	</view>
</template>

<script>
	import {
		http
	} from '../../utils/pay_http.js'
	export default {
		data() {
			return {
				page: {
					icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAEAYAAAD6+a2dAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAAASAAAAEgARslrPgAACAlJREFUeNrtnVlszF8Ux++d4B+JWhqERGJvlRJLJQ1RHsQeFEXFUmt5scWWiPVB2qKERIglSpEg9vJAYn8RQlRFI5ryYm+prbZ7/g/fOdPOtNPfdDrjzEx/n5dvf3fuTM895869v3t/997RKswhQ4ZM69a4SkpSWmmle/TAdbdu0JgYaIsW0ObNoU2auH/a16/QT5+gpaXQwkLos2fQggJFihTdvq0d2qEd795J+yHiQaD794dmZxMREeXnQ40hEfj/5ufDru3boQkJ0v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Hl0iW0wBMmiB0WzbgMIEWKxo2DcotgE1hycwMV+KDBXQNahq1bpR9/hDe8QCczExqG2/dh+Pjx0PryuLWufP4MnTxZOn4Brgi8jv7WLWkXhyY3b0Kr7pSKGFBAz5+NC9eNFXWFfzZuwQL2i3R8hCpE8+bQ9evdHRNp8Ba8detcB0bYuAPHNGkCRy1fDn3yRDp0/sErq5Yt43JJ+zdsgSP79HEfXTx6BJVavcvLqx8+5M2kSK9hzV2IEfZ9jmt9u/PUK4yTu3fHdVwcrvnn4/nM3Bp+Pp4UKeKHKiUlyF9Y6Dq4QiuttOfPx/NCk/Djf0hQD04eJaNOAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIyLTEwLTI3VDE0OjAzOjAyKzA4OjAwisT1owAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMi0xMC0yN1QxNDowMzowMiswODowMPuZTR8AAABQdEVYdHN2ZzpiYXNlLXVyaQBmaWxlOi8vL2hvbWUvYWRtaW4vaWNvbi1mb250L3RtcC9pY29uX3ZwM212emVpcjcvemhpZnVjaGVuZ2dvbmcuc3ZntdPldAAAAABJRU5ErkJggg==",
					payTime: '',
					createTime: ''
				},
				data: {
					"price": "0.01",
					"order_url": {
						"page": "/pages/index2/index2",
						"params": {
							"trade_no": "velit Duis"
						}
					},
					"pay_url": {
						"url": "http://192.168.2.110:7777/order/pay ",
						"params": {
							"mainSid": "9e04ee75-3b85-49eb-a24c-8a608814035d",
							"type": "wxpay"
						}
					},
					"trade_no_url": {
						"url": "http://192.168.2.110:7777/order/orderQuery",
						"params": {
							'mainSid': '9ebb7ca3-3203-4e91-b256-32ad0f821afd'
						}
					},
					"orderId": "288320940398",
					"remainder": 33,
					"goods": "无骨鸡柳等3件商品",
					"color": "#09bb07",
					"pay": "微信"
				}
			}
		},
		// 监听 - 页面每次【加载时】执行(如：前进)
		onLoad(options = {}) {
			try {
				// 跳转携带数据
				this.data = JSON.parse(options.data)
			} catch (e) {
				this.data = JSON.parse(decodeURIComponent(options.data))
			}

			http({
				url: this.data.trade_no_url.url,
				data: this.data.trade_no_url.params
			}).then((res) => {
				this.page.payTime = res.data.time_end
				this.page.createTime = res.data.createTime
			}).catch((err) => {
				console.log('fail', JSON.stringify(err));
			});
		},
		onUnload() {
			let bus = this.data.bus
			for (var i = 0; i < bus.length; i++) {
				uni.$emit(bus[i] + '')
			}
		},
		// 函数
		methods: {
			queryOrder() {
				// 数据源转换成字符
				let data = JSON.stringify(this.data.order_url.params)
				// 转码传输
				let value = encodeURIComponent(data)
				uni.redirectTo({
					url: this.data.order_url.page + '?data=' +
						value
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
	.app {
		--bgcolor: #f3f3f3;

		background-color: var(--bgcolor);
		min-height: calc(100vh - var(--window-bottom) - var(--window-top));
	}

	.header {
		text-align: center;
		color: #ffffff;
		padding: 80rpx 30rpx 50rpx 30rpx;

		.success-image {
			width: 120rpx;
			height: 120rpx;
		}

		.success-title {
			font-size: 34rpx;
			margin-top: 40rpx;
			font-weight: bold;
		}

		.hr {
			margin-top: 40rpx;
			width: 100%;
			height: 30rpx;
			border-radius: 20rpx;
			opacity: 0.1;
			background-color: #000000;
		}
	}

	.info-box {
		width: calc(100% - 100rpx);
		margin: 0 50rpx;
		position: relative;
		margin-top: -64rpx;
		background-color: #ffffff;

		.info-amount {
			height: 150rpx;
			line-height: 150rpx;
			text-align: center;
			font-weight: bold;
			font-size: 60rpx;
			border-bottom: 4rpx dashed #f3f3f3;
		}

		.left-circle {
			background-color: var(--bgcolor);
			position: absolute;
			width: 40rpx;
			height: 40rpx;
			border-radius: 50%;
			top: calc(150rpx - 20rpx);
			left: -20rpx;
		}

		.right-circle {
			background-color: var(--bgcolor);
			position: absolute;
			width: 40rpx;
			height: 40rpx;
			border-radius: 50%;
			top: calc(150rpx - 20rpx);
			right: -20rpx;
		}

		.info-main {
			padding: 30rpx;
			font-size: 26rpx;
			color: #333333;

			.info-cell {
				/* #ifndef APP-NVUE */
				display: flex;
				/* #endif */
				line-height: 50rpx;

				.left {
					width: 200rpx;
					text-align: left;
				}

				.right {
					flex: 1;
					text-align: right;
				}
			}
		}
	}

	.button-query {
		color: #ffffff;
		width: calc(100% - 120rpx);
		margin: 50rpx 60rpx 0 60rpx;
		padding: 20rpx 30rpx;
		border-radius: 50rpx;
		text-align: center;
		box-sizing: border-box;
	}

	.button-query:active {
		opacity: 0.7;
	}

	.footer-hr {
		height: 100rpx;
		display: block;
	}
</style>