Card.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <nuxt-link :to="{name: 'product-code', params: { code: cardData.product_code}}" class="card">
  3. <figure >
  4. <!-- <nuxt-link :to="{ name: 'product-code', params: { code: cardData.product_code } }"> -->
  5. <div class="card-img">
  6. <el-image
  7. :src="comImg"
  8. class="card-img-1"
  9. fit="cover"
  10. style="width: 100%; height: 100%"
  11. ></el-image>
  12. <div class="co2-info" v-if="cardData.co2_au_air && cardData.co2_au_sea">
  13. <img src="@/assets/img/esg/ship.png" alt="CO2" class="co2-icon" />
  14. <span>{{ cardData.co2_au_sea || 0 }} kg</span>
  15. <div></div>
  16. <img src="@/assets/img/esg/aircraft.png" alt="CO2" class="co2-icon" />
  17. <span>{{ cardData.co2_au_air || 0 }} kg</span>
  18. </div>
  19. <img class="best_icon" :src="comBestIcon" v-if="comBestIcon"/>
  20. <div class="cycle_icon">
  21. <img
  22. :src="item.images"
  23. v-for="(item, index) of cardData.cycle_icon"
  24. :key="index"
  25. />
  26. </div>
  27. </div>
  28. <p class="show-pricing" v-if="showPricing">Pricing</p>
  29. <!-- </nuxt-link> -->
  30. <figcaption class="card-info">
  31. <h1>{{ cardData.alias_name || cardData.product_name }}</h1>
  32. <p class="card-info-point">{{ cardData.product_code }}</p>
  33. <div class="card-info-icon">
  34. <img
  35. :src="item.url"
  36. v-for="(item, index) of cardData.icon"
  37. :key="index"
  38. />
  39. </div>
  40. </figcaption>
  41. </figure>
  42. </nuxt-link>
  43. </template>
  44. <script>
  45. export default {
  46. props: {
  47. cardData: {},
  48. showPricing: { type: Boolean, default: false },
  49. },
  50. data() {
  51. return {};
  52. },
  53. computed:{
  54. comImg(){
  55. return this.$utils.generateResizedImageUrl(this.cardData.main?.image,300)
  56. },
  57. comBestIcon(){
  58. const bestSeller = this.cardData.collection_detail?.find(item => item.name === "Best Seller");
  59. return bestSeller ? bestSeller.img : '';
  60. }
  61. },
  62. methods: {
  63. goProduct(cardData) {
  64. this.$router.push({
  65. name: "product-code",
  66. params: { code: cardData.product_code },
  67. });
  68. // let routeData = this.$router.resolve({
  69. // name: "product-code",
  70. // params:{ code: cardData.product_code },
  71. // });
  72. // window.open(routeData.href, '_blank');
  73. },
  74. },
  75. };
  76. </script>
  77. <style lang="scss" scoped>
  78. .card {
  79. position: relative;
  80. width: 220px;
  81. // border: 1px solid rgba(0, 0, 0, 0.1);
  82. box-shadow: 0px 0px 10px rgba(137, 137, 137, 0.05);
  83. margin-bottom: 30px;
  84. cursor: pointer;
  85. transition: all 0.2s ease-out 0s;
  86. padding-bottom: 30px;
  87. box-sizing: border-box;
  88. overflow: hidden;
  89. border-radius: 4px;
  90. &:hover {
  91. // transform: translate3d(0px, -2px, 0);
  92. box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
  93. .card-img-1 {
  94. transform: scale(1.1);
  95. }
  96. h1 {
  97. color: #006dc9;
  98. }
  99. .card-info-compare {
  100. visibility: visible !important;
  101. }
  102. }
  103. .card-img {
  104. width: 220px;
  105. height: 220px;
  106. padding: 10px;
  107. box-sizing: border-box;
  108. overflow: hidden;
  109. position: relative;
  110. .card-img-1{
  111. transition: all 0.5s ;
  112. }
  113. .best_icon {
  114. position: absolute;
  115. top: 0;
  116. left: 0;
  117. }
  118. .co2-info {
  119. display: flex;
  120. align-items: center;
  121. background: #07A73A;
  122. color: #fff;
  123. font-weight: bold;
  124. border-radius: 2px;
  125. padding: 5px;
  126. position: absolute;
  127. bottom: 10px;
  128. box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  129. div{
  130. display: inline-block;
  131. margin: 0 10px;
  132. width: 2px;
  133. height: 12px;
  134. border-right: 2px solid #fff;
  135. }
  136. .co2-icon {
  137. width: 20px;
  138. height: 20px;
  139. margin-right: 4px;
  140. }
  141. }
  142. .cycle_icon {
  143. position: absolute;
  144. top: 0;
  145. right: 0;
  146. display: flex;
  147. flex-wrap: wrap;
  148. justify-content: flex-end;
  149. width: 132px;
  150. img {
  151. margin-left: 4px;
  152. margin-bottom: 4px;
  153. width: 40px;
  154. height: auto;
  155. vertical-align: middle;
  156. border-radius: 4px;
  157. }
  158. }
  159. }
  160. .card-info {
  161. margin: 0 10px 10px 10px;
  162. border-top: 1px solid rgba(0, 35, 105, 0.1);
  163. h1 {
  164. font-size: 18px;
  165. line-height: 24px;
  166. height: 48px;
  167. font-weight: 600;
  168. margin: 10px 0;
  169. overflow: hidden;
  170. text-overflow: ellipsis;
  171. display: -webkit-box;
  172. -webkit-line-clamp: 2;
  173. -webkit-box-orient: vertical;
  174. }
  175. .card-info-point {
  176. color: #4a596c;
  177. line-height: 16px;
  178. height: 32px;
  179. overflow: hidden;
  180. text-overflow: ellipsis;
  181. display: -webkit-box;
  182. -webkit-line-clamp: 2;
  183. -webkit-box-orient: vertical;
  184. }
  185. .card-info-icon {
  186. margin: 10px 0;
  187. height: 32px;
  188. overflow: hidden;
  189. img {
  190. margin-right: 5px;
  191. // width: 30px;
  192. height: 30px;
  193. }
  194. }
  195. }
  196. .card-info-compare {
  197. text-align: center;
  198. visibility: hidden;
  199. // display: none;
  200. position: absolute;
  201. bottom: 15px;
  202. left: 30%;
  203. }
  204. .show-pricing {
  205. width: 43px;
  206. height: 13px;
  207. font-size: 14px;
  208. font-family: Proxima Nova;
  209. font-weight: bold;
  210. color: #ffffff;
  211. background-color: #000;
  212. padding: 5px 10px;
  213. border-radius: 5px;
  214. position: absolute;
  215. top: 198px;
  216. right: 18px;
  217. }
  218. }
  219. </style>