Card.vue 5.6 KB

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