floor-style-4.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <div class="floor-style-4">
  3. <div class="head-wrap" v-if="data.value.title.value.text">
  4. <h2 @click="$util.pushToTab(data.value.title.value.link.url)" :style="{ color: data.value.title.value.color }">{{ data.value.title.value.text }}</h2>
  5. <div class="more" @click="$util.pushToTab(data.value.more.value.link.url)" :style="{color: data.value.more.value.color}">
  6. <span>{{data.value.more.value.text}}</span>
  7. <i class="el-icon-arrow-right"></i>
  8. </div>
  9. </div>
  10. <div class="body-wrap">
  11. <div class="left-wrap" v-if="data.value.leftImg.value.url"><img :src="$img(data.value.leftImg.value.url)" @click="$util.pushToTab(data.value.leftImg.value.link.url)" /></div>
  12. <el-carousel trigger="click" height="324px" indicator-position="none" arrow="never">
  13. <el-carousel-item v-for="num in itemNum" :key="num">
  14. <ul class="goods-list">
  15. <li v-for="(item, index) in itemList(num)" :key="index" :title="item.goods_name" @click="goSku(item.sku_id)">
  16. <div class="img-wrap"><img alt="商品图片" :src="$img(item.goods_image.split(',')[0], { size: 'mid' })" @error="imageError(index)" /></div>
  17. <div class="price">
  18. <span class="num">¥{{ item.discount_price }}</span>
  19. <del v-show="Number.parseInt(item.market_price)">¥{{ item.market_price }}</del>
  20. </div>
  21. <h3 class="name">{{ item.goods_name }}</h3>
  22. <div class="other-info" v-if="item.sale_num">
  23. <span>已售{{ item.sale_num }}件</span>
  24. </div>
  25. </li>
  26. </ul>
  27. </el-carousel-item>
  28. </el-carousel>
  29. </div>
  30. <div class="bottom-wrap" v-if="data.value.bottomImg.value.url">
  31. <img :src="$img(data.value.bottomImg.value.url)" @click="$util.pushToTab(data.value.bottomImg.value.link.url)" />
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import { mapGetters } from 'vuex';
  37. export default {
  38. name: 'floor-style-4',
  39. props: {
  40. data: {
  41. type: Object
  42. }
  43. },
  44. data() {
  45. return {};
  46. },
  47. created() {
  48. },
  49. mounted() {},
  50. computed: {
  51. ...mapGetters(['defaultGoodsImage'])
  52. },
  53. computed: {
  54. goodsList() {
  55. let arr = [];
  56. try {
  57. arr = this.data.value.goodsList.value.list;
  58. } catch (e) {
  59. arr = [];
  60. }
  61. return arr;
  62. },
  63. itemNum() {
  64. let [num, listLen] = [0, this.goodsList.length];
  65. num = parseInt(listLen / 3);
  66. if (parseInt(listLen % 3) > 0) num += 1;
  67. return num;
  68. }
  69. },
  70. methods: {
  71. goSku(skuId) {
  72. this.$util.pushToTab('/sku/' + skuId);
  73. },
  74. imageError(index) {
  75. this.data.value.goodsList.value.list[index].goods_image = this.defaultGoodsImage;
  76. },
  77. itemList(index) {
  78. index -= 1;
  79. if (!this.goodsList.length) return [];
  80. let [start, end, arr] = [index * 3, index * 3 + 3, []];
  81. arr = this.goodsList.slice(start, end);
  82. return arr;
  83. }
  84. }
  85. };
  86. </script>
  87. <style lang="scss">
  88. .floor-style-4 {
  89. .head-wrap {
  90. display: flex;
  91. align-items: center;
  92. justify-content: space-between;
  93. }
  94. .head-wrap h2 {
  95. line-height: 30px;
  96. color: #333;
  97. padding: 10px;
  98. font-size: 18px;
  99. cursor: pointer;
  100. overflow: hidden;
  101. text-overflow: ellipsis;
  102. white-space: nowrap;
  103. }
  104. .body-wrap {
  105. display: flex;
  106. .left-wrap {
  107. margin-right: 15px;
  108. width: 478px;
  109. height: 324px;
  110. cursor: pointer;
  111. transition: all 0.2s linear;
  112. &:hover {
  113. z-index: 2;
  114. -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  115. box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  116. -webkit-transform: translate3d(0, -2px, 0);
  117. transform: translate3d(0, -2px, 0);
  118. }
  119. img {
  120. max-width: 100%;
  121. cursor: pointer;
  122. }
  123. }
  124. .el-carousel {
  125. flex: 1;
  126. }
  127. .goods-list {
  128. display: flex;
  129. li {
  130. position: relative;
  131. width: 228px;
  132. height: 324px;
  133. margin-right: 15px;
  134. background-color: #fff;
  135. cursor: pointer;
  136. padding: 10px 18px;
  137. transition: all 0.2s linear;
  138. box-sizing: border-box;
  139. &:last-of-type {
  140. margin-right: 0;
  141. }
  142. &:hover {
  143. z-index: 2;
  144. -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  145. box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  146. -webkit-transform: translate3d(0, -2px, 0);
  147. transform: translate3d(0, -2px, 0);
  148. }
  149. .img-wrap {
  150. width: 168px;
  151. height: 168px;
  152. line-height: 168px;
  153. margin: 0 auto 18px;
  154. img {
  155. max-width: 100%;
  156. max-height: 100%;
  157. }
  158. }
  159. .name {
  160. margin-top: 5px;
  161. font-size: 14px;
  162. color: #444;
  163. line-height: 1.5;
  164. font-weight: normal;
  165. @extend .multi-hidden;
  166. }
  167. .other-info {
  168. position: absolute;
  169. bottom: 15px;
  170. display: flex;
  171. align-items: center;
  172. justify-content: space-between;
  173. span {
  174. font-size: 14px;
  175. color: #aaa;
  176. }
  177. }
  178. .price {
  179. .num {
  180. color: $base-color;
  181. font-size: 20px;
  182. font-weight: bold;
  183. }
  184. del {
  185. font-size: 14px;
  186. margin-left: 15px;
  187. color: #aaa;
  188. }
  189. }
  190. }
  191. }
  192. }
  193. .bottom-wrap {
  194. margin-top: 35px;
  195. width: $width;
  196. cursor: pointer;
  197. overflow: hidden;
  198. img {
  199. max-width: 100%;
  200. }
  201. }
  202. }
  203. </style>