<template>
    <view class="container flex-d h100">
        <!-- 库位列表 -->
        <view class="location-list flex-1">
            <view class="no-data flex-c mt-60">请输入快递单号/订单编号</view>
        </view>

        <!-- 底部搜索框 -->
        <view class="pad-20 flex flex-column" style="background: #ffffff">
            <u-radio-group v-model="searchType" class="mb-20 ml-20">
                <u-radio label="查订单" name="1" label-size="17" />
                <u-radio label="查物流" custom-style="margin-left:20px" name="2" label-size="17" />
            </u-radio-group>

            <view class="flex-a">
                <u-search
                    v-model="searchText"
                    placeholder="请输入快递单号/订单编号"
                    :show-action="false"
                    :clearabled="true"
                    @search="onSearch"
                    height="40"
                >
                </u-search>
                <u-icon name="scan" size="28" color="#19be6b" @click="openScan"></u-icon>
            </view>
        </view>
    </view>
</template>

<script setup>
import { ref, computed, onMounted } from "vue";
// 搜索文本
const searchText = ref("");
const searchType = ref("1");

// 搜索处理
const onSearch = () => {
    // 实现搜索逻辑
    uni.navigateTo({
        url: `/pages/index/wms/bad-out-order?searchText=${searchText.value}&searchType=${searchType.value}`,
    });
};

// 打开扫码
const openScan = () => {
    // #ifdef APP-PLUS || MP-WEIXIN
    uni.scanCode({
        success: (res) => {
            searchText.value = res.result;
            onSearch();
        },
        fail: (err) => {
            uni.showToast({
                title: "扫码失败",
                icon: "error",
            });
        },
    });
    // #endif

    // #ifdef H5
    uni.showToast({
        title: "H5环境不支持扫码",
        icon: "none",
    });
    // #endif
};
</script>
