Search.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div class="searchWrap">
  3. <div class="searchTop">
  4. <div class="iptWrap">
  5. <img
  6. class="searchImg"
  7. src="../images/searchB.png"
  8. alt=""
  9. >
  10. <input
  11. type="text"
  12. autofocus
  13. placeholder="请搜索"
  14. v-model="searchVal"
  15. >
  16. </div>
  17. <span @click="search">取消</span>
  18. </div>
  19. <div class="searchList">
  20. <p
  21. class="waring"
  22. v-if="!searchVal&&searchLis.length==0"
  23. >请输入搜索内容</p>
  24. <p
  25. class="waring"
  26. v-if="searchVal&&searchLis.length==0"
  27. >暂无搜索结果</p>
  28. <ul>
  29. <li
  30. v-for="(item,idx) in searchLis"
  31. :key="item.conceptId+idx"
  32. @click="showDetil(item)"
  33. :style="{'borderBottom':(idx==searchLis.length-1)?'0':'1px solid #a8a8a8'}"
  34. ><img
  35. class="searchImgLis"
  36. src="../images/search.png"
  37. alt=""
  38. >{{item.name}}</li>
  39. </ul>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import api from '@utils/api.js';
  45. export default {
  46. props: ['age', 'sexType', 'chooseSymp'],
  47. data() {
  48. return {
  49. searchVal: '',
  50. searchLis: []
  51. }
  52. },
  53. watch:{
  54. searchVal(curVal, oldVal) {
  55. if (curVal.trim() == "") {
  56. this.searchVal = "";
  57. this.searchLis = [];
  58. return;
  59. }
  60. if (curVal != "" && curVal != oldVal) {
  61. this.searchList()
  62. }
  63. }
  64. },
  65. methods: {
  66. showDetil(item) {
  67. this.$emit('showDetil', item,true)
  68. // this.$emit('search', false)
  69. },
  70. search() {
  71. this.$emit('search', false)
  72. },
  73. searchList() {
  74. let tmpArr = [], chooseSymp = this.chooseSymp;
  75. for (let i = 0; i < chooseSymp.length; i++) {
  76. tmpArr.push(chooseSymp[i].conceptId)
  77. }
  78. const param = {
  79. "age": this.age,
  80. "inputIds": tmpArr,
  81. "inputStr": this.searchVal,
  82. "sexType": this.sexType
  83. }
  84. api.getTagInfos(param).then((res) => {
  85. const result = res.data;
  86. console.log(result)
  87. if (result.code == 0) {
  88. this.searchLis = result.data
  89. }
  90. })
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="less" scoped>
  96. .searchWrap {
  97. position: fixed;
  98. height: 100%;
  99. width: 100%;
  100. top: 0;
  101. left: 0;
  102. z-index: 55;
  103. background-color: #ededed;
  104. }
  105. .searchTop {
  106. padding: 0.15rem 0.4rem;
  107. padding-right: 1.2rem;
  108. background-color: #ededed;
  109. box-sizing: border-box;
  110. position: absolute;
  111. width: 100%;
  112. top: 0;
  113. z-index: 999;
  114. span {
  115. position: absolute;
  116. right: 0.32rem;
  117. top: 0.32rem;
  118. font-size: 0.3rem;
  119. color: #666666;
  120. }
  121. }
  122. .iptWrap {
  123. height: 0.74rem;
  124. border-radius: 0.37rem;
  125. background-color: #fff;
  126. overflow: hidden;
  127. padding: 0.16rem 0.3rem 0.16rem 0.75rem;
  128. box-sizing: border-box;
  129. width: 100%;
  130. position: relative;
  131. .searchImg {
  132. width: 0.44rem;
  133. height: 0.44rem;
  134. position: absolute;
  135. left: 0.2rem;
  136. top: 0.14rem;
  137. }
  138. input {
  139. width: 100%;
  140. height: 0.42rem;
  141. font-size: 0.3rem;
  142. line-height: 0.42rem;
  143. }
  144. }
  145. .searchList {
  146. overflow: scroll;
  147. position: absolute;
  148. -webkit-overflow-scrolling: touch;
  149. top: 0;
  150. left: 0;
  151. padding-top: 1.04rem;
  152. height: 100%;
  153. width: 100%;
  154. background-color: #ededed;
  155. .waring {
  156. padding-left: 0.5rem;
  157. margin-top: 0.2rem;
  158. }
  159. ul {
  160. padding: 0 0.4rem;
  161. box-sizing: border-box;
  162. background-color: #fff;
  163. }
  164. li {
  165. height: 1rem;
  166. line-height: 1rem;
  167. padding: 0 0.4rem;
  168. border-bottom: 1px solid #a8a8a8;
  169. box-sizing: border-box;
  170. .searchImgLis {
  171. width: 0.44rem;
  172. height: 0.44rem;
  173. float: left;
  174. margin-top: 0.26rem;
  175. margin-right: 0.15rem;
  176. }
  177. }
  178. }
  179. </style>