|
|
@@ -24,7 +24,8 @@ export default {
|
|
|
top_list:'',
|
|
|
filterProductInfo:'',
|
|
|
//当前页面默认使用的单位 0大单位 1小单位
|
|
|
- globalUnitType:0
|
|
|
+ globalUnitType:0,
|
|
|
+ globalItemList:[]
|
|
|
};
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
@@ -240,7 +241,8 @@ export default {
|
|
|
try {
|
|
|
let params = { py: this.py, id:id, shopId:shopId, showAll:showAll }
|
|
|
const { data } = await getGhsProductListV2(params);
|
|
|
- this.productInfo = data;
|
|
|
+ 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)
|
|
|
@@ -968,101 +970,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});
|