search.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="content">
  3. <fxyk-navbar isSearch iconColor="#000"></fxyk-navbar>
  4. <view class="d-flex a-center j-sb u-p-38" style="margin-top:125rpx;margin-bottom:50rpx">
  5. <view class="word-one">历史搜索</view>
  6. <view @click="showModal = true"><u-image width="31rpx" height="35rpx" src="/static/images/waste.png" :fade="false"></u-image></view>
  7. </view>
  8. <view style="margin-top:-20rpx">
  9. <u-tag v-for="(item,index) in historySearchInFive" style="width:150rpx" :key="index" :text="item" class="u-m-l-80 u-m-b-35 over_style" type="info" border-color="transparent" shape="circle" @click="show_text(item)" />
  10. <u-tag v-if="historySearch.length > 5" :text="icon" type="info" border-color="transparent" style="position:relative;top:-47rpx;margin-left:122rpx;" shape="circle" @click="show_search_data" />
  11. <template v-if="show">
  12. <u-tag v-for="(item,index) in historySearchOverFive" style="width:150rpx" :key="item" :text="item" class="u-m-l-80 u-m-b-35 over_style" type="info" border-color="transparent" shape="circle" @click="show_text(item)" />
  13. </template>
  14. </view>
  15. <u-modal v-model="showModal" content="是否清空历史记录" :isBgColor="false" show-cancel-button @confirm="clear_history_data"></u-modal>
  16. </view>
  17. </template>
  18. <script>
  19. import { mapGetters, mapMutations,mapActions } from 'vuex'
  20. export default {
  21. data() {
  22. return {
  23. icon: "∨",
  24. show: false,
  25. showModal: false,
  26. }
  27. },
  28. // 监听页面卸载
  29. onUnload() {
  30. this.updateSearchItemData()
  31. },
  32. computed: {
  33. ...mapGetters(['historySearch', 'historySearchInFive', 'historySearchOverFive'])
  34. },
  35. methods: {
  36. ...mapMutations(['updateSearchItemData', 'clearSearchData']),
  37. // 显示更多数据
  38. show_search_data() {
  39. this.show = !this.show
  40. this.icon = this.icon === '∨' ? '∧' : '∨'
  41. },
  42. // 导航栏内显示数据
  43. show_text(value) {
  44. this.updateSearchItemData(value)
  45. },
  46. // 清空历史记录
  47. clear_history_data() {
  48. uni.removeStorageSync('searchData')
  49. this.clearSearchData([])
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. page {
  56. width: 100%;
  57. height: 100%;
  58. }
  59. .content {
  60. width: 100%;
  61. height: 100%;
  62. min-height: 100vh;
  63. background-color: $yk-bg-color;
  64. }
  65. .icon-style {
  66. width:52rpx;
  67. height:52rpx;
  68. border-radius: 50%;
  69. background-color: $yk-gray-color;
  70. margin-top: -35rpx;
  71. margin-left: 110rpx;
  72. }
  73. .cell-item {
  74. width: 125rpx;
  75. height: 50rpx;
  76. border: 1px solid $yk-gray-color;
  77. border-radius: 17rpx;
  78. background-color: $yk-gray-color;
  79. }
  80. .word-one {
  81. font-size: 29rpx;
  82. font-family: SimSun;
  83. font-weight: 400;
  84. line-height: 40rpx;
  85. color: #666666;
  86. }
  87. .word-two {
  88. font-size: 25rpx;
  89. font-family: SimSun;
  90. font-weight: 400;
  91. line-height: 33rpx;
  92. color: #666666;
  93. }
  94. .over_style {
  95. width: 150rpx;
  96. overflow: hidden;
  97. white-space: nowrap;
  98. text-overflow: ellipsis;
  99. text-align: center;
  100. }
  101. </style>