index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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 v-if="item.originalPrice && item.originalPrice > item.price" class="original-price">
  152. ¥ {{ item.originalPrice }}
  153. </div>
  154. </div>
  155. <div
  156. style="width: fit-content;margin-top: -4upx;padding: 2upx 12upx 6upx 2upx;background-color: #f0f0f0;font-size: 28upx;color: #fa5151;border-radius: 0 22upx 22upx 0;vertical-align: middle;"
  157. >
  158. 可使用{{ Math.ceil(Number(item.price || 0)) }}代金券抵扣
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. <button v-show="componentContent.showMore" class="btn-more" @click="jumpProList(componentContent.productData)">
  166. 查看全部 <span class="icon iconfont icon-arrow-right"></span>
  167. </button>
  168. </div>
  169. </template>
  170. <script>
  171. import { commonMixin } from '../mixin'
  172. import ProductSkeleton from '@/components/basics/components/ProductSkeleton'
  173. export default {
  174. components: {
  175. ProductSkeleton
  176. },
  177. mixins: [ commonMixin ],
  178. data() {
  179. return {
  180. swiperCurrent: 0
  181. }
  182. },
  183. methods: {
  184. swiperChange(e) {
  185. this.swiperCurrent = e.detail.current
  186. }
  187. }
  188. }
  189. </script>
  190. <style
  191. lang="scss"
  192. scoped
  193. >
  194. .hom-pro-list {
  195. padding: 20rpx 13rpx;
  196. .title {
  197. text-align: center;
  198. margin-bottom: 20rpx;
  199. .title-img {
  200. width: 211rpx;
  201. }
  202. }
  203. /**多行多列**/
  204. .product-list {
  205. position: relative;
  206. &-box {
  207. display: flex;
  208. flex-wrap: wrap;
  209. flex-direction: row;
  210. &.swiper {
  211. height: 620rpx;
  212. }
  213. }
  214. &.product-swiper .product-list-box {
  215. padding-left: 0;
  216. }
  217. &-item-warp {
  218. margin: 0 0 20rpx 0;
  219. }
  220. &-item {
  221. width: 348rpx;
  222. padding: 0 7rpx;
  223. box-sizing: content-box;
  224. }
  225. &-img {
  226. width: 348rpx;
  227. height: 348rpx;
  228. background-color: #f5f5f5;
  229. border-radius: 10rpx 10rpx 0 0;
  230. .img {
  231. width: 100%;
  232. height: 100%;
  233. object-fit: contain;
  234. }
  235. }
  236. &-info {
  237. background-color: #FFFFFF;
  238. //box-shadow: 0px 0px 15px 0px rgba(52, 52, 52, 0.15);
  239. border-radius: 0 0 10rpx 10rpx;
  240. padding: 20rpx;
  241. label {
  242. font-weight: normal;
  243. }
  244. .product-name {
  245. font-size: 28rpx;
  246. color: #333;
  247. display: block;
  248. overflow: hidden;
  249. text-overflow: ellipsis;
  250. white-space: nowrap;
  251. margin-bottom: 18rpx;
  252. line-height: 40rpx;
  253. }
  254. .flex {
  255. display: flex;
  256. align-items: center;
  257. }
  258. .shop-box {
  259. background-color: #333333;
  260. border-radius: 0rpx 20rpx 20rpx 0rpx;
  261. line-height: 40rpx;
  262. display: flex;
  263. align-items: center;
  264. height: 40rpx;
  265. margin-right: 10rpx;
  266. .shop-name {
  267. font-size: 20rpx;
  268. color: #FFEBC4;
  269. padding: 0 8rpx 0 12rpx;
  270. }
  271. .shop-logo {
  272. border: 2rpx solid #707070;
  273. border-radius: 50%;
  274. overflow: hidden;
  275. float: right;
  276. img {
  277. width: 34rpx;
  278. height: 34rpx;
  279. display: block;
  280. }
  281. }
  282. }
  283. .buy-count {
  284. color: #C5AA7B;
  285. font-size: 20rpx;
  286. border: 2rpx solid #E4E5E6;
  287. line-height: 40rpx;
  288. padding: 0 5rpx;
  289. }
  290. .price-warp {
  291. display: flex;
  292. align-items: baseline;
  293. line-height: 56rpx;
  294. .iconImg {
  295. width: 58rpx;
  296. height: 36rpx;
  297. margin-right: 10rpx;
  298. }
  299. .price {
  300. color: #C83732;
  301. font-size: 40rpx;
  302. margin-right: 20rpx;
  303. }
  304. .original-price {
  305. font-size: 24rpx;
  306. color: #ccc;
  307. text-decoration: line-through;
  308. }
  309. }
  310. }
  311. //::v-deep .swiper-pagination-bullet{
  312. // display: none;
  313. //}
  314. }
  315. }
  316. //::v-deep .uni-swiper-dots{
  317. // display: flex;
  318. // justify-content: center;
  319. // padding: 10rpx 0;
  320. // .uni-swiper-dot{
  321. // width: 10rpx;
  322. // height: 10rpx;
  323. // background: #333333;
  324. // opacity: 0.3;
  325. // border-radius: 5rpx;
  326. // margin: 0 5rpx;
  327. // &-active{
  328. // width: 20rpx;
  329. // height: 10rpx;
  330. // opacity: 1;
  331. // }
  332. // }
  333. //}
  334. .swiper-dots {
  335. display: flex;
  336. position: absolute;
  337. left: 50%;
  338. transform: translateX(-50%);
  339. bottom: 15rpx;
  340. z-index: 66;
  341. .dot {
  342. width: 10rpx;
  343. height: 10rpx;
  344. background: #333333;
  345. opacity: 0.3;
  346. border-radius: 5rpx;
  347. margin: 0 10rpx;
  348. }
  349. .dot-active {
  350. width: 20rpx;
  351. opacity: 1;
  352. }
  353. }
  354. //.pagination{
  355. // display: flex;
  356. // justify-content: center;
  357. // padding: 20rpx 0;
  358. // ::v-deep .swiper-pagination-bullet{
  359. // width: 10rpx;
  360. // height: 10rpx;
  361. // background: #333333;
  362. // opacity: 0.3;
  363. // border-radius: 5rpx;
  364. // margin: 0 5rpx;
  365. // }
  366. // ::v-deep .swiper-pagination-bullet-active{
  367. // width: 20rpx;
  368. // height: 10rpx;
  369. // opacity: 1;
  370. // }
  371. //}
  372. .btn-more {
  373. width: 170rpx;
  374. height: 54rpx;
  375. line-height: 54rpx;
  376. border: 2rpx solid #C5AA7B;
  377. color: #C5AA7B;
  378. font-size: 24rpx;
  379. background-color: transparent;
  380. margin: 20rpx auto 0;
  381. display: flex;
  382. align-items: center;
  383. }
  384. </style>