Browse Source

优化buyer页面搜索框样式,设置内部为白色背景

pull/1/head
徐飞洋 3 months ago
parent
commit
09511236dc
  1. 18
      pages/buyer/index.js
  2. 10
      pages/seller/index.js
  3. 3
      pages/seller/index.wxml
  4. 61
      pages/seller/index.wxss

18
pages/buyer/index.js

@ -1067,6 +1067,24 @@ Page({
}); });
}, },
// 清除搜索
clearSearch() {
this.setData({
searchKeyword: '',
page: 1,
hasMoreData: true,
selectedCategory: '全部'
}, () => {
// 重新加载第一页数据
this.loadGoods().then(() => {
console.log('清除搜索后数据加载完成');
}).catch(err => {
console.error('清除搜索后数据加载失败:', err);
this.fallbackToLocalStorageWithPagination();
});
});
},
// 搜索输入处理 // 搜索输入处理
onSearchInput(e) { onSearchInput(e) {
const searchKeyword = e.detail.value const searchKeyword = e.detail.value

10
pages/seller/index.js

@ -237,6 +237,16 @@ Page({
}); });
}, },
// 清除搜索
clearSearch() {
this.setData({
searchKeyword: ''
}, () => {
// 重新加载所有数据
this.loadSupplies();
});
},
// 处理搜索输入 // 处理搜索输入
onSearchInput(e) { onSearchInput(e) {
this.setData({ this.setData({

3
pages/seller/index.wxml

@ -23,14 +23,15 @@
<!-- 搜索框 --> <!-- 搜索框 -->
<view class="search-container"> <view class="search-container">
<view class="search-box"> <view class="search-box">
<view class="search-icon">🔍</view>
<input <input
class="search-input" class="search-input"
placeholder="搜索货源名称或品种" placeholder="搜索货源名称或品种"
bindinput="onSearchInput" bindinput="onSearchInput"
bindconfirm="searchSupplies" bindconfirm="searchSupplies"
value="{{searchKeyword}}" value="{{searchKeyword}}"
style="width: 100%;"
/> />
<view wx:if="searchKeyword" class="clear-icon" bindtap="clearSearch">✕</view>
</view> </view>
</view> </view>

61
pages/seller/index.wxss

@ -23,6 +23,67 @@ button {
background-color: #fafafa; background-color: #fafafa;
} }
/* 搜索框样式 */
.search-container {
position: relative;
padding: 20rpx 0;
z-index: 10;
box-sizing: border-box;
}
.search-box {
width: 90%;
display: flex;
align-items: center;
background-color: #f8f9fa;
border: 2rpx solid #e9ecef;
border-radius: 50rpx;
padding: 0 20rpx;
margin: 0 auto;
transition: all 0.3s ease;
}
.search-box:focus-within {
border-color: #07c160;
box-shadow: 0 0 0 4rpx rgba(7, 193, 96, 0.1);
background-color: white;
}
.search-icon {
font-size: 28rpx;
color: #999;
margin-right: 16rpx;
}
.search-input {
flex: 1;
padding: 24rpx 0;
font-size: 28rpx;
color: #333;
background-color: transparent;
border: none;
outline: none;
}
.search-input::placeholder {
color: #ccc;
}
.clear-icon {
font-size: 24rpx;
color: #999;
padding: 8rpx;
border-radius: 50%;
background-color: #e9ecef;
cursor: pointer;
transition: all 0.2s ease;
}
.clear-icon:hover {
background-color: #dee2e6;
color: #666;
}
/* 页面标题栏 */ /* 页面标题栏 */
.title-bar { .title-bar {
display: flex; display: flex;

Loading…
Cancel
Save