heart.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <view>
  3. <u-navbar :border-bottom="false" :is-back="true" title="收藏"></u-navbar>
  4. <view class="wrap">
  5. <scroll-view scroll-y style="height: 100%;width: 100%;">
  6. <view class="page-box">
  7. <view v-if="heartList.length === 0">
  8. <view class="centre">
  9. <image :src="empty" mode=""></image>
  10. <view class="explain">
  11. 您还没有收藏的房源
  12. <view class="tips">可以去逛逛</view>
  13. </view>
  14. <view class="btn" @click="goHome">首页</view>
  15. </view>
  16. </view>
  17. <view v-for="(item, index) in heartList"
  18. v-else :key="index" class="order"
  19. @click="viewImage(item.id)">
  20. <view class="top">
  21. <view class="left">
  22. <view class="store">{{ item.code }}</view>
  23. <u-icon :size="26" color="rgb(203,203,203)" name="arrow-right"></u-icon>
  24. </view>
  25. </view>
  26. <view class="item">
  27. <view class="left">
  28. <image :src="item.image" mode="aspectFill"></image>
  29. </view>
  30. <view class="content">
  31. <view class="title u-line-2">
  32. {{ item.villageName }}
  33. {{ item.type == '整租' ? item.houseNum + item.houseHall + item.toiletNum : item.roomType }}
  34. </view>
  35. <view class="price">¥{{ item.price }}</view>
  36. <view class="type">
  37. {{ item.type }} | {{ item.type == '整租' ? item.houseArea : item.roomArea }}㎡ | {{ item.decoration }}
  38. </view>
  39. </view>
  40. </view>
  41. <view class="bottom">
  42. <view class="evaluate btn" @click="viewImage(item.id)">查看</view>
  43. </view>
  44. </view>
  45. </view>
  46. </scroll-view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import config from "@/common/config.js" // 全局配置文件
  52. export default {
  53. data() {
  54. return {
  55. empty: '/static/empty/default.png',
  56. heartList: [],
  57. pageNum: 1,
  58. pageSize: 100,
  59. };
  60. },
  61. onLoad() {
  62. this.findHeartList();
  63. },
  64. methods: {
  65. findHeartList() {
  66. let url = "/api/houseApi/findHouseHeartList";
  67. let lifeData = uni.getStorageSync('lifeData');
  68. let vuex_user = lifeData.vuex_user
  69. this.$u.get(url, {
  70. userId: vuex_user.user.userId,
  71. pageNum: this.pageNum,
  72. pageSize: this.pageSize,
  73. orderByColumn: 'update_time,create_time',
  74. isAsc: 'desc'
  75. }
  76. ).then(result => {
  77. const data = result.rows;
  78. this.houseList = data;
  79. for (let i = 0; i < this.houseList.length; i++) {
  80. // 先转成字符串再转成对象,避免数组对象引用导致数据混乱
  81. let item = this.houseList[i]
  82. if (!item.faceUrl.includes(config.staticUrl)) {
  83. item.image = config.staticUrl + item.faceUrl
  84. } else {
  85. item.image = item.faceUrl
  86. }
  87. if (item.type == 0) {
  88. item.type = '整租'
  89. } else if (item.type == 1) {
  90. item.type = '合租'
  91. }
  92. if (item.roomType == 1) {
  93. item.roomType = '主卧'
  94. } else if (item.roomType == 2) {
  95. item.roomType = '次卧'
  96. } else {
  97. item.roomType = '未知'
  98. }
  99. if (this.$u.test.isEmpty(item.houseNum)) {
  100. item.houseNum = ''
  101. }
  102. if (this.$u.test.isEmpty(item.houseHall)) {
  103. item.houseHall = ''
  104. }
  105. if (this.$u.test.isEmpty(item.toiletNum)) {
  106. item.toiletNum = ''
  107. }
  108. this.heartList.push(item);
  109. }
  110. });
  111. },
  112. goHome() {
  113. uni.switchTab({
  114. url: '/pages/index/index'
  115. })
  116. },
  117. viewImage(houseId) {
  118. this.$u.route({
  119. url: '/pages/detail/detail',
  120. params: {
  121. houseId: houseId
  122. }
  123. })
  124. }
  125. }
  126. };
  127. </script>
  128. <style>
  129. /* #ifndef H5 */
  130. page {
  131. height: 100%;
  132. background-color: #f2f2f2;
  133. }
  134. /* #endif */
  135. </style>
  136. <style lang="scss" scoped>
  137. .container {
  138. width: 100%;
  139. height: 100%;
  140. display: flex;
  141. justify-content: center;
  142. align-items: center;
  143. text-align: center;
  144. .empty {
  145. overflow: hidden;
  146. .tip {
  147. color: #909399;
  148. }
  149. .btn {
  150. color: #fff;
  151. background-color: #2979ff;
  152. width: 200 rpx;
  153. padding: 15 rpx 28 rpx;
  154. border-radius: 130 rpx;
  155. margin: 30 rpx 0 0 100 rpx;
  156. }
  157. }
  158. }
  159. .order {
  160. width: 710 rpx;
  161. background-color: #ffffff;
  162. margin: 20 rpx auto;
  163. border-radius: 20 rpx;
  164. box-sizing: border-box;
  165. padding: 20 rpx;
  166. font-size: 28 rpx;
  167. .top {
  168. display: flex;
  169. justify-content: space-between;
  170. .left {
  171. display: flex;
  172. align-items: center;
  173. .store {
  174. // margin: 0 10rpx;
  175. font-size: 32 rpx;
  176. }
  177. }
  178. .right {
  179. color: #2979ff;
  180. }
  181. }
  182. .item {
  183. display: flex;
  184. margin: 20 rpx 0 0 0;
  185. .left {
  186. margin-right: 30 rpx;
  187. image {
  188. width: 150 rpx;
  189. height: 150 rpx;
  190. border-radius: 10 rpx;
  191. }
  192. }
  193. .content {
  194. .title {
  195. font-weight: bold;
  196. font-size: 28 rpx;
  197. line-height: 50 rpx;
  198. }
  199. .price {
  200. margin: 10 rpx 0;
  201. font-size: 30 rpx;
  202. }
  203. .type {
  204. margin: 10 rpx 0;
  205. font-size: 24 rpx;
  206. color: $u-tips-color;
  207. }
  208. .desc {
  209. margin: 10 rpx 0;
  210. font-size: 24 rpx;
  211. color: $u-tips-color;
  212. }
  213. }
  214. }
  215. .bottom {
  216. display: flex;
  217. margin-top: 20 rpx;
  218. padding: 0 10 rpx;
  219. justify-content: flex-end;
  220. align-items: center;
  221. .btn {
  222. margin-left: 20 rpx;
  223. line-height: 52 rpx;
  224. width: 160 rpx;
  225. border-radius: 26 rpx;
  226. border: 2 rpx solid $u-border-color;
  227. font-size: 26 rpx;
  228. text-align: center;
  229. color: $u-type-info-dark;
  230. }
  231. .evaluate {
  232. color: $u-tips-color;
  233. }
  234. }
  235. }
  236. .centre {
  237. text-align: center;
  238. margin: 200 rpx auto;
  239. font-size: 32 rpx;
  240. image {
  241. width: 164 rpx;
  242. height: 164 rpx;
  243. border-radius: 50%;
  244. margin-bottom: 20 rpx;
  245. }
  246. .tips {
  247. font-size: 24 rpx;
  248. color: #999999;
  249. margin-top: 20 rpx;
  250. }
  251. .btn {
  252. margin: 80 rpx auto;
  253. width: 200 rpx;
  254. border-radius: 32 rpx;
  255. line-height: 64 rpx;
  256. color: #ffffff;
  257. font-size: 26 rpx;
  258. background-image: linear-gradient(to left, #2979ff, rgba(#2979ff, 0.6));
  259. }
  260. }
  261. .wrap {
  262. display: flex;
  263. flex-direction: column;
  264. height: calc(100vh - var(--window-top));
  265. width: 100%;
  266. }
  267. .swiper-box {
  268. flex: 1;
  269. }
  270. .swiper-item {
  271. height: 100%;
  272. }
  273. .buttom {
  274. .loginType {
  275. font-size: 14px;
  276. position: fixed;
  277. right: 30 rpx;
  278. bottom: 120 rpx;
  279. width: 60px;
  280. height: 60px;
  281. padding: 4px;
  282. cursor: pointer;
  283. background: #FFF;
  284. text-align: center;
  285. line-height: 60px;
  286. border-radius: 100%;
  287. -webkit-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, 0.1), inset 0px -1px 0px 0px rgba(0, 0, 0, 0.1);
  288. box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, 0.1), inset 0px -1px 0px 0px rgba(0, 0, 0, 0.1);
  289. }
  290. }
  291. </style>