index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <div class="hom-pro-list">
  3. <div class="title">
  4. <!-- #ifdef MP-WEIXIN -->
  5. <img class="title-img" src="../../../static/images/product/img-title.png" alt="商品推荐" mode="widthFix" />
  6. <!-- #endif -->
  7. <!-- #ifdef H5 || APP-PLUS -->
  8. <image class="title-img" src="../../../static/images/product/img-title.png" alt="商品推荐" mode="widthFix" />
  9. <!-- #endif -->
  10. </div>
  11. <div v-if="componentContent.arrangeType == '横向滑动' && productData.length > 2" class="product-list">
  12. <swiper
  13. ref="mySwiper" class="swiper product-list-box" :circular="true" :indicator-dots="false"
  14. :autoplay="true"
  15. :display-multiple-items="2" @change="swiperChange"
  16. >
  17. <swiper-item v-for="(item, index) in productData" :key="index" class="product-list-item-warp">
  18. <div v-if="JSON.stringify(item) !== '{}'" class="product-list-item" @click="jumpProductDetail(item)">
  19. <div class="product-list-img">
  20. <img class="img pic-img default-img" :src="item.image">
  21. </div>
  22. <div class="product-list-info">
  23. <label class="product-name">{{ item.productName }}</label>
  24. <div class="flex">
  25. <div v-if="typeId == 1" class="shop-box" @click.stop="jumpStore(item)">
  26. <label class="shop-name">{{ item.shopName }}</label>
  27. <div class="shop-logo">
  28. <img :src="item.shopLogo">
  29. </div>
  30. </div>
  31. <label class="buy-count">已售{{ item.number ? item.number : 0 }}件</label>
  32. </div>
  33. <div class="price-warp">
  34. <!-- #ifdef MP-WEIXIN -->
  35. <img v-if="item.activityType == 1" class="iconImg" src="../../../static/images/groupBuyIcon.png">
  36. <img v-if="item.activityType == 2" class="iconImg" src="../../../static/images/spikeIcon.png">
  37. <img v-if="item.activityType == 4" class="iconImg" src="../../../static/images/spikeIcon.png">
  38. <img v-if="item.activityType == 3" class="iconImg" src="../../../static/images/discountListIcon.png">
  39. <img v-if="item.activityType == 5" class="iconImg" src="../../../static/images/discountListIcon.png">
  40. <img v-if="item.activityType == 9" class="iconImg" src="../../../static/images/memberCenterIcon.png">
  41. <img
  42. v-if="item.activityType == 8" class="iconImg"
  43. src="../../../../../static/images/origin/jierizhekou.png"
  44. >
  45. <!-- #endif -->
  46. <!-- #ifdef H5 || APP-PLUS -->
  47. <image v-if="item.activityType == 1" class="iconImg" src="../../../static/images/groupBuyIcon.png">
  48. <image v-if="item.activityType == 2" class="iconImg" src="../../../static/images/spikeIcon.png">
  49. <image v-if="item.activityType == 4" class="iconImg" src="../../../static/images/spikeIcon.png">
  50. <image
  51. v-if="item.activityType == 3" class="iconImg"
  52. src="../../../static/images/discountListIcon.png"
  53. >
  54. <image
  55. v-if="item.activityType == 5" class="iconImg"
  56. src="../../../static/images/discountListIcon.png"
  57. >
  58. <image
  59. v-if="item.activityType == 9" class="iconImg"
  60. src="../../../static/images/memberCenterIcon.png"
  61. >
  62. <image
  63. v-if="item.activityType == 8" class="iconImg"
  64. src="../../../../../static/images/origin/jierizhekou.png"
  65. >
  66. <!-- #endif -->
  67. <div class="price">
  68. ¥ {{ item.price }}
  69. </div>
  70. <div class="original-price">
  71. ¥ {{ item.originalPrice }}
  72. </div>
  73. </image>
  74. </image>
  75. </image>
  76. </image>
  77. </image>
  78. </image>
  79. </image>
  80. </div>
  81. </div>
  82. </div>
  83. <!-- 自定义骨架屏 -->
  84. <div v-else class="product-list-item ske-loading">
  85. <div class="product-list-img child-loading">
  86. </div>
  87. <div class="product-list-info">
  88. <label class="product-name child-loading"></label>
  89. <div class="price-warp child-loading" style="padding: 5px 0">
  90. </div>
  91. <div class="price-warp child-loading" style="padding: 5px 0">
  92. </div>
  93. </div>
  94. </div>
  95. </swiper-item>
  96. </swiper>
  97. <view v-if="productData && productData.length > 2" class="swiper-dots">
  98. <text
  99. v-for="(dot, index) in productData.length" :key="index" class="dot"
  100. :class="index - swiperCurrent <= 1 && index - swiperCurrent >= 0 && 'dot-active'"
  101. ></text>
  102. </view>
  103. </div>
  104. <div v-else class="product-list">
  105. <ProductSkeleton v-if="isFirst" style="" :loading="loading" :is-first="isFirst" />
  106. <div v-else class="product-list-box">
  107. <div v-for="(item, index) in productData" :key="index" class="product-list-item-warp">
  108. <div class="product-list-item" @click="jumpProductDetail(item)">
  109. <div class="product-list-img">
  110. <img class="img pic-img default-img" :src="item.image">
  111. </div>
  112. <div class="product-list-info">
  113. <label class="product-name">{{ item.productName }}</label>
  114. <div class="flex">
  115. <div v-if="typeId == 1" class="shop-box" @click.stop="jumpStore(item)">
  116. <label class="shop-name">{{ item.shopName }}</label>
  117. <div class="shop-logo">
  118. <img :src="item.shopLogo">
  119. </div>
  120. </div>
  121. <label class="buy-count">已售{{ item.number ? item.number : 0 }}件</label>
  122. </div>
  123. <div class="price-warp">
  124. <!-- #ifdef MP-WEIXIN -->
  125. <img v-if="item.activityType == 1" class="iconImg" src="../../../static/images/groupBuyIcon.png" />
  126. <img v-if="item.activityType == 2" class="iconImg" src="../../../static/images/spikeIcon.png" />
  127. <img v-if="item.activityType == 4" class="iconImg" src="../../../static/images/spikeIcon.png" />
  128. <img v-if="item.activityType == 3" class="iconImg" src="../../../static/images/discountListIcon.png" />
  129. <img v-if="item.activityType == 5" class="iconImg" src="../../../static/images/discountListIcon.png" />
  130. <img v-if="item.activityType == 9" class="iconImg" src="../../../static/images/memberCenterIcon.png" />
  131. <img
  132. v-if="item.activityType == 8" class="iconImg"
  133. src="../../../../../static/images/origin/jierizhekou.png"
  134. />
  135. <!-- #endif -->
  136. <!-- #ifdef H5 || APP-PLUS -->
  137. <image v-if="item.activityType == 1" class="iconImg" src="../../../static/images/groupBuyIcon.png" />
  138. <image v-if="item.activityType == 2" class="iconImg" src="../../../static/images/spikeIcon.png" />
  139. <image v-if="item.activityType == 4" class="iconImg" src="../../../static/images/spikeIcon.png" />
  140. <image v-if="item.activityType == 3" class="iconImg" src="../../../static/images/discountListIcon.png" />
  141. <image v-if="item.activityType == 5" class="iconImg" src="../../../static/images/discountListIcon.png" />
  142. <image v-if="item.activityType == 9" class="iconImg" src="../../../static/images/memberCenterIcon.png" />
  143. <image
  144. v-if="item.activityType == 8" class="iconImg"
  145. src="../../../../../static/images/origin/jierizhekou.png"
  146. />
  147. <!-- #endif -->
  148. <div class="price">
  149. ¥ {{ item.price }}
  150. </div>
  151. <div class="original-price">
  152. ¥ {{ item.originalPrice }}
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. <button v-show="componentContent.showMore" class="btn-more" @click="jumpProList(componentContent.productData)">
  161. 查看全部 <span class="icon iconfont icon-arrow-right"></span>
  162. </button>
  163. </div>
  164. </template>
  165. <script>
  166. import { commonMixin } from '../mixin'
  167. import ProductSkeleton from '@/components/basics/components/ProductSkeleton'
  168. export default {
  169. components: {
  170. ProductSkeleton
  171. },
  172. mixins: [ commonMixin ],
  173. data() {
  174. return {
  175. swiperCurrent: 0
  176. }
  177. },
  178. methods: {
  179. swiperChange(e) {
  180. this.swiperCurrent = e.detail.current
  181. }
  182. }
  183. }
  184. </script>
  185. <style
  186. lang="scss"
  187. scoped
  188. >
  189. .hom-pro-list {
  190. padding: 20rpx 13rpx;
  191. .title {
  192. text-align: center;
  193. margin-bottom: 20rpx;
  194. .title-img {
  195. width: 211rpx;
  196. }
  197. }
  198. /**多行多列**/
  199. .product-list {
  200. position: relative;
  201. &-box {
  202. display: flex;
  203. flex-wrap: wrap;
  204. flex-direction: row;
  205. &.swiper {
  206. height: 620rpx;
  207. }
  208. }
  209. &.product-swiper .product-list-box {
  210. padding-left: 0;
  211. }
  212. &-item-warp {
  213. margin: 0 0 20rpx 0;
  214. }
  215. &-item {
  216. width: 348rpx;
  217. padding: 0 7rpx;
  218. box-sizing: content-box;
  219. }
  220. &-img {
  221. width: 348rpx;
  222. height: 348rpx;
  223. background-color: #f5f5f5;
  224. border-radius: 10rpx 10rpx 0 0;
  225. .img {
  226. width: 100%;
  227. height: 100%;
  228. object-fit: contain;
  229. }
  230. }
  231. &-info {
  232. background-color: #FFFFFF;
  233. //box-shadow: 0px 0px 15px 0px rgba(52, 52, 52, 0.15);
  234. border-radius: 0 0 10rpx 10rpx;
  235. padding: 20rpx;
  236. label {
  237. font-weight: normal;
  238. }
  239. .product-name {
  240. font-size: 28rpx;
  241. color: #333;
  242. display: block;
  243. overflow: hidden;
  244. text-overflow: ellipsis;
  245. white-space: nowrap;
  246. margin-bottom: 18rpx;
  247. line-height: 40rpx;
  248. }
  249. .flex {
  250. display: flex;
  251. align-items: center;
  252. }
  253. .shop-box {
  254. background-color: #333333;
  255. border-radius: 0rpx 20rpx 20rpx 0rpx;
  256. line-height: 40rpx;
  257. display: flex;
  258. align-items: center;
  259. height: 40rpx;
  260. margin-right: 10rpx;
  261. .shop-name {
  262. font-size: 20rpx;
  263. color: #FFEBC4;
  264. padding: 0 8rpx 0 12rpx;
  265. }
  266. .shop-logo {
  267. border: 2rpx solid #707070;
  268. border-radius: 50%;
  269. overflow: hidden;
  270. float: right;
  271. img {
  272. width: 34rpx;
  273. height: 34rpx;
  274. display: block;
  275. }
  276. }
  277. }
  278. .buy-count {
  279. color: #C5AA7B;
  280. font-size: 20rpx;
  281. border: 2rpx solid #E4E5E6;
  282. line-height: 40rpx;
  283. padding: 0 5rpx;
  284. }
  285. .price-warp {
  286. display: flex;
  287. align-items: baseline;
  288. line-height: 56rpx;
  289. .iconImg {
  290. width: 58rpx;
  291. height: 36rpx;
  292. margin-right: 10rpx;
  293. }
  294. .price {
  295. color: #C83732;
  296. font-size: 40rpx;
  297. margin-right: 20rpx;
  298. }
  299. .original-price {
  300. font-size: 24rpx;
  301. color: #ccc;
  302. text-decoration: line-through;
  303. }
  304. }
  305. }
  306. //::v-deep .swiper-pagination-bullet{
  307. // display: none;
  308. //}
  309. }
  310. }
  311. //::v-deep .uni-swiper-dots{
  312. // display: flex;
  313. // justify-content: center;
  314. // padding: 10rpx 0;
  315. // .uni-swiper-dot{
  316. // width: 10rpx;
  317. // height: 10rpx;
  318. // background: #333333;
  319. // opacity: 0.3;
  320. // border-radius: 5rpx;
  321. // margin: 0 5rpx;
  322. // &-active{
  323. // width: 20rpx;
  324. // height: 10rpx;
  325. // opacity: 1;
  326. // }
  327. // }
  328. //}
  329. .swiper-dots {
  330. display: flex;
  331. position: absolute;
  332. left: 50%;
  333. transform: translateX(-50%);
  334. bottom: 15rpx;
  335. z-index: 66;
  336. .dot {
  337. width: 10rpx;
  338. height: 10rpx;
  339. background: #333333;
  340. opacity: 0.3;
  341. border-radius: 5rpx;
  342. margin: 0 10rpx;
  343. }
  344. .dot-active {
  345. width: 20rpx;
  346. opacity: 1;
  347. }
  348. }
  349. //.pagination{
  350. // display: flex;
  351. // justify-content: center;
  352. // padding: 20rpx 0;
  353. // ::v-deep .swiper-pagination-bullet{
  354. // width: 10rpx;
  355. // height: 10rpx;
  356. // background: #333333;
  357. // opacity: 0.3;
  358. // border-radius: 5rpx;
  359. // margin: 0 5rpx;
  360. // }
  361. // ::v-deep .swiper-pagination-bullet-active{
  362. // width: 20rpx;
  363. // height: 10rpx;
  364. // opacity: 1;
  365. // }
  366. //}
  367. .btn-more {
  368. width: 170rpx;
  369. height: 54rpx;
  370. line-height: 54rpx;
  371. border: 2rpx solid #C5AA7B;
  372. color: #C5AA7B;
  373. font-size: 24rpx;
  374. background-color: transparent;
  375. margin: 20rpx auto 0;
  376. display: flex;
  377. align-items: center;
  378. }
  379. </style>