search-record.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="seacrh-record-index iPhone-bottom flex-common-css box-border-box">
  3. <view class="seacrh-bg"></view>
  4. <Nav title='搜索' bgckgroundBox='transparent'></Nav>
  5. <view class="s-input">
  6. <!-- <view class="input-icon">
  7. <uni-icons type="search" size="18" color="#999"></uni-icons>
  8. </view> -->
  9. <image class="wh32" src="@/static/img/index/ss.png" mode=""></image>
  10. <input v-model="search" type="text" placeholder="店铺名称或者商品名称">
  11. <view class="input-buttom fs-28 fc-f fw-500" @click="toList()">搜索</view>
  12. </view>
  13. <view class="scroll-view-css bgc-f seacrh-info box-border-box p-32">
  14. <view class="flex-justify-space mb-32">
  15. <view class="fs-32 fw-600 fc-3">搜索历史</view>
  16. <view class="align-items-center" v-if="list.length > 0 && historyType">
  17. <view @click="isOpen=!isOpen" class="">{{!isOpen?'收起':'展开'}}</view>
  18. <view @click="isOpen=!isOpen" :class="!isOpen?'down':'up'">
  19. <uni-icons type="right" size="14" color="#999"></uni-icons>
  20. </view>
  21. <view class="view-x"></view>
  22. <uni-icons @click="delList()" type="trash" size="18" color="#999"></uni-icons>
  23. </view>
  24. </view>
  25. <view id='' :class="isOpen?'hide-h':''" class="flex-wrap-wrap mb-50 search-history" v-if="list.length > 0">
  26. <view class="fs-28 list-item text-overflow-ellipsis-one" @click="toList(item)" v-for="(item,i) in list"
  27. :key="i">{{item}}</view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import tools from "@/service/tools";
  34. import {
  35. getSearchList,
  36. delSearch
  37. } from '@/api/goods.js';
  38. export default {
  39. data() {
  40. return {
  41. search: '',
  42. isOpen: false,
  43. list: [],
  44. historyType: false
  45. }
  46. },
  47. onShow() {
  48. this.getList()
  49. },
  50. mounted() {},
  51. methods: {
  52. history() {
  53. // uni.createSelectorQuery().select('.search-history').boundingClientRect(data => {
  54. // if (data.height > 116) {
  55. // this.historyType = true
  56. // }
  57. // console.log(this.historyType);
  58. // }).exec()
  59. const query = uni.createSelectorQuery().in(this)
  60. query
  61. .select('.search-history')
  62. .boundingClientRect(data => {
  63. console.log(data.height)
  64. })
  65. .exec();
  66. },
  67. getList() {
  68. getSearchList().then((res) => {
  69. if (res.code === 1) {
  70. this.list = res.data.my_search;
  71. }
  72. })
  73. },
  74. toList(name) {
  75. let search = '';
  76. if (name) {
  77. search = name;
  78. } else {
  79. search = this.search;
  80. }
  81. if (!search) {
  82. return tools.error('请输入搜索内容')
  83. }
  84. uni.navigateTo({
  85. url: "pages/index/search-list?search=" + search
  86. })
  87. },
  88. delList() {
  89. delSearch().then((res) => {
  90. if (res.code === 1) {
  91. tools.success('删除成功');
  92. this.list = [];
  93. }
  94. })
  95. },
  96. },
  97. }
  98. </script>
  99. <style scoped lang="scss">
  100. .seacrh-record-index {
  101. position: relative;
  102. .hide-h {
  103. height: 232rpx !important;
  104. overflow: hidden !important;
  105. }
  106. .down {
  107. transform: rotate(-90deg);
  108. transition: all 0.5s;
  109. }
  110. .up {
  111. transform: rotate(90deg);
  112. transition: all 0.5s;
  113. }
  114. .view-x {
  115. width: 2rpx;
  116. height: 20rpx;
  117. background-color: #eee;
  118. margin: 0 24rpx;
  119. }
  120. .find-item {
  121. width: 48%;
  122. text-align: left;
  123. }
  124. .list-item {
  125. max-height: 688rpx;
  126. min-width: 10rpx;
  127. height: 56rpx;
  128. line-height: 56rpx;
  129. background: #F7F8FC;
  130. border-radius: 200rpx;
  131. margin: 0 8rpx 32rpx 0;
  132. box-sizing: border-box;
  133. padding: 0 24rpx;
  134. }
  135. .seacrh-bg {
  136. position: absolute;
  137. top: 0;
  138. left: 0;
  139. width: 100%;
  140. height: 376rpx;
  141. filter: blur(80rpx);
  142. background-image: linear-gradient(to right, #C9F7FC, #F9F6E0, #F6F5F3);
  143. z-index: -1;
  144. }
  145. .s-input {
  146. margin-top: 24rpx;
  147. width: 100%;
  148. height: 72rpx;
  149. padding: 0 24rpx;
  150. box-sizing: border-box;
  151. position: relative;
  152. .wh32 {
  153. position: absolute;
  154. left: 48rpx;
  155. top: 20rpx;
  156. width: 32rpx;
  157. height: 32rpx;
  158. }
  159. input {
  160. font-size: 32rpx;
  161. width: 100%;
  162. height: 72rpx;
  163. background: #FFFFFF;
  164. border-radius: 200rpx;
  165. box-sizing: border-box;
  166. padding: 0 126rpx 0 78rpx;
  167. }
  168. .input-buttom {
  169. width: 120rpx;
  170. height: 60rpx;
  171. background: linear-gradient(90deg, #57CAFF 0%, #41ABF5 100%);
  172. border-radius: 200rpx;
  173. text-align: center;
  174. line-height: 60rpx;
  175. position: absolute;
  176. right: 30rpx;
  177. top: 6rpx;
  178. }
  179. }
  180. .seacrh-info {
  181. margin-top: 20rpx;
  182. border-radius: 24rpx 24rpx 0rpx 0rpx;
  183. }
  184. }
  185. </style>