云迈博客

您现在的位置是:首页 > 前端技术 > 微信小程序 > 正文

微信小程序

珊福车俱小程序之钣金喷漆功能实现(二)

徐颖2020-09-16微信小程序495
本章主要讲钣金喷漆点击事件先展示一下json数据,数据太多,以数组第一条为例{"id":"16","name":"车头车尾","parent_id":"0",

本章主要讲钣金喷漆点击事件

先展示一下json数据,数据太多,以数组第一条为例

 {
    "id":"16",
    "name":"车头车尾",
    "parent_id":"0",
    "price":"0.00",
    "showtitle":null,
    "children":[
        {
            "id":"10",
            "name":"前保险杠",
            "parent_id":"16",
            "price":"200.00",
            "showtitle":null,
            "children":[
                {
                    "id":"11",
                    "name":"喷漆",
                    "parent_id":"10",
                    "price":"100.00",
                    "showtitle":null,
                    "children":[
                        {
                            "id":"91",
                            "name":"标准漆",
                            "parent_id":"11",
                            "price":"100.00",
                            "showtitle":"标准漆",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"92",
                            "name":"特殊漆",
                            "parent_id":"11",
                            "price":"200.00",
                            "showtitle":"特殊漆",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        }
                    ],
                    "view_show":0,
                    "img_show":0
                },
                {
                    "id":"19",
                    "name":"钣金",
                    "parent_id":"10",
                    "price":"200.00",
                    "showtitle":null,
                    "children":[
                        {
                            "id":"86",
                            "name":"轻微修复5CM*5CM(普通钣金)",
                            "parent_id":"19",
                            "price":"200.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"87",
                            "name":"轻度修复10CM*10CM(普通钣金)",
                            "parent_id":"19",
                            "price":"300.00",
                            "showtitle":"10CM*10CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"95",
                            "name":"中度修复20CM*20CM(普通钣金)",
                            "parent_id":"19",
                            "price":"200.00",
                            "showtitle":"20CM*20CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"94",
                            "name":"重度修复30CM*30CM(普通钣金)",
                            "parent_id":"19",
                            "price":"200.00",
                            "showtitle":"30CM*30CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"99",
                            "name":"轻微修复5CM*5CM(铝合金车身)",
                            "parent_id":"19",
                            "price":"100.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"98",
                            "name":"轻度修复5CM*5CM(铝合金车身)",
                            "parent_id":"19",
                            "price":"200.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"97",
                            "name":"中度修复5CM*5CM(铝合金车身)",
                            "parent_id":"19",
                            "price":"100.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"96",
                            "name":"重度修复5CM*5CM(铝合金车身)",
                            "parent_id":"19",
                            "price":"300.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        }
                    ],
                    "view_show":0,
                    "img_show":0
                }
            ],
            "class_name":"img_0_0",
            "img":"/images/car/img_0_0.png",
            "show":0
        },
        {
            "id":"20",
            "name":"后保险杠",
            "parent_id":"16",
            "price":"0.00",
            "showtitle":null,
            "children":[
                {
                    "id":"22",
                    "name":"喷漆",
                    "parent_id":"20",
                    "price":"100.00",
                    "showtitle":"",
                    "children":[
                        {
                            "id":"130",
                            "name":"标准漆",
                            "parent_id":"22",
                            "price":"100.00",
                            "showtitle":"标准漆",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"131",
                            "name":"特殊漆",
                            "parent_id":"22",
                            "price":"200.00",
                            "showtitle":"特殊漆",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        }
                    ],
                    "view_show":0,
                    "img_show":0
                },
                {
                    "id":"21",
                    "name":"钣金",
                    "parent_id":"20",
                    "price":"200.00",
                    "showtitle":null,
                    "children":[
                        {
                            "id":"132",
                            "name":"轻微修复5CM*5CM(普通钣金)",
                            "parent_id":"21",
                            "price":"200.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"133",
                            "name":"轻度修复10CM*10CM(普通钣金)",
                            "parent_id":"21",
                            "price":"300.00",
                            "showtitle":"10CM*10CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"135",
                            "name":"中度修复20CM*20CM(普通钣金)",
                            "parent_id":"21",
                            "price":"200.00",
                            "showtitle":"20CM*20CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"134",
                            "name":"重度修复30CM*30CM(普通钣金)",
                            "parent_id":"21",
                            "price":"200.00",
                            "showtitle":"30CM*30CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"139",
                            "name":"轻微修复5CM*5CM(铝合金车身)",
                            "parent_id":"21",
                            "price":"100.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"138",
                            "name":"轻度修复5CM*5CM(铝合金车身)",
                            "parent_id":"21",
                            "price":"200.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"137",
                            "name":"中度修复5CM*5CM(铝合金车身)",
                            "parent_id":"21",
                            "price":"100.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"136",
                            "name":"重度修复5CM*5CM(铝合金车身)",
                            "parent_id":"21",
                            "price":"300.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        }
                    ],
                    "view_show":0,
                    "img_show":0
                }
            ],
            "class_name":"img_0_1",
            "img":"/images/car/img_0_1.png",
            "show":0
        },
        {
            "id":"23",
            "name":"前车盖",
            "parent_id":"16",
            "price":"0.00",
            "showtitle":null,
            "children":[
                {
                    "id":"25",
                    "name":"喷漆",
                    "parent_id":"23",
                    "price":"100.00",
                    "showtitle":"",
                    "children":[
                        {
                            "id":"140",
                            "name":"标准漆",
                            "parent_id":"25",
                            "price":"100.00",
                            "showtitle":"标准漆",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"141",
                            "name":"特殊漆",
                            "parent_id":"25",
                            "price":"200.00",
                            "showtitle":"特殊漆",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        }
                    ],
                    "view_show":0,
                    "img_show":0
                },
                {
                    "id":"24",
                    "name":"钣金",
                    "parent_id":"23",
                    "price":"200.00",
                    "showtitle":null,
                    "children":[
                        {
                            "id":"142",
                            "name":"轻微修复5CM*5CM(普通钣金)",
                            "parent_id":"24",
                            "price":"200.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"143",
                            "name":"轻度修复10CM*10CM(普通钣金)",
                            "parent_id":"24",
                            "price":"300.00",
                            "showtitle":"10CM*10CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"145",
                            "name":"中度修复20CM*20CM(普通钣金)",
                            "parent_id":"24",
                            "price":"200.00",
                            "showtitle":"20CM*20CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"144",
                            "name":"重度修复30CM*30CM(普通钣金)",
                            "parent_id":"24",
                            "price":"200.00",
                            "showtitle":"30CM*30CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"149",
                            "name":"轻微修复5CM*5CM(铝合金车身)",
                            "parent_id":"24",
                            "price":"100.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"148",
                            "name":"轻度修复5CM*5CM(铝合金车身)",
                            "parent_id":"24",
                            "price":"200.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"147",
                            "name":"中度修复5CM*5CM(铝合金车身)",
                            "parent_id":"24",
                            "price":"100.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"146",
                            "name":"重度修复5CM*5CM(铝合金车身)",
                            "parent_id":"24",
                            "price":"300.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        }
                    ],
                    "view_show":0,
                    "img_show":0
                }
            ],
            "class_name":"img_0_2",
            "img":"/images/car/img_0_2.png",
            "show":0
        },
        {
            "id":"26",
            "name":"后车盖",
            "parent_id":"16",
            "price":"0.00",
            "showtitle":null,
            "children":[
                {
                    "id":"28",
                    "name":"喷漆",
                    "parent_id":"26",
                    "price":"100.00",
                    "showtitle":"",
                    "children":[
                        {
                            "id":"150",
                            "name":"标准漆",
                            "parent_id":"28",
                            "price":"100.00",
                            "showtitle":"标准漆",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"151",
                            "name":"特殊漆",
                            "parent_id":"28",
                            "price":"200.00",
                            "showtitle":"特殊漆",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        }
                    ],
                    "view_show":0,
                    "img_show":0
                },
                {
                    "id":"27",
                    "name":"钣金",
                    "parent_id":"26",
                    "price":"200.00",
                    "showtitle":null,
                    "children":[
                        {
                            "id":"152",
                            "name":"轻微修复5CM*5CM(普通钣金)",
                            "parent_id":"27",
                            "price":"200.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"153",
                            "name":"轻度修复10CM*10CM(普通钣金)",
                            "parent_id":"27",
                            "price":"300.00",
                            "showtitle":"10CM*10CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"155",
                            "name":"中度修复20CM*20CM(普通钣金)",
                            "parent_id":"27",
                            "price":"200.00",
                            "showtitle":"20CM*20CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"154",
                            "name":"重度修复30CM*30CM(普通钣金)",
                            "parent_id":"27",
                            "price":"200.00",
                            "showtitle":"30CM*30CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"159",
                            "name":"轻微修复5CM*5CM(铝合金车身)",
                            "parent_id":"27",
                            "price":"100.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"158",
                            "name":"轻度修复5CM*5CM(铝合金车身)",
                            "parent_id":"27",
                            "price":"200.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"157",
                            "name":"中度修复5CM*5CM(铝合金车身)",
                            "parent_id":"27",
                            "price":"100.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"156",
                            "name":"重度修复5CM*5CM(铝合金车身)",
                            "parent_id":"27",
                            "price":"300.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        }
                    ],
                    "view_show":0,
                    "img_show":0
                }
            ],
            "class_name":"img_0_3",
            "img":"/images/car/img_0_3.png",
            "show":0
        },
        {
            "id":"29",
            "name":"尾翼",
            "parent_id":"16",
            "price":"0.00",
            "showtitle":null,
            "children":[
                {
                    "id":"31",
                    "name":"喷漆",
                    "parent_id":"29",
                    "price":"100.00",
                    "showtitle":"",
                    "children":[
                        {
                            "id":"160",
                            "name":"标准漆",
                            "parent_id":"31",
                            "price":"100.00",
                            "showtitle":"标准漆",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"161",
                            "name":"特殊漆",
                            "parent_id":"31",
                            "price":"200.00",
                            "showtitle":"特殊漆",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        }
                    ],
                    "view_show":0,
                    "img_show":0
                },
                {
                    "id":"30",
                    "name":"钣金",
                    "parent_id":"29",
                    "price":"200.00",
                    "showtitle":null,
                    "children":[
                        {
                            "id":"162",
                            "name":"轻微修复5CM*5CM(普通钣金)",
                            "parent_id":"30",
                            "price":"200.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"163",
                            "name":"轻度修复10CM*10CM(普通钣金)",
                            "parent_id":"30",
                            "price":"300.00",
                            "showtitle":"10CM*10CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"165",
                            "name":"中度修复20CM*20CM(普通钣金)",
                            "parent_id":"30",
                            "price":"200.00",
                            "showtitle":"20CM*20CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"164",
                            "name":"重度修复30CM*30CM(普通钣金)",
                            "parent_id":"30",
                            "price":"200.00",
                            "showtitle":"30CM*30CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"169",
                            "name":"轻微修复5CM*5CM(铝合金车身)",
                            "parent_id":"30",
                            "price":"100.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"168",
                            "name":"轻度修复5CM*5CM(铝合金车身)",
                            "parent_id":"30",
                            "price":"200.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"167",
                            "name":"中度修复5CM*5CM(铝合金车身)",
                            "parent_id":"30",
                            "price":"100.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        },
                        {
                            "id":"166",
                            "name":"重度修复5CM*5CM(铝合金车身)",
                            "parent_id":"30",
                            "price":"300.00",
                            "showtitle":"5CM*5CM",
                            "children":[

                            ],
                            "view_show":0,
                            "img_show":0
                        }
                    ],
                    "view_show":0,
                    "img_show":0
                }
            ],
            "class_name":"img_0_4",
            "img":"/images/car/img_0_4.png",
            "show":0
        }
    ],
    "num":0,
    "tab_id":0
},

注:点击钣金或者喷漆,弹出选择框,选择相应型号的钣金或者喷漆,然后对所选择的车辆相应部位设置阴影。
项目整体数据有 车头车尾、左侧车身、右侧车身、其他四大部分,对应车辆每个部位,当点击的是车头车尾,正常操作。当点击的是左侧或者右侧时,需要额外判断。如:点击左侧前叶子板,需要判断右侧前叶子板是否被选择,如果左右同时被选择,则展示的是左右阴影图片(与单独的左侧阴影图片或者右侧阴影图片不一)。
当点击的是其他部分中的整车喷漆时,需要单独操作,把其他所有被选择清空,只展示整车喷漆以及,其他种类被选择总数(1)。

例:前保险杠:其之下钣金和喷漆同时控制阴影的展示,当二者皆无选择,则不展示,否则示。

以下是点击事件,对每个种类进行单独判断。
//js
//点击 第一步
fn_penqi:function(e){
console.log(e);
let tabs = that.data.tabs;
let index = e.currentTarget.dataset.index; //一级
let index1 = e.currentTarget.dataset.index1; //二级
let index2 = e.currentTarget.dataset.index2; //三级
let view_show = e.currentTarget.dataset.view_show; //view—show
let sm = tabs[index].children[index1].children[index2].children;
if(sm.length>0 && view_show==0){
that.setData({
level_1:index,
level_2:index1,
level_3:index2,
e:e
})
that.setData({
code_s:true
})
}else{
that.get_e(e);
}
},
banjin_xuanze(e){
let id = e.currentTarget.dataset.id;
let level_1 = that.data.level_1;
let level_2 = that.data.level_2;
let level_3 = that.data.level_3;
let xx = that.data.e;
that.setData({
[“tabs[“+level_1+”].children[“+level_2+”].children[“+level_3+”].children[“+id+”].view_show”]:1,
code_s:false,
level_4:id
})
that.get_e(xx);
},
get_e(e){
// console.log(“eeeeeee”,e);
var tabs = that.data.tabs;
let lr_list = that.data.lr_list;
var zc_location_1,zc_location_2;
for(var i=0;i<tabs.length;i++){
if(tabs[i].name==”其他”){
for(var j=0;j<tabs[i].children.length;j++){
if(tabs[i].children[j].name==”整车喷漆”){
zc_location_1=i;
zc_location_2=j;
}
}
}
}
let index = e.currentTarget.dataset.index; //一级
let index1 = e.currentTarget.dataset.index1; //二级
let index2 = e.currentTarget.dataset.index2; //三级
let img_show = e.currentTarget.dataset.img_show; //img-show
let view_show = e.currentTarget.dataset.view_show; //view—show
let zhengche_show = tabs[zc_location_1].children[zc_location_2].children[0].view_show; //整车喷漆
if(index==0){
let num = tabs[index].num;
if(view_show==0){
num = num+1;
}else{
num=num-1;
}
if(zhengche_show==1){
that.setData({
[“tabs[“+zc_location_1+”].children[“+zc_location_2+”].children[0].view_show”]:0,
[“tabs[“+zc_location_1+”].children[“+zc_location_2+”].children[0].img_show”]:0,
[“tabs[“+zc_location_1+”].children[“+zc_location_2+”].show”]:0,
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].view_show”]:view_show==1? 0:1,
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].img_show”]:img_show==1? 0:1,
[“tabs[“+index+”].children[“+index1+”].show”]:1,
[“tabs[“+index+”].num”]:num,
[“tabs[“+zc_location_1+”].num”]:0
})
}else{
console.log(“一二三级”,index,index1,index2);
that.setData({
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].view_show”]:view_show==1? 0:1,
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].img_show”]:img_show==1? 0:1,
[“tabs[“+index+”].num”]:num,
})
if(tabs[index].children[index1].children[index2].view_show==1){
}else{
for(var i=0;i<tabs[index].children[index1].children[index2].children.length;i++){
if(tabs[index].children[index1].children[index2].children[i].view_show==1){
that.setData({
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].children[“+i+”].view_show”]:0,
})
}
}
}
let xx;
for(var i=0;i<tabs[index].children[index1].children.length;i++){
if(tabs[index].children[index1].children[i].view_show==1){
xx=1;
break;
}else{
xx=0;
}
}
if(xx==1){
that.setData({
[“tabs[“+index+”].children[“+index1+”].show”]:1
})
}else{
that.setData({
[“tabs[“+index+”].children[“+index1+”].show”]:0
})
}
console.log(that.data.tabs)
}
}else if(index==1){
let num = tabs[index].num;
if(view_show==0){
num = num+1;
}else{
num=num-1;
}
if(zhengche_show==1){
that.setData({
[“tabs[“+zc_location_1+”].children[“+zc_location_2+”].children[0].view_show”]:0,
[“tabs[“+zc_location_1+”].children[“+zc_location_2+”].children[0].img_show”]:0,
[“tabs[“+zc_location_1+”].children[“+zc_location_2+”].show”]:0,
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].view_show”]:view_show==1? 0:1,
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].img_show”]:img_show==1? 0:1,
[“tabs[“+index+”].children[“+index1+”].show”]:1,
[“tabs[“+index+”].num”]:num,
[“tabs[“+zc_location_1+”].num”]:0
})
}else{
that.setData({
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].view_show”]:view_show==1? 0:1,
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].img_show”]:img_show==1? 0:1,
[“tabs[“+index+”].num”]:num,
})
let xx,yy;
for(var i=0;i<tabs[index].children[index1].children.length;i++){
if(tabs[index].children[index1].children[i].view_show==1){
xx=1;
break;
}else{
xx=0;
}
}
for(var i=0;i<tabs[2].children[index1].children.length;i++){
if(tabs[2].children[index1].children[i].view_show==1){
yy=1;
break;
}else{
yy=0;
}
}
// console.log(“xxyy”,xx,yy);
if(xx==1 && yy==1){
console.log(“同时等于1”);
that.setData({
[“lr_list[“+index1+”].show”]:1,
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].view_show”]:view_show==1? 0:1,
[“tabs[“+index+”].children[“+index1+”].show”]:0,
[“tabs[2].children[“+index1+”].children[“+index2+”].img_show”]:0,
[“tabs[2].children[“+index1+”].show”]:0,
})
}else if(xx==0 && yy==1){
that.setData({
[“lr_list[“+index1+”].show”]:0,
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].view_show”]:view_show==1? 0:1,
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].img_show”]:0,
[“tabs[“+index+”].children[“+index1+”].show”]:0,
[“tabs[2].children[“+index1+”].show”]:yy==0? 0:1,
[“tabs[2].children[“+index1+”].children[“+index2+”].img_show”]:yy==0? 0:1,
})
}else{
that.setData({
[“lr_list[“+index1+”].show”]:0,
[“tabs[“+index+”].children[“+index1+”].children[“+index2+”].view_show”]:view_show==1? 0:1,
[“tabs[“+index+”].children[“+index1+”].show”]:img_show==1? 0:1,
[“tabs[2].children[“+index1+”].show”]:yy==0? 0:1,
[“tabs[2].children[“+index1+”].children[“+index2+”].img_show”]:yy==0? 0:1,
})
}

    //钣金选择判断
    if(tabs[index].children[index1].children[index2].view_show==1){

    }else{
      for(var i=0;i<tabs[index].children[index1].children[index2].children.length;i++){
        if(tabs[index].children[index1].children[index2].children[i].view_show==1){
          that.setData({
            ["tabs["+index+"].children["+index1+"].children["+index2+"].children["+i+"].view_show"]:0,
          })
        }
      }

    }
  }
}else if(index==2){
  let num = tabs[index].num;
  if(view_show==0){
    num = num+1;
  }else{
    num=num-1;
  }
  if(zhengche_show==1){
    that.setData({
      ["tabs["+zc_location_1+"].children["+zc_location_2+"].children[0].view_show"]:0,
      ["tabs["+zc_location_1+"].children["+zc_location_2+"].children[0].img_show"]:0,
      ["tabs["+zc_location_1+"].children["+zc_location_2+"].show"]:0,
      ["tabs["+index+"].children["+index1+"].children["+index2+"].view_show"]:view_show==1? 0:1,
      ["tabs["+index+"].children["+index1+"].children["+index2+"].img_show"]:img_show==1? 0:1,
      ["tabs["+index+"].children["+index1+"].show"]:1,
      ["tabs["+index+"].num"]:num,
      ["tabs["+zc_location_1+"].num"]:0
    })
  }else{
    that.setData({
      ["tabs["+index+"].children["+index1+"].children["+index2+"].view_show"]:view_show==1? 0:1,
      ["tabs["+index+"].children["+index1+"].children["+index2+"].img_show"]:img_show==1? 0:1,
      ["tabs["+index+"].num"]:num,
    })
    let xx,yy;
    for(var i=0;i<tabs[index].children[index1].children.length;i++){
      if(tabs[index].children[index1].children[i].view_show==1){
        xx=1;
        break;
      }else{
        xx=0;
      }
    }
    for(var i=0;i<tabs[1].children[index1].children.length;i++){
      if(tabs[1].children[index1].children[i].view_show==1){
        yy=1;
        break;
      }else{
        yy=0;
      }
    }
    console.log("xxyy",xx,yy)
    if(xx==1 && yy==1){
      console.log("同时等于1");
      that.setData({
        ["lr_list["+index1+"].show"]:1,
        ["tabs["+index+"].children["+index1+"].children["+index2+"].view_show"]:view_show==1? 0:1,
        ["tabs["+index+"].children["+index1+"].show"]:0,
        ["tabs[1].children["+index1+"].children["+index2+"].img_show"]:0,
        ["tabs[1].children["+index1+"].show"]:0,
      })
    }else if(xx==0 && yy==1){
      that.setData({
        ["lr_list["+index1+"].show"]:0,
        ["tabs["+index+"].children["+index1+"].children["+index2+"].view_show"]:view_show==1? 0:1,
        ["tabs["+index+"].children["+index1+"].children["+index2+"].img_show"]:0,
        ["tabs["+index+"].children["+index1+"].show"]:0,
        ["tabs[1].children["+index1+"].show"]:yy==0? 0:1,
        ["tabs[1].children["+index1+"].children["+index2+"].img_show"]:yy==0? 0:1,
      })
    }else{
      that.setData({
        ["lr_list["+index1+"].show"]:0,
        ["tabs["+index+"].children["+index1+"].children["+index2+"].view_show"]:view_show==1? 0:1,
        ["tabs["+index+"].children["+index1+"].show"]:img_show==1? 0:1,
        ["tabs[1].children["+index1+"].show"]:yy==0? 0:1,
        ["tabs[1].children["+index1+"].children["+index2+"].img_show"]:yy==0? 0:1,
      })
    }
    //钣金选择判断
    if(tabs[index].children[index1].children[index2].view_show==1){
    }else{
      for(var i=0;i<tabs[index].children[index1].children[index2].children.length;i++){
        if(tabs[index].children[index1].children[index2].children[i].view_show==1){
          that.setData({
            ["tabs["+index+"].children["+index1+"].children["+index2+"].children["+i+"].view_show"]:0,
          })
        }
      }

    }
  }
}else if(index==3){
  let num = tabs[index].num;
  if(view_show==0){
    num = num+1;
  }else{
    num=num-1;
  }
  if(index1==0){
    if(zhengche_show==1){
      let num_1 = num -1;
      that.setData({
        ["tabs["+zc_location_1+"].children["+zc_location_2+"].children[0].view_show"]:0,
        ["tabs["+zc_location_1+"].children["+zc_location_2+"].children[0].img_show"]:0,
        ["tabs["+zc_location_1+"].children["+zc_location_2+"].show"]:0,
        ["tabs["+index+"].children["+index1+"].children["+index2+"].view_show"]:view_show==1? 0:1,
        ["tabs["+index+"].children["+index1+"].children["+index2+"].img_show"]:img_show==1? 0:1,
        ["tabs["+index+"].children["+index1+"].show"]:1,
        ["tabs["+index+"].num"]:num_1,
      })
    }else{
      that.setData({
        ["tabs["+index+"].children["+index1+"].children["+index2+"].view_show"]:view_show==1? 0:1,
        ["tabs["+index+"].children["+index1+"].children["+index2+"].img_show"]:img_show==1? 0:1,
        ["tabs["+index+"].num"]:num,
      })
      let xx;
      for(var i=0;i<tabs[index].children[index1].children.length;i++){
        if(tabs[index].children[index1].children[i].view_show==1){
          xx=1;
          break;
        }else{
          xx=0;
        }
      }
      if(xx==1){
        that.setData({
          ["tabs["+index+"].children["+index1+"].show"]:1
        })
      }else{
        that.setData({
          ["tabs["+index+"].children["+index1+"].show"]:0
        })
      }
      //钣金选择判断
      if(tabs[index].children[index1].children[index2].view_show==1){

      }else{
        for(var i=0;i<tabs[index].children[index1].children[index2].children.length;i++){
          if(tabs[index].children[index1].children[index2].children[i].view_show==1){
            that.setData({
              ["tabs["+index+"].children["+index1+"].children["+index2+"].children["+i+"].view_show"]:0,
            })
          }
        }

      }
    }
  }else{
    if(zhengche_show==1){
      that.setData({
        ["tabs["+index+"].children["+index1+"].children["+index2+"].view_show"]:view_show==1? 0:1,
        ["tabs["+index+"].children["+index1+"].children["+index2+"].img_show"]:img_show==1? 0:1,
        ["tabs["+index+"].num"]:num,
        ["tabs["+index+"].children["+index1+"].show"]:0
      })
    }else{
      for(var i=0;i<tabs.length;i++){
        if(tabs[i].num!=0){
          that.setData({
            ["tabs["+i+"].num"]:0
          })
        }

        for(var i1=0;i1<tabs[i].children.length;i1++){
          if(tabs[i].children[i1].show!=0){
            that.setData({
              ["tabs["+i+"].children["+i1+"].show"]:0,
            })
          }

          for(var i2=0;i2<tabs[i].children[i1].children.length;i2++){
            if(tabs[i].children[i1].children[i2].view_show!=0 || tabs[i].children[i1].children[i2].img_show!=0){
              that.setData({
                ["tabs["+i+"].children["+i1+"].children["+i2+"].view_show"]:0,
                ["tabs["+i+"].children["+i1+"].children["+i2+"].img_show"]:0,
              })
            }

            for(var i3=0;i3<tabs[i].children[i1].children[i2].children.length;i3++){
              if(tabs[i].children[i1].children[i2].children[i3].view_show!=0 || tabs[i].children[i1].children[i2].children[i3].img_show!=0){
                that.setData({
                  ["tabs["+i+"].children["+i1+"].children["+i2+"].children["+i3+"].view_show"]:0,
                  ["tabs["+i+"].children["+i1+"].children["+i2+"].children["+i3+"].img_show"]:0,
                })
              }

            }
          }
        }
      }

      for(var i=0;i<lr_list.length;i++){
        that.setData({
          ["lr_list["+i+"].show"]:0,
        })
      }
      let num = tabs[index].num;
      if(view_show==0){
        num = num+1;
      }else{
        num=num-1;
      }
      that.setData({
        ["tabs["+index+"].children["+index1+"].children["+index2+"].view_show"]:view_show==1? 0:1,
        ["tabs["+index+"].children["+index1+"].children["+index2+"].img_show"]:img_show==1? 0:1,
        ["tabs["+index+"].num"]:num,
      })
      let xx;
      for(var i=0;i<tabs[index].children[index1].children.length;i++){
        if(tabs[index].children[index1].children[i].view_show==1){
          xx=1;
          break;
        }else{
          xx=0;
        }
      }
      if(xx==1){
        that.setData({
          ["tabs["+index+"].children["+index1+"].show"]:1
        })
      }else{
        that.setData({
          ["tabs["+index+"].children["+index1+"].show"]:0
        })
      }
    }
  }
}

},

发表评论

评论列表

  • 这篇文章还没有收到评论,赶紧来抢沙发吧~