goods.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div class="goods_wrap flex">
  3. <div :class="[pc_temp?'fourGoods':'goods']" v-for="(item,index) in list" :key="index"
  4. @click="toGoods(item)" :style="{width:pc_temp?'220px':'230px'}">
  5. <img v-lazy="item.thumb">
  6. <div class="goods_info flex flex-col">
  7. <div class="title ">{{item.title}}</div>
  8. <div class="price col_red"><span style="font-size:14px;color:#666;display:inline-block;margin-right:10px;">{{basic_info.lang && basic_info.lang.goods &&basic_info.lang.goods.price ? basic_info.lang.goods.price : '现价'}}:</span><span
  9. style="font-size: 18px;">¥</span>{{item.min_price||item.price}}
  10. </div>
  11. </div>
  12. </div>
  13. <div class="no-goods" v-if="list && list.length <= 0">
  14. 暂无更多
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import {mapState} from "vuex";
  20. export default {
  21. props: {
  22. list: {
  23. type: null
  24. },
  25. pc_temp:{
  26. type: Boolean
  27. }
  28. },
  29. data() {
  30. return {};
  31. },
  32. mounted() {
  33. },
  34. computed: {
  35. ...mapState(["basicSet", "basic_info"]),
  36. },
  37. methods: {
  38. toGoods(item) {
  39. let id = item.id || item.goods_id;
  40. if(this.$baseURL) {
  41. // 静态部署环境下
  42. window.open(this.fun.getSiteRoot() + "/plugins/shop_server/goods?i=" +this.fun.getKeyByI()+'&id='+id, "_blank");
  43. }else {
  44. window.open(this.fun.getSiteRoot() + "/plugins/shop_server/goods/"+ id +"?i=" +this.fun.getKeyByI(), "_blank");
  45. }
  46. // this.$router.push(this.fun.getUrl('goods-id', {id: id}));
  47. },
  48. toUrl(url, params, query) {
  49. this.$router.push(this.fun.getUrl(url, params, query));
  50. },
  51. }
  52. };
  53. </script>
  54. <style lang="scss" scoped>
  55. .goods_wrap {
  56. flex-wrap: wrap;
  57. .goods,.fourGoods {
  58. box-shadow: 1px 1px 2px rgba(191, 191, 191, 0.3);
  59. width: 230px;
  60. background: #fff;
  61. margin-right: 12px;
  62. box-sizing: border-box;
  63. margin-bottom: 20px;
  64. cursor: pointer;
  65. overflow: hidden;
  66. transition: all 0.5s ease;
  67. img {
  68. width: 100%;
  69. height: 230px;
  70. object-fit: contain;
  71. overflow: hidden;
  72. }
  73. .goods_info {
  74. font-size: 16px;
  75. padding: 15px;
  76. height: 130px;
  77. box-sizing: border-box;
  78. flex-wrap: wrap;
  79. justify-content: space-between;
  80. align-items: flex-start;
  81. .title {
  82. overflow: hidden;
  83. text-overflow: ellipsis;
  84. display: -webkit-box;
  85. -webkit-line-clamp: 2;
  86. -webkit-box-orient: vertical;
  87. }
  88. .price {
  89. font-size: 18px;
  90. }
  91. }
  92. }
  93. .goods:hover,.fourGoods:hover {
  94. opacity: 0.8;
  95. box-shadow: 0px 4px 8px 0px rgba(191, 191, 191, 0.6);
  96. img {
  97. transform: scale(1.04);
  98. transition: all 0.5s ease;
  99. }
  100. }
  101. .goods:nth-child(5n) {
  102. margin-right: 0;
  103. }
  104. .fourGoods:nth-child(4n) {
  105. margin-right: 0;
  106. }
  107. .no-goods {
  108. margin: 20px auto;
  109. font-size: 16px;
  110. color: var(--color);
  111. text-align: center;
  112. }
  113. }
  114. </style>