小程序添加扫码

This commit is contained in:
Ledo 2025-07-09 22:12:58 +08:00
parent f8cd8db633
commit 37a3a4ee88

View File

@ -112,26 +112,76 @@ const onRefresherrefresh = async () => {
// //
isTriggered.value = false isTriggered.value = false
} }
// const searchVal = ref('') const searchVal = ref("");
// const dataListDefault = ref([]) // const dataListDefault = ref([])
// const handleSearch = async () => { const handleSearch = async (e) => {
// const code = searchVal.value queryParams.subOrDetailName = e.inputValue;
// if (code) { queryParams.pageNo = 1;
// dataListDefault.value = dataList.value isFinish.value = false;
// dataList.value = dataList.value.filter((e) => { dataList.value = [];
// return e.code == code await getListData();
// }) };
// } else {
// dataList.value = dataListDefault.value
// } const handleScan = () => {
// } uni.scanCode({
success: (res) => {
searchVal.value = res.result
handleSearch({ inputValue: res.result })
},
fail: () => {
uni.showToast({ title: '扫码失败', icon: 'none' })
}
})
}
</script> </script>
<template> <template>
<view class="cont"> <view class="cont">
<!-- <view class="search" v-if="dataList.length > 5"> <view class="search" v-if="props.orderState == '0,1'">
<view class="title"></view> <view
<input class="uni-input" v-model="searchVal" @change="handleSearch" placeholder="根据编号搜索" /> style="
</view> --> width: 100%;
display: flex;
align-items: center;
background: #e2f3ff;
border-radius: 20rpx;
padding: 0 8rpx;
height: 50px;
"
>
<input
class="uni-input"
v-model="searchVal"
placeholder="请输入项目或子项目名称"
:placeholder-style="'color:#28A0F8;'"
style="
flex: 1;
background: transparent;
border: none;
outline: none;
font-size: 25rpx;
color: #28a0f8;
height: 50px;
line-height: 50px;
"
@input="handleSearch({ inputValue: searchVal })"
clearable
/>
<view
style="
background: none;
border: none;
padding: 0 10rpx;
height: 50px;
display: flex;
align-items: center;
"
@click="handleScan"
>
<uni-icons type="scan" size="28" color="#28A0F8"></uni-icons>
</view>
</view>
</view>
<scroll-view enable-back-to-top scroll-y class="data-list" refresher-enabled :refresher-triggered="isTriggered" <scroll-view enable-back-to-top scroll-y class="data-list" refresher-enabled :refresher-triggered="isTriggered"
@refresherrefresh="onRefresherrefresh" @scrolltolower="getListData"> @refresherrefresh="onRefresherrefresh" @scrolltolower="getListData">
<view class="item" v-for="item in dataList" :key="item.id" @click="handleDetail(item)"> <view class="item" v-for="item in dataList" :key="item.id" @click="handleDetail(item)">
@ -185,17 +235,24 @@ const onRefresherrefresh = async () => {
<style lang="scss"> <style lang="scss">
// //
.search { .search {
padding: 4rpx; padding: 0rpx;
width: 80%; width: 90%;
margin: 30rpx auto; margin: auto;
margin-top: 20rpx;
position: relative;
.uni-input { .uni-input {
border: 1px solid #D1D6DB; border: 1px solid #d1d6db;
height: 60rpx; height: 60rpx;
line-height: 60rpx; line-height: 60rpx;
padding: 4rpx 10rpx; padding: 4rpx 10rpx;
font-size: 32rpx; font-size: 32rpx;
border-radius: 6rpx; border-radius: 10rpx;
}
.icons {
width: 30rpx;
position: absolute;
right: 40rpx;
top: 0rpx;
} }
} }