瀏覽代碼

Merge remote-tracking branch 'origin/dev3.0.0' into dev3.0.0

wangkaiyue 4 年之前
父節點
當前提交
d4009fdb29

+ 4 - 4
src/jfw/modules/app/src/web/staticres/jyapp/js/searchindex.js

@@ -375,7 +375,7 @@ var SuperSearch = {
 			if(localStorage){
 				localStorage.removeItem("superSearch_history");
 			}
-			if(userId != "" && $("#supersearchPage ul.history-list-box").find("li").length >0){
+			if(userId != "" && $("#supersearchPage .search-one-box ul.history-list-box").find("li").length >0){
 				$.ajax({
 					type:"post",
 					url:"/jyapp/swordfish/delWxHistorySearch",
@@ -384,7 +384,7 @@ var SuperSearch = {
 					}
 				});
 			}
-			$("#supersearchPage ul.history-list-box").find("li").remove();
+			$("#supersearchPage .search-one-box ul.history-list-box").find("li").remove();
 		});
 		////
 		SuperSearch.njTipEasyPopup = new EasyPopup("nijianTip");
@@ -1683,14 +1683,14 @@ var SuperSearch = {
 				historyHtml+="<li  class='hover-css--slide'>"+hy+"</li>"
 			}
 		}
-		$("#supersearchPage ul.history-list-box").html(historyHtml);
+		$("#supersearchPage .search-one-box ul.history-list-box").html(historyHtml);
 		if(historyHtml == ""){
 			$("#supersearchPage .tabs-box .tabs-content-page").eq(0).addClass("hidden");
 		}else{
             $("#supersearchPage .tabs-box .tabs-content-page").eq(0).removeClass("hidden");
 		}
 		// 点击历史记录内容 进行搜索
-		$("#supersearchPage .history-list-box").off("click", 'li').on("click", 'li', function () {
+		$("#supersearchPage .search-one-box .history-list-box").off("click", 'li').on("click", 'li', function () {
 			$("#supersearchPage input[name=super_searchinput]").val($(this).text());
 			SuperSearch.canSearch();
 			SuperSearch.formSubmit("N");

+ 9 - 0
src/jfw/modules/app/src/web/templates/weixin/search/mainSearch.html

@@ -795,6 +795,15 @@
                 $("#resbm #zjdy").prev("span").text("如果您对以上结果满意可【直接订阅】");
             }
 
+            // 大会员筛选条件
+            if (result.member > 0) {
+                $("div[data-open='buyer']").show()
+                $("div[data-open='win']").show()
+            } else {
+                $("div[data-open='buyer']").hide()
+                $("div[data-open='win']").hide()
+            }
+
             // 查询是否需要(微信)账号合并
             mergeAccountForWx.init({
                 _className: 'app-main-search',

+ 102 - 46
src/jfw/modules/app/src/web/templates/weixin/search/tabSearch.html

@@ -141,7 +141,8 @@
         box-sizing: border-box;
         padding-left: 0.32rem;
     }
-    .history-title-box .padding-icon {
+    .history-title-box .padding-icon,
+    #del_history.padding-icon {
         padding: 0.32rem;
         margin: unset;
         float: unset;
@@ -448,58 +449,38 @@
             <span class="slide-line"></span>
         </div>
         <div class="tabs-content">
-            <div class="tabs-content-page active">
+            <div class="search-one-box tabs-content-page active">
                 <div class="history-title-box">
                     <span>历史搜索</span>
                     <div class="padding-icon" id="del_history">
                         <span class="j-icon base-icon icon-delete"></span>
                     </div>
                 </div>
-                <ul class="history-list-box">
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                </ul>
+                <ul class="history-list-box"></ul>
             </div>
             <div class="tabs-content-page">
                 <ul class="ent-search-list-box"  id="search-ent-list"></ul>
-                <div class="history-title-box">
-                    <span>历史搜索</span>
-                    <div class="padding-icon" id="del_ent_history">
-                        <span class="j-icon base-icon icon-delete"></span>
+                <div class="del_ent_history">
+                    <div class="history-title-box">
+                        <span>历史搜索</span>
+                        <div class="padding-icon" id="del_ent_history">
+                            <span class="j-icon base-icon icon-delete"></span>
+                        </div>
                     </div>
+                    <ul class="history-list-box"></ul>
                 </div>
-                <ul class="history-list-box">
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                </ul>
             </div>
             <div class="tabs-content-page">
                 <ul class="ent-search-list-box" id="search-buyer-list"></ul>
-                <div class="history-title-box">
-                    <span>历史搜索</span>
-                    <div class="padding-icon" id="del_buyer_history">
-                        <span class="j-icon base-icon icon-delete"></span>
+                <div class="del_buyer_history">
+                    <div class="history-title-box">
+                        <span>历史搜索</span>
+                        <div class="padding-icon" id="del_buyer_history">
+                            <span class="j-icon base-icon icon-delete"></span>
+                        </div>
                     </div>
+                    <ul class="history-list-box"></ul>
                 </div>
-                <ul class="history-list-box">
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                    <li class="hover-css--slide">万达集团</li>
-                </ul>
             </div>
         </div>
     </div>
@@ -1107,7 +1088,8 @@
         }
 
         if (!nowInput.length) {
-            $(outDom).html('').siblings().show()
+            $(outDom).html('')
+            getSearchHistory(nowType, true)
         } else {
             if (window.topSearchData[nowType] === nowInput) {
                 return
@@ -1175,6 +1157,7 @@
         $('div[data-wait-open="'+ $(this).attr('data-open') +'"]').removeClass('hidden')
         $("#swiper-filter .jyshaxuan").animate({scrollLeft: $(this).offset().left})
     }
+    window.isAddEventListener = false
     function initSearchHeader (t) {
         console.log('是否仅刷新数据', t)
         if (t) {
@@ -1195,8 +1178,17 @@
             } else {
                 $("#supersearchPage .industry_item.whole:not(.active)").addClass('active')
             }
+
+            var oldIndex = sessionStorage.getItem('home_top_search_tab_index') || '0'
+            $(".tabs-nav div").eq(oldIndex).trigger('click')
+
             return
         }
+        if (window.isAddEventListener) {
+            console.log('拒绝重复初始化事件')
+            return
+        }
+        window.isAddEventListener = true
         // 通用输入框删除ICON事件
         $("form[data-name='input-clear-box'] input").on('input change', checkInputClear).on('focus', checkInputClear).on('blur', function () {
             var that = this
@@ -1209,9 +1201,9 @@
             $(this).prev().val('')
         })
         console.log('初始化时间')
-        // $("#search-header-input").on('focus', function () {
-        //     $("#clickFilter").text('搜索')
-        // }).on('blur', utils.debounce(checkFilterButtonText))
+        $("#search-header-input").on('focus', function () {
+            $("#clickFilter").text('搜索')
+        }).on('blur', utils.debounce(checkFilterButtonText))
         // 头部输入框事件
         $("#search-header-input").on('input change', utils.debounce(function () {
             createSearchResultList()
@@ -1235,8 +1227,11 @@
         $(".tabs-nav div").on('click', function () {
             $(this).addClass('active').siblings().removeClass('active')
             var nowIndex = $(this).index()
+            var tipArr = ['税务局软件', '企业名称', '采购单位名称']
+            $("#search-header-input").attr('placeholder', tipArr[nowIndex])
             $(".tabs-content > .tabs-content-page").eq(nowIndex).addClass('active').siblings().removeClass('active')
             if (nowIndex !== 0) {
+                var type = nowIndex === 1 ? 'ent' : 'buyer'
                 $(".search-header-box").addClass('m-r').removeAttr("action").next().hide()
                 createSearchResultList()
             } else {
@@ -1333,19 +1328,80 @@
             $(this).addClass('active').parents('.list').find('.industry_item:not(.whole)').removeClass('active');
         })
         // 选择非全部行业
+        console.log('初始化点击事件')
         $('.industry_item:not(.whole)').on('click', function () {
             $('.industry_item.whole').removeClass('active');
             $(this).toggleClass('active');
         })
 
         // 企业搜索点击
-        $("#search-ent-list").on('click', 'li', function () {
-            location.href = "/jyapp/big/page/ent_portrait?name="+encodeURIComponent($(this).text())
-        })
+        $("#search-ent-list").on('click', 'li', goEntPage)
+        $(".del_ent_history").on('click', 'li', goEntPage)
         // 采购单位搜索点击
-        $("#search-buyer-list").on('click', 'li', function () {
-            location.href = "/jyapp/big/page/unit_portrayal?entName="+encodeURIComponent($(this).text())
+        $("#search-buyer-list").on('click', 'li', goBuyPage)
+        $(".del_buyer_history").on('click', 'li', goBuyPage)
+
+        // 清除搜索历史记录
+        $('#del_ent_history').on('click', function () {
+            clearSearchHistory('ent')
         })
+        $('#del_buyer_history').on('click', function () {
+            clearSearchHistory('buyer')
+        })
+    }
+
+    function goEntPage () {
+        sessionStorage.setItem('home_top_search_tab_index', $(".tabs-nav .active").index())
+        saveSearchHistory('ent', $(this).text())
+        location.href = "/jyapp/big/page/ent_portrait?name="+encodeURIComponent($(this).text())
+    }
+
+    function goBuyPage () {
+        sessionStorage.setItem('home_top_search_tab_index', $(".tabs-nav .active").index())
+        saveSearchHistory('buyer', $(this).text())
+        location.href = "/jyapp/big/page/unit_portrayal?entName="+encodeURIComponent($(this).text())
+    }
+
+    function saveSearchHistory (type, insetStr) {
+        var saveOnlyKey = 'home_top_search_' + type + '_history'
+        var oldArr = JSON.parse(sessionStorage.getItem(saveOnlyKey) || '[]')
+        if (oldArr.indexOf(insetStr) === -1) {
+            oldArr.push(insetStr)
+        }
+        sessionStorage.setItem(saveOnlyKey, JSON.stringify(oldArr))
+    }
+
+    function clearSearchHistory (type) {
+        var saveOnlyKey = 'home_top_search_' + type + '_history'
+        sessionStorage.removeItem(saveOnlyKey)
+        var domNode = $('.del_' + type + '_history')
+        if (domNode) {
+            domNode.find('ul.history-list-box').html('')
+            domNode.hide()
+        }
+    }
+
+    function getSearchHistory (type, setDom) {
+        console.log('tyoe', type)
+        var saveOnlyKey = 'home_top_search_' + type + '_history'
+        var oldArr = JSON.parse(sessionStorage.getItem(saveOnlyKey) || '[]')
+        console.log(oldArr)
+        if (setDom) {
+            var domNode = $('.del_' + type + '_history')
+            if (domNode) {
+                var outHtml = ''
+                oldArr.forEach(function (v) {
+                    outHtml += '<li class="hover-css--slide">' + v + '</li>'
+                })
+                domNode.find('ul.history-list-box').html(outHtml)
+                if (oldArr.length > 0) {
+                    domNode.show()
+                } else {
+                    domNode.hide()
+                }
+            }
+        }
+        return oldArr
     }
 </script>
 <!--E-脚本-->