瀏覽代碼

Merge branch 'dev/v4.9.36_yf' of qmx/jy into feature/v4.9.36

yangfeng 1 年之前
父節點
當前提交
097c859169

二進制
src/web/staticres/images/index/new/delete.png


+ 224 - 1
src/web/staticres/js/index/index_2023.12.js

@@ -27,6 +27,14 @@ var entAssoc = {
       var type = $(this).attr('data-type')
       var id = $(this).attr('data-id')
       var name = $(this).attr('data-name')
+      if (loginflag) {
+        try {
+          searchHistory.saveBrowseRecord({
+            type: type === 'ent' ? 'ent' : 'buyer',
+            name: type === 'ent' ? name +'_' + id : name
+          })
+        } catch (error) {}
+      }
       if (type === 'ent') {
         window.open('/swordfish/page_big_pc/svip/ent_ser_portrait/' + id)
       } else {
@@ -94,7 +102,7 @@ var entAssoc = {
     var isEntSearch = this.isEntSearch()
     this.list.forEach(function (item) {
       if (isEntSearch) {
-        html += ('<div class="pre-search-item ellipsis" data-type="ent" data-id=' + item.entId + '>' + item.name + '</div>')
+        html += ('<div class="pre-search-item ellipsis" data-type="ent" data-name=' + item.name + '  data-id=' + item.entId + '>' + item.name + '</div>')
       } else {
         html += ('<div class="pre-search-item ellipsis" data-type="buyer" data-name=' + item + '>' + item + '</div>')
       }
@@ -132,6 +140,218 @@ var entAssoc = {
   }
 }
 
+var searchHistory = {
+  preSearch: {
+    hover: false,
+    focus: false
+  },
+  searchList: [],
+  browseList: [],
+  init: function () {
+    var _this = this
+    _this.getSearchHistory()
+    // 控制list显示隐藏
+    $('#keywords').on('focus', function () {
+      _this.preSearch.focus = true
+      _this.checkListShow()
+    }).on('blur', function () {
+      setTimeout(() => {
+        _this.preSearch.focus = false
+        _this.checkListShow()
+      }, 300)
+    })
+    $('#keywords').on('input', function () {
+      if ($(this).val() === '') {
+        _this.preSearch.focus = true
+        _this.checkListShow()
+      } else {
+        _this.preSearch.focus = false
+        _this.checkListShow()
+      }
+    })
+    // 清除历史
+    $('.keywords-history-card .delete-img').click(function () {
+      var type = ''
+      if (_this.isBidSearch()) {
+        type = 1
+      } else if (_this.isEntSearch()) {
+        type = 2
+      } else if (_this.isBuyerSearch()) {
+        type = 4
+      }
+      _this.removeSearchHistory(type)
+    })
+    $('.browse-history-card .delete-img').click(function () {
+      var type = ''
+      if (_this.isEntSearch()) {
+        type = 3
+      } else if (_this.isBuyerSearch()) {
+        type = 5
+      }
+      _this.removeSearchHistory(type)
+    })
+    _this.goSearchInitEvent()
+  },
+  getType: function () {
+    var type = 1
+    if (this.isBidSearch()) {
+      type = 1
+    } else if (this.isEntSearch()) {
+      type = '2,3'
+    } else if (this.isBuyerSearch()) {
+      type = '4,5'
+    } else {
+      type = ''
+    }
+    return type
+  },
+  isBidSearch: function () {
+    return $('.index-search-module .search-type-list .active').text().indexOf('招标采购搜索') !== -1
+  },
+  isEntSearch: function () {
+    return $('.index-search-module .search-type-list .active').text().indexOf('企业搜索') !== -1
+  },
+  isBuyerSearch: function () {
+    return $('.index-search-module .search-type-list .active').text().indexOf('采购单位搜索') !== -1
+  },
+  checkListShow: function () {
+    var pass = this.isBidSearch() || this.isEntSearch() || this.isBuyerSearch()
+    var show = $('#keywords').val() === '' && this.preSearch.focus && (this.searchList.length || this.browseList.length) && pass
+    this.listShow(show)
+  },
+  listShow: function (f) {
+    if (f) {
+      $('.search-history-list').show()
+    } else {
+      $('.search-history-list').hide()
+    }
+  },
+  render: function (searchList, browseList) {
+    var searchContainer = $('.search-tag-container')
+    var browseContainer = $('.browse-list-container')
+    searchContainer.empty()
+    browseContainer.empty()
+    var sHtml = ''
+    var bHtml = ''
+    if (searchList && searchList.length) {
+      searchList.forEach(function (item) {
+        sHtml += ('<span class="search-tag-item">' + item + '</span>')
+      })
+      searchContainer.html(sHtml)
+      $('.keywords-history-card').show()
+    } else {
+      $('.keywords-history-card').hide()
+    }
+    if(browseList && browseList.length) {
+      browseList.forEach(function (item) {
+        bHtml += ('<div class="browse-history-item ellipsis" data-id=' + item.id +  '>' + item.name + '</div>')
+      })
+      browseContainer.html(bHtml)
+      $('.browse-history-card').show()
+    } else {
+      $('.browse-history-card').hide()
+    }
+  },
+  // 获取搜索历史记录
+  getSearchHistory: function () {
+    // type: 1-标讯搜索历史记录  2-企业历史搜索 3-企业历史浏览 4-采购单位历史搜索 5-采购单位历史浏览
+    var type = this.getType();
+    console.log(type, loginflag);
+    if(!type) return
+    if(!loginflag) return
+    var _this = this
+    _this.searchList = []
+    _this.browseList = []
+    $.ajax({
+      url: '/publicapply/history/get',
+      method: 'POST',
+      data: { type: type },
+      success: function (res) {
+        if (res.error_code === 0) {
+          _this.searchList = res.data.search
+          if (res.data.browse) {
+            // 格式化浏览历史数据(企业画像浏览记录跳转需要企业id, 存历史记录的时候保存格式为“企业名称_企业id”, 取的时候要分割开)
+            res.data.browse = res.data.browse.map(function(item) {
+              if (item.indexOf('_') > -1) {
+                var name = item.split('_')[0]
+                var id = item.split('_')[1]
+                return {
+                  name,
+                  id
+                }
+              } else {
+                return {
+                  name: item
+                }
+              }
+            })
+            _this.browseList = res.data.browse
+          }
+          _this.render(res.data.search, res.data.browse)
+        }
+      }
+    })
+  },
+  // 点击搜索记录,跳转到搜索结果页
+  goSearchInitEvent: function () {
+    var _this = this
+    $('.search-tag-container').click('.search-tag-item', function(){
+      var biddingSearch = _this.isBidSearch()
+      var entSearch = _this.isEntSearch()
+      var buyerSearch = _this.isBuyerSearch()
+      var name = $(this).text()
+      if (biddingSearch) {
+        window.location.href = '/jylab/supsearch/index.html?keywords=' + name
+      } else if (entSearch) {
+        window.location.href = '/jylab/entSearch/index.html?searchvalue=' + name
+      } else if (buyerSearch) {
+        window.location.href = '/jylab/buyerSearch/index.html?searchvalue=' + name
+      }
+    })
+    $('.browse-list-container').click('.browse-history-item', function(item){
+      var entSearch = _this.isEntSearch()
+      var buyerSearch = _this.isBuyerSearch()
+      var entId = item.target.dataset.id
+      var buyer = item.target.innerText
+      if (entSearch) {
+        window.open('/swordfish/page_big_pc/free/loading/ent/' + entId)
+      } else if (buyerSearch) {
+        window.open('/swordfish/page_big_pc/free/loading/buyer/' + buyer)
+      }
+    })
+  },
+  // 清除历史搜索记录
+  removeSearchHistory: function(type) {
+    var _this = this
+    if (!type) return
+    $.ajax({
+      url: '/publicapply/history/del',
+      method: 'POST',
+      data: { type: type },
+      success: function (res) {
+        console.log(res)
+        if (res.error_code === 0) {
+         _this.getSearchHistory()
+        }
+      }
+    })
+  },
+  // 保存浏览记录(企业画像、采购单位画像)
+  saveBrowseRecord: function (data) {
+    var _this = this
+    $.ajax({
+      url: '/publicapply/history/savePortrait',
+      method: 'POST',
+      data: data,
+      success: function (res) {
+        if (res.error_code === 0 && res.data) {
+          _this.getSearchHistory()
+        }
+      }
+    })
+  }
+}
+
 var _page = {
   searchInput: $('.index-search-container .search-input'),
   searchConfMap: {
@@ -226,6 +446,8 @@ var _page = {
       } else if (dataId == 'wd') {
         searchInput.attr('placeholder', conf.placeholder)
       }
+      searchHistory.getSearchHistory()
+      searchHistory.listShow(false)
     })
     // 确认搜索
     $('#doSearch').on('click', function () {
@@ -401,6 +623,7 @@ var _page = {
 $(function () {
   entAssoc.init()
   _page.init()
+  searchHistory.init()
 })
 
 // seo优化-底部广告位html内js迁移

+ 57 - 1
src/web/staticres/pccss/index_pc.css

@@ -1639,4 +1639,60 @@
   padding: 0px 0 32px;
   border-bottom: 1px solid rgba(255,255,255,0.12);
 }
-/* ---- seo优化html内的样式迁移 END ---- */
+/* ---- seo优化html内的样式迁移 END ---- */
+
+/* 搜索历史 */
+.search-history-list {
+  position: absolute;
+  padding: 20px 0;
+  z-index: 6;
+  top: 38px;
+  left: 0;
+  width: 544px;
+  background: #fff;
+  box-shadow: 0 0 20px rgb(0, 0, 0, 0.1);
+  border-radius: 8px;
+  overflow: hidden;
+}
+.search-history-card .history-header{
+  display: flex;
+  justify-content: space-between;
+  padding: 0 20px;
+  font-size: 12px;
+  line-height: 18px;
+  color: #686868;
+}
+.search-history-card .delete-img{
+  width: 18px;
+  height: 18px;
+  cursor: pointer;
+}
+.search-history-card .history-main{
+  margin-top: 12px;
+}
+.search-history-card .search-tag-container{
+  padding: 0 20px;
+}
+.search-history-card .search-tag-container .search-tag-item{
+  display: inline-block;
+  padding: 1px 8px;
+  margin-right: 12px;
+  margin-bottom: 12px;
+  border-radius: 4px;
+  background: #F5F6F7;
+  font-size: 14px;
+  line-height: 22px;
+  border: 1px solid #ECECEC;
+  cursor: pointer;
+}
+.browse-history-card .browse-list-container .browse-history-item {
+  padding: 9px 20px;
+  font-size: 14px;
+  line-height: 22px;
+  cursor: pointer;
+}
+
+.browse-history-card .browse-list-container .browse-history-item:hover{
+  background: #EAF8FA;
+  color: #2ABED1;
+}

+ 1 - 1
src/web/templates/pc/newIndex.html

@@ -231,7 +231,7 @@
   <script>
     haslogin('10')
   </script>
-  <script type="text/javascript" src='{{Msg "seo" "cdn"}}/js/index/index_2023.12.js?v={{Msg "seo" "version"}}'></script>
+  <script type="text/javascript" src='{{Msg "seo" "cdn"}}/js/index/index_2023.12.js?v={{Msg "seo" "version"}}1'></script>
   <script defer src=//cdn-common.jianyu360.com/cdn/lib/echarts/4.8.0/echarts.min.js></script>
   <script defer type="text/javascript" src='{{Msg "seo" "cdn"}}/js/index/index_charts.js?v={{Msg "seo" "version"}}'></script>
 </body>

+ 22 - 0
src/web/templates/pc/template/index/search-module.html

@@ -30,6 +30,28 @@
           <input type="text" class="search-input" id="keywords" name="keywords" autocomplete="off" maxlength="50" placeholder="请输入项目名称等关键词,例如:医疗设备">
         </div>
         <section class="pre-search-list" style="display: none;"></section>
+        <section class="search-history-list" style="display: none;">
+            <div class="search-history-card keywords-history-card" style="display: none;">
+              <div class="history-header">
+                <span>历史搜索</span>
+                <img class="delete-img" src="/images/index/new/delete.png" alt="delete">
+              </div>
+              <div class="history-main">
+                <div class="search-tag-container"></div>
+              </div>
+            </div>
+            <div class="search-history-card browse-history-card" style="display: none;">
+              <div class="history-header">
+                <span>历史浏览</span>
+                <img class="delete-img" src="/images/index/new/delete.png" alt="delete">
+              </div>
+              <div class="history-main">
+                <div class="browse-list-container">
+                  <div class="browse-history-item ellipsis"></div>
+                </div>
+              </div>
+            </div>
+        </section>
         <button class="search-button button-blink blink-fast" type="submit" id="doSearch">剑鱼一下</button>
       </div>
     </div>