|
|
@@ -1,4 +1,4 @@
|
|
|
-import { getGoodsDataApi,getProductDataApi,getPxClassDataApi,getGhsProductList } from "@/api/product";
|
|
|
+import { getGoodsDataApi,getProductDataApi,getPxClassDataApi,getGhsProductList,getGhsProductListV2 } from "@/api/product";
|
|
|
import { mapGetters, mapActions } from "vuex";
|
|
|
import { copyObject } from "@/utils/util";
|
|
|
export default {
|
|
|
@@ -24,7 +24,8 @@ export default {
|
|
|
top_list:'',
|
|
|
filterProductInfo:'',
|
|
|
//当前页面默认使用的单位 0大单位 1小单位
|
|
|
- globalUnitType:0
|
|
|
+ globalUnitType:0,
|
|
|
+ globalItemList:[]
|
|
|
};
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
@@ -236,7 +237,31 @@ export default {
|
|
|
this.customData.smallCount = null
|
|
|
}
|
|
|
},
|
|
|
- //采购时请求供货商花材
|
|
|
+ async initGhsDataV2(id,shopId,showAll) {
|
|
|
+ try {
|
|
|
+ let params = { py: this.py, id:id, shopId:shopId, showAll:showAll }
|
|
|
+ const { data } = await getGhsProductListV2(params);
|
|
|
+ this.productInfo = data.classItem||[];
|
|
|
+ this.globalItemList = data.itemList || []
|
|
|
+ if(this.pageType == 'cg' || this.pageType == 'bookCg'){
|
|
|
+ let targetId = this.option.id ? this.option.id : 0
|
|
|
+ let currentInfo = uni.getStorageSync('selectList'+this.pageType+'_ghs_'+targetId)
|
|
|
+ if(!this.$util.isEmpty(currentInfo)){
|
|
|
+ this.setSelectInfoByType({ type: this.pageType, info: currentInfo })
|
|
|
+ }else{
|
|
|
+ //临时解决方案
|
|
|
+ this.resetSelectInfoByType(this.pageType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.classIndex = 0;
|
|
|
+ this.scroll_into_view = 'class_0';
|
|
|
+ this.scrollPushList();
|
|
|
+ } catch (error) {
|
|
|
+ uni.hideLoading()
|
|
|
+ } finally {
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+ },
|
|
|
async initGhsData(id,shopId,showAll) {
|
|
|
//extendInfo调用时的扩展参数,如shopId
|
|
|
try {
|
|
|
@@ -323,18 +348,30 @@ export default {
|
|
|
let node2 = this.top_list[i+1];
|
|
|
if(node2 && top_page >= node1 && top_page < node2){
|
|
|
this.classIndex = i;
|
|
|
- this.filterProductInfo[this.classIndex].isActive = true;
|
|
|
- this.filterProductInfo[this.classIndex+1].isActive = true;
|
|
|
+ if(this.filterProductInfo[this.classIndex]){
|
|
|
+ this.filterProductInfo[this.classIndex].isActive = true;
|
|
|
+ }
|
|
|
+ if(this.filterProductInfo[this.classIndex+1]){
|
|
|
+ this.filterProductInfo[this.classIndex+1].isActive = true;
|
|
|
+ }
|
|
|
if(this.filterProductInfo[this.classIndex+1].child.length<5){
|
|
|
- this.filterProductInfo[this.classIndex+2].isActive = true;
|
|
|
+ if(this.filterProductInfo[this.classIndex+2]){
|
|
|
+ this.filterProductInfo[this.classIndex+2].isActive = true;
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
}else if(node2 && top_page === node2){
|
|
|
this.classIndex = i + 1;
|
|
|
- this.filterProductInfo[this.classIndex].isActive = true;
|
|
|
- this.filterProductInfo[this.classIndex+1].isActive = true;
|
|
|
+ if(this.filterProductInfo[this.classIndex]){
|
|
|
+ this.filterProductInfo[this.classIndex].isActive = true;
|
|
|
+ }
|
|
|
+ if(this.filterProductInfo[this.classIndex+1]){
|
|
|
+ this.filterProductInfo[this.classIndex+1].isActive = true;
|
|
|
+ }
|
|
|
if(this.filterProductInfo[this.classIndex+1].child.length<5){
|
|
|
- this.filterProductInfo[this.classIndex+2].isActive = true;
|
|
|
+ if(this.filterProductInfo[this.classIndex+2]){
|
|
|
+ this.filterProductInfo[this.classIndex+2].isActive = true;
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
@@ -611,8 +648,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
-
|
|
|
- console.log('this.selectList','减少花材之后:',this.selectList)
|
|
|
//记忆已经选择的花材
|
|
|
this.rememberProduct()
|
|
|
},
|
|
|
@@ -643,10 +678,7 @@ export default {
|
|
|
},
|
|
|
//多风格-添加商品
|
|
|
addGoodsEvent(item) {
|
|
|
- console.log(item,'itemitem')
|
|
|
const list = this.selectList;
|
|
|
- //过滤空数据
|
|
|
- // if(item.bigCount==0||!item.bigCount){return}
|
|
|
let has = false;
|
|
|
for (let index = 0; index < list.length; index++) {
|
|
|
const element = list[index];
|
|
|
@@ -868,7 +900,6 @@ export default {
|
|
|
const query = uni.createSelectorQuery().in(this); //获得实力
|
|
|
//获取多个节点方式
|
|
|
query.selectAll(".suitSelectAll").boundingClientRect(data=>{
|
|
|
- // console.log(data); //得到class类名为 selectAll的数组集合
|
|
|
this.suit_top_list = data.map(item=>{
|
|
|
return Math.ceil(item.top);
|
|
|
});
|
|
|
@@ -878,20 +909,27 @@ export default {
|
|
|
suit_async_detail_msg(options){
|
|
|
//options 为滚动信息。 options.detail.scrollTop 值为相对于scroll-view。
|
|
|
let top_page = options.detail.scrollTop + this.suit_top_list[0];
|
|
|
-
|
|
|
for(let i = 0;i < this.suit_top_list.length; i++){
|
|
|
let node1 = this.suit_top_list[i];
|
|
|
let node2 = this.suit_top_list[i+1];
|
|
|
if(node2 && top_page >= node1 && top_page < node2){
|
|
|
this.suitClassIndex = i;
|
|
|
- this.suitFilterProductInfo[this.suitClassIndex].isActive = true;
|
|
|
- this.suitFilterProductInfo[this.suitClassIndex+1].isActive = true;
|
|
|
+ if(this.suitFilterProductInfo[this.suitClassIndex]){
|
|
|
+ this.suitFilterProductInfo[this.suitClassIndex].isActive = true;
|
|
|
+ }
|
|
|
+ if(this.suitFilterProductInfo[this.suitClassIndex+1]){
|
|
|
+ this.suitFilterProductInfo[this.suitClassIndex+1].isActive = true;
|
|
|
+ }
|
|
|
// this.suitScrollPushList();
|
|
|
break;
|
|
|
}else if(node2 && top_page === node2){
|
|
|
this.suitClassIndex = i + 1;
|
|
|
- this.suitFilterProductInfo[this.suitClassIndex].isActive = true;
|
|
|
- this.suitFilterProductInfo[this.suitClassIndex+1].isActive = true;
|
|
|
+ if(this.suitFilterProductInfo[this.suitClassIndex]){
|
|
|
+ this.suitFilterProductInfo[this.suitClassIndex].isActive = true;
|
|
|
+ }
|
|
|
+ if(this.suitFilterProductInfo[this.suitClassIndex+1]){
|
|
|
+ this.suitFilterProductInfo[this.suitClassIndex+1].isActive = true;
|
|
|
+ }
|
|
|
// this.suitScrollPushList();
|
|
|
break;
|
|
|
}
|
|
|
@@ -899,7 +937,9 @@ export default {
|
|
|
},
|
|
|
suit_scroll_bottom(){
|
|
|
this.suitClassIndex = this.suitFilterProductInfo.length-1
|
|
|
- this.suitFilterProductInfo[this.suitClassIndex].isActive = true;
|
|
|
+ if(this.suitFilterProductInfo[this.suitClassIndex]){
|
|
|
+ this.suitFilterProductInfo[this.suitClassIndex].isActive = true;
|
|
|
+ }
|
|
|
// this.suitScrollPushList();
|
|
|
},
|
|
|
//搜索对应花材
|
|
|
@@ -945,101 +985,112 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
searchFn(limit=1) {
|
|
|
- let list = copyObject(this.productInfo);
|
|
|
- if(!this.$util.isEmpty(this.py)){
|
|
|
-
|
|
|
- if(limit == 1){
|
|
|
- //大于等于2个字符才开始搜索 shish 20210622
|
|
|
- if(this.py.length <=1){
|
|
|
- return
|
|
|
- }
|
|
|
- //红色粉色紫色绿色白色花材太多,搜索时会卡住,所以设置输入第三个字母时才搜索
|
|
|
- if(this.py.toLocaleLowerCase().indexOf('fs') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('粉色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.toLocaleLowerCase().indexOf('hs') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('红色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('黄色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.toLocaleLowerCase().indexOf('zs') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('紫色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.toLocaleLowerCase().indexOf('ls') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('绿色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.toLocaleLowerCase().indexOf('bs') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('白色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.toLocaleLowerCase().indexOf('cs') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('橙色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.py.indexOf('银色') == 0 && this.py.length <= 2){
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- let commonChildList = [];
|
|
|
- list.forEach(ele => {
|
|
|
- if (!this.$util.isEmpty(ele.child)) {
|
|
|
- ele.child.forEach(obj => {
|
|
|
- let hasName = obj.itemName && obj.itemName.indexOf(this.py) >= 0;
|
|
|
- let hasPy = false
|
|
|
- if(hasName == false){
|
|
|
- let elePy = (obj.py && obj.py.toLocaleUpperCase()) || "";
|
|
|
- hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0;
|
|
|
- }
|
|
|
- if (hasName || hasPy) {
|
|
|
- if(this.$util.isEmpty(commonChildList)){
|
|
|
- commonChildList = [...commonChildList,{classId: ele.classId, className: ele.className,isActive:true,child:[obj]}];
|
|
|
- }else{
|
|
|
- commonChildList.forEach(res => {
|
|
|
- if(res.classId==ele.classId){
|
|
|
- res.child.push(obj)
|
|
|
- }else{
|
|
|
- commonChildList.push({classId: ele.classId, className: ele.className,isActive:true,child:[obj]});
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- })
|
|
|
- list = this.$util.unique(commonChildList)
|
|
|
- this.filterProductInfo = list;
|
|
|
- this.classIndex = 0;
|
|
|
- this.scroll_into_view = 'class_'+0;
|
|
|
- }else{
|
|
|
+ let list = this.globalItemList
|
|
|
+ if(this.$util.isEmpty(this.py)){
|
|
|
this.filterProductInfo = '';
|
|
|
this.classIndex = 0;
|
|
|
this.scroll_into_view = 'class_'+0;
|
|
|
this.scrollPushList();
|
|
|
}
|
|
|
- },
|
|
|
-
|
|
|
+ var reg = /^[0-9a-zA-Z]*$/g
|
|
|
+ let notChinese = reg.test(this.py) == true ? true : false
|
|
|
+ if(limit == 1){
|
|
|
+ //大于等于2个字符才开始搜索 shish 20210622
|
|
|
+ if(this.py.length <=1){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //红色粉色紫色绿色白色花材太多,搜索时会卡住,所以设置输入第三个字母时才搜索
|
|
|
+ if(this.py.toLocaleLowerCase().indexOf('fs') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.indexOf('粉色') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.toLocaleLowerCase().indexOf('hs') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.indexOf('红色') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.indexOf('黄色') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.toLocaleLowerCase().indexOf('zs') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.indexOf('紫色') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.toLocaleLowerCase().indexOf('ls') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.indexOf('绿色') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.toLocaleLowerCase().indexOf('bs') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.indexOf('白色') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.toLocaleLowerCase().indexOf('cs') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.indexOf('橙色') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.py.indexOf('银色') == 0 && this.py.length <= 2){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 请求课程数据
|
|
|
- */
|
|
|
+ //将已选的花材按productId键名组合
|
|
|
+ let selectListData = []
|
|
|
+ if(!this.$util.isEmpty(this.selectList)){
|
|
|
+ this.selectList.forEach((i)=>{
|
|
|
+ selectListData[i.id] = i
|
|
|
+ })
|
|
|
+ }
|
|
|
+ let filterItemData = [];
|
|
|
+ list.forEach(currentItem => {
|
|
|
+ //组合已记忆已选择的花材
|
|
|
+ let currentPId = currentItem.id
|
|
|
+ let selectProduct = selectListData[currentPId] || []
|
|
|
+ if(!this.$util.isEmpty(selectProduct)){
|
|
|
+ currentItem.bigCount = selectProduct.bigCount || 0
|
|
|
+ currentItem.userPrice = selectProduct.userPrice || 0
|
|
|
+ currentItem.smallCount = selectProduct.smallCount || 0
|
|
|
+ }else{
|
|
|
+ currentItem.bigCount = 0
|
|
|
+ currentItem.userPrice = 0
|
|
|
+ currentItem.smallCount = 0
|
|
|
+ }
|
|
|
+ let has = false
|
|
|
+ if (notChinese){
|
|
|
+ let elePy = (currentItem.py && currentItem.py.toLocaleUpperCase()) || "";
|
|
|
+ has = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0 ? true : false
|
|
|
+ }else{
|
|
|
+ has = currentItem.name && currentItem.name.indexOf(this.py) >= 0 ? true : false
|
|
|
+ }
|
|
|
+ if (has) {
|
|
|
+ if(this.$util.isEmpty(filterItemData)){
|
|
|
+ filterItemData = [{classId: currentItem.classId, className: currentItem.className,isActive:true,child:[currentItem]}]
|
|
|
+ }else{
|
|
|
+ filterItemData.forEach(res => {
|
|
|
+ if(res.classId==currentItem.classId){
|
|
|
+ res.child.push(currentItem)
|
|
|
+ }else{
|
|
|
+ filterItemData.push({classId: currentItem.classId, className: currentItem.className,isActive:true,child:[currentItem]})
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ let searchList = this.$util.unique(filterItemData)
|
|
|
+ this.filterProductInfo = searchList;
|
|
|
+ this.classIndex = 0;
|
|
|
+ this.scroll_into_view = 'class_'+0;
|
|
|
+ },
|
|
|
async initPxClassData() {
|
|
|
try {
|
|
|
const { data } = await getPxClassDataApi({pageSize:50});
|