修改首页搜索框数据异常的问题

This commit is contained in:
赵毅 2025-10-28 10:35:28 +08:00
parent c8c4cd6bd4
commit 3115b45600

View File

@ -38,12 +38,12 @@
<!-- 未搜索到 --> <!-- 未搜索到 -->
<view class="empty" v-if="isSearched && searchGoodsLisat.length == 0"> <view class="empty" v-if="isSearched && !searchGoodsLisat">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_noSearch.png"></image> <image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_noSearch.png"></image>
对不起没有找到您想要的商品 对不起没有找到您想要的商品
</view> </view>
<view class="searchList" v-if="isSearched && searchGoodsLisat.length > 0"> <view class="searchList" v-if="isSearched && searchGoodsLisat && searchGoodsLisat.length > 0">
<!-- <view class="searchSubTit"> <!-- <view class="searchSubTit">
<view class="searchSubItem">综合</view> <view class="searchSubItem">综合</view>
<view class="searchSubItem"> <view class="searchSubItem">
@ -207,7 +207,7 @@ export default {
request(apiArr.goodsSearch, "POST", params).then((res) => { request(apiArr.goodsSearch, "POST", params).then((res) => {
// //
const commodityList = JSON.parse(JSON.stringify(res.commodity_list)); const commodityList = JSON.parse(JSON.stringify(res.commodity_list));
commodityList.forEach((item) => { commodityList?.forEach((item) => {
// isShow // isShow
this.$set(item, 'isShow', false); this.$set(item, 'isShow', false);
item.commodity_goods_info_list.forEach((param) => { item.commodity_goods_info_list.forEach((param) => {
@ -215,7 +215,8 @@ export default {
const goods = this.goodsDetail.find(g => g.goods_id === param.id); const goods = this.goodsDetail.find(g => g.goods_id === param.id);
this.$set(param, 'quantity', goods ? goods.count : 0); this.$set(param, 'quantity', goods ? goods.count : 0);
}); });
}); }) || [];
console.log("🚀 ~ commodityList:", commodityList)
this.searchGoodsLisat = commodityList; this.searchGoodsLisat = commodityList;
}); });
} }
@ -366,7 +367,7 @@ export default {
// //
syncGoodsQuantities() { syncGoodsQuantities() {
// //
this.searchGoodsLisat.forEach((item) => { this.searchGoodsLisat?.forEach((item) => {
item.commodity_goods_info_list.forEach((param) => { item.commodity_goods_info_list.forEach((param) => {
const goods = this.goodsDetail.find(g => g.goods_id === param.id); const goods = this.goodsDetail.find(g => g.goods_id === param.id);
if (goods) { if (goods) {