search.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="search1">
  3. <view class="search-box u-flex u-row-between">
  4. <u-icon name="search" color="#CCCCCC" size="36"></u-icon>
  5. <input type="text" placeholder="搜索楼盘" class="input" v-model="keyword1">
  6. <text class="text" @click="tosearch">搜索</text>
  7. </view>
  8. <view class="lishi-box" v-if="list.length == 0">
  9. <view class="lishi-title">
  10. 历史搜索
  11. </view>
  12. <view class="u-flex u-flex-wrap">
  13. <text v-for="(item,index) in lishilist" :key="index" class="lishi-item" @click="lishisearch(item)">{{item}}</text>
  14. </view>
  15. <!-- <view class="news-item u-flex u-row-between" v-for="(item,index) in 2" :key="index" @click="toinfo">
  16. <image src="https://dummyimage.com/140x110" class="image" mode=""></image>
  17. <view class="item-right">
  18. <view class="name u-line-2">
  19. 已取证!差价1.5W+/㎡!戏水池、会所、嵌入式冰箱,冠军推荐!
  20. </view>
  21. <view class="u-flex u-row-between">
  22. <view class="time u-flex">
  23. <u-icon name="eye-fill" color="#CCCCCC" size="26"></u-icon>
  24. <text class="look">12345人浏览</text>
  25. <text class="time-text">2023-03-25</text>
  26. </view>
  27. <view class="user u-flex">
  28. <image src="https://dummyimage.com/24x24" class="head" mode=""></image>
  29. <text class="user-name">温州购房通</text>
  30. </view>
  31. </view>
  32. </view>
  33. </view> -->
  34. </view>
  35. <view class="list-box" style="padding: 0 24rpx;">
  36. <view class="list-item" v-for="(item,index) in list" :key="index">
  37. <gf-goods :data="item" type="1"></gf-goods>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import { mapState } from "vuex"
  44. export default {
  45. data() {
  46. return {
  47. lishilist: [],
  48. keyword1: '',
  49. keyword: '',
  50. page: 1,
  51. list: []
  52. }
  53. },
  54. onLoad() {
  55. this.lishilist = uni.getStorageSync("lishi") || []
  56. },
  57. onShow() {
  58. uni.setNavigationBarTitle({
  59. title: this.config.store_title
  60. })
  61. },
  62. computed: {
  63. ...mapState(['config', 'city'])
  64. },
  65. onReachBottom() {
  66. if(this.list.length % 20 == 0){
  67. this.page++
  68. this.getlist()
  69. }
  70. },
  71. methods: {
  72. lishisearch(item){
  73. this.keyword = item
  74. this.keyword1 = item
  75. this.page = 1
  76. this.list = []
  77. this.getlist()
  78. },
  79. tosearch() {
  80. this.keyword = this.$u.trim(this.keyword1)
  81. this.setlishi()
  82. this.getlist()
  83. },
  84. setlishi() {
  85. if (this.keyword) {
  86. if (this.lishilist.indexOf(this.keyword) == -1) {
  87. this.lishilist.unshift(this.keyword)
  88. uni.setStorageSync("lishi", this.lishilist)
  89. }
  90. }
  91. },
  92. getlist() {
  93. this.$u.post('/api/Index/property_list', {
  94. page: this.page,
  95. page_num: 20,
  96. keyword: this.keyword
  97. }).then(res => {
  98. if (this.page == 1) {
  99. this.list = res.data
  100. } else {
  101. this.list = this.list.concat(res.data)
  102. }
  103. })
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss">
  109. .search1 {
  110. .lishi-box {
  111. padding: 0 24rpx;
  112. .news-item {
  113. padding: 32rpx 0;
  114. border-bottom: 2rpx solid #CCCCCC;
  115. .image {
  116. width: 140rpx;
  117. height: 110rpx;
  118. border-radius: 10rpx;
  119. }
  120. .item-right {
  121. flex: 1;
  122. margin-left: 14rpx;
  123. .name {
  124. font-size: 24rpx;
  125. font-family: PingFangSC-Regular, PingFang SC;
  126. font-weight: 400;
  127. color: #333333;
  128. margin-bottom: 16rpx;
  129. }
  130. .user {
  131. .user-name {
  132. font-size: 18rpx;
  133. font-family: PingFangSC-Regular, PingFang SC;
  134. font-weight: 400;
  135. color: #999999;
  136. }
  137. .head {
  138. width: 24rpx;
  139. height: 24rpx;
  140. border-radius: 100rpx;
  141. margin-right: 10rpx;
  142. }
  143. }
  144. .time {
  145. font-size: 18rpx;
  146. font-weight: 400;
  147. color: #999999;
  148. .look {
  149. margin: 0 10rpx;
  150. }
  151. }
  152. }
  153. }
  154. .lishi-item {
  155. line-height: 44rpx;
  156. background: #E5E5E5;
  157. border-radius: 22rpx;
  158. padding: 0 30rpx;
  159. font-size: 18rpx;
  160. font-family: PingFangSC-Regular, PingFang SC;
  161. font-weight: 400;
  162. color: #999999;
  163. margin-bottom: 20rpx;
  164. margin-right: 20rpx;
  165. }
  166. .lishi-title {
  167. font-size: 24rpx;
  168. font-family: PingFangSC-Medium, PingFang SC;
  169. font-weight: 500;
  170. color: #333333;
  171. margin-bottom: 14rpx;
  172. }
  173. }
  174. .search-box {
  175. width: 702rpx;
  176. height: 72rpx;
  177. background: #FFFFFF;
  178. border-radius: 20rpx;
  179. margin: 24rpx auto;
  180. padding-left: 24rpx;
  181. border: 2rpx solid #CCCCCC;
  182. .input {
  183. flex: 1;
  184. margin: 0 10rpx;
  185. }
  186. .text {
  187. padding: 0 24rpx;
  188. border-left: 1rpx solid #E5E7ED;
  189. line-height: 36rpx;
  190. font-size: 28rpx;
  191. font-family: PingFangSC-Medium, PingFang SC;
  192. font-weight: 500;
  193. color: #1E7DFF;
  194. }
  195. }
  196. }
  197. </style>