修改首页搜索框数据异常的问题
This commit is contained in:
parent
c8c4cd6bd4
commit
3115b45600
@ -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) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user