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

propertyCard.vue 4.5KB

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