Browse Source

serviceList

liting2017 6 years ago
parent
commit
1ee536694a
2 changed files with 59 additions and 37 deletions
  1. 2 4
      src/js/newMenu/patentList.js
  2. 57 33
      src/js/newMenu/serviceList.js

+ 2 - 4
src/js/newMenu/patentList.js

@@ -148,13 +148,11 @@ $(function () {
                                  `)
                             })
                             theArrs.push(`
-                                </ul>
-                               
+                                    </ul>
+                                </div>
                             </div>
-                        </div>
                         `)
                         }
-
                     })
 
                     $('.serviceList').html(theArrs.join(''));

+ 57 - 33
src/js/newMenu/serviceList.js

@@ -23,14 +23,14 @@ $(function () {
         inpFun();
         summary();
         search();
-        jump();
+        // jump();
         $('.onSelect .preFirst').css('display', 'none');
         $('.onSelect .next').css('display', 'none');
         $('.hot ul li').removeClass('active');
     };
     //一级界面跳转此页面
    
-    function jump() {
+    function jump(theData) {
         let hash = window.location.search;
         if (hash) {
             if (hash.indexOf('name') > -1 || hash.indexOf('topId') > -1 || hash.indexOf('secondId') > -1) {
@@ -42,10 +42,12 @@ $(function () {
                             let names = item.split('=')
                             dataList.name = decodeURIComponent(names[1])
                             $('.demandSearch').val(dataList.name);
+                            menuInit(theData)
                         }
                         if (item.indexOf('topId') > -1) {
                             let topIds = item.split('=')
                             dataList.topId = decodeURIComponent(topIds[1])
+                            menuInit(theData,topIds)
                         }
                         if (item.indexOf('secondId') > -1) {
                             let secondIds = item.split('=')
@@ -57,15 +59,18 @@ $(function () {
                         let names = newHash.split('=')
                         dataList.name = decodeURIComponent(names[1])
                         $('.demandSearch').val(dataList.name);
+                        menuInit(theData)
                     }
                     if (newHash.indexOf('topId') > -1) {
                         let topIds = newHash.split('=')
                         dataList.topId = decodeURIComponent(topIds[1])
+                        menuInit(theData,topIds[1])
                     }
                     if (newHash.indexOf('secondId') > -1) {
                         let secondIds = newHash.split('=')
                         dataList.secondId = decodeURIComponent(secondIds[1])
                     }
+                    
                 }
                 loadDate()
             }
@@ -74,9 +79,56 @@ $(function () {
             dataList.topId = "", //行业
             dataList.secondId = "" //类型
             loadDate();
+            menuInit(theData)
         }
     }
-
+    //跳转渲染菜单
+    function menuInit(data,id=''){
+        var theArrs = '',htmls='';
+            htmls+='<div class="objList">'
+            let thisdata=data,m,n;
+            thisdata.unshift({
+                    module: '',
+                    name: '不限',
+                    list:[{
+                        topLevelId:'',
+                        topLevel:'不限'
+                    }]
+                })
+            thisdata.map((item,index)=>{
+                htmls+='<div>';
+                theArrs+='<li data-module='+item.module+'><span>'+item.name+'</span></li>';
+                if(item.list&&(item.list).length){
+                    (item.list).map((atem,ind)=>{
+                        if(atem.topLevelId==id){
+                            m=index;n=ind;
+                            htmls+='<span class="active" data-id='+atem.topLevelId+'>'+atem.topLevel+'</span>'
+                            return;
+                        }
+                        htmls+='<span data-id="'+atem.topLevelId+'">'+atem.topLevel+'</span>'
+                    })
+                }
+                htmls+='</div>'
+            })
+            htmls+='</div>';
+            if(!id){
+                $('.industryList').append(htmls);
+                $('.industryList ul').html(theArrs);
+                $('.industryList ul li').eq(0).addClass('active');
+                $('.objList div').eq(0).addClass('active');
+                $('.objList div').eq(0).find('span').addClass('active');
+                $('.productionType ol').html(`<li data-id='' class="active">不限</li>`);
+                $('.productionType ol li').eq(0).addClass = "active";
+            }else{
+                $('.industryList').append(htmls);
+                $('.industryList ul').html(theArrs);
+                $('.industryList ul li').eq(m).addClass('active');
+                $('.objList>div').eq(m).addClass('active');
+                $('.productionType ol').html(`<li data-id='' class="active">不限</li>`);
+                $('.productionType ol li').eq(0).addClass = "active";
+            }
+            onSelect(thisdata);
+    }
     function summary() {
         $.ajax({
             method: "get",
@@ -84,37 +136,9 @@ $(function () {
             url: globalConfig.context + "/portal/service/jtBusiness/makeMoneyCategoryList",
             data: {},
             success: function (data) {
-                var theArrs = '',htmls='';
-                htmls+='<div class="objList">'
                 if (data.data && data.data.length) {
                     let thisdata = data.data;
-                    thisdata.unshift({
-                            module: '',
-                            name: '不限',
-                            list:[{
-                                topLevelId:'',
-                                topLevel:'不限'
-                            }]
-                        })
-                    thisdata.map((item,index)=>{
-                        htmls+='<div>';
-                        theArrs+='<li data-module='+item.module+'><span>'+item.name+'</span></li>';
-                        if(item.list&&(item.list).length){
-                            (item.list).map(atem=>{
-                                htmls+='<span data-id='+atem.topLevelId+'>'+atem.topLevel+'</span>'
-                            })
-                        }
-                        htmls+='</div>'
-                    })
-                    htmls+='</div>';
-                    $('.industryList').append(htmls);
-                    $('.industryList ul').html(theArrs);
-                    $('.industryList ul li').eq(0).addClass('active');
-                    $('.objList div').eq(0).addClass('active');
-                    $('.objList div').eq(0).find('span').addClass('active');
-                    $('.productionType ol').html(`<li data-id='' class="active">不限</li>`);
-                    $('.productionType ol li').eq(0).addClass = "active";
-                    onSelect(thisdata);
+                    jump(thisdata)
                 };
             }
         })
@@ -251,7 +275,7 @@ $(function () {
             }
         })
     }
-
+    
     //已选类型
     function onSelect(data) {
         $('.industryList ul li').click(function(){