See999 4 år sedan
förälder
incheckning
811fc99147
1 ändrade filer med 59 tillägg och 50 borttagningar
  1. 59 50
      src/pages/search/index.vue

+ 59 - 50
src/pages/search/index.vue Visa fil

@@ -1,59 +1,38 @@
1 1
 <template>
2 2
   <div class="page_search">
3
-    <div class="header">
4
-      <i class="iconfont icon-zuojiantou" @click="toHomeIndex"></i>
5
-      <van-search
6
-        v-model="value"
7
-        placeholder=" 姓名 / 首拼 / 透析号"
8
-        @search="toSearchPatient"
9
-      />
10
-    </div>
3
+    <van-sticky>
4
+      <div class="header">
5
+        <i class="iconfont icon-zuojiantou" @click="toHomeIndex"></i>
6
+        <van-search v-model="value" placeholder=" 姓名 / 首拼 / 透析号" @search="toSearchPatient" />
7
+      </div>
8
+    </van-sticky>
11 9
     <div class="searchList">
12
-      <div class="patientOne">
13
-        <img src="../../assets/images/m01.png" alt="" />
14
-        <p>名字</p>
10
+      <div
11
+        class="patientOne"
12
+        v-for="(item,index) in patientList"
13
+        :key="index"
14
+        @click="toPatient(item.id)"
15
+      >
16
+        <img :src="item.avatar" alt />
17
+        <p>{{ item.name }}</p>
15 18
       </div>
16 19
     </div>
17 20
     <div class="history">
18 21
       <div class="historyTitle">
19 22
         <span>历史搜索</span>
20
-        <i class="iconfont icon-lajixiang"></i>
23
+        <i class="iconfont icon-lajixiang" @click="deteleHistory"></i>
21 24
       </div>
22 25
       <div class="record">
23 26
         <ul class="recordList">
24
-          <li class="recordOne">123</li>
25
-          <li class="recordOne">123</li>
26
-          <li class="recordOne">哦驾驶的拉升的</li>
27
-          <li class="recordOne">哦驾驶的拉升的</li>
28
-          <li class="recordOne">asd</li>
27
+          <li
28
+            class="recordOne"
29
+            v-for="(item,index) in historyWord"
30
+            :key="index"
31
+            @click="toSearchPatient(item)"
32
+          >{{item}}</li>
29 33
         </ul>
30 34
       </div>
31 35
     </div>
32
-
33
-    <!-- <div class="searchList">
34
-      <van-tabs
35
-        v-model="active"
36
-        title-active-color="#000000"
37
-        title-inactive-color="#3C3C3C"
38
-      >
39
-        <van-tab title="全部">
40
-          <ul class="list">
41
-            <li class="searchOne">
42
-              <img src="../../assets/images/one.jpg" alt />
43
-              <span>爱听课的小</span>
44
-            </li>
45
-            <li class="searchOne">
46
-              <img src="../../assets/images/one.jpg" alt />
47
-              <span>爱听课的小</span>
48
-            </li>
49
-          </ul>
50
-        </van-tab>
51
-        <van-tab title="血透">血透</van-tab>
52
-        <van-tab title="慢病">慢病</van-tab>
53
-        <van-tab title="会员">会员</van-tab>
54
-        <van-tab title="电商">电商</van-tab>
55
-      </van-tabs>
56
-    </div> -->
57 36
   </div>
58 37
 </template>
59 38
 
@@ -65,35 +44,61 @@ export default {
65 44
       searchVal: "",
66 45
       active: 0,
67 46
       keyword: "",
68
-      value: ""
47
+      value: "",
48
+      patientList: [],
49
+      historyWord: []
69 50
     };
70 51
   },
71 52
   methods: {
72
-    SaveSearch() {
73
-      SaveSearch(this.searchVal).then(response => {});
74
-    },
75
-    watchNum() {
76
-      console.log(this.searchVal);
77
-    },
78 53
     toHomeIndex() {
79 54
       this.$router.push({ path: "/homeIndex" });
80 55
     },
81 56
     toSearchPatient(val) {
57
+      let searchWord = localStorage.getItem("searchWord");
58
+      if (searchWord == null) {
59
+        localStorage.setItem("searchWord", val);
60
+      } else {
61
+        let arr = localStorage.getItem("searchWord");
62
+        arr = arr.split(",");
63
+        if (arr.indexOf(val) != -1) {
64
+          arr = arr;
65
+        } else {
66
+          arr.unshift(val);
67
+        }
68
+        self.historyWord = arr;
69
+        localStorage.setItem("searchWord", self.historyWord);
70
+      }
71
+
82 72
       toSearchPatient(val).then(response => {
83 73
         if (response.data.state === 1) {
84 74
           var patient = response.data.data.patient;
85 75
           console.log("patient", patient);
76
+          this.patientList = patient;
77
+          this.historyWord = localStorage.getItem("searchWord");
78
+          this.historyWord = this.historyWord.split(",");
86 79
         }
87 80
       });
81
+    },
82
+    toPatient(id) {
83
+      this.$router.push({ path: "/patientdetail?patientid=" + id });
84
+    },
85
+    deteleHistory() {
86
+      this.historyWord = [];
87
+      localStorage.removeItem("searchWord");
88 88
     }
89 89
   },
90
-  created() {}
90
+  created() {
91
+    this.historyWord = localStorage.getItem("searchWord");
92
+    this.historyWord = this.historyWord.split(","); //将字符串转成数组
93
+    console.log();
94
+  }
91 95
 };
92 96
 </script>
93 97
 
94 98
 <style lang="scss" scoped>
95 99
 .page_search {
96 100
   overflow: hidden;
101
+  overflow-y: auto;
97 102
   height: 100%;
98 103
   .header {
99 104
     height: 2.5rem;
@@ -102,6 +107,7 @@ export default {
102 107
     border-bottom: 1px solid #f4f4f4;
103 108
     display: flex;
104 109
     align-items: center;
110
+    background: #fff;
105 111
     .icon-zuojiantou {
106 112
       float: left;
107 113
       width: 2.5rem;
@@ -175,4 +181,7 @@ export default {
175 181
     }
176 182
   }
177 183
 }
184
+::-webkit-scrollbar {
185
+  width: 0;
186
+}
178 187
 </style>