<template>
	<view>
		支付查询中...
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		$image,
		$api,
		$response
	} from '@/api'
	import {
		onLoad
	} from '@dcloudio/uni-app'

	let orderid=ref(0);
	const CheckPay = async () => {
		uni.showLoading()
		const response = await $api('CheckPay', {
			openid: localStorage.getItem('OPENID'),
			order_number: orderid.value,
		})
		uni.hideLoading()
		$response(response, () => {
			 if(response.status){
				 uni.showToast({
				 	title: '支付成功'
				 });
				 if(response.data.is_yuyue){
					 uni.redirectTo({
					 		url: '/pages/buy/done/yuyue_done?id='+response.data.id
					 });
				 }else{
					 uni.redirectTo({
					 		url: '/pages/buy/done/done?id='+response.data.id
					 });
				 }
				 
			 }
		})
	}
	onLoad((option) => {
		 if(!!option.orderid){
			 orderid.value=option.orderid
			 CheckPay()
		 }else{
			 uni.showToast({
			 	title: '获取订单号失败',
				icon:"none"
			 });
		 }
	})
</script>

<style>

</style>