您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

propertyCard.vue 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <div>
  3. <div class="form-group row" v-if="showSort">
  4. <button
  5. type="button"
  6. class="btn btn-link font-weight-bold color-b"
  7. style="width: 150px; height:40px;"
  8. @click="sortNewest()"
  9. >Newest</button>
  10. <button
  11. type="button"
  12. class="btn btn-link font-weight-bold color-b"
  13. style="width: 150px; height:40px;"
  14. @click="sortLowPrice()"
  15. >Lowest Price</button>
  16. <button
  17. type="button"
  18. class="btn btn-link font-weight-bold color-b"
  19. style="width: 150px; height:40px;"
  20. @click="sortHighPrice()"
  21. >Highest Price</button>
  22. <hr />
  23. </div>
  24. <div class="form-group row">
  25. <div class="col-md-4" v-for="currentProperty in properties" :key="currentProperty.id">
  26. <router-link :to="`/property/property/${currentProperty.id}`">
  27. <div class="card-box-a card-shadow">
  28. <div class="img-box-a">
  29. <img
  30. :src="currentProperty.displayImage"
  31. alt
  32. class="img-a img-fluid"
  33. style="height:466px; width:350px; object-fit: cover;"
  34. />
  35. </div>
  36. <div class="card-overlay">
  37. <div class="card-overlay-a-content">
  38. <div class="card-header-a">
  39. <h4 class="card-title-a">
  40. <router-link
  41. :to="`/property/property/${currentProperty.id}`"
  42. class="link-a"
  43. >{{ currentProperty.shortDescription }}</router-link>
  44. </h4>
  45. <h4 class="card-title-c">
  46. <router-link :to="`/property/property/${currentProperty.id}`" class="link-a">
  47. {{ currentProperty.province }}
  48. <br />
  49. {{ currentProperty.city }}
  50. <br />
  51. {{ currentProperty.suburb }}
  52. </router-link>
  53. </h4>
  54. </div>
  55. <div class="card-body-a">
  56. <div class="price-box d-flex">
  57. <span
  58. v-if="currentProperty.isSale"
  59. class="price-a"
  60. >sale | {{ currentProperty.displayPrice }}</span>
  61. <span
  62. v-if="!currentProperty.isSale"
  63. class="price-a"
  64. >rent | {{ currentProperty.displayPrice }}</span>
  65. </div>
  66. <router-link :to="`/property/property/${currentProperty.id}`" class="link-a">
  67. Click here to view
  68. <span class="ion-ios-arrow-forward"></span>
  69. </router-link>
  70. </div>
  71. <div class="card-footer-a" v-if="currentProperty.showFooter">
  72. <ul class="card-info d-flex justify-content-around">
  73. <li v-if="currentProperty.area !== null">
  74. <h4 class="card-info-title">Area</h4>
  75. <span v-html="currentProperty.area"></span>
  76. </li>
  77. <li v-if="currentProperty.beds !== null">
  78. <h4 class="card-info-title">Beds</h4>
  79. <span>{{ currentProperty.beds }}</span>
  80. </li>
  81. <li v-if="currentProperty.baths !== null">
  82. <h4 class="card-info-title">Baths</h4>
  83. <span>{{ currentProperty.baths }}</span>
  84. </li>
  85. <li v-if="currentProperty.garages !== null">
  86. <h4 class="card-info-title">Garages</h4>
  87. <span>{{ currentProperty.garages }}</span>
  88. </li>
  89. </ul>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </router-link>
  95. <br />
  96. </div>
  97. </div>
  98. </div>
  99. </template>
  100. <script>
  101. export default {
  102. props: {
  103. properties: { type: Array, default: () => [] },
  104. showSort: { type: Boolean, default: true },
  105. },
  106. methods: {
  107. sortHighPrice() {
  108. function compare(a, b) {
  109. if (a.price < b.price) return 1;
  110. if (a.price > b.price) return -1;
  111. return 0;
  112. }
  113. return this.properties.sort(compare);
  114. },
  115. sortLowPrice() {
  116. function compare(a, b) {
  117. if (a.price < b.price) return -1;
  118. if (a.price > b.price) return 1;
  119. return 0;
  120. }
  121. return this.properties.sort(compare);
  122. },
  123. sortNewest() {
  124. function compare(a, b) {
  125. if (a.dateCreated < b.dateCreated) return 1;
  126. if (a.dateCreated > b.dateCreated) return -1;
  127. return 0;
  128. }
  129. return this.properties.sort(compare);
  130. },
  131. },
  132. };
  133. </script>