search.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="content">
  3. <u-navbar
  4. title="搜索"
  5. :autoBack="true"
  6. bgColor="transparent"
  7. :placeholder="true"
  8. :fixed="false"
  9. >
  10. </u-navbar>
  11. <u-input placeholder="任务标题、用户ID、任务ID" fontSize="14" shape="circle"
  12. v-model="keyword" style="background-color: #fff;border: none;">
  13. <u-icon
  14. size="20"
  15. color="#303030"
  16. slot="prefix"
  17. name="search"
  18. ></u-icon>
  19. <template slot="suffix">
  20. <u-button
  21. @click="cancel"
  22. text="取消"
  23. type="primary"
  24. size="mini"
  25. style="width: 112rpx;height: 56rpx;font-size: 24rpx;"
  26. shape="circle"
  27. ></u-button>
  28. </template>
  29. </u-input>
  30. <template v-if="!keyword && searchList.length == 0">
  31. <view class="flex jc_between mgt-32 pdx-16">
  32. <view class="text-28 text-500">搜索历史</view>
  33. <u-icon
  34. size="18"
  35. color="#B9B9B9"
  36. name="trash"
  37. @click="delAllHistory"
  38. ></u-icon>
  39. </view>
  40. <view class="history_list pdx-16">
  41. <view class="item" v-for="(item,index) in list">
  42. <text @click="search(item)"> {{ item }}</text>
  43. <u-icon
  44. size="12"
  45. @click="delHistory(item,index)"
  46. color="#e2dcdc"
  47. name="close"
  48. class="mgl-10"
  49. ></u-icon>
  50. </view>
  51. </view>
  52. </template>
  53. <u-empty
  54. v-if="keyword && searchList.length == 0"
  55. marginTop="107"
  56. mode="data"
  57. text="您搜索的内容暂无"
  58. icon="/static/image/index/search_empty.png"
  59. >
  60. </u-empty>
  61. <view class="w flex1" v-if="searchList.length > 0">
  62. <scroll-view scroll-y class="scroll">
  63. <view v-for="item in 10" :key="item" class="bounty">
  64. <BountyItem class="mgb-10" :showTags="false"></BountyItem>
  65. </view>
  66. <view class="loading">上拉加载更多 ></view>
  67. </scroll-view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import BountyItem from "components/bountyItem.vue";
  73. export default {
  74. components: { BountyItem },
  75. data() {
  76. return {
  77. list:[
  78. '任务',
  79. '微信运营端口',
  80. '高效'
  81. ],
  82. keyword:'',// 搜索关键词
  83. searchList:[]
  84. }
  85. },
  86. onLoad() {
  87. },
  88. methods: {
  89. //搜索
  90. search(item){
  91. this.keyword = item
  92. if(this.keyword == '任务'){
  93. this.searchList = ['','','']
  94. }
  95. },
  96. //取消
  97. cancel(){
  98. this.keyword = ''
  99. this.searchList = []
  100. // uni.navigateBack()
  101. },
  102. //删除单个历史
  103. delHistory(item,index){
  104. uni.showToast({
  105. title:'删除成功',
  106. })
  107. this.list.splice(index,1)
  108. },
  109. //删除全部历史
  110. delAllHistory(item){
  111. uni.showModal({
  112. title: '提示',
  113. content: '是否确认删除全部搜索历史?',
  114. success: function (res) {
  115. if (res.confirm) {
  116. console.log('用户点击确定');
  117. uni.showToast({
  118. title:'删除成功',
  119. })
  120. this.list = []
  121. } else if (res.cancel) {
  122. console.log('用户点击取消');
  123. }
  124. }
  125. });
  126. },
  127. }
  128. }
  129. </script>
  130. <style scoped lang="scss">
  131. .content{
  132. height: 568rpx;
  133. padding: 32rpx;
  134. background: linear-gradient(to bottom, #ffe3d1, #fafafa);
  135. .history_list{
  136. display: flex;
  137. padding-top:24rpx;
  138. gap: 20rpx;
  139. .item{
  140. display: flex;
  141. height: 56rpx;
  142. line-height: 56rpx;
  143. background-color: #fff;
  144. border-radius: 64rpx;
  145. padding: 0 20rpx;
  146. color: #7E7E7E;
  147. font-size: 24rpx;
  148. }
  149. }
  150. .loading {
  151. text-align: center;
  152. margin-top: 50rpx;
  153. padding-bottom: 86rpx;
  154. font-size: 20rpx;
  155. font-weight: 400;
  156. color: #c0c0c0;
  157. }
  158. }
  159. </style>