海南旅游项目 前端仓库
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.

110 lines
2.3 KiB

5 years ago
  1. <template>
  2. <view>
  3. <view class="lf-p-t-30 lf-p-r-30 lf-flex lf-w-100 lf-bg-white">
  4. <u-icon name="search" class="search-icon"></u-icon>
  5. <input class="rom-search" type="text" v-model="searchContent" @confirm="setSearch()" placeholder="请输入商品名称"/>
  6. </view>
  7. <view class="history-card" v-if="historySearch != ''">
  8. <view class="lf-font-28 lf-color-gray lf-p-b-30 lf-p-l-30">
  9. 历史搜索
  10. </view>
  11. <view class="lf-flex lf-flex-wrap lf-p-l-20 lf-p-r-20">
  12. <view class="search-tag" v-for="i of historySearch" @click="gosearch(i)">{{i}}</view>
  13. </view>
  14. </view>
  15. <view class="history-card" v-else>
  16. <view class="lf-font-28 lf-color-gray lf-p-b-30 lf-p-l-30">
  17. 历史搜索
  18. </view>
  19. <view class="lf-flex lf-flex-wrap lf-p-l-30 lf-p-r-20">
  20. 暂无历史搜索记录
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. let list = []
  27. export default {
  28. data() {
  29. return {
  30. historySearch: [],
  31. searchContent: ''
  32. }
  33. },
  34. methods: {
  35. gosearch(i) {
  36. uni.navigateTo({
  37. url: '/pages/search/searchList?serach_content=' + i
  38. })
  39. },
  40. setSearch() {
  41. console.log(this.searchContent)
  42. // let list = [];
  43. list.push(this.searchContent)
  44. uni.navigateTo({
  45. url: '/pages/search/searchList?serach_content=' + this.searchContent
  46. })
  47. setTimeout(() => {
  48. this.historySearch = list
  49. uni.setStorageSync('historySearch',this.historySearch)
  50. },1000)
  51. }
  52. },
  53. onShow() {
  54. this.historySearch = uni.getStorageSync('historySearch') || [];
  55. console.log('初始',this.historySearch)
  56. }
  57. }
  58. </script>
  59. <style>
  60. page {
  61. background-color: #F8F8F8;
  62. }
  63. </style>
  64. <style lang="scss" scoped>
  65. .history-card {
  66. background-color: white;
  67. width: 100%;
  68. height: 100%;
  69. padding: 30rpx 0;
  70. }
  71. .search-tag {
  72. padding: 10rpx 20rpx;
  73. border-radius: 30rpx;
  74. background: #f5f5f5;
  75. color: #222;
  76. display: flex;
  77. align-items: center;
  78. text-align: center;
  79. width: max-content;
  80. height: max-content;
  81. font-size: 28rpx;
  82. margin-right: 20rpx;
  83. &:nth-child(5n) {
  84. margin-right: 0;
  85. }
  86. &:nth-child(n + 6) {
  87. margin-top: 20rpx;
  88. }
  89. }
  90. .search-icon {
  91. position: relative;
  92. bottom: 0;
  93. left: 54rpx;
  94. }
  95. /deep/.input-placeholder{
  96. color: #777;
  97. font-size: 28rpx;
  98. }
  99. .rom-search {
  100. width: 686rpx;
  101. height: 60rpx;
  102. background: #f5f5f5;
  103. border-radius: 30rpx;
  104. padding-left: 74rpx;
  105. font-size: 28rpx;
  106. }
  107. </style>