Browse Source

Merge branch 'iteration' of https://git.ouxuan.net/APP/ox_zhiNengZhuShou into iteration

voice
郑锦全 4 years ago
parent
commit
72e393c32c
  1. 12
      src/subpackage/retail/components/hover_cart_list/hover_cart_list.vue
  2. 6
      src/subpackage/retail/js/retail_api.js
  3. 62
      src/subpackage/retail/pages/confirm_goods/confirm_goods.vue
  4. 365
      src/subpackage/retail/pages/index/index.vue
  5. 105
      src/subpackage/retail/pages/search/search.vue

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

@ -10,16 +10,16 @@
<scroll-view class="hover-cart-list-dialog-content" :style="{ height:cartListHeight }" :scroll-top="0" :scroll-y="cartListScroll">
<view class="hover-cart-list-dialog-content-for" :style="{ borderBottom:cartListItemBorderBottom }" v-for="item in cartList" :key="item.id">
<view class="hover-cart-list-dialog-content-col1">
<view>{{ item.name }}</view>
<view>{{ item.spec }}</view>
<view>{{ item.erp_goods_name }}</view>
<view>{{ item.erp_goods_specs }}</view>
</view>
<view class="hover-cart-list-dialog-content-col2">
<input type="digit" :value="item.price" @confirm="cartInputConfirm($event, item.id)" @blur="cartInputConfirm($event, item.id)" />
<input type="digit" :value="item.erp_goods_price" @confirm="cartInputConfirm($event, item.id)" @blur="cartInputConfirm($event, item.id)" />
<view></view>
</view>
<view class="hover-cart-list-dialog-content-col3">
<image mode="aspectFit" src="/static/images/icon/retail/sub.png" @click="cartCountClick('sub', item.id)"></image>
<view>{{ item.count }}</view>
<view>{{ item.erp_goods_sale_total }}</view>
<image mode="aspectFit" src="/static/images/icon/retail/add.png" @click="cartCountClick('add', item.id)"></image>
</view>
</view>
@ -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);

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

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

@ -9,17 +9,17 @@
<scroll-view class="final-cart-list-dialog-content" :scroll-top="0" :scroll-y="cartListScroll" :style="{ height:cartListFinalHeight, paddingBottom:cartListFinalPaddingBottom }">
<view class="final-cart-list-dialog-content-for" :style="{ borderBottom:item.borderBottom }" v-for="item in cartListFinal" :key="item.id">
<view class="final-cart-list-dialog-content-col1">
<view>{{ item.name }}</view>
<view>{{ item.spec }}</view>
<view>{{ item.erp_goods_name }}</view>
<view>{{ item.erp_goods_specs }}</view>
</view>
<view class="final-cart-list-dialog-content-col2">
<input v-if="isEdited" type="digit" :value="item.price" @confirm="cartInputConfirm($event, item.id)" @blur="cartInputConfirm($event, item.id)" />
<view v-if="!isEdited">{{item.price}}</view>
<input v-if="isEdited" type="digit" :value="item.erp_goods_price" @confirm="cartInputConfirm($event, item.id)" @blur="cartInputConfirm($event, item.id)" />
<view v-if="!isEdited">{{item.erp_goods_price}}</view>
<view></view>
</view>
<view class="final-cart-list-dialog-content-col3">
<image v-if="isEdited" mode="aspectFit" src="/static/images/icon/retail/sub.png" @click="cartCountClick('sub', item.id)"></image>
<view>{{ item.count }}</view>
<view>{{ item.erp_goods_sale_total }}</view>
<image v-if="isEdited" mode="aspectFit" src="/static/images/icon/retail/add.png" @click="cartCountClick('add', item.id)"></image>
</view>
</view>
@ -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,18 +94,52 @@
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
});
});
},
//
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;
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);

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

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

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

@ -11,7 +11,7 @@
/>
<image @click="searchClear" mode="aspectFit" src="/static/images/icon/retail/searchClear.png"></image>
</view>
<button hover-class="hover-active" @click="searchTrigger(searchText)">搜索</button>
<button hover-class="hover-active" @click="searchTrigger(searchText, 'search')">搜索</button>
</view>
<view class="history-search">
@ -20,13 +20,17 @@
<image @click="searchHistoryDelete" mode="aspectFit" src="/static/images/icon/retail/historySearchDelete.png"></image>
</view>
<view>
<view v-for="item in historyList" :key="item.id" @click="searchTrigger(item.text)">{{ item.text }}</view>
<view v-for="(item, index) in historyList" :key="index" @click="searchTrigger(item, 'text')">{{ item }}</view>
</view>
</view>
</view>
</template>
<script>
import util from '../../../../utils/util.js';
import retailServer from '../../js/retail_server';
import retailApi from '../../js/retail_api';
export default {
data() {
return {
@ -57,6 +61,12 @@
console.log('用户点击确定');
_this.historyList = [];
uni.removeStorage({
key: 'searchHistoryData',
success: function (res) {
console.log('success');
}
});
}
else if (res.cancel) {
console.log('用户点击取消');
@ -71,7 +81,7 @@
},
//
searchTrigger(text) {
searchTrigger(text, type) {
if (!text) {
uni.showToast({
title: "请输入商品名称!",
@ -81,35 +91,84 @@
return;
}
//
let _this = this;
uni.setStorage({
key: 'searchData',
if (type == "search") {
//
_this.historyList.push(text);
uni.setStorage({
key: 'searchHistoryData',
data: _this.historyList,
success: function() {
console.log('success');
},
fail: function(err) {
console.log(err);
},
});
}
util.showLoad();
retailServer.get({
url: retailApi.assistantListErpGoodsCateAndGoods,
data: {
list: [], //
assistant_key: text
},
success: function() {
console.log('success');
//
uni.navigateBack({
delta: 1
failMsg: '搜索失败!'
}).then(res => {
let mark = false;
for (let i = 0; i < res.list.length; ++i) {
if (res.list[i].goods_list) {
mark = true;
}
}
//
if (!mark) {
uni.showToast({
title: "暂无数据",
icon: "none"
});
},
fail: function(err) {
console.log(err);
},
return;
}
uni.setStorage({
key: "searchData",
data: res.list,
success: function() {
util.hideLoad();
//
uni.navigateBack({
delta: 1
});
},
fail: function(err) {
uni.showToast({
title: "搜索失败",
icon: "none"
});
},
});
});
},
//
getSearchHistory() {
for (let i = 0; i < 20; ++i) {
this.historyList.push({
id: i + 1,
text: "历史" + i
});
}
let _this = this;
uni.getStorage({
key: 'searchHistoryData',
success: function (res) {
console.log(res.data);
for (let i = 0; i < res.data.length; ++i) {
_this.historyList.push(res.data[i]);
}
},
fail: function(err) {
console.log(err);
_this.historyList = [];
},
});
},
}
}

Loading…
Cancel
Save