Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

propertyCard.vue 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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">
  75. <img src="../../../public/img/icons/area.png" height="16px" width="16px" />
  76. <!-- <i class="fa fa-ruler-combined"></i> -->
  77. </h4>
  78. <span v-html="currentProperty.area"></span>
  79. </li>
  80. <li v-if="currentProperty.beds !== null">
  81. <h4 class="card-info-title">
  82. <i class="fa fa-bed"></i>
  83. </h4>
  84. <span>{{ currentProperty.beds }}</span>
  85. </li>
  86. <li v-if="currentProperty.baths !== null">
  87. <h4 class="card-info-title">
  88. <i class="fa fa-bath"></i>
  89. </h4>
  90. <span>{{ currentProperty.baths }}</span>
  91. </li>
  92. <li v-if="currentProperty.garages !== null">
  93. <h4 class="card-info-title">
  94. <!-- <i class="fa fa-warehouse"></i> -->
  95. <img src="../../../public/img/icons/garage.png" height="16px" width="16px" />
  96. </h4>
  97. <span>{{ currentProperty.garages }}</span>
  98. </li>
  99. </ul>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </router-link>
  105. <br />
  106. </div>
  107. </div>
  108. </div>
  109. </template>
  110. <script>
  111. export default {
  112. props: {
  113. properties: { type: Array, default: () => [] },
  114. showSort: { type: Boolean, default: true },
  115. },
  116. methods: {
  117. sortHighPrice() {
  118. function compare(a, b) {
  119. if (a.price < b.price) return 1;
  120. if (a.price > b.price) return -1;
  121. return 0;
  122. }
  123. return this.properties.sort(compare);
  124. },
  125. sortLowPrice() {
  126. function compare(a, b) {
  127. if (a.price < b.price) return -1;
  128. if (a.price > b.price) return 1;
  129. return 0;
  130. }
  131. return this.properties.sort(compare);
  132. },
  133. sortNewest() {
  134. function compare(a, b) {
  135. if (a.dateCreated < b.dateCreated) return 1;
  136. if (a.dateCreated > b.dateCreated) return -1;
  137. return 0;
  138. }
  139. return this.properties.sort(compare);
  140. },
  141. },
  142. };
  143. </script>