You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
5.4 KiB

6 months ago
  1. <template>
  2. <view>
  3. <view class="top">
  4. <view class="input-box">
  5. <input
  6. placeholder="请输入关键字"
  7. placeholder-style="color:#c0c0c0;"
  8. v-model="searchValue"
  9. @confirm="toSearch()"
  10. value="searchValue"
  11. />
  12. <cjl-icon @touch="toSearch()">&#xe60b;</cjl-icon>
  13. </view>
  14. </view>
  15. <view class="history">
  16. <view>历史记录</view>
  17. <view class="icon shanchu" @click="clean()"></view>
  18. </view>
  19. <view class="item">
  20. <view class="itemcontent" v-for="item in historyList" :key='item' @click="addkey(item)">{{item}}</view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. loading: false,
  29. showValue: 'name',
  30. searchValue: '',
  31. historyList: [],
  32. type:0,
  33. }
  34. },
  35. onShow(){
  36. this.historyList=uni.getStorageSync('history')
  37. },
  38. onLoad(e){
  39. if(e.type==1){
  40. this.type=1;
  41. }
  42. },
  43. methods: {
  44. toSearch(){
  45. let getkeyword=this.searchValue;
  46. let getarrfromsys=uni.getStorageSync('history');
  47. if(getkeyword!=''){
  48. // if(getarrfromsys.length>0){
  49. // getarrfromsys.push(getkeyword)
  50. // }else{
  51. // getarrfromsys=[];
  52. // getarrfromsys.push(getkeyword)
  53. // }
  54. if(getarrfromsys.length>0){
  55. if (getarrfromsys.length >= 30) {
  56. getarrfromsys.splice(0, getarrfromsys.length-30)
  57. // 如果数组长度超过30个数据,删除最早添加的数据
  58. // getarrfromsys.shift();
  59. }
  60. getarrfromsys.push(getkeyword)
  61. }else{
  62. getarrfromsys=[];
  63. getarrfromsys.push(getkeyword)
  64. }
  65. uni.setStorageSync('history',getarrfromsys);
  66. uni.navigateTo({
  67. url:'../product/product?keyword='+getkeyword
  68. })
  69. if(this.type==1){
  70. uni.navigateTo({
  71. url:'../product/productjiad?keyword='+keyword
  72. })
  73. }else{
  74. uni.navigateTo({
  75. url:'../product/product?keyword='+keyword
  76. })
  77. }
  78. }else{
  79. uni.showToast({
  80. title:'请输入关键字',icon:'none'
  81. })
  82. }
  83. this.historyList=uni.getStorageSync('history');
  84. },
  85. addkey(keyword){
  86. if(this.type==1){
  87. uni.navigateTo({
  88. url:'../product/productjiad?keyword='+keyword
  89. })
  90. }else{
  91. uni.navigateTo({
  92. url:'../product/product?keyword='+keyword
  93. })
  94. }
  95. },
  96. clean(){
  97. uni.setStorageSync('history',[])
  98. this.historyList=[]
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. .top{
  105. width: 100%;
  106. display: flex;
  107. justify-content: center;
  108. align-items: center;
  109. .input-box {
  110. width: 70%;
  111. height: 60upx;
  112. background-color: #f5f5f5;
  113. border-radius: 30upx;
  114. position: relative;
  115. display: flex;
  116. align-items: center;
  117. justify-content: space-between;
  118. padding-right: 15upx;
  119. input {
  120. padding-left: 30upx;
  121. height: 28upx;
  122. font-size: 28upx;
  123. }
  124. margin-bottom: 15upx;
  125. }
  126. }
  127. @font-face {font-family:"HMfont-home";src:url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAYcAAsAAAAAC7AAAAXPAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDMgqKTIgRATYCJAMUCwwABCAFhG0HShufCciemjxtEyiE0MJUUYjN7gIePI911ftJqrY61RxhAeHWc1taR0BXaRAvS0cGxd7FXycwvQF4WLxnP3czaSZwFdHkmjTO77s3Gq8T2hKtbaWhlUQDcsL+/+Ne1UzbGprPvsVxjwUYCnAsmHRvDnUssKU9L4hXRPoIr6uBbOALl0MAS25cYBo2vnuELAZbIlAwchg7gGxBi+mgCp7CbTjUIPNx8NQMdRvAvOj75TNe4oHC0di7th18Poajd/VebNbx/+gZoODNZwbEo0ADJQEYkPGN1pEkEnHJSGqbliepC2DxUKi5FjV4MezF5v+HTHgiuXWsoGb5wzMgLrY0CPi6MQPvIj0ECt5FI9Dwrg6BwLtl/CdG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enqYu3JHobtpKAm5KaAX9q76sXoK+D99XnsCINpCVsB/+oHu/rvYjG+TOQ/62Nb86vnfh5kHD1Lmofs/A00KH24ZZN6vgEccMYbA1jlGa/e4Wq4j5YGAzxX/A9/y2Xcm8GAeeTKZ9yOTJ2egyEU2aDwKog2+JDj4VAQXjzpgKUH80T6JdCGBmABQnOEMhCgbQRHmHGiinEcb/H1wSOE9uERFg6WzJJ7Sp7AMsw3G08CiMZb3xroKVWFcg5WPC++JtaWBkRdE9GcyTD6Anm4e5cQlKWTMsUfXHuxmt24MVndRZYxjVyNJUrFTF1WgkbVa283Sdtzdq5vWtFrRIkOeBhgQAyyIMUg5PkgdI1QUmGC6Rb7y9fcQLDYSA4yOjjrnM4SBCT8/4okbHgT0pVQhddxLeVccWDbphmEGpFrMV5FB4tBMSE5UBenUvJEAMcJildoRYY0d3HFSNVW6ur5cfox5f8Gu9qkdUaLFiCMugWnDTI73+IGaGO6Lk55LyUwYCpERZwMAAA==') format('woff2');}
  128. .icon {
  129. font-family:"HMfont-home" !important;
  130. font-size:40upx;
  131. font-style:normal;
  132. color:#94AFCE;
  133. &.shanchu {
  134. &:before{content:"\e6a4";}
  135. }
  136. }
  137. .history{
  138. display: flex;
  139. justify-content: space-between;
  140. margin: 20upx 40upx;
  141. font-size: 35upx;
  142. color:gray;
  143. }
  144. .item{
  145. display: flex;
  146. width: 100%;
  147. margin: 20upx;
  148. justify-content: baseline;
  149. flex-wrap:wrap;
  150. .itemcontent{
  151. color: #A6A6A6;
  152. border-radius: 10upx;
  153. padding: 5upx 15upx;
  154. background-color: #F7F7F7;
  155. margin: 10upx;
  156. }
  157. }
  158. </style>