liting2017 6 years ago
parent
commit
057929c4cd
3 changed files with 189 additions and 126 deletions
  1. 10 3
      src/css/newMenu/serviceList.css
  2. 178 57
      src/js/newMenu/serviceList.js
  3. 1 66
      template/newMenu/serviceList.html

+ 10 - 3
src/css/newMenu/serviceList.css

@@ -26,14 +26,21 @@
 }
 
 .industry .industryList ul li {
-    width: 90px;
+    width: 110px;
     text-align: center;
     cursor: pointer;
     float: left;
     margin-bottom: 8px;
     font-size: 14px;
+    color: #333;
+    line-height: 48px;
+}
+.industry .industryList ul li:hover{
+    color: #ff570c;
+}
+.industry .industryList ul li.active,.productionType ol li.active{
+    color: #ff570c
 }
-
 .industry .industryList ul li span {
     color: #7a7878
 }
@@ -66,7 +73,7 @@
 
 .productionType ol li {
     float: left;
-    width: 90px;
+    width: 110px;
     text-align: center;
     line-height: 50px;
     color: #7a7878

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

@@ -11,48 +11,122 @@ import 'css/newMenu/serviceList.css';
 import 'js/public.js';
 
 "use strict";
-$(function() {
+$(function () {
     var thePageNo = 1,
         thePageLength = 1,
-        dataList={},
-        globalConfig={context:''},
-        pageSize =15;
+        dataList = {},
+        projectList = [],
+        pageSize = 15;
     init();
-    function init(){
+    function init() {
         loadDate();
         pages();
-        onSelect();
         inpFun();
-        $('.onSelect .preFirst').css('display','none')
-        $('.onSelect .next').css('display','none')
+        summary();
+        search();
+        jump();
+        $('.onSelect .preFirst').css('display', 'none');
+        $('.onSelect .next').css('display', 'none');
     };
-	function loadDate(pageNo) {
+    //一级界面跳转此页面
+    function jump(){
+        let hash = window.location.search;
+       
+        if(hash.indexOf('name')>-1||hash.indexOf('topId')>-1||hash.indexOf('secondId')>-1){
+                console.log(hash)
+                let newHash = hash.substr(1,hash.length)
+                if(newHash.indexOf('&')>-1){
+                   let hashArr =  newHash.split('&');
+                    console.log(hashArr)
+                    hashArr.map(item=>{
+                        if(item.indexOf('name')>-1){
+                            let names = item.split('=')
+                            dataList.name=names[1]
+                        }
+                        if(item.indexOf('topId')>-1){
+                            let topIds = item.split('=')
+                            dataList.topId=topIds[1]
+                        }
+                        if(item.indexOf('secondId')>-1){
+                            let secondIds = item.split('=')
+                            dataList.secondId=secondIds[1]
+                        }
+                    })
+                }else{
+                    if(newHash.indexOf('name')>-1){
+                        let names = newHash.split('=')
+                        dataList.name=names[1]
+                    }
+                    if(newHash.indexOf('topId')>-1){
+                        let topIds = newHash.split('=')
+                        dataList.topId=topIds[1]
+                    }
+                    if(newHash.indexOf('secondId')>-1){
+                        let secondIds = newHash.split('=')
+                        dataList.secondId=secondIds[1]
+                    }
+                }
+                loadDate()
+        }
+    }
+    function summary() {
+        $.ajax({
+            method: "get",
+            dataType: "json",
+            url: globalConfig.context + "/portal/service/jtBusiness/getCategoryList",
+            data: {
+
+            },
+            success: function (data) {
+                var theArrs = [];
+                if (data.data && data.data.length) {
+                    let thisdata = data.data;
+                    thisdata.unshift({
+                        topLevelId: '',
+                        topLevel: '不限',
+                        children: [{
+                            id: '',
+                            name: '不限'
+                        }]
+                    })
+                    thisdata.map(item => {
+                        theArrs.push(`
+                            <li data-id=${item.topLevelId}>${item.topLevel}</li>
+                        `)
+                    })
+                    $('.industryList ul').html(theArrs);
+                    $('.industryList ul li').eq(0).className = "active";
+                    $('.productionType ol').html(`<li data-id=''>不限</li>`);
+                    $('.productionType ol li ').eq(0).addClass = "active";
+                    onSelect(thisdata);
+                };
+            }
+        })
+    }
+
+    function loadDate(pageNo) {
         $.ajax({
             method: "get",
             dataType: "json",
-            //url: globalConfig.context + "/portal/search/achievementList",
-            url:"https://www.apiopen.top/satinApi",
+            url: globalConfig.context + "/portal/service/jtProject/list",
             data: {
-                //page:1
                 pageNo: pageNo || 1,
                 pageSize: 15,
-                // keyword: theKeyword,
-                fieldA: dataList.industryVal, //行业
-                fieldB: dataList.productionVal //类型
+                name:dataList.name,
+                topId: dataList.topId, //行业
+                secondId: dataList.secondId //类型
             },
             success: function (data) {
-                console.log(data)
                 var theArrs = [];
-                data.data.totalCount=400;
-                if (data.data&&data.data.length) {
-                    for (let i = 0; i < 12; i++) {
-                        let thisdata = data.data[i];
-                        console.log(thisdata)
+                if (data.data && data.data.list.length) {
+                    let nub = data.data.list.length;
+                    for (let i = 0; i < nub; i++) {
+                        let thisdata = data.data.list[i];
                         theArrs.push(`
                         <li>
-                            <a href="${globalConfig.context}/portal/technologyTrading/achievementDetail?id=${thisdata.user_id}&type=${thisdata.type}">
+                            <a href="${globalConfig.context}/portal/service/serviceDetail?id=${thisdata.id?thisdata.id:''}">
                                 <div class="img">
-                                    <img src="${thisdata.cdn_img}" alt="">
+                                    <img src="${thisdata.maxImgUrl}" alt="">
                                     <span></span>
                                 </div>
                                 <div class="txtIntroduce">
@@ -61,26 +135,25 @@ $(function() {
                                     </div>
                                     <div class="hr"></div>
                                     <div class="btnTxt">
-                                        <p>${thisdata.text}</p>
+                                        <p>${thisdata.introduce}</p>
                                     </div>
                                 </div>
                             </a>
-                        </li>`
-                     );
+                        </li>`);
                     };
                 };
                 $('.achievementHot .hotList').empty();
                 $('.achievementHot .hotList').append(theArrs.join(''));
-                
-                $('.pagination_box').css('display','block');
-                $('.inp').css('display','block');
-                if(data.data.length===0){
-                        $('.achievementHot .hotList').html("<div class='list_none'></div>")	;
-                        $('.pagination_box').css('display','none')
-                        $('.inp').css('display','none');
+
+                $('.pagination_box').css('display', 'block');
+                $('.inp').css('display', 'block');
+                if (data.data.list.length === 0) {
+                    $('.achievementHot .hotList').html("<div class='list_none'></div>");
+                    $('.pagination_box').css('display', 'none')
+                    $('.inp').css('display', 'none');
                 };
                 thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1;
-                $('.totalCount').html(`共${data.data.totalCount}条数据 ${thePageLength}页`)    
+                $('.totalCount').html(`共${data.data.totalCount}条数据 ${thePageLength}页`)
                 var pageArr = [],
                     firstNo = 1,
                     endNo = 5;
@@ -107,7 +180,7 @@ $(function() {
         });
     }
     //f分页
-    function pages(){
+    function pages() {
         $('.pagination').on('click', 'li', function (e) {
             e.preventDefault();
             if (this.className === 'pagePre') {
@@ -132,35 +205,83 @@ $(function() {
         });
     }
     //输入跳转
-    function inpFun(){
-        $('.inp .btn').on('click',function(){
+    function inpFun() {
+        $('.inp .btn').on('click', function () {
             let val = $(this).siblings().val();
-            if(!isNaN(val)&&val<thePageLength&&val>0){
-                thePageNo=val;
+            if (!isNaN(val) && val < thePageLength && val > 0) {
+                thePageNo = val;
                 loadDate(thePageNo);
             }
         })
     }
 
     //已选类型
-    function onSelect(){
-       $('.industryList ul li').on('click',function(){
-        dataList.industryVal = $(this).attr('value');
-           let txt = $(this).text();
-           $('.onSelect .preFirst').css('display','block').html(`
-                <span>${txt}</span>
-                <span class="typeClose">x</span>
-           `)
-           loadDate();
-       }) ;
-       $('.productionType ol li').on('click',function(){
-        dataList.productionVal = $(this).attr('value');
-        let txt = $(this).text();
-        $('.onSelect .next').css('display','block').html(`
-             <span>${txt}</span>
-             <span class="typeClose">x</span>
-             `)
+    function onSelect(data) {
+        $('.industryList ul li').on('click', function () {
+            let secondTxt = [],
+                scondHtml = [];
+            $(this).addClass('active').siblings().removeClass('active')
+            dataList.topId = $(this).attr('data-id');
+            dataList.name='';
+            dataList.secondId='';
+            $('.next').css('display','none')
+            data.map(item => {
+                if (item.topLevelId == dataList.topId) {
+                    secondTxt = item.children
+                }
+            })
+            secondTxt.map(item => {
+                scondHtml.push(`
+                    <li data-id=${item.id}>${item.name}</li>
+                    `)
+            })
+            if(!dataList.topId){
+                dataList.topId='';
+                dataList.secondId='';
+                $('.preFirst').html('不限');
+                $('.next').css('display','none')
+                scondHtml=['<li>不限</li>'];
+            }
+            $('.productionType ol').html(scondHtml);
+            let txt = $(this).text();
+            $('.onSelect .preFirst').css('display', 'block').html(`
+                    <span>${txt}</span>
+                    <span class="typeClose">x</span>
+            `)
+            loadDate();
+            $('.productionType ol li').on('click', function () {
+                dataList.name='';
+                dataList.topId=$('.industryList ul li.active').attr('data-id');
+                $(this).addClass('active').siblings().removeClass('active');
+                dataList.secondId = $(this).attr('data-id');
+                if(!dataList.secondId) return;
+
+                let txt = $(this).text();
+                $('.onSelect .next').css('display', 'block').html(`
+                        <span>${txt}</span>
+                        <span class="typeClose">x</span>
+                        `)
+                loadDate();
+            })
+        });
+    }
+    //搜索
+    function search(){
+        $('.hot ul li').click(function(){
+            dataList.name = $(this).text();
+            dataList.topId='';
+            dataList.secondId='';
+            loadDate();
+        });
+        $('.searchBtn').click(function(){
+          let val = $('.demandSearch').val();
+          if(val){
+             dataList.name=val;
+             dataList.topId='';
+             dataList.secondId='';
              loadDate();
-        }) 
+          }
+        })
     }
+
 })

+ 1 - 66
template/newMenu/serviceList.html

@@ -115,72 +115,7 @@
             <p>业务分类</p>
             <div class="industryList">
                 <ul>
-                    <li value="464" class="active">
-                        <span>教育休闲</span>
-                    </li>
-                    <li value="463" class="">
-                        <span>包装印刷</span>
-                    </li>
-                    <li value="462">
-                        <span>电气自动化</span>
-                    </li>
-                    <li value="461">
-                        <span>采矿冶金</span>
-                    </li>
-                    <li value="460">
-                        <span>航空航天</span>
-                    </li>
-                    <li value="459">
-                        <span>海洋开发</span>
-                    </li>
-                    <li value="458">
-                        <span>农林牧业</span>
-                    </li>
-                    <li value="457">
-                        <span>医药与医疗</span>
-                    </li>
-                    <li value="456">
-                        <span>电子信息</span>
-                    </li>
-                    <li value="375">
-                        <span>新型材料</span>
-                    </li>
-                    <li value="31">
-                        <span>仪器仪表</span>
-                    </li>
-                    <li value="26">
-                        <span>橡胶塑料</span>
-                    </li>
-                    <li value="25">
-                        <span>交通运输</span>
-                    </li>
-                    <li value="20">
-                        <span>安全防护</span>
-                    </li>
-                    <li value="19">
-                        <span>环保和资源</span>
-                    </li>
-                    <li value="18">
-                        <span>机械</span>
-                    </li>
-                    <li value="17">
-                        <span>新能源</span>
-                    </li>
-                    <li value="15">
-                        <span>化学化工</span>
-                    </li>
-                    <li value="7">
-                        <span>轻工纺织</span>
-                    </li>
-                    <li value="5">
-                        <span>家居用品</span>
-                    </li>
-                    <li value="4">
-                        <span>建筑建材</span>
-                    </li>
-                    <li value="2">
-                        <span>食品饮料</span>
-                    </li>
+                    <li>不限</li>
                 </ul>
             </div>
         </div>