<template>
	<view>

	</view>
</template>

<script>
	import {
		wxLogin,
	} from '../../../util/index'

	import {
		queryHasOrder
	} from '@/config/user.js'

	export default {
		data() {
			return {

			}
		},
		async onLoad(option) {
			try {
				uni.showLoading({
					title: '加载中...'
				});

				if (!uni.getStorageSync('token')) {
					await wxLogin();
				}

				const result = await queryHasOrder(option.deviceNo);
				uni.hideLoading();
				
				if (!option.deviceNo) {
					uni.showToast({
						title: '设备编号不能为空',
						icon: 'none'
					});
					return;
				}

				if (result.data.length != 0) {
					uni.redirectTo({
						url: `/pages/device/return?deviceNo=${option.deviceNo}`
					});
				} else {
					uni.redirectTo({
						url: `/pages/device/detail?deviceNo=${option.deviceNo}`
					});
				}
			} catch (error) {
				uni.hideLoading();
				uni.showToast({
					title: '页面加载失败，请重试',
					icon: 'none'
				});
				console.error('bagCheck onLoad error:', error);
			}
		},
		methods: {

		}
	}
</script>

<style>

</style>