<template>
	<view>
		<web-view :src="url"></web-view>
	</view>
</template>

<script>
	import url from '@/common/http/url.js'
	export default {
		data() {
			return {
				url: '',
				orderId: '',
				isFirst: true
			};
		},
		onLoad(e) {
			console.log('e.url=======', e.url);
			
			if (e.type == 'aliPay') {
				this.url = e.url;
				uni.showLoading({
					title: '正在打开支付宝...'
				})
			} else if (e.type == 'lkl') {
				let urlArr = e.url.split('?')
				this.url = urlArr[0] + '?' + encodeURIComponent(urlArr[1]);
			} else {
				this.url = e.url;
			}
			
			this.orderId = e.orderId;
			console.log('this.url ', this.url)
			
			
		},
		onHide() {
			uni.hideLoading()
		},
		onShow() {
			if (!this.isFirst) this.getOrderInfoQuery();
			this.isFirst = false
		},
		methods: {
			async getOrderInfoQuery (httptype = "GET") {
			  const { data, code } = await this.$http(httptype, url.order.getOrderInfoById, {
			    orderId: this.orderId
			  })
			  await uni.showToast({
			    title: `${code === 200 && (data.status == 3 || data.status == 5) ? '支付成功' : '支付失败'}`,
			    duration: 1500
			  });
			  // if (code == 200 && data.status == 3) {
			  uni.redirectTo({
			    url: '/pages/order/payment/result?orderInfo=' + JSON.stringify(this.orderInfo) + '&status='
				+ data.status
			  })
			  // }
			},
		}
	}
</script>

<style lang="scss">

</style>
