feat: bug修改

This commit is contained in:
黄泽群
2026-07-23 14:02:58 +08:00
committed by charles
parent b8dd02b4a7
commit 7ce469195f
5 changed files with 42 additions and 199 deletions
+31 -24
View File
@@ -4,15 +4,12 @@
<view class="search-view">
<view class="head-view">
<u-icon size="30rpx" name="arrow-left" @click="onBack" color="#333"></u-icon>
<view class="search-box">
<input class="input-view wx-width" v-model="searchInput"></input>
<!-- <u-input class="input-view wx-width"
v-model="searchInput"></u-input> -->
<view class="search-box" :style="{ maxWidth: searchBoxMaxWidth + 'rpx' }">
<input class="input-view" v-model="searchInput" placeholder="请输入搜索关键词"></input>
<view class="search-btn flex-c" @click="onSearch">
<text class="text-32 text-white">搜索</text>
</view>
</view>
</view>
<view class="top-view mt-24">
<view class="flex-r-lr">
@@ -65,16 +62,18 @@ export default {
historyList:[],
isDel:false,
dataList:[],
searchBoxMaxWidth: 0 // 搜索框最大宽度
};
},
onShow() {
this.init();
},
onLoad() {
// 获取胶囊按钮位置信息,计算搜索框最大宽度
this.calculateSearchBoxMaxWidth();
},
methods: {
init(){
// this.isSignContract()
// this.getSignContract()
let arr = uni.getStorageSync('history') || '';
if(arr){
this.historyList = arr.split(',');
@@ -82,6 +81,24 @@ export default {
this.historyList = [];
}
},
// 计算搜索框最大宽度,确保不与胶囊按钮重叠
calculateSearchBoxMaxWidth() {
// #ifdef MP-WEIXIN
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
if (menuButtonInfo) {
const systemInfo = uni.getSystemInfoSync();
// 计算屏幕宽度减去左侧内边距和胶囊按钮左侧距离
// 左侧内边距32rpx转换为px
const leftPadding = 32 * (systemInfo.windowWidth / 750);
// 箭头图标宽度和间距约为30rpx + 24rpx = 54rpx
const arrowWidth = 54 * (systemInfo.windowWidth / 750);
// 计算搜索框最大宽度(px)
const maxWidthPx = menuButtonInfo.left - leftPadding - arrowWidth - 20; // 20px额外间距
// 转换为rpx
this.searchBoxMaxWidth = Math.ceil(maxWidthPx * (750 / systemInfo.windowWidth));
}
// #endif
},
onJump(item){
uni.navigateTo({
url: '/pages/other_package/productInfo/productInfo?id='+item.id,
@@ -107,8 +124,7 @@ export default {
this.historyList.splice(index,1);
this.onSave()
},
onAdd(){
onAdd(){
if(this.searchInput){
let bool = false;
this.historyList.forEach(item=>{
@@ -122,8 +138,7 @@ export default {
this.historyList.pop();
}
this.onSave();
}
}
}
},
onText(item){
@@ -218,7 +233,7 @@ export default {
box-sizing: border-box;
background-color: #fff;
.search-box{
width:100%;
/* 移除flex:1,使用固定最大宽度 */
height:84rpx;
min-height:16rpx;
display: flex;
@@ -238,20 +253,12 @@ export default {
.input-view{
height:72rpx;
box-sizing: border-box;
padding: 0 30rpx !important;
padding: 0 7rpx !important;
border-radius: 36rpx;
margin-left:12rpx;
flex:1;
flex:1; /* 输入框在搜索框内自适应 */
}
/* #ifdef MP-WEIXIN */
.wx-width{
width:350rpx !important;
flex:none;
}
/* #endif */
}
}
</style>
</style>