<template>
	<view style="width: 100%;">
		<web-view id="webview" :src="url" style="width: 100%;"></web-view>
	</view>
</template>

<script>
	import httpsRequest from '@/common/httpRequest.js'
	import {cacheClear} from '@/store/cashe.js'
	export default {
		data() {
			return {
				ordersId: '',
				timer: null,
				maxAjaxNum: 5,
				ajaxNum: 0,
				url: null, //要打开的外部链接
				viewerUrl: '/hybrid/html/web/viewer.html',
				webviewStyles: {
					width: '750px',
					height: '100%',
				},

			}
		},
		methods:{
			getOrder(){
				httpsRequest.getT("/app/wuyou/queryOrder/" + this.ordersId, {}).then(res => {
					console.log(res.data);
				
					if (res.data == 1) {
						uni.hideLoading()
						const sysInfo = uni.getSystemInfoSync();
						let isIos = sysInfo.platform == 'ios'
						console.log("is ios ", isIos);
						if (isIos) {
							uni.navigateBack()
							uni.showToast({
								title: '支付成功',
								icon: 'none'
							})
							cacheClear(['renwu','user'])
							setTimeout(() => {
								uni.navigateBack()
							}, 1500)
						} else {
							uni.showToast({
								title: '支付成功',
								icon: 'none'
							})
							this.timer = setTimeout(() => {
								clearTimeout(this.timer)
								uni.navigateBack()
							}, 500)
						}
					} else {
						// #ifdef APP
						uni.showLoading({
							title: '支付中'
						})
						// #endif
					}
				});
			}
		},
		onReady() {},
		onShow() {
			console.log(this.ordersId);
			this.getOrder()
		},
		onHide() {
			clearInterval(this.timer)
			uni.hideLoading()
		},
		onUnload() {
			uni.hideLoading()
		},
		onLoad: function(option) {
			console.log(option)
			this.url = option.url
			this.ordersId = option.ordersId
			console.log('this.ordersId' + this.ordersId);
		}
	}
</script>
<style lang="scss">
	.webview {
		width: 100%;
		height: 100%;
	}
</style>