Browse Source

零售商品页修整

tags/v1.1.30
张家华 3 years ago
parent
commit
5cf49633a5
  1. 11
      src/subpackage/retail/components/hover_cart_list/hover_cart_list.vue
  2. 3
      src/subpackage/retail/components/store_card_select/store_card_select.vue
  3. 2
      src/subpackage/retail/js/retail_api.js
  4. 27
      src/subpackage/retail/pages/confirm_goods/confirm_goods.vue
  5. 54
      src/subpackage/retail/pages/confirm_order/confirm_order.vue
  6. 382
      src/subpackage/retail/pages/index/index.vue
  7. 65
      src/subpackage/retail/pages/search/search.vue

11
src/subpackage/retail/components/hover_cart_list/hover_cart_list.vue

@ -10,17 +10,17 @@
<scroll-view class="hover-cart-list-dialog-content" :scroll-top="0" :scroll-y="true">
<view class="main-right-list" v-for="item in cartList" :key="item.id">
<view class="item-left">
<image mode="aspectFit" src="/static/images/icon/author_modal.png"></image>
<image mode="aspectFit" :src="item.goods_img"></image>
</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-name">{{ item.goods_name }}</view>
<view class="item-right-spec">{{ item.erp_goods.erp_goods_specs }}</view>
</view>
<view class="item-right-price-count">
<view class="item-right-price-row">
<view><text></text>{{ item.erp_goods_price }}</view>
<view><text></text>{{ item.erp_goods.erp_goods_price }}</view>
</view>
<view class="item-right-count-row">
@ -169,11 +169,13 @@
.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-price-count {
@ -181,6 +183,7 @@
.item-right-price-row {
color: $orange;
word-break: break-all;
>view {
&:first-child {

3
src/subpackage/retail/components/store_card_select/store_card_select.vue

@ -37,7 +37,7 @@
export default {
props: [
"show", "price", "storeId"
"show", "price", "storeId", "brandId"
],
data() {
return {
@ -72,6 +72,7 @@
retailServer.get({
url: retailApi.assistantGetValueCardList,
data: {
brand_id: this.brandId,
stadium_id: this.storeId,
key: this.searchCardValue,
total_amount: this.price

2
src/subpackage/retail/js/retail_api.js

@ -7,6 +7,8 @@ export const RETAIL_API = {
assistantGetAssistantStadiums:`${ORIGIN}/admin/assistant/getAssistantStadiums`, // 店铺列表
assistantListErpGoodsCateAndGoods:`${ORIGIN}/admin/assistant/listErpGoodsCateAndGoods`, // 分类物品列表
assistantGetValueCardList:`${ORIGIN}/admin/assistant/getValueCardList`, // 搜索储蓄卡
getCategoryList:`${ORIGIN}/classifyer/all`, // 分类列表
getGoodsList:`${ORIGIN}/admin/erpRetailGoods/list`, // 商品列表
}
export default RETAIL_API;

27
src/subpackage/retail/pages/confirm_goods/confirm_goods.vue

@ -10,20 +10,20 @@
<scroll-view class="cg-header-content" :scroll-top="0" :scroll-y="true" :style="{ height:cartListFinalHeight, paddingBottom:cartListFinalPaddingBottom }">
<view class="main-list" v-for="item in cartListFinal" :key="item.id">
<view class="item-left">
<image mode="aspectFit" src="/static/images/icon/author_modal.png"></image>
<image mode="aspectFit" :src="item.goods_img"></image>
</view>
<view class="item-right">
<view class="item-right-top">
<view class="item-right-name">{{ item.erp_goods_name }}</view>
<view class="item-right-name">{{ item.goods_name }}</view>
<view class="item-right-spec">
<view>{{ `${item.erp_goods_specs}/${item.erp_goods_specs}/${item.erp_goods_specs}` }}</view>
<view>{{ item.erp_goods.erp_goods_specs }}</view>
<view>x{{ item.count }}</view>
</view>
</view>
<view class="item-right-price-count">
<view class="item-right-price-row">
<view><text></text>{{ item.erp_goods_price }}</view>
<view><text></text>{{ item.erp_goods.erp_goods_price }}</view>
</view>
</view>
</view>
@ -66,31 +66,21 @@
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]));
this.cartListFinal = data.cartListFinal;
this.totalPrice = data.totalPrice;
this.fixMainHeight(); //
this.calcTotalPrice(); //
util.showLoad();
setTimeout(util.hideLoad, 500);
},
methods: {
//
cartConfirm() {
let data = { cartListFinal: this.cartListFinal, curStore: this.curStore };
let data = { cartListFinal: this.cartListFinal, curStore: this.curStore, totalPrice: this.totalPrice };
uni.navigateTo({
url: `/subpackage/retail/pages/confirm_order/confirm_order?data=${encodeURIComponent(JSON.stringify(data))}`
});
},
//
calcTotalPrice() {
let price = 0.0;
for (let i = 0; i < this.cartListFinal.length; ++i)
price += (this.cartListFinal[i].count * this.cartListFinal[i].erp_goods_price);
this.totalPrice = price.toFixed(2);
},
//
fixMainHeight() {
let _this = this;
@ -205,11 +195,13 @@
.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;
@include centerFlex(space-between);
}
}
@ -218,6 +210,7 @@
.item-right-price-row {
color: $orange;
word-break: break-all;
>view {
&:first-child {

54
src/subpackage/retail/pages/confirm_order/confirm_order.vue

@ -42,7 +42,7 @@
</view>
<storeCardSelect
:show="storeCardSelectShow" :price="totalPrice" :storeId="curStore.id"
:show="storeCardSelectShow" :price="totalPrice" :storeId="curStore.id" :brandId="brandInfo.brand.id"
@update:onClose="showOrHideStoreCardSelect" @update:onConfirm="storeCardConfirm"
>
</storeCardSelect>
@ -54,6 +54,7 @@
import tools from '../../js/tools';
import retailServer from '../../js/retail_server';
import retailApi from '../../js/retail_api';
import { mapState } from 'vuex'
import storeCardSelect from '../../components/store_card_select/store_card_select';
@ -82,12 +83,10 @@
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]));
this.cartListFinal = data.cartListFinal;
this.totalPrice = data.totalPrice;
this.fixMainHeight(); //
this.calcTotalPrice(); //
this.createPayWayList(); //
util.showLoad();
setTimeout(util.hideLoad, 500);
@ -95,6 +94,9 @@
onShow() {
this.getPaySuccess(); //
},
computed:{
...mapState([ 'brandInfo',])
},
methods: {
getPaySuccess() {
uni.getStorage({
@ -111,31 +113,27 @@
//
goodsRetail(info) {
let _this = this;
let data = [];
let goods_data = [];
for (let i = 0; i < this.cartListFinal.length; ++i) {
if (this.cartListFinal[i].count) {
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].count,
unit: this.cartListFinal[i].erp_goods_unit,
});
}
goods_data.push({
id: this.cartListFinal[i].erp_goods.erp_goods_cid,
name: this.cartListFinal[i].erp_goods.erp_goods_name,
price: this.cartListFinal[i].erp_goods.erp_goods_price,
nums: this.cartListFinal[i].count,
unit: this.cartListFinal[i].erp_goods.erp_goods_unit,
});
}
let newData = {
store_id: _this.curStore.id,
goods_data: data,
pay_type: info.type,
};
if (info.inputValue) newData["other_pay_type"] = info.inputValue;
if (info.cardNo) newData["card_no"] = info.cardNo;
util.showLoad();
retailServer.post({
url: retailApi.assistantRetail,
data: newData,
data: {
goods_data,
brand_id: _this.brandInfo.brand.id, store_id: _this.curStore.id,
amount: _this.totalPrice, pay_type: info.type,
other_pay_type: info.inputValue,
card_no: info.cardNo
},
isDefaultGet: false,
failMsg: '出库失败!'
}).then(res => {
@ -249,14 +247,6 @@
showOrHideStoreCardSelect(status) {
this.storeCardSelectShow= status;
},
//
calcTotalPrice() {
let price = 0.0;
for (let i = 0; i < this.cartListFinal.length; ++i)
price += (this.cartListFinal[i].count * this.cartListFinal[i].erp_goods_price);
this.totalPrice = price.toFixed(2);
},
//
fixMainHeight() {
let _this = this;

382
src/subpackage/retail/pages/index/index.vue

@ -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;

65
src/subpackage/retail/pages/search/search.vue

@ -32,12 +32,14 @@
searchText: "", //
historyList: [], //
curStore: {}, //
brandInfo: {}, //
}
},
onLoad(option) {
this.getSearchHistory(); //
let data = JSON.parse(decodeURIComponent(option.data));
this.curStore = data.curStore;
this.brandInfo = data.brandInfo;
},
methods: {
//
@ -67,9 +69,9 @@
this.searchText = "";
},
//
searchTrigger(text, type) {
async searchTrigger(text, type) {
if (!text) {
util.showNone("请输入商品名称、sku");
util.showNone("请输入商品名称");
return;
}
@ -86,39 +88,40 @@
}
util.showLoad();
retailServer.get({
url: retailApi.assistantListErpGoodsCateAndGoods,
data: { assistant_key: text, stadium_id: _this.curStore.id },
let res = await retailServer.get({
url: retailApi.getGoodsList,
data: {
brand_id: _this.brandInfo.brand.id,
stadium_id: _this.curStore.id,
type_key: '',
key: text,
page: 1,
page_size: 10
},
isDefaultGet: false,
failMsg: '搜索失败!'
}).then(res => {
if (res.data.code == 0) {
let mark = false;
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)
mark = true;
}
//
if (!mark) {
util.showNone("暂无数据");
return;
}
uni.setStorage({
key: "searchData",
data: res.data.data.list,
success: () => {
util.hideLoad();
uni.navigateBack({ delta: 1 }); //
},
fail: (err) => { util.showNone("搜索失败"); },
});
}).catch(() => {});
if (res && res.data && res.data.data && res.data.data.list) {
if (!res.data.data.list.length) {
util.showNone("暂无数据");
return;
}
else {
util.showNone(res.data.message || '操作失败!');
for (let j = 0; j < res.data.data.list.length; ++j) {
res.data.data.list[j].count = 0; //
res.data.data.list[j].erp_goods = res.data.data.list[j].erp_goods || {};
}
});
uni.setStorage({
key: "searchData",
data: { searchText: text, list: res.data.data.list },
success: () => {
util.hideLoad();
uni.navigateBack({ delta: 1 }); //
},
fail: (err) => { util.showNone("搜索失败"); },
});
} else {
util.showNone(res.data.message || '操作失败!');
}
},
//
getSearchHistory() {

Loading…
Cancel
Save