history.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view>
  3. <u-navbar :border-bottom="false" :is-back="true" title="浏览记录">
  4. <view slot="right" class="u-nav-slot" @click="clearHistory">
  5. <u-icon name="trash"></u-icon>
  6. 清除
  7. </view>
  8. </u-navbar>
  9. <scroll-view scroll-y style="height: 100%;width: 100%;">
  10. <view class="page-box">
  11. <view v-if="houseHistory.length === 0">
  12. <view class="centre">
  13. <image :src="empty" mode=""></image>
  14. <view class="explain">
  15. 您还没有浏览过的房源
  16. <view class="tips">可以去逛逛</view>
  17. </view>
  18. <view class="btn" @click="goHome">首页</view>
  19. </view>
  20. </view>
  21. <view v-for="(item, index) in houseHistory" v-else :key="index" class="order"
  22. @click="clickImage(item.id)">
  23. <view class="top">
  24. <view class="left">
  25. <view class="store">{{ item.code }}</view>
  26. <u-icon :size="26" color="rgb(203,203,203)" name="arrow-right"></u-icon>
  27. </view>
  28. </view>
  29. <view class="item">
  30. <view class="left">
  31. <image :src="item.faceUrl" mode="aspectFill"></image>
  32. </view>
  33. <view class="content">
  34. <view class="title u-line-2">
  35. {{ item.villageName }}
  36. {{ item.type == '整租' ? item.houseNum + item.houseHall + item.toiletNum : item.roomType }}
  37. </view>
  38. <view class="price">¥{{ item.price }}</view>
  39. <view class="type">
  40. {{ item.type }} | {{ item.type == '整租' ? item.houseArea : item.roomArea }}㎡ | {{ item.decoration }}
  41. </view>
  42. </view>
  43. </view>
  44. <view class="bottom">
  45. <view class="evaluate btn" @click="clickImage(item.id)">查看</view>
  46. </view>
  47. </view>
  48. </view>
  49. </scroll-view>
  50. </view>
  51. </template>
  52. <script>
  53. import config from "@/common/config.js" // 全局配置文件
  54. export default {
  55. data() {
  56. return {
  57. empty: '/static/empty/default.png',
  58. houseHistory: uni.getStorageSync('houseHistory').reverse()
  59. };
  60. },
  61. onLoad() {
  62. },
  63. methods: {
  64. clickImage(houseId) {
  65. this.$u.route({
  66. url: '/pages/detail/detail',
  67. params: {
  68. houseId: houseId
  69. }
  70. })
  71. },
  72. goHome() {
  73. uni.switchTab({
  74. url: '/pages/index/index'
  75. })
  76. },
  77. clearHistory() {
  78. // 清除搜索记录
  79. uni.showModal({
  80. title: '提示',
  81. content: '是否清除浏览记录?',
  82. cancelText: '取消',
  83. confirmText: '确认',
  84. success: res => {
  85. if (res.confirm) {
  86. uni.removeStorageSync('houseHistory');
  87. this.houseHistory = []
  88. this.$mytip.toast('清除成功')
  89. }
  90. }
  91. });
  92. }
  93. }
  94. };
  95. </script>
  96. <style>
  97. /* #ifndef H5 */
  98. page {
  99. height: 100%;
  100. background-color: #f2f2f2;
  101. }
  102. /* #endif */
  103. </style>
  104. <style lang="scss" scoped>
  105. .u-nav-slot {
  106. color: $u-tips-color;
  107. font-weight: normal;
  108. font-size: 28 rpx;
  109. margin-right: 30 rpx;
  110. }
  111. .container {
  112. width: 100%;
  113. height: 100%;
  114. display: flex;
  115. justify-content: center;
  116. align-items: center;
  117. text-align: center;
  118. .empty {
  119. overflow: hidden;
  120. .tip {
  121. color: #909399;
  122. }
  123. .btn {
  124. color: #fff;
  125. background-color: #909399;
  126. width: 200 rpx;
  127. padding: 15 rpx 28 rpx;
  128. border-radius: 130 rpx;
  129. margin: 30 rpx 0 0 100 rpx;
  130. }
  131. }
  132. }
  133. .order {
  134. width: 710 rpx;
  135. background-color: #ffffff;
  136. margin: 20 rpx auto;
  137. border-radius: 20 rpx;
  138. box-sizing: border-box;
  139. padding: 20 rpx;
  140. font-size: 28 rpx;
  141. .top {
  142. display: flex;
  143. justify-content: space-between;
  144. .left {
  145. display: flex;
  146. align-items: center;
  147. .store {
  148. // margin: 0 10rpx;
  149. font-size: 32 rpx;
  150. }
  151. }
  152. .right {
  153. color: #2979ff;
  154. }
  155. }
  156. .item {
  157. display: flex;
  158. margin: 20 rpx 0 0;
  159. .left {
  160. margin-right: 30 rpx;
  161. image {
  162. width: 150 rpx;
  163. height: 150 rpx;
  164. border-radius: 10 rpx;
  165. }
  166. }
  167. .content {
  168. .title {
  169. font-weight: bold;
  170. font-size: 28 rpx;
  171. line-height: 50 rpx;
  172. }
  173. .price {
  174. margin: 10 rpx 0;
  175. font-size: 30 rpx;
  176. }
  177. .type {
  178. margin: 10 rpx 0;
  179. font-size: 24 rpx;
  180. color: $u-tips-color;
  181. }
  182. }
  183. }
  184. .bottom {
  185. display: flex;
  186. // margin-top: 40rpx;
  187. padding: 0 10 rpx;
  188. justify-content: flex-end;
  189. align-items: center;
  190. .btn {
  191. margin-left: 20 rpx;
  192. line-height: 52 rpx;
  193. width: 160 rpx;
  194. border-radius: 26 rpx;
  195. border: 2 rpx solid $u-border-color;
  196. font-size: 26 rpx;
  197. text-align: center;
  198. color: $u-type-info-dark;
  199. }
  200. .evaluate {
  201. color: $u-tips-color;
  202. border-color: $u-tips-color;
  203. }
  204. }
  205. }
  206. .centre {
  207. text-align: center;
  208. margin: 200 rpx auto;
  209. font-size: 32 rpx;
  210. image {
  211. width: 164 rpx;
  212. height: 164 rpx;
  213. border-radius: 50%;
  214. margin-bottom: 20 rpx;
  215. }
  216. .tips {
  217. font-size: 24 rpx;
  218. color: #999999;
  219. margin-top: 20 rpx;
  220. }
  221. .btn {
  222. margin: 80 rpx auto;
  223. width: 200 rpx;
  224. border-radius: 32 rpx;
  225. line-height: 64 rpx;
  226. color: #ffffff;
  227. font-size: 26 rpx;
  228. background-image: linear-gradient(to left, #2979ff, rgba(#2979ff, 0.6));
  229. }
  230. }
  231. </style>