From bbbf2ff2452744c012cda7b217a2a6d01daeff35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=B6=E5=8D=8E?= <3599164049@qq.com> Date: Mon, 22 Mar 2021 17:52:03 +0800 Subject: [PATCH 1/4] cart change --- src/subpackage/retail/pages/index/index.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/subpackage/retail/pages/index/index.vue b/src/subpackage/retail/pages/index/index.vue index ee99477..8103b08 100644 --- a/src/subpackage/retail/pages/index/index.vue +++ b/src/subpackage/retail/pages/index/index.vue @@ -352,6 +352,9 @@ export default { else { this.addToCartList(); // 将主页数据加入到购物车列表 this.cartListStatusChange(); // 购物车列表状态变化 + + this.cartTotalPrice = this.totalPrice; + this.cartTotalCount = this.totalCount; this.isShowCartList = true; this.calcCartTotalPriceAndCount(); // 计算购物车总价跟总量 } @@ -393,8 +396,6 @@ export default { this.totalPrice = price.toFixed(2); this.totalCount = count; - this.cartTotalPrice = this.totalPrice; - this.cartTotalCount = this.totalCount; }, // 主页数量选项触发 From f670ba4947b7076c3bd3c7f4cfa8509f1cb746d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=B6=E5=8D=8E?= <3599164049@qq.com> Date: Thu, 25 Mar 2021 09:36:55 +0800 Subject: [PATCH 2/4] index header z-index --- src/subpackage/retail/pages/index/index.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/subpackage/retail/pages/index/index.vue b/src/subpackage/retail/pages/index/index.vue index 8103b08..a527035 100644 --- a/src/subpackage/retail/pages/index/index.vue +++ b/src/subpackage/retail/pages/index/index.vue @@ -618,6 +618,7 @@ export default { display: flex; flex-direction: column; background-color: rgb(237,237,245); + z-index: 0; .header-store-selecter { display: flex; From 484b2ae3ce7449dfc7540db9eba93dd5ef82a52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=B6=E5=8D=8E?= <3599164049@qq.com> Date: Thu, 25 Mar 2021 13:27:43 +0800 Subject: [PATCH 3/4] cart price check --- src/subpackage/retail/components/hover_cart_list/hover_cart_list.vue | 4 +++- src/subpackage/retail/pages/confirm_goods/confirm_goods.vue | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/subpackage/retail/components/hover_cart_list/hover_cart_list.vue b/src/subpackage/retail/components/hover_cart_list/hover_cart_list.vue index e1949ec..ebee5d6 100644 --- a/src/subpackage/retail/components/hover_cart_list/hover_cart_list.vue +++ b/src/subpackage/retail/components/hover_cart_list/hover_cart_list.vue @@ -52,7 +52,9 @@ // 购物车输入确认 cartInputConfirm(event, id) { // 修改购物车列表对应的价格 - let value = parseFloat(event.detail.value).toFixed(2); + // console.log(event.detail.value.match(/(([0-9]+\.[0-9]+)|([0-9]+))/g)); // 取正浮点数 跟 正整数 + + let value = parseFloat(event.detail.value ? event.detail.value : 0).toFixed(2); for (let i = 0; i < this.cartList.length; ++i) { if (this.cartList[i].id == id) { this.$emit("update:cartInputConfirm", value, i); diff --git a/src/subpackage/retail/pages/confirm_goods/confirm_goods.vue b/src/subpackage/retail/pages/confirm_goods/confirm_goods.vue index d9cb4aa..011f7a1 100644 --- a/src/subpackage/retail/pages/confirm_goods/confirm_goods.vue +++ b/src/subpackage/retail/pages/confirm_goods/confirm_goods.vue @@ -100,7 +100,7 @@ // 购物车输入确认 cartInputConfirm(event, id) { // 修改购物车列表对应的价格 - let value = parseFloat(event.detail.value).toFixed(2); + let value = parseFloat(event.detail.value ? event.detail.value : 0).toFixed(2); for (let i = 0; i < this.cartListFinal.length; ++i) { if (this.cartListFinal[i].id == id) { this.cartListFinal[i].price = value; From 2b9347e6bf0d71b236959cc2f5f59d547c1c401d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=B6=E5=8D=8E?= <3599164049@qq.com> Date: Wed, 14 Apr 2021 13:30:18 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E9=9B=B6=E5=94=AE=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/hover_cart_list/hover_cart_list.vue | 8 +- src/subpackage/retail/js/retail_api.js | 6 +- .../retail/pages/confirm_goods/confirm_goods.vue | 60 +++- src/subpackage/retail/pages/index/index.vue | 359 +++++++++++---------- src/subpackage/retail/pages/search/search.vue | 105 ++++-- 5 files changed, 332 insertions(+), 206 deletions(-) diff --git a/src/subpackage/retail/components/hover_cart_list/hover_cart_list.vue b/src/subpackage/retail/components/hover_cart_list/hover_cart_list.vue index ebee5d6..202e2ac 100644 --- a/src/subpackage/retail/components/hover_cart_list/hover_cart_list.vue +++ b/src/subpackage/retail/components/hover_cart_list/hover_cart_list.vue @@ -10,16 +10,16 @@ - {{ item.name }} - {{ item.spec }} + {{ item.erp_goods_name }} + {{ item.erp_goods_specs }} - + - {{ item.count }} + {{ item.erp_goods_sale_total }} diff --git a/src/subpackage/retail/js/retail_api.js b/src/subpackage/retail/js/retail_api.js index b672450..846c7fc 100644 --- a/src/subpackage/retail/js/retail_api.js +++ b/src/subpackage/retail/js/retail_api.js @@ -1,7 +1,11 @@ import { ORIGIN } from '../../../js/api'; export const RETAIL_API = { - stadiumList:`${ORIGIN}/stadium/list`, // 店铺列表 + assistantRetail:`${ORIGIN}/admin/assistant/retail`, // 收款出库 + assistantListErpGoods:`${ORIGIN}/admin/assistant/listErpGoods`, // 物品管理 + assistantListErpGoodsCate:`${ORIGIN}/admin/assistant/listErpGoodsCate`, // 物品分类管理 + assistantGetAssistantStadiums:`${ORIGIN}/admin/assistant/getAssistantStadiums`, // 店铺列表 + assistantListErpGoodsCateAndGoods:`${ORIGIN}/admin/assistant/listErpGoodsCateAndGoods`, // 物品分类物品列表 } export default RETAIL_API; \ No newline at end of file diff --git a/src/subpackage/retail/pages/confirm_goods/confirm_goods.vue b/src/subpackage/retail/pages/confirm_goods/confirm_goods.vue index 011f7a1..f83eca3 100644 --- a/src/subpackage/retail/pages/confirm_goods/confirm_goods.vue +++ b/src/subpackage/retail/pages/confirm_goods/confirm_goods.vue @@ -9,17 +9,17 @@ - {{ item.name }} - {{ item.spec }} + {{ item.erp_goods_name }} + {{ item.erp_goods_specs }} - - {{item.price}} + + {{item.erp_goods_price}} - {{ item.count }} + {{ item.erp_goods_sale_total }} @@ -52,6 +52,7 @@ data() { return { isEdited: false, // 是否处于编辑模式 + curStore: null, // 当前店铺信息 cartListFinal: [], // 购物车最终列表数据 totalPrice: 0, // 最终价格 cartConfirmText: "收款出库", // 收款出库 || 确认 @@ -63,6 +64,7 @@ onLoad(option) { let data = JSON.parse(decodeURIComponent(option.data)); + this.curStore = data.curStore; this.cartListFinal = []; for (let i = 0; i < data.cartListFinal.length; ++i) { this.cartListFinal.push(tools.getNewObj(data.cartListFinal[i])); @@ -92,8 +94,42 @@ return; } - uni.navigateBack({ - delta: 1 + let _this = this; + let data = []; + for (let i = 0; i < this.cartListFinal.length; ++i) { + if (this.cartListFinal[i].erp_goods_sale_total) { + data.push({ + id: this.cartListFinal[i].id, + name: this.cartListFinal[i].erp_goods_name, + price: this.cartListFinal[i].erp_goods_price, + nums: this.cartListFinal[i].erp_goods_sale_total, + unit: this.cartListFinal[i].erp_goods_unit, + }); + } + } + + if (!data.length) { + uni.showToast({ + title: "暂无商品数量!", + icon: "none" + }); + + return; + } + + util.showLoad(); + retailServer.get({ + url: retailApi.assistantRetail, + data: { + store_id: _this.curStore.id, + goods_data: data, + }, + failMsg: '出库失败!' + }).then(res => { + util.hideLoad(); + uni.navigateBack({ + delta: 1 + }); }); }, @@ -103,7 +139,7 @@ let value = parseFloat(event.detail.value ? event.detail.value : 0).toFixed(2); for (let i = 0; i < this.cartListFinal.length; ++i) { if (this.cartListFinal[i].id == id) { - this.cartListFinal[i].price = value; + this.cartListFinal[i].erp_goods_price = value; } } @@ -124,14 +160,14 @@ if (item) { switch (type) { case "add": { - item.count += 1; + item.erp_goods_sale_total += 1; } break; case "sub": { - if (item.count <= 0) { + if (item.erp_goods_sale_total <= 0) { return; } - item.count -= 1; + item.erp_goods_sale_total -= 1; } break; } @@ -144,7 +180,7 @@ let price = 0.0; for (let i = 0; i < this.cartListFinal.length; ++i) { - price += (this.cartListFinal[i].count * this.cartListFinal[i].price); + price += (this.cartListFinal[i].erp_goods_sale_total * this.cartListFinal[i].erp_goods_price); } this.totalPrice = price.toFixed(2); diff --git a/src/subpackage/retail/pages/index/index.vue b/src/subpackage/retail/pages/index/index.vue index a527035..4be3b3b 100644 --- a/src/subpackage/retail/pages/index/index.vue +++ b/src/subpackage/retail/pages/index/index.vue @@ -30,24 +30,24 @@ - - + + - - - {{ item.name }} - {{ item.spec }} + + + {{ item.erp_goods_name }} + {{ item.erp_goods_specs }} - {{ item.price }} + {{ item.erp_goods_price }} - - {{ item.count }} - + + {{ item.erp_goods_sale_total }} + @@ -100,9 +100,11 @@ export default { }, categoryScrollTop: 0, // 分类滚动值 categoryOldScrollTop: 0, // 分类滚动旧值 - categoryIndex: 1, // 分类索引值,默认第一项是搜索,过滤掉,直接从第二项开始计算 + // 分类索引值,默认第一项是搜索,第二项可能是热销,会在获取接口数据时判断,然后过滤掉 + categoryIndex: 1, // curStoreList: [{ id: '', name: '请选择门店'}], // 当前门店列表 + indexData: {}, // 首页 统计数据 curStoreList: [], // 当前门店列表 curStore: {}, // 当前门店 goodsInfo: [], // 商品信息 @@ -122,13 +124,12 @@ export default { } }, onLoad() { - this.deleteSearchLocal(); // 删除本地的历史搜索 + this.deleteSearchLocal(); // 删除本地的搜索记录 this.getStoreList(); // 获取店铺列表 - this.getGoodsInfo(); // 获取商品信息 this.fixMainHeight(); // 适配主内容高度 }, onShow() { - this.getSearchLocal(); // 获取本地的历史搜索 + this.getSearchLocal(); // 获取本地的搜索记录 }, methods: { // 分类列表滚动监听 @@ -149,31 +150,41 @@ export default { util.showLoad(); setTimeout(util.hideLoad, 1000); - this.goodsInfo[0].goodsData = []; - let random = Math.floor(Math.random() * 5 + 1); - console.log(random); + this.goodsInfo[0].goods_list = []; - let tempData = []; - for (let i = 0; i < this.goodsInfo[random].goodsData.length; ++i) { - tempData.push(tools.getNewObj(this.goodsInfo[random].goodsData[i])); + // 剔除相同的商品 + let tempData = {}; + for (let i = 0; i < data.length; ++i) { + if (data[i].goods_list) { + for (let j = 0; j < data[i].goods_list.length; ++j) { + tempData["" + data[i].goods_list[j].id] = data[i].goods_list[j]; + } + } } - let conectData = [] - for (let i = 1; i < this.goodsInfo.length; ++i) { - conectData = [ ...conectData, ...this.goodsInfo[i].goodsData ]; + for (let key in tempData) { + this.goodsInfo[0].goods_list.push(tempData[key]); } - for (let i = 0; i < tempData.length; ++i) { - for (let j = 0; j < conectData.length; ++j) { - if (tempData[i].id == conectData[j].id) { - this.goodsInfo[0].goodsData.push(conectData[j]); + // 同步一下数据,因为有可能搜索的数据 在其他分类出现过 + let otherData = []; + for (let i = this.categoryIndex; i < this.goodsInfo.length; ++i) { + for (let j = 0; j < this.goodsInfo[i].goods_list.length; ++j) { + otherData.push(this.goodsInfo[i].goods_list[j]); + } + } + for (let i = 0; i < this.goodsInfo[0].goods_list.length; ++i) { + for (let j = 0; j < otherData.length; ++j) { + if (this.goodsInfo[0].goods_list[i].id == otherData[j].id) { + this.goodsInfo[0].goods_list[i].erp_goods_sale_total = otherData[j].erp_goods_sale_total; } } } + // end this.categoryGoTop(); // 每次搜索后,分类列表都要滚动到顶部 - this.goodsInfo[0].isSearch = true; - this.mainCategoryClick(this.goodsInfo[0].id); + this.goodsInfo[0].isCateShow = true; + this.mainCategoryClick(this.goodsInfo[0].cate.id); }, // 获取本地的历史搜索 @@ -183,7 +194,6 @@ export default { uni.getStorage({ key: 'searchData', success: function (res) { - console.log(res.data); _this.setSearchData(res.data); // 设置搜索数据 _this.deleteSearchLocal(); // 删除本地的历史搜索 }, @@ -215,7 +225,7 @@ export default { // 购物车输入确认 cartInputConfirm(value, i) { - this.cartList[i].price = value; + this.cartList[i].erp_goods_price = value; this.calcCartTotalPriceAndCount(); // 计算购物车总价跟总量 }, @@ -225,8 +235,8 @@ export default { let count = 0; for (let i = 0; i < this.cartList.length; ++i) { - price += (this.cartList[i].count * this.cartList[i].price); - count += this.cartList[i].count; + price += (this.cartList[i].erp_goods_sale_total * this.cartList[i].erp_goods_price); + count += this.cartList[i].erp_goods_sale_total; } this.cartTotalPrice = price.toFixed(2); @@ -237,33 +247,38 @@ export default { cartCountClick(type, i) { // 增减购物车对应的主页数量 let curId = this.cartList[i].id; - let mainItem = null; + let mainItems = []; // 可能不止一个 for (let i = 0; i < this.goodsInfo.length; ++i) { - for (let j = 0; j < this.goodsInfo[i].goodsData.length; ++j) { - if (curId == this.goodsInfo[i].goodsData[j].id) { - mainItem = this.goodsInfo[i].goodsData[j]; + for (let j = 0; j < this.goodsInfo[i].goods_list.length; ++j) { + if (curId == this.goodsInfo[i].goods_list[j].id) { + mainItems.push(this.goodsInfo[i].goods_list[j]); } } } switch (type) { case "add": { - this.cartList[i].count += 1; - mainItem.count += 1; + this.cartList[i].erp_goods_sale_total += 1; + for (let i = 0; i < mainItems.length; ++i) { + mainItems[i].erp_goods_sale_total += 1; + } } break; case "sub": { - if (this.cartList[i].count > 0) { - this.cartList[i].count -= 1; + if (this.cartList[i].erp_goods_sale_total > 0) { + this.cartList[i].erp_goods_sale_total -= 1; } - if (mainItem.count > 0) { - mainItem.count -= 1; + for (let i = 0; i < mainItems.length; ++i) { + if (mainItems[i].erp_goods_sale_total > 0) { + mainItems[i].erp_goods_sale_total -= 1; + } } + } break; } // 没数量了就删掉 - if (this.cartList[i].count <= 0) { + if (this.cartList[i].erp_goods_sale_total <= 0) { this.cartList.splice(i, 1); } @@ -277,7 +292,7 @@ export default { let arr = []; for (let i = 0; i < this.cartList.length; ++i) { - if (this.cartList[i].count) { + if (this.cartList[i].erp_goods_sale_total) { arr.push(tools.getNewObj(this.cartList[i])); } } @@ -295,6 +310,7 @@ export default { let data = { cartListFinal: this.cartListFinal, + curStore: this.curStore, }; uni.navigateTo({ url: `/subpackage/retail/pages/confirm_goods/confirm_goods?data=${encodeURIComponent(JSON.stringify(data))}` @@ -314,12 +330,18 @@ export default { // 计算购物车列表 for (let i = this.categoryIndex; i < this.goodsInfo.length; ++i) { - for (let j = 0; j < this.goodsInfo[i].goodsData.length; ++j) { - if (this.goodsInfo[i].goodsData[j].count) { - this.cartList.push(tools.getNewObj(this.goodsInfo[i].goodsData[j])); + for (let j = 0; j < this.goodsInfo[i].goods_list.length; ++j) { + if (this.goodsInfo[i].goods_list[j].erp_goods_sale_total) { + this.cartList.push(tools.getNewObj(this.goodsInfo[i].goods_list[j])); } } } + + // 再把搜索跟热销的 不在其他分类里的数据找出来也加上 + let tempData = this.findDifferentData(); // 找不同 + for (let i = 0; i < tempData.length; ++i) { + this.cartList.push(tools.getNewObj(tempData[i])); + } }, // 购物车列表状态变化 @@ -382,15 +404,61 @@ export default { }); }, + // 找搜索跟热销 不同于其他分类的数据 + findDifferentData() { + let searchAndHotData = []; + for (let i = 0; i < this.categoryIndex; ++i) { + for (let j = 0; j < this.goodsInfo[i].goods_list.length; ++j) { + searchAndHotData.push(this.goodsInfo[i].goods_list[j]); + } + } + + let otherData = []; + for (let i = this.categoryIndex; i < this.goodsInfo.length; ++i) { + for (let j = 0; j < this.goodsInfo[i].goods_list.length; ++j) { + otherData.push(this.goodsInfo[i].goods_list[j]); + } + } + + let mark = false; + let tempData = []; + for (let i = 0; i < searchAndHotData.length; ++i) { + mark = false; // 表示不在其他分类里面 + + for (let j = 0; j < otherData .length; ++j) { + if (searchAndHotData[i].id == otherData [j].id) { + mark = true; + } + } + + // 如果不在 并且有数量,那么加进列表 + if (!mark && searchAndHotData[i].erp_goods_sale_total) { + tempData.push(searchAndHotData[i]); + } + } + + return tempData; + }, + // 计算总价跟总量 calcTotalPriceAndCount() { let price = 0.0; let count = 0; + // 先计算搜索、热销后面的价格跟数量 for (let i = this.categoryIndex; i < this.goodsInfo.length; ++i) { - for (let j = 0; j < this.goodsInfo[i].goodsData.length; ++j) { - price += (this.goodsInfo[i].goodsData[j].count * this.goodsInfo[i].goodsData[j].price); - count += this.goodsInfo[i].goodsData[j].count; + for (let j = 0; j < this.goodsInfo[i].goods_list.length; ++j) { + price += (this.goodsInfo[i].goods_list[j].erp_goods_sale_total * this.goodsInfo[i].goods_list[j].erp_goods_price); + count += this.goodsInfo[i].goods_list[j].erp_goods_sale_total; + } + } + + // 再回过头来计算搜索跟热销的,计算热销物品不在 其他分类里的价格跟数量 + let tempData = this.findDifferentData(); // 找不同 + if (tempData.length) { + for (let i = 0; i < tempData.length; ++i) { + price += (tempData[i].erp_goods_sale_total * tempData[i].erp_goods_price); + count += tempData[i].erp_goods_sale_total; } } @@ -399,11 +467,11 @@ export default { }, // 主页数量选项触发 - mainCountClick(type, id, goodsId) { + mainCountClick(type, id, cateName, goodsId) { // 找点击的对应分类 let item = null; for (let i = 0; i < this.goodsInfo.length; ++i) { - if (this.goodsInfo[i].id == id) { + if (this.goodsInfo[i].cate.id == id) { item = this.goodsInfo[i]; break; } @@ -412,9 +480,9 @@ export default { // 分类有了,继续找该分类下的商品id let goodsItem = null; if (item) { - for (let i = 0; i < item.goodsData.length; ++i) { - if (item.goodsData[i].id == goodsId) { - goodsItem = item.goodsData[i]; + for (let i = 0; i < item.goods_list.length; ++i) { + if (item.goods_list[i].id == goodsId) { + goodsItem = item.goods_list[i]; break; } } @@ -423,20 +491,29 @@ export default { if (goodsItem) { switch (type) { case "add": { - goodsItem.count += 1; + goodsItem.erp_goods_sale_total += 1; } break; case "sub": { - if (goodsItem.count <= 0) { + if (goodsItem.erp_goods_sale_total <= 0) { return; } - goodsItem.count -= 1; + goodsItem.erp_goods_sale_total -= 1; } break; } - - this.calcTotalPriceAndCount(); // 计算总价跟总量 - this.addToCartList(); // 将主页数据加入到购物车列表 } + + // 遍历物品列表,把相同物品的数量 设置成当前点击物品的数量 + for (let i = 0; i < this.goodsInfo.length; ++i) { + for (let j = 0; j < this.goodsInfo[i].goods_list.length; ++j) { + if (this.goodsInfo[i].goods_list[j].id == goodsItem.id) { + this.goodsInfo[i].goods_list[j].erp_goods_sale_total = goodsItem.erp_goods_sale_total; + } + } + } + + this.calcTotalPriceAndCount(); // 计算总价跟总量 + this.addToCartList(); // 将主页数据加入到购物车列表 }, // 主页分类选项触发 @@ -447,7 +524,7 @@ export default { this.goodsInfo[i].style = this.categoryBtnStyle.default; this.goodsInfo[i].isShow = false; - if (this.goodsInfo[i].id == id) { + if (this.goodsInfo[i].cate.id == id) { item = this.goodsInfo[i]; } } @@ -462,122 +539,72 @@ export default { getGoodsInfo() { let _this = this; - util.showLoad(); - setTimeout(util.hideLoad, 1000); - _this.goodsInfo = []; - let categoryName = ""; - for (let i = 0; i < 20; ++i) { - categoryName = i <= 0 ? "搜索" : "分类"; - + // let categoryName = ""; + + retailServer.get({ + url: retailApi.assistantListErpGoodsCateAndGoods, + data: { + // brand_id: _this.indexData.brand.id, + }, + failMsg: '加载物品数据失败!' + }).then(res => { _this.goodsInfo.push({ - id: i + 1, - isSearch: true, + isCateShow: false, isShow: false, - categoryName: `${categoryName}${i + 1}`, style: _this.categoryBtnStyle.default, - goodsData: [ - { - id: 1 + Math.random(), - name: `柠檬味维他奶原味豆奶${Math.floor(Math.random() * 20)}`, - spec: "250ml 300ml 350ml", - price: 3.5, - count: 0, - }, - { - id: 2 + Math.random(), - name: `原味豆奶${Math.floor(Math.random() * 20)}`, - spec: "150ml 200ml 100ml", - price: 300.2, - count: 0, - }, - { - id: 3 + Math.random(), - name: `豆奶${Math.floor(Math.random() * 20)}`, - spec: "50ml 100ml 150ml", - price: 18, - count: 0, - }, - { - id: 4 + Math.random(), - name: `原味豆奶${Math.floor(Math.random() * 20)}`, - spec: "150ml 200ml 100ml", - price: 300.2, - count: 0, - }, - { - id: 5 + Math.random(), - name: `豆奶${Math.floor(Math.random() * 20)}`, - spec: "50ml 100ml 150ml", - price: 18, - count: 0, - }, - { - id: 6 + Math.random(), - name: `原味豆奶${Math.floor(Math.random() * 20)}`, - spec: "150ml 200ml 100ml", - price: 300.2, - count: 0, - }, - { - id: 7 + Math.random(), - name: `豆奶${Math.floor(Math.random() * 20)}`, - spec: "50ml 100ml 150ml", - price: 18, - count: 0, - }, - { - id: 8 + Math.random(), - name: `原味豆奶${Math.floor(Math.random() * 20)}`, - spec: "150ml 200ml 100ml", - price: 300.2, - count: 0, - }, - { - id: 9 + Math.random(), - name: `豆奶${Math.floor(Math.random() * 20)}`, - spec: "50ml 100ml 150ml", - price: 18, - count: 0, - }, - { - id: 10 + Math.random(), - name: `原味豆奶${Math.floor(Math.random() * 20)}`, - spec: "150ml 200ml 100ml", - price: 300.2, - count: 0, - }, - { - id: 11 + Math.random(), - name: `豆奶${Math.floor(Math.random() * 20)}`, - spec: "50ml 100ml 150ml", - price: 18, - count: 0, - } - ] + cate: { + created_at: "", + erp_goods_cate_brandid: -1, + erp_goods_cate_name: "搜索", + id: -1, + update_at: "", + }, + goods_list: [], }); - } - - _this.totalCount = 0; - _this.totalPrice = 0; - _this.goodsInfo[0].isSearch = false; - _this.goodsInfo[0].goodsData = []; - _this.goodsInfo[1].style = _this.categoryBtnStyle.click; - _this.goodsInfo[1].isShow = true; - _this.categoryGoTop(); // 分类列表需要滚动至顶部 + + console.log(res); + for (let i = 0; i < res.list.length; ++i) { + if (res.list[i].cate.erp_goods_cate_name == "热销") { + _this.categoryIndex = 2; // 如果有热销,那么分类索引值从2开始,前面两项过滤掉(搜索、热销) + } + + if (!res.list[i].goods_list) { + res.list[i].goods_list = []; + } + + res.list[i].isCateShow = true; + res.list[i].isShow = false; + res.list[i].style = _this.categoryBtnStyle.default; + _this.goodsInfo.push(res.list[i]); + } + + _this.totalCount = 0; + _this.totalPrice = 0; + _this.goodsInfo[1].style = _this.categoryBtnStyle.click; + _this.goodsInfo[1].isShow = true; + _this.categoryGoTop(); // 分类列表需要滚动至顶部 + + util.hideLoad(); + }); }, // 店铺列表 getStoreList() { + util.showLoad(); + let _this = this; return retailServer.get({ - url: retailApi.stadiumList, - data: {}, + url: retailApi.assistantGetAssistantStadiums, + data: { + // brand_id: _this.indexData.brand.id + }, failMsg: '加载店铺失败!' }).then(res => { let _list = res.list || []; _this.curStoreList = [..._this.curStoreList, ..._list]; _this.curStore = _this.curStoreList[0] || {}; + _this.getGoodsInfo(); // 获取商品信息 }); }, @@ -586,9 +613,9 @@ export default { let _this = this; let curStoreList = _this.curStoreList; _this.curStore = curStoreList[e.detail.value] || {}; - _this.$nextTick(function() { - _this.getGoodsInfo(); // 获取商品信息 - }); + // _this.$nextTick(function() { + // _this.getGoodsInfo(); // 获取商品信息 + // }); }, } } diff --git a/src/subpackage/retail/pages/search/search.vue b/src/subpackage/retail/pages/search/search.vue index 273458c..fee4490 100644 --- a/src/subpackage/retail/pages/search/search.vue +++ b/src/subpackage/retail/pages/search/search.vue @@ -11,7 +11,7 @@ /> - + @@ -20,13 +20,17 @@ - {{ item.text }} + {{ item }}