|
|
@ -46,8 +46,8 @@ |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="main-right-list-count-row"> |
|
|
|
<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 v-if="item.count>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.count>0?true:false">{{ item.count }}</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> |
|
|
@ -132,8 +132,38 @@ export default { |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
this.getSearchLocal(); // 获取本地的搜索记录 |
|
|
|
this.getRetailStatus(); // 获取收款出库状态 |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 获取收款出库状态 |
|
|
|
getRetailStatus() { |
|
|
|
let _this = this; |
|
|
|
|
|
|
|
uni.getStorage({ |
|
|
|
key: 'retailStatus', |
|
|
|
success: function (res) { |
|
|
|
_this.getGoodsInfo(); // 重新获取 刷新商品数据,把出库的数据清了 |
|
|
|
_this.deleteRetailLocal(); // 删除收款出库状态 |
|
|
|
}, |
|
|
|
fail: function(err) { |
|
|
|
console.log(err); |
|
|
|
_this.deleteRetailLocal(); // 删除收款出库状态 |
|
|
|
}, |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 删除收款出库状态 |
|
|
|
deleteRetailLocal() { |
|
|
|
this.searchData = null; |
|
|
|
|
|
|
|
uni.removeStorage({ |
|
|
|
key: 'retailStatus', |
|
|
|
success: function (res) { |
|
|
|
console.log('success'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 分类列表滚动监听 |
|
|
|
categoryOnScroll(e) { |
|
|
|
this.categoryOldScrollTop = e.detail.scrollTop; |
|
|
@ -159,6 +189,7 @@ export default { |
|
|
|
for (let i = 0; i < data.length; ++i) { |
|
|
|
if (data[i].goods_list) { |
|
|
|
for (let j = 0; j < data[i].goods_list.length; ++j) { |
|
|
|
data[i].goods_list[j].count = 0; // 用来计数 |
|
|
|
tempData["" + data[i].goods_list[j].id] = data[i].goods_list[j]; |
|
|
|
} |
|
|
|
} |
|
|
@ -178,7 +209,7 @@ export default { |
|
|
|
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; |
|
|
|
this.goodsInfo[0].goods_list[i].count = otherData[j].count; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -241,8 +272,8 @@ export default { |
|
|
|
let count = 0; |
|
|
|
|
|
|
|
for (let i = 0; i < this.cartList.length; ++i) { |
|
|
|
price += (this.cartList[i].erp_goods_sale_total * this.cartList[i].erp_goods_price); |
|
|
|
count += this.cartList[i].erp_goods_sale_total; |
|
|
|
price += (this.cartList[i].count * this.cartList[i].erp_goods_price); |
|
|
|
count += this.cartList[i].count; |
|
|
|
} |
|
|
|
|
|
|
|
this.cartTotalPrice = price.toFixed(2); |
|
|
@ -265,24 +296,24 @@ export default { |
|
|
|
switch (type) { |
|
|
|
case "add": { |
|
|
|
// 判断库存 |
|
|
|
if (this.cartList[i].erp_goods_sale_total + 1 > this.cartList[i].stock_num) { |
|
|
|
if (this.cartList[i].count + 1 > this.cartList[i].stock_num) { |
|
|
|
util.showNone("库存就这么多了!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this.cartList[i].erp_goods_sale_total += 1; |
|
|
|
this.cartList[i].count += 1; |
|
|
|
for (let i = 0; i < mainItems.length; ++i) { |
|
|
|
mainItems[i].erp_goods_sale_total += 1; |
|
|
|
mainItems[i].count += 1; |
|
|
|
} |
|
|
|
} break; |
|
|
|
case "sub": { |
|
|
|
if (this.cartList[i].erp_goods_sale_total > 0) { |
|
|
|
this.cartList[i].erp_goods_sale_total -= 1; |
|
|
|
if (this.cartList[i].count > 0) { |
|
|
|
this.cartList[i].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; |
|
|
|
if (mainItems[i].count > 0) { |
|
|
|
mainItems[i].count -= 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -290,7 +321,7 @@ export default { |
|
|
|
} |
|
|
|
|
|
|
|
// 没数量了就删掉 |
|
|
|
if (this.cartList[i].erp_goods_sale_total <= 0) { |
|
|
|
if (this.cartList[i].count <= 0) { |
|
|
|
this.cartList.splice(i, 1); |
|
|
|
} |
|
|
|
|
|
|
@ -304,7 +335,7 @@ export default { |
|
|
|
let arr = []; |
|
|
|
|
|
|
|
for (let i = 0; i < this.cartList.length; ++i) { |
|
|
|
if (this.cartList[i].erp_goods_sale_total) { |
|
|
|
if (this.cartList[i].count) { |
|
|
|
arr.push(tools.getNewObj(this.cartList[i])); |
|
|
|
} |
|
|
|
} |
|
|
@ -340,7 +371,7 @@ export default { |
|
|
|
// 计算购物车列表 |
|
|
|
for (let i = this.categoryIndex; i < this.goodsInfo.length; ++i) { |
|
|
|
for (let j = 0; j < this.goodsInfo[i].goods_list.length; ++j) { |
|
|
|
if (this.goodsInfo[i].goods_list[j].erp_goods_sale_total) { |
|
|
|
if (this.goodsInfo[i].goods_list[j].count) { |
|
|
|
this.cartList.push(tools.getNewObj(this.goodsInfo[i].goods_list[j])); |
|
|
|
} |
|
|
|
} |
|
|
@ -441,7 +472,7 @@ export default { |
|
|
|
} |
|
|
|
|
|
|
|
// 如果不在 并且有数量,那么加进列表 |
|
|
|
if (!mark && searchAndHotData[i].erp_goods_sale_total) { |
|
|
|
if (!mark && searchAndHotData[i].count) { |
|
|
|
tempData.push(searchAndHotData[i]); |
|
|
|
} |
|
|
|
} |
|
|
@ -457,8 +488,8 @@ export default { |
|
|
|
// 先计算搜索、热销后面的价格跟数量 |
|
|
|
for (let i = this.categoryIndex; i < this.goodsInfo.length; ++i) { |
|
|
|
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; |
|
|
|
price += (this.goodsInfo[i].goods_list[j].count * this.goodsInfo[i].goods_list[j].erp_goods_price); |
|
|
|
count += this.goodsInfo[i].goods_list[j].count; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -466,8 +497,8 @@ export default { |
|
|
|
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; |
|
|
|
price += (tempData[i].count * tempData[i].erp_goods_price); |
|
|
|
count += tempData[i].count; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -501,18 +532,18 @@ export default { |
|
|
|
switch (type) { |
|
|
|
case "add": { |
|
|
|
// 判断库存 |
|
|
|
if (goodsItem.erp_goods_sale_total + 1 > goodsItem.stock_num) { |
|
|
|
if (goodsItem.count + 1 > goodsItem.stock_num) { |
|
|
|
util.showNone("库存就这么多了!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
goodsItem.erp_goods_sale_total += 1; |
|
|
|
goodsItem.count += 1; |
|
|
|
} break; |
|
|
|
case "sub": { |
|
|
|
if (goodsItem.erp_goods_sale_total <= 0) { |
|
|
|
if (goodsItem.count <= 0) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
goodsItem.erp_goods_sale_total -= 1; |
|
|
|
goodsItem.count -= 1; |
|
|
|
} break; |
|
|
|
} |
|
|
|
} |
|
|
@ -521,7 +552,7 @@ export default { |
|
|
|
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.goodsInfo[i].goods_list[j].count = goodsItem.count; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -579,12 +610,18 @@ export default { |
|
|
|
}); |
|
|
|
|
|
|
|
for (let i = 0; i < res.data.data.list.length; ++i) { |
|
|
|
// 过滤没有商品数据的分类 |
|
|
|
if (!res.data.data.list[i].goods_list || !res.data.data.list[i].goods_list.length) { |
|
|
|
// res.data.data.list[i].goods_list = []; |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (res.data.data.list[i].cate.erp_goods_cate_name == "热销") { |
|
|
|
_this.categoryIndex = 2; // 如果有热销,那么分类索引值从2开始,前面两项过滤掉(搜索、热销) |
|
|
|
} |
|
|
|
|
|
|
|
if (!res.data.data.list[i].goods_list) { |
|
|
|
res.data.data.list[i].goods_list = []; |
|
|
|
for (let j = 0; j < res.data.data.list[i].goods_list.length; ++j) { |
|
|
|
res.data.data.list[i].goods_list[j].count = 0; // 用来计数 |
|
|
|
} |
|
|
|
|
|
|
|
res.data.data.list[i].isCateShow = true; |
|
|
@ -596,8 +633,10 @@ export default { |
|
|
|
_this.cartList = []; // 购物车的数据清空,每次切换门店都执行 |
|
|
|
_this.totalCount = 0; |
|
|
|
_this.totalPrice = 0; |
|
|
|
_this.goodsInfo[1].style = _this.categoryBtnStyle.click; |
|
|
|
_this.goodsInfo[1].isShow = true; |
|
|
|
if (_this.goodsInfo.length > 1) { |
|
|
|
_this.goodsInfo[1].style = _this.categoryBtnStyle.click; |
|
|
|
_this.goodsInfo[1].isShow = true; |
|
|
|
} |
|
|
|
_this.categoryGoTop(); // 分类列表需要滚动至顶部 |
|
|
|
|
|
|
|
util.hideLoad(); |
|
|
|