|
|
@ -26,34 +26,34 @@ |
|
|
|
<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.isCateShow" v-for="item in goodsInfo" :key="item.cate.id"> |
|
|
|
<button plain=true @click="mainCategoryClick(item.cate.id)" :style="{ fontWeight: item.style.fontWeight, color:item.style.color, backgroundColor:item.style.backgroundColor }">{{ item.cate.erp_goods_cate_name }}</button> |
|
|
|
<button plain=true @click="mainCategoryClick(item.cate.id, item.isShow)" :style="{ fontWeight: item.style.fontWeight, color:item.style.color, backgroundColor:item.style.backgroundColor }">{{ item.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.cate.id"> |
|
|
|
<scroll-view class="main-right" scroll-top="0" scroll-y="true" v-if="scrollItem.isShow" v-for="scrollItem in goodsInfo" :key="scrollItem.cate.id" @scrolltolower="refreshList()"> |
|
|
|
<view class="main-right-list" v-for="item in scrollItem.goods_list" :key="item.id"> |
|
|
|
<view class="item-left"> |
|
|
|
<image mode="aspectFit" src="/static/images/icon/author_modal.png"></image> |
|
|
|
<view v-if="item.stock_num?false:true" class="item-left-empty"> |
|
|
|
<image mode="aspectFit" :src="item.goods_img"></image> |
|
|
|
<view v-if="item.erp_goods.stock_num?false:true" class="item-left-empty"> |
|
|
|
<view>盘罄</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="item-right"> |
|
|
|
<view class="item-right-top"> |
|
|
|
<view class="item-right-name">{{ item.erp_goods_name }}</view> |
|
|
|
<view class="item-right-spec">{{ `${item.erp_goods_specs}/${item.erp_goods_specs}/${item.erp_goods_specs}` }}</view> |
|
|
|
<view class="item-right-special">特价</view> |
|
|
|
<view class="item-right-name">{{ item.goods_name }}</view> |
|
|
|
<view class="item-right-spec">{{ item.erp_goods.erp_goods_specs }}</view> |
|
|
|
<!-- <view class="item-right-special">特价</view> --> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="item-right-price-count"> |
|
|
|
<view class="item-right-price-row" :style="{color:item.stock_num?'#FF873D':'#9A9A9D'}"> |
|
|
|
<view><text>¥</text>{{ item.erp_goods_price }}</view> |
|
|
|
<view class="item-right-price-row" :style="{color:item.erp_goods.stock_num?'#FF873D':'#9A9A9D'}"> |
|
|
|
<view><text>¥</text>{{ item.erp_goods.erp_goods_price }}</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="item-right-count-row"> |
|
|
|
<image v-if="item.count?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, item.stock_num)"></image> |
|
|
|
<image v-if="item.count?true:false" mode="aspectFit" src="/static/images/icon/retail/sub.png" @click="mainCountClick('sub', scrollItem.cate.id, scrollItem.cate.name, item.id, item.erp_goods.stock_num)"></image> |
|
|
|
<view v-if="item.count?true:false">{{ item.count }}</view> |
|
|
|
<image v-if="item.stock_num?true:false" mode="aspectFit" src="/static/images/icon/retail/add.png" @click="mainCountClick('add', scrollItem.cate.id, scrollItem.cate.erp_goods_cate_name, item.id, item.stock_num)"></image> |
|
|
|
<image v-else mode="aspectFit" src="/static/images/icon/retail/addEmpty.png" @click="mainCountClick('add', scrollItem.cate.id, scrollItem.cate.erp_goods_cate_name, item.id, item.stock_num)"></image> |
|
|
|
<image v-if="item.erp_goods.stock_num?true:false" mode="aspectFit" src="/static/images/icon/retail/add.png" @click="mainCountClick('add', scrollItem.cate.id, scrollItem.cate.name, item.id, item.erp_goods.stock_num)"></image> |
|
|
|
<image v-else mode="aspectFit" src="/static/images/icon/retail/addEmpty.png" @click="mainCountClick('add', scrollItem.cate.id, scrollItem.cate.name, item.id, item.erp_goods.stock_num)"></image> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -75,12 +75,10 @@ |
|
|
|
<view class="footer-price"> |
|
|
|
<view @click="cartClick"> |
|
|
|
<image mode="aspectFit" src="/static/images/icon/retail/cart.png"></image> |
|
|
|
<view v-if="(totalCount && !isShowCartList) ? true:false">{{ totalCount }}</view> |
|
|
|
<view v-if="(cartTotalCount && isShowCartList) ? true:false">{{ cartTotalCount }}</view> |
|
|
|
<view v-if="totalCount">{{ totalCount }}</view> |
|
|
|
</view> |
|
|
|
<view>合计:</view> |
|
|
|
<view v-if="!isShowCartList"><text>¥</text>{{ totalPrice }}</view> |
|
|
|
<view v-if="isShowCartList"><text>¥</text>{{ cartTotalPrice }}</view> |
|
|
|
<view><text>¥</text>{{ totalPrice }}</view> |
|
|
|
</view> |
|
|
|
<view class="footer-confirm"> |
|
|
|
<button hover-class="hover-active" @click="cartConfirm" :style="{opacity:cartConfirmOpacity}">去结算</button> |
|
|
@ -96,6 +94,7 @@ import tools from '../../js/tools'; |
|
|
|
import retailServer from '../../js/retail_server'; |
|
|
|
import retailApi from '../../js/retail_api'; |
|
|
|
import hoverCartList from '../../components/hover_cart_list/hover_cart_list'; |
|
|
|
import { mapState } from 'vuex' |
|
|
|
|
|
|
|
export default { |
|
|
|
components: { |
|
|
@ -110,10 +109,20 @@ export default { |
|
|
|
categoryScrollTop: 0, // 分类滚动值 |
|
|
|
categoryOldScrollTop: 0, // 分类滚动旧值 |
|
|
|
// 分类索引值,默认第一项是搜索,第二项可能是热销,会在获取接口数据时判断,然后过滤掉 |
|
|
|
categoryIndex: 1, |
|
|
|
categoryIndex: 1, |
|
|
|
params: { |
|
|
|
brand_id: '', |
|
|
|
stadium_id: '', |
|
|
|
type_key: '', |
|
|
|
key: '', |
|
|
|
page: 1, |
|
|
|
page_size: 10, |
|
|
|
}, |
|
|
|
total: 0, |
|
|
|
searchData: null, |
|
|
|
searchText: '', |
|
|
|
|
|
|
|
// curStoreList: [{ id: '', name: '请选择门店'}], // 当前门店列表 |
|
|
|
indexData: {}, // 首页 统计数据 |
|
|
|
curStoreList: [], // 当前门店列表 |
|
|
|
storeListDisabled: false, // 当前门店列表禁用状态 |
|
|
|
curStore: {}, // 当前门店 |
|
|
@ -121,8 +130,6 @@ export default { |
|
|
|
mainHeight: "0rpx", // 主内容高度 |
|
|
|
totalPrice: 0, // 总价 |
|
|
|
totalCount: 0, // 总量 |
|
|
|
cartTotalPrice: 0, // 购物车总价 |
|
|
|
cartTotalCount: 0, // 购物车总量 |
|
|
|
|
|
|
|
cartList: [], // 购物车列表 |
|
|
|
cartListFinal: [], // 购物车最终列表数据 |
|
|
@ -131,6 +138,7 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad() { |
|
|
|
this.params.brand_id = this.brandInfo.brand.id; |
|
|
|
this.deleteSearchLocal(); // 删除本地的搜索记录 |
|
|
|
this.getStoreList(); // 获取店铺列表 |
|
|
|
this.fixMainHeight(); // 适配主内容高度 |
|
|
@ -139,6 +147,9 @@ export default { |
|
|
|
this.getSearchLocal(); // 获取本地的搜索记录 |
|
|
|
this.getRetailStatus(); // 获取收款出库状态 |
|
|
|
}, |
|
|
|
computed:{ |
|
|
|
...mapState([ 'brandInfo',]) |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
cartList() { |
|
|
|
this.setCartConfirmStyle(); |
|
|
@ -152,7 +163,11 @@ export default { |
|
|
|
uni.getStorage({ |
|
|
|
key: 'retailStatus', |
|
|
|
success: (res) => { |
|
|
|
_this.getGoodsInfo(); // 重新获取 刷新商品数据,把出库的数据清了 |
|
|
|
_this.searchText = ''; |
|
|
|
_this.params.page = 1; |
|
|
|
_this.params.type_key = ''; |
|
|
|
_this.params.key = ''; |
|
|
|
_this.getCategoryInfo(); // 重新获取 刷新商品数据,把出库的数据清了 |
|
|
|
_this.deleteRetailLocal(); // 删除收款出库状态 |
|
|
|
}, |
|
|
|
fail: (err) => { _this.deleteRetailLocal();}, |
|
|
@ -177,37 +192,13 @@ export default { |
|
|
|
setSearchData(data) { |
|
|
|
util.showLoad(); |
|
|
|
setTimeout(util.hideLoad, 500); |
|
|
|
this.goodsInfo[0].goods_list = []; |
|
|
|
|
|
|
|
// 剔除相同的商品 |
|
|
|
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) { |
|
|
|
data[i].goods_list[j].count = 0; // 用来计数 |
|
|
|
tempData["" + data[i].goods_list[j].id] = data[i].goods_list[j]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (let key in tempData) this.goodsInfo[0].goods_list.push(tempData[key]); |
|
|
|
|
|
|
|
// 同步一下数据,因为有可能搜索的数据 在其他分类出现过 |
|
|
|
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].count = otherData[j].count; |
|
|
|
} |
|
|
|
} |
|
|
|
// end |
|
|
|
this.searchData = data; |
|
|
|
this.goodsInfo[0].goods_list = data.list; |
|
|
|
this.searchText = data.searchText; |
|
|
|
this.setCount(0); |
|
|
|
this.categoryGoTop(); // 每次搜索后,分类列表都要滚动到顶部 |
|
|
|
this.goodsInfo[0].isCateShow = true; |
|
|
|
this.mainCategoryClick(this.goodsInfo[0].cate.id); |
|
|
|
this.mainCategoryClick(this.goodsInfo[0].cate.id, this.goodsInfo[0].isShow); |
|
|
|
}, |
|
|
|
// 获取本地的历史搜索 |
|
|
|
getSearchLocal() { |
|
|
@ -229,7 +220,7 @@ export default { |
|
|
|
}, |
|
|
|
// 触发搜索 |
|
|
|
searchTrigger() { |
|
|
|
let data = { curStore: this.curStore }; |
|
|
|
let data = { curStore: this.curStore, brandInfo: this.brandInfo }; |
|
|
|
uni.navigateTo({ |
|
|
|
url: `/subpackage/retail/pages/search/search?data=${encodeURIComponent(JSON.stringify(data))}` |
|
|
|
}); |
|
|
@ -237,19 +228,7 @@ export default { |
|
|
|
// 购物车输入确认 |
|
|
|
cartInputConfirm(value, i) { |
|
|
|
this.cartList[i].erp_goods_price = value; |
|
|
|
this.calcCartTotalPriceAndCount(); // 计算购物车总价跟总量 |
|
|
|
}, |
|
|
|
// 计算购物车总价跟总量 |
|
|
|
calcCartTotalPriceAndCount() { |
|
|
|
let price = 0.0; |
|
|
|
let count = 0; |
|
|
|
|
|
|
|
for (let i = 0; i < this.cartList.length; ++i) { |
|
|
|
price += (this.cartList[i].count * this.cartList[i].erp_goods_price); |
|
|
|
count += this.cartList[i].count; |
|
|
|
} |
|
|
|
this.cartTotalPrice = price.toFixed(2); |
|
|
|
this.cartTotalCount = count; |
|
|
|
this.calcTotalPriceAndCount(); // 计算购物车总价跟总量 |
|
|
|
}, |
|
|
|
// 清空购物车 |
|
|
|
clearCart() { |
|
|
@ -259,85 +238,64 @@ export default { |
|
|
|
this.goodsInfo[i].goods_list[j].count = 0; |
|
|
|
} |
|
|
|
this.isShowCartList = false; |
|
|
|
this.calcCartTotalPriceAndCount(); // 计算购物车总价跟总量 |
|
|
|
this.calcTotalPriceAndCount(); // 计算总价跟总量 |
|
|
|
}, |
|
|
|
// 购物车列表数量选项触发 |
|
|
|
cartCountClick(type, i) { |
|
|
|
// 增减购物车对应的主页数量 |
|
|
|
let curId = this.cartList[i].id; |
|
|
|
let mainItems = []; // 可能不止一个 |
|
|
|
for (let i = 0; i < this.goodsInfo.length; ++i) { |
|
|
|
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": { |
|
|
|
if (this.cartList[i].count + 1 > this.cartList[i].stock_num) { |
|
|
|
if (this.cartList[i].count + 1 > this.cartList[i].erp_goods.stock_num) { |
|
|
|
util.showNone("库存就这么多了!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this.cartList[i].count += 1; |
|
|
|
for (let i = 0; i < mainItems.length; ++i) mainItems[i].count += 1; |
|
|
|
this.cartList[i].count += 1; |
|
|
|
} break; |
|
|
|
case "sub": { |
|
|
|
if (this.cartList[i].count > 0) this.cartList[i].count -= 1; |
|
|
|
|
|
|
|
for (let i = 0; i < mainItems.length; ++i) { |
|
|
|
if (mainItems[i].count > 0) mainItems[i].count -= 1; |
|
|
|
} |
|
|
|
} break; |
|
|
|
} |
|
|
|
// 找主页当前列表有无该数据 |
|
|
|
for (let k = 0; k < this.goodsInfo.length; ++k) { |
|
|
|
if (this.goodsInfo[k].isShow) { |
|
|
|
for (let j = 0; j < this.goodsInfo[k].goods_list.length; ++j) { |
|
|
|
if (this.goodsInfo[k].goods_list[j].id === this.cartList[i].id) { |
|
|
|
this.goodsInfo[k].goods_list[j].count = this.cartList[i].count; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (this.cartList[i].count <= 0) this.cartList.splice(i, 1); // 没数量了就删掉 |
|
|
|
if (!this.cartList.length) this.isShowCartList = false; // 列表没了,隐藏 |
|
|
|
this.calcCartTotalPriceAndCount(); // 计算购物车总价跟总量 |
|
|
|
this.calcTotalPriceAndCount(); // 计算总价跟总量 |
|
|
|
}, |
|
|
|
// 获取购物车列表的最终数据 |
|
|
|
getCartListFinalData() { |
|
|
|
let arr = []; |
|
|
|
for (let i = 0; i < this.cartList.length; ++i) { |
|
|
|
if (this.cartList[i].count) arr.push(tools.getNewObj(this.cartList[i])); |
|
|
|
} |
|
|
|
return arr; |
|
|
|
}, |
|
|
|
// 购物车确认 |
|
|
|
cartConfirm() { |
|
|
|
if (this.cartList.length <= 0) return; |
|
|
|
this.cartListFinal = this.getCartListFinalData(); |
|
|
|
|
|
|
|
// 有数据,那么需要跳到确定页面 |
|
|
|
if (this.cartListFinal.length) { |
|
|
|
this.isShowCartList = false; |
|
|
|
let data = { cartListFinal: this.cartListFinal, curStore: this.curStore }; |
|
|
|
uni.navigateTo({ |
|
|
|
url: `/subpackage/retail/pages/confirm_goods/confirm_goods?data=${encodeURIComponent(JSON.stringify(data))}` |
|
|
|
}); |
|
|
|
} |
|
|
|
else { |
|
|
|
util.showNone("购物车无数据!"); |
|
|
|
} |
|
|
|
this.cartListFinal = JSON.parse(JSON.stringify(this.cartList)); |
|
|
|
this.isShowCartList = false; |
|
|
|
let data = { cartListFinal: this.cartListFinal, curStore: this.curStore, totalPrice: this.totalPrice }; |
|
|
|
uni.navigateTo({ |
|
|
|
url: `/subpackage/retail/pages/confirm_goods/confirm_goods?data=${encodeURIComponent(JSON.stringify(data))}` |
|
|
|
}); |
|
|
|
}, |
|
|
|
// 加入购物车列表 |
|
|
|
addToCartList() { |
|
|
|
this.cartList = []; |
|
|
|
|
|
|
|
// 计算购物车列表 |
|
|
|
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].count) |
|
|
|
this.cartList.push(tools.getNewObj(this.goodsInfo[i].goods_list[j])); |
|
|
|
addToCartList(goodsItem) { |
|
|
|
let mark = -1; |
|
|
|
for (let i = 0; i < this.cartList.length; ++i) { |
|
|
|
if (this.cartList[i].id === goodsItem.id) { |
|
|
|
mark = i; |
|
|
|
this.cartList[i].count = goodsItem.count; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 再把搜索跟热销的 不在其他分类里的数据找出来也加上 |
|
|
|
let tempData = this.findDifferentData(); // 找不同 |
|
|
|
for (let i = 0; i < tempData.length; ++i) this.cartList.push(tools.getNewObj(tempData[i])); |
|
|
|
if (mark === -1) { |
|
|
|
this.cartList.push(JSON.parse(JSON.stringify(goodsItem))); |
|
|
|
} else if (goodsItem.count <= 0) { |
|
|
|
this.cartList.splice(mark, 1); |
|
|
|
} |
|
|
|
}, |
|
|
|
setCartConfirmStyle() { |
|
|
|
this.cartConfirmOpacity = this.cartList.length > 0 ? 1 : 0.3; |
|
|
@ -345,17 +303,7 @@ export default { |
|
|
|
// 购物车点击 |
|
|
|
cartClick() { |
|
|
|
if (!this.cartList.length) return; |
|
|
|
|
|
|
|
if (this.isShowCartList) { |
|
|
|
this.isShowCartList = false; |
|
|
|
} |
|
|
|
else { |
|
|
|
this.addToCartList(); // 将主页数据加入到购物车列表 |
|
|
|
this.cartTotalPrice = this.totalPrice; |
|
|
|
this.cartTotalCount = this.totalCount; |
|
|
|
this.isShowCartList = true; |
|
|
|
this.calcCartTotalPriceAndCount(); // 计算购物车总价跟总量 |
|
|
|
} |
|
|
|
this.isShowCartList = !this.isShowCartList; |
|
|
|
}, |
|
|
|
// 适配主内容高度 |
|
|
|
fixMainHeight() { |
|
|
@ -410,21 +358,9 @@ export default { |
|
|
|
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].goods_list.length; ++j) { |
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 再回过头来计算搜索跟热销的,计算热销物品不在 其他分类里的价格跟数量 |
|
|
|
let tempData = this.findDifferentData(); // 找不同 |
|
|
|
if (tempData.length) { |
|
|
|
for (let i = 0; i < tempData.length; ++i) { |
|
|
|
price += (tempData[i].count * tempData[i].erp_goods_price); |
|
|
|
count += tempData[i].count; |
|
|
|
} |
|
|
|
for (let i = 0; i < this.cartList.length; ++i) { |
|
|
|
price = parseFloat(price) + parseFloat(this.cartList[i].count * this.cartList[i].erp_goods.erp_goods_price); |
|
|
|
count += this.cartList[i].count; |
|
|
|
} |
|
|
|
this.totalPrice = price.toFixed(2); |
|
|
|
this.totalCount = count; |
|
|
@ -456,11 +392,11 @@ export default { |
|
|
|
if (goodsItem) { |
|
|
|
switch (type) { |
|
|
|
case "add": { |
|
|
|
if (goodsItem.count + 1 > goodsItem.stock_num) { |
|
|
|
if (goodsItem.count + 1 > goodsItem.erp_goods.stock_num) { |
|
|
|
util.showNone("库存就这么多了!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
goodsItem.count += 1; |
|
|
|
goodsItem.count += 1; |
|
|
|
} break; |
|
|
|
case "sub": { |
|
|
|
if (goodsItem.count <= 0) return; |
|
|
@ -469,18 +405,12 @@ 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].count = goodsItem.count; |
|
|
|
} |
|
|
|
} |
|
|
|
this.addToCartList(goodsItem); // 将主页数据加入到购物车列表 |
|
|
|
this.calcTotalPriceAndCount(); // 计算总价跟总量 |
|
|
|
this.addToCartList(); // 将主页数据加入到购物车列表 |
|
|
|
}, |
|
|
|
// 主页分类选项触发 |
|
|
|
mainCategoryClick(id) { |
|
|
|
mainCategoryClick(id, isShow) { |
|
|
|
if (isShow) return; |
|
|
|
// 将所有按钮恢复默认状态,点击的按钮则是另外的状态 |
|
|
|
let item = null; |
|
|
|
for (let i = 0; i < this.goodsInfo.length; ++i) { |
|
|
@ -489,72 +419,109 @@ export default { |
|
|
|
|
|
|
|
if (this.goodsInfo[i].cate.id == id) item = this.goodsInfo[i]; |
|
|
|
} |
|
|
|
|
|
|
|
if (item) { |
|
|
|
item.style = this.categoryBtnStyle.click; |
|
|
|
item.isShow = true; |
|
|
|
this.params.type_key = item.cate.classifyer_id; |
|
|
|
this.params.key = item.cate.name === '搜索' ? this.searchText : ''; |
|
|
|
this.params.page = 1; |
|
|
|
|
|
|
|
util.showLoad(); |
|
|
|
if (!this.searchData) { |
|
|
|
item.goods_list = []; |
|
|
|
this.getGoodsInfo(); // 获取商品信息 |
|
|
|
} else { |
|
|
|
util.hideLoad(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
// 获取商品信息 |
|
|
|
getGoodsInfo() { |
|
|
|
// 获取商品分类 |
|
|
|
async getCategoryInfo() { |
|
|
|
let _this = this; |
|
|
|
_this.goodsInfo = []; |
|
|
|
_this.params.page = 1; |
|
|
|
|
|
|
|
retailServer.get({ |
|
|
|
url: retailApi.assistantListErpGoodsCateAndGoods, |
|
|
|
// 获取分类 |
|
|
|
let res = await retailServer.get({ |
|
|
|
url: retailApi.getCategoryList, |
|
|
|
data: { |
|
|
|
// brand_id: _this.indexData.brand.id, |
|
|
|
stadium_id: _this.curStore.id, |
|
|
|
parent_classifyer_id: `${_this.brandInfo.brand.id}-${_this.curStore.id}-零售商品分类` |
|
|
|
}, |
|
|
|
isDefaultGet: false, |
|
|
|
failMsg: '加载物品数据失败!' |
|
|
|
}).then(res => { |
|
|
|
if (res.data.code == 0) { |
|
|
|
failMsg: '加载商品分类数据失败!' |
|
|
|
}).catch(() => {}); |
|
|
|
// 默认第一个搜索,第二个全部 |
|
|
|
_this.categoryIndex = 2; // 分类索引值从2开始,前面两项过滤掉(搜索、全部) |
|
|
|
_this.goodsInfo = [{ |
|
|
|
isCateShow: false, isShow: false, style: _this.categoryBtnStyle.default, goods_list: [], |
|
|
|
cate: { id: -2, classifyer_id: '', name: "搜索" } |
|
|
|
}, { |
|
|
|
isCateShow: true, isShow: true, style: _this.categoryBtnStyle.click, goods_list: [], |
|
|
|
cate: { id: -1, classifyer_id: '', name: "全部" } |
|
|
|
} |
|
|
|
]; |
|
|
|
if (res && res.data && res.data.data) { |
|
|
|
for (let i = 0; i < res.data.data.length; ++i) { |
|
|
|
_this.goodsInfo.push({ |
|
|
|
isCateShow: false, |
|
|
|
isShow: false, |
|
|
|
style: _this.categoryBtnStyle.default, |
|
|
|
cate: { |
|
|
|
created_at: "", |
|
|
|
erp_goods_cate_brandid: -1, |
|
|
|
erp_goods_cate_name: "搜索", |
|
|
|
id: -1, |
|
|
|
update_at: "", |
|
|
|
}, |
|
|
|
goods_list: [], |
|
|
|
isCateShow: true, isShow: false, style: _this.categoryBtnStyle.default, goods_list: [], |
|
|
|
cate: { |
|
|
|
id: res.data.data[i].id, |
|
|
|
classifyer_id: res.data.data[i].classifyer_id, |
|
|
|
name: res.data.data[i].name |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
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) continue; |
|
|
|
|
|
|
|
// 如果有热销,那么分类索引值从2开始,前面两项过滤掉(搜索、热销) |
|
|
|
if (res.data.data.list[i].cate.erp_goods_cate_name == "热销") _this.categoryIndex = 2; |
|
|
|
|
|
|
|
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; |
|
|
|
res.data.data.list[i].isShow = false; |
|
|
|
res.data.data.list[i].style = _this.categoryBtnStyle.default; |
|
|
|
_this.goodsInfo.push(res.data.data.list[i]); |
|
|
|
} |
|
|
|
|
|
|
|
_this.cartList = []; // 购物车的数据清空,每次切换门店都执行 |
|
|
|
_this.totalCount = 0; |
|
|
|
_this.totalPrice = 0; |
|
|
|
if (_this.goodsInfo.length > 1) { |
|
|
|
_this.goodsInfo[1].style = _this.categoryBtnStyle.click; |
|
|
|
_this.goodsInfo[1].isShow = true; |
|
|
|
} |
|
|
|
_this.cartList = []; // 购物车的数据清空,每次切换门店都执行 |
|
|
|
_this.totalCount = 0; |
|
|
|
_this.totalPrice = 0; |
|
|
|
_this.categoryGoTop(); // 分类列表需要滚动至顶部 |
|
|
|
} |
|
|
|
|
|
|
|
this.getGoodsInfo(); |
|
|
|
}, |
|
|
|
// 获取商品信息 |
|
|
|
async getGoodsInfo() { |
|
|
|
let _this = this; |
|
|
|
let goodsRes = await retailServer.get({ |
|
|
|
url: retailApi.getGoodsList, |
|
|
|
data: _this.params, |
|
|
|
isDefaultGet: false, |
|
|
|
failMsg: '加载商品数据失败!' |
|
|
|
}).catch(() => {}); |
|
|
|
if (goodsRes && goodsRes.data && goodsRes.data.data && goodsRes.data.data.list) { |
|
|
|
for (let j = 0; j < goodsRes.data.data.list.length; ++j) { |
|
|
|
goodsRes.data.data.list[j].count = 0; // 用来计数 |
|
|
|
goodsRes.data.data.list[j].erp_goods = goodsRes.data.data.list[j].erp_goods || {}; |
|
|
|
} |
|
|
|
for (let i = 0; i < _this.goodsInfo.length; ++i) { |
|
|
|
if (_this.goodsInfo[i].isShow) { |
|
|
|
// _this.goodsInfo[i].goods_list = goodsRes.data.data.list; |
|
|
|
_this.goodsInfo[i].goods_list = _this.goodsInfo[i].goods_list.concat(goodsRes.data.data.list); |
|
|
|
this.setCount(i); // 购物车列表的数量覆盖上当前列表的数量 |
|
|
|
break; |
|
|
|
} |
|
|
|
_this.categoryGoTop(); // 分类列表需要滚动至顶部 |
|
|
|
util.hideLoad(); |
|
|
|
} |
|
|
|
else { |
|
|
|
util.hideLoad(); |
|
|
|
util.showNone(res.data.message || '操作失败!'); |
|
|
|
_this.total = goodsRes.data.data.total; |
|
|
|
} |
|
|
|
util.hideLoad(); |
|
|
|
}, |
|
|
|
setCount(index) { |
|
|
|
for (let i = 0; i < this.cartList.length; ++i) { |
|
|
|
for (let j = 0; j < this.goodsInfo[index].goods_list.length; ++j) { |
|
|
|
if (this.cartList[i].id === this.goodsInfo[index].goods_list[j].id) { |
|
|
|
this.goodsInfo[index].goods_list[j].count = this.cartList[i].count; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
refreshList() { |
|
|
|
// 还没到最后一页 |
|
|
|
if (this.params.page * this.params.page_size <= this.total) { |
|
|
|
util.showLoad(); |
|
|
|
this.params.page += 1; |
|
|
|
this.getGoodsInfo(); |
|
|
|
} |
|
|
|
}, |
|
|
|
// 店铺列表 |
|
|
|
getStoreList() { |
|
|
@ -574,7 +541,8 @@ export default { |
|
|
|
_this.curStoreList = [..._this.curStoreList, ..._list]; |
|
|
|
_this.curStore = _this.curStoreList[0] || {}; |
|
|
|
_this.storeListDisabled = _this.curStoreList.length > 1 ? false : true; |
|
|
|
_this.getGoodsInfo(); // 获取商品信息 |
|
|
|
_this.params.stadium_id = _this.curStore.id; |
|
|
|
_this.getCategoryInfo(); // 获取商品分类 |
|
|
|
} |
|
|
|
else { |
|
|
|
util.hideLoad(); |
|
|
@ -589,7 +557,7 @@ export default { |
|
|
|
_this.curStore = curStoreList[e.detail.value] || {}; |
|
|
|
_this.$nextTick(function() { |
|
|
|
util.showLoad(); |
|
|
|
_this.getGoodsInfo(); // 获取商品信息 |
|
|
|
_this.getCategoryInfo(); // 获取商品分类 |
|
|
|
}); |
|
|
|
}, |
|
|
|
} |
|
|
@ -720,6 +688,7 @@ export default { |
|
|
|
display: flex; |
|
|
|
flex-direction: row; |
|
|
|
padding: 20rpx 0; |
|
|
|
overflow: hidden; |
|
|
|
|
|
|
|
.item-left { |
|
|
|
position: relative; |
|
|
@ -768,11 +737,13 @@ export default { |
|
|
|
|
|
|
|
.item-right-name { |
|
|
|
font-size: 28rpx; |
|
|
|
word-break: break-all; |
|
|
|
} |
|
|
|
.item-right-spec { |
|
|
|
margin: 8rpx 0 14rpx 0; |
|
|
|
font-size: 24rpx; |
|
|
|
color: #9A9A9D; |
|
|
|
word-break: break-all; |
|
|
|
} |
|
|
|
.item-right-special { |
|
|
|
width: 58rpx; |
|
|
@ -791,6 +762,7 @@ export default { |
|
|
|
|
|
|
|
.item-right-price-row { |
|
|
|
color: $orange; |
|
|
|
word-break: break-all; |
|
|
|
|
|
|
|
>view { |
|
|
|
font-size: 36rpx; |
|
|
|