search.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="content">
  3. <view class="top-cont" >
  4. <view class="status_bar" :style="{height: statusBarHeight}"></view>
  5. <view class="inner">
  6. <image class="back" src="../../static/images/icon_back_b.png" mode="heightFix" @click="back()"></image>
  7. <view class="screen-box">
  8. <image class="search" src="../../static/images/icon_search.png" mode=""></image>
  9. <input type="text" v-model="searchKey" placeholder="搜索医生/疾病/知识" @confirm="toSearchList(searchKey)" placeholder-style="font-size:26rpx;color:#DADADA;">
  10. <text class="text" @click="toSearchList">搜索</text>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="cont-inner">
  15. <!-- 搜索历史 -->
  16. <view class="search-info">
  17. <view class="title-box">
  18. <view class="title">搜索历史</view>
  19. <view class="btn" @click="clearHistory()">清除搜索历史</view>
  20. </view>
  21. <view class="search-list">
  22. <view @click="goSearchList(item)" v-for="(item,index) in searchHistory" :key="index" class="item ellipsis">
  23. <text class="text">{{ item }}</text>
  24. </view>
  25. <!-- <view class="item ellipsis">
  26. <text class="text">名字很长很长很长很长很长很长很长很长</text>
  27. </view> -->
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {getConfigByKey} from '@/api/common'
  35. export default {
  36. data() {
  37. return {
  38. searchHistory:[],
  39. searchKey:"",
  40. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  41. }
  42. },
  43. onLoad() {
  44. this.searchHistory=this.$getHisSearch();
  45. },
  46. methods: {
  47. clearHistory() {
  48. this.$clearHisSearch();
  49. this.searchHistory=this.$getHisSearch();
  50. },
  51. back() {
  52. uni.navigateBack({
  53. delta: 1
  54. })
  55. },
  56. goSearchList(key){
  57. uni.navigateTo({
  58. url: '/pages_doctor/doctorList?keyword='+key
  59. })
  60. },
  61. toSearchList() {
  62. if(this.searchKey!=""){
  63. this.$addHisSearch(this.searchKey);
  64. }
  65. uni.navigateTo({
  66. url: '/pages_doctor/doctorList?keyword='+this.searchKey
  67. })
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="scss">
  73. page{
  74. height: 100%;
  75. }
  76. </style>
  77. <style scoped lang="scss">
  78. .content{
  79. height: 100%;
  80. display: flex;
  81. flex-direction: column;
  82. .top-cont{
  83. background-color: #f6f6f6;
  84. .inner{
  85. height: 88upx;
  86. display: flex;
  87. align-items: center;
  88. padding-right: 240upx;
  89. padding-left: 30upx;
  90. .back{
  91. width: 34upx;
  92. height: 34upx;
  93. margin-right: 24upx;
  94. }
  95. .screen-box{
  96. flex: 1;
  97. height: 60upx;
  98. border-radius: 30upx;
  99. background-color: #fff;
  100. display: flex;
  101. align-items: center;
  102. justify-content: space-between;
  103. padding: 0 20upx;
  104. .search{
  105. width: 30upx;
  106. height: 30upx;
  107. margin-right: 12upx;
  108. }
  109. input{
  110. flex: 1;
  111. font-size: 26upx;
  112. color: #000;
  113. }
  114. .text{
  115. font-size: 26upx;
  116. color: #000;
  117. margin-left: 12upx;
  118. }
  119. }
  120. }
  121. }
  122. .cont-inner{
  123. flex: 1;
  124. background-color: #fff;
  125. border-radius: 20upx 20upx 0 0;
  126. padding: 0 25upx;
  127. .search-info{
  128. padding-top: 20upx;
  129. .title-box{
  130. padding: 20upx 0;
  131. display: flex;
  132. align-items: center;
  133. justify-content: space-between;
  134. .title{
  135. font-size: 28upx;
  136. color: #000;
  137. font-weight: bold;
  138. }
  139. .btn{
  140. font-size: 24upx;
  141. color: #575757;
  142. }
  143. }
  144. .search-list{
  145. display: flex;
  146. flex-wrap: wrap;
  147. .item{
  148. max-width: 250upx;
  149. height: 54upx;
  150. line-height: 54upx;
  151. padding: 0 20upx;
  152. border-radius: 27upx;
  153. margin: 0 20upx 15upx 0;
  154. background-color: #f4f4f4;
  155. display: flex;
  156. align-items: center;
  157. font-size: 22upx;
  158. &.hot{
  159. background-color: #fef0f0;
  160. }
  161. .img{
  162. width: 26upx;
  163. height: 26upx;
  164. margin-right: 10upx;
  165. }
  166. .text{
  167. font-size: 22upx;
  168. color: #363636;
  169. }
  170. }
  171. }
  172. }
  173. }
  174. }
  175. </style>