productItem.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <div class="product-item-box">
  3. <div class="product-item" @click="clickItem">
  4. <div class="product-item-image" :style="'background-image: url('+imageUrl(item.showPictures)+');'"></div>
  5. <div class="product-content">
  6. <div class="product-item-title hui-ellipsis">{{item.name}}</div>
  7. <div class="space hui-ellipsis">{{item.remark}}</div>
  8. </div>
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. import Crypto from '@/uitls/crypto'
  14. export default {
  15. props: ['item', 'parent'],
  16. methods: {
  17. imageUrl(data) {
  18. let itemData = this.parent.showPictures;
  19. if (itemData && JSON.parse(itemData)[0]) return JSON.parse(itemData)[0].url;
  20. if (data && JSON.parse(data)[0]) return JSON.parse(data)[0].url;
  21. return 'https://assets.api.uizard.io/api/cdn/stream/c05650d2-192b-4a56-ae97-05638f53804c.png';
  22. },
  23. clickItem() {
  24. let id = Crypto.AES.encrypt(String(this.item.id), 'bosshand');
  25. this.$router.push('/website/serveDetail?type=' + encodeURIComponent(id) + '&sign=' + this.item.sign);
  26. }
  27. }
  28. }
  29. </script>
  30. <style lang="scss">
  31. .product-item-box {
  32. width: 25%;
  33. padding: 10px;
  34. }
  35. .product-item {
  36. width: 100%;
  37. background: $--color-white;
  38. border-radius: 8px;
  39. box-sizing: border-box;
  40. position: relative;
  41. cursor: pointer;
  42. box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.1);
  43. overflow: hidden;
  44. padding: 15px;
  45. box-sizing: border-box;
  46. .product-item-image {
  47. width: 100%;
  48. height: 160px;
  49. overflow: hidden;
  50. border-radius: 8px;
  51. background-repeat: no-repeat;
  52. background-size: cover;
  53. background-position: center center;
  54. }
  55. .product-content {
  56. padding-top: 15px;
  57. }
  58. .product-item-title {
  59. font-size: 16px;
  60. font-weight: 600;
  61. margin-bottom: 7px;
  62. }
  63. .space {
  64. color: $--color-text-regular;
  65. font-size: $--font-size-small;
  66. margin-bottom: 3px;
  67. }
  68. .pirce {
  69. color: $--color-danger;
  70. display: flex;
  71. align-items: end;
  72. .number {
  73. font-size: 20px;
  74. font-weight: 600;
  75. height: 20px;
  76. }
  77. .unit {
  78. height: 15px;
  79. font-size: 12px;
  80. }
  81. }
  82. }
  83. </style>