search-record.vue 3.7 KB

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