Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/cdss0407' into scale0414

# Conflicts:
#	src/html/homeStatic.html
zhouna 4 gadi atpakaļ
vecāks
revīzija
7336b59e68

+ 1 - 7
src/html/homeStatic.html

@@ -22,13 +22,7 @@
         </div>
         <div class="staticTopTab">
           <ul>
-            <li class="tabFst" data-id="0">全部</li>
-            <li data-id="1">诊断</li>
-            <li data-id="2">药品</li>
-            <li data-id="3">检验</li>
-            <li data-id="5">检查</li>
-            <li data-id="6">手术和操作</li>
-            <li data-id="8">量表</li>
+
           </ul>
         </div>
         <div class="staticTopSearch clearfix">

+ 1 - 6
src/html/searchStaticList.html

@@ -21,12 +21,7 @@
       </div>
       <div class="staticTopTab">
         <ul>
-          <li class="tabFst" data-id="0">全部</li>
-          <li data-id="1">诊断</li>
-          <li data-id="2">药品</li>
-          <li data-id="3">检验</li>
-          <li data-id="4">检查</li>
-          <li data-id="5">手术和操作</li>
+          
         </ul>
       </div>
       <div class="staticTopSearch clearfix">

+ 26 - 3
src/js/homeStatic.js

@@ -1,17 +1,24 @@
 require('./../css/homeStatic.less');
 
 const $ = require("jquery");
+const {post,config} = require('./promise.js');
 let searchType = 0;
 require('./../images/staticBgS.png').replace(/^undefined/g, '')
 require('./../images/staticLogo.png').replace(/^undefined/g, '')
 require('./../images/staticBg.png').replace(/^undefined/g, '')
 
 $(function(){
-  changeTab()
+  getAllTypes()
   goSearchList()
 });
-//tab切换
-function changeTab(){
+//tab
+function renderTab(data){
+  let str = '';
+  for (let i = 0; i < data.length; i++) {
+    const element = data[i];
+    str += `<li class="${i==0?'tabFst':''}" data-id="${element.val}">${element.name}</li>`
+  }
+  $('.staticTopTab ul').html(str)
   $(".staticTopTab li").click(function(){
     searchType = $(this).attr('data-id')
     $(this).css({borderColor:'#fff'}).siblings().css({borderColor:'#2A9BD5'})
@@ -24,3 +31,19 @@ function goSearchList(){
     window.location.href = './searchStaticList.html?type='+searchType+'&inputStr='+vals
   })
 }
+//获取字典信息
+function getAllTypes(){
+  const allTypes = localStorage.getItem('allTypes')&&JSON.parse(localStorage.getItem('allTypes'))||[];
+  if(allTypes.length>0){
+    renderTab(allTypes)
+    return
+  }
+  post(config.dictionaryInfo, {}).then((res) => {
+    const result = res.data
+    if(result.code==='0'){
+      const data = result.data[7]||[];
+      localStorage.setItem('allTypes',JSON.stringify(data))
+      renderTab(data)
+    }
+  })
+}

+ 30 - 9
src/js/searchStaticList.js

@@ -2,7 +2,6 @@ require('./../css/searchStaticList.less');
 
 const $ = require("jquery");
 const { post,config,getUrlArgObject,openNewWin } = require('./promise.js');
-const { renderRecommendInfo, renderMultRecommendInfo, renderTreat, renderRecommendConditTips, renderTipsInfo ,renderKnowledgeInfo,renderScaleInfo} = require('./indexVertDom.js');
 
 let searchType = 0,inputStr = '',curPage=1,size=10;
 searchType = getUrlArgObject('type') || 0
@@ -17,17 +16,39 @@ require('./../images/nolis.png').replace(/^undefined/g, '')
 
 $(function(){
   initData()
-  changeTab()
+  getAllTypes()
   getSearchList()
   getTabData(curPage)
 });
-//tab切换
-function changeTab(){
-  $(".staticTopTab li").click(function(){
-    searchType = $(this).attr('data-id')
-    $(this).css({color:'#2A9BD5'}).siblings().css({color:'#333'})
-  })
-}
+//tab
+function renderTab(data){
+    let str = '';
+    for (let i = 0; i < data.length; i++) {
+      const element = data[i];
+      str += `<li class="${i==0?'tabFst':''}" data-id="${element.val}">${element.name}</li>`
+    }
+    $('.staticTopTab ul').html(str)
+    $(".staticTopTab li").click(function(){
+      searchType = $(this).attr('data-id')
+      $(this).css({color:'#2A9BD5'}).siblings().css({color:'#333'})
+    })
+  }
+//获取字典信息
+function getAllTypes(){
+    const allTypes = localStorage.getItem('allTypes')&&JSON.parse(localStorage.getItem('allTypes'))||[];
+    if(allTypes.length>0){
+      renderTab(allTypes)
+      return
+    }
+    post(config.dictionaryInfo, {}).then((res) => {
+      const result = res.data
+      if(result.code==='0'){
+        const data = result.data[7]||[];
+        localStorage.setItem('allTypes',JSON.stringify(data))
+        renderTab(data)
+      }
+    })
+  }
 function getSearchList(){
     $(".searchBtn").click(function(){
         $(".resultItemWrap,.pagination").html("");