|
|
@ -30,24 +30,24 @@ |
|
|
|
|
|
|
|
<view class="main" :style="{ height:mainHeight }"> |
|
|
|
<scroll-view class="main-left" :scroll-top="categoryScrollTop" scroll-y="true" @scroll="categoryOnScroll"> |
|
|
|
<view class="main-left-list" v-if="item.isSearch" v-for="item in goodsInfo" :key="item.id"> |
|
|
|
<button plain=true @click="mainCategoryClick(item.id)" :style="{ color:item.style.color, backgroundColor:item.style.backgroundColor }">{{ item.categoryName }}</button> |
|
|
|
<view class="main-left-list" v-if="item.isCateShow" v-for="item in goodsInfo" :key="item.cate.id"> |
|
|
|
<button plain=true @click="mainCategoryClick(item.cate.id)" :style="{ color:item.style.color, backgroundColor:item.style.backgroundColor }">{{ item.cate.erp_goods_cate_name }}</button> |
|
|
|
</view> |
|
|
|
</scroll-view> |
|
|
|
<scroll-view class="main-right" scroll-top="0" scroll-y="true" v-if="scrollItem.isShow" v-for="scrollItem in goodsInfo" :key="scrollItem.id"> |
|
|
|
<view class="main-right-list" v-for="item in scrollItem.goodsData" :key="item.id"> |
|
|
|
<view>{{ item.name }}</view> |
|
|
|
<view>{{ item.spec }}</view> |
|
|
|
<scroll-view class="main-right" scroll-top="0" scroll-y="true" v-if="scrollItem.isShow" v-for="scrollItem in goodsInfo" :key="scrollItem.cate.id"> |
|
|
|
<view class="main-right-list" v-for="item in scrollItem.goods_list" :key="item.id"> |
|
|
|
<view>{{ item.erp_goods_name }}</view> |
|
|
|
<view>{{ item.erp_goods_specs }}</view> |
|
|
|
|
|
|
|
<view class="main-right-list-price-count"> |
|
|
|
<view class="main-right-list-price-row"> |
|
|
|
<view><text>¥</text>{{ item.price }}</view> |
|
|
|
<view><text>¥</text>{{ item.erp_goods_price }}</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="main-right-list-count-row"> |
|
|
|
<image v-if="item.count>0?true:false" mode="aspectFit" src="/static/images/icon/retail/sub.png" @click="mainCountClick('sub', scrollItem.id, item.id)"></image> |
|
|
|
<view v-if="item.count>0?true:false">{{ item.count }}</view> |
|
|
|
<image mode="aspectFit" src="/static/images/icon/retail/add.png" @click="mainCountClick('add', scrollItem.id, item.id)"></image> |
|
|
|
<image v-if="item.erp_goods_sale_total>0?true:false" mode="aspectFit" src="/static/images/icon/retail/sub.png" @click="mainCountClick('sub', scrollItem.cate.id, scrollItem.cate.erp_goods_cate_name, item.id)"></image> |
|
|
|
<view v-if="item.erp_goods_sale_total>0?true:false">{{ item.erp_goods_sale_total }}</view> |
|
|
|
<image mode="aspectFit" src="/static/images/icon/retail/add.png" @click="mainCountClick('add', scrollItem.cate.id, scrollItem.cate.erp_goods_cate_name, item.id)"></image> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -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])); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 购物车列表状态变化 |
|
|
@ -352,6 +374,9 @@ export default { |
|
|
|
else { |
|
|
|
this.addToCartList(); // 将主页数据加入到购物车列表 |
|
|
|
this.cartListStatusChange(); // 购物车列表状态变化 |
|
|
|
|
|
|
|
this.cartTotalPrice = this.totalPrice; |
|
|
|
this.cartTotalCount = this.totalCount; |
|
|
|
this.isShowCartList = true; |
|
|
|
this.calcCartTotalPriceAndCount(); // 计算购物车总价跟总量 |
|
|
|
} |
|
|
@ -379,30 +404,74 @@ 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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.totalPrice = price.toFixed(2); |
|
|
|
this.totalCount = count; |
|
|
|
this.cartTotalPrice = this.totalPrice; |
|
|
|
this.cartTotalCount = this.totalCount; |
|
|
|
}, |
|
|
|
|
|
|
|
// 主页数量选项触发 |
|
|
|
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; |
|
|
|
} |
|
|
@ -411,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; |
|
|
|
} |
|
|
|
} |
|
|
@ -422,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(); // 将主页数据加入到购物车列表 |
|
|
|
}, |
|
|
|
|
|
|
|
// 主页分类选项触发 |
|
|
@ -446,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]; |
|
|
|
} |
|
|
|
} |
|
|
@ -461,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(); // 获取商品信息 |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
@ -585,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(); // 获取商品信息 |
|
|
|
// }); |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
@ -617,6 +645,7 @@ export default { |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
background-color: rgb(237,237,245); |
|
|
|
z-index: 0; |
|
|
|
|
|
|
|
.header-store-selecter { |
|
|
|
display: flex; |
|
|
|