seckill.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view v-if="spikeList.length > 0" class="skeleton-rect" :style="'margin-top:'+mbConfig+'rpx'">
  3. <view class="seckill-count" :class="'wrapper-count'+styleType" :style="'background:'+bgColor+';border-radius:'+bgStyle+'rpx'">
  4. <view class="spike-bd">
  5. <view class="acea-row row-middle">
  6. <image class="title-img" src="/static/images/spike_title.png"></image>
  7. <view class="spike-distance">
  8. <text :style="'background-color:'+countDownColor" class="text bg-red">距结束</text>
  9. <countDown :is-day="false" :tip-text="' '" :day-text="' '" :hour-text="':'" :minute-text="':'" :second-text="' '" :datatime="datatime" :colors="themeColor" @getProduct="getProduct"></countDown>
  10. </view>
  11. </view>
  12. <navigator v-if="!merId" url="/pages/activity/goods_seckill/index" class="more-btn" hover-class="none">
  13. 更多惊喜
  14. <text class="iconfont icon-jiantou" hover-class="none"></text>
  15. </navigator>
  16. </view>
  17. <view class="spike-wrapper" :class="'wrapper'+styleType">
  18. <scroll-view v-if="styleType != 2" :class="'colum'+styleType" :scroll-x="styleType == 0 ? true : false" show-scrollbar="false">
  19. <navigator
  20. class="spike-item"
  21. v-for="(item, index) in spikeList"
  22. :key="index"
  23. :url="'/pages/activity/goods_seckill_details/index?id=' + item.product_id + '&time=' + item.stop + ''"
  24. hover-class="none">
  25. <view class="img-box" :class="'img-box'+conStyle">
  26. <easy-loadimage mode="widthFix" :image-src="item.image"></easy-loadimage>
  27. </view>
  28. <view class="info">
  29. <view v-if="titleShow" class="name line1">{{ item.store_name }}</view>
  30. <view v-if="progressShow" class="stock-box">
  31. <view class="grabbed" :style="'width:' + item.percent + ';'"></view>
  32. <text class="stock-sales">{{ item.percent }}</text>
  33. </view>
  34. <view class="price-box">
  35. <text class="price">
  36. <text>¥</text>
  37. {{ item.price }}
  38. </text>
  39. <text v-if="priceShow" class="old-price">
  40. <text>¥</text>
  41. {{ item.ot_price }}
  42. </text>
  43. </view>
  44. </view>
  45. </navigator>
  46. </scroll-view>
  47. <block v-else class="acea-row row-between-wrapper combination">
  48. <navigator
  49. class="combination-item"
  50. v-for="(item, index) in spikeList"
  51. :key="index"
  52. :url="'/pages/activity/goods_seckill_details/index?id=' + item.product_id + '&time=' + item.stop + ''"
  53. hover-class="none"
  54. :style="'border-radius:'+conStyle">
  55. <view class="info">
  56. <view class="price-box combination-price">
  57. <view v-if="titleShow" class="name line1">{{ item.store_name }}</view>
  58. <text class="price">
  59. <text>¥</text>
  60. {{ item.price }}
  61. </text>
  62. <text class="gocom_btn">
  63. 去抢购
  64. <text class="iconfont icon-jiantou"></text>
  65. </text>
  66. </view>
  67. </view>
  68. <view class="img-box">
  69. <easy-loadimage mode="widthFix" :image-src="item.image"></easy-loadimage>
  70. </view>
  71. </navigator>
  72. <navigator v-if="spikeList.length == 1"
  73. class="combination-item"
  74. hover-class="none"
  75. :url="'/pages/activity/goods_seckill_details/index?id=' + spikeList[0].product_id + '&time=' + spikeList[0].stop + ''"
  76. :style="'border-radius:'+conStyle">
  77. <view class="info">
  78. <view class="price-box combination-price">
  79. <view v-if="titleShow" class="name line1">{{ spikeList[0].store_name }}</view>
  80. <text class="price">
  81. <text>¥</text>
  82. {{ spikeList[0].price }}
  83. </text>
  84. <text class="gocom_btn">
  85. 去抢购
  86. <text class="iconfont icon-jiantou"></text>
  87. </text>
  88. </view>
  89. </view>
  90. <view class="img-box">
  91. <easy-loadimage mode="widthFix" :image-src="spikeList[0].image"></easy-loadimage>
  92. </view>
  93. </navigator>
  94. <navigator v-if="spikeList.length == 1"
  95. class="combination-item"
  96. hover-class="none"
  97. :url="'/pages/activity/goods_seckill_details/index?id=' + spikeList[0].product_id + '&time=' + spikeList[0].stop + ''"
  98. :style="'border-radius:'+conStyle">
  99. <view class="info">
  100. <view class="price-box combination-price">
  101. <view v-if="titleShow" class="name line1">{{ spikeList[0].store_name }}</view>
  102. <text class="price">
  103. <text>¥</text>
  104. {{ spikeList[0].price }}
  105. </text>
  106. <text class="gocom_btn">
  107. 去抢购
  108. <text class="iconfont icon-jiantou"></text>
  109. </text>
  110. </view>
  111. </view>
  112. <view class="img-box">
  113. <easy-loadimage mode="widthFix" :image-src="spikeList[0].image"></easy-loadimage>
  114. </view>
  115. </navigator>
  116. <navigator v-if="spikeList.length == 2"
  117. class="combination-item"
  118. hover-class="none"
  119. :url="'/pages/activity/goods_seckill_details/index?id=' + spikeList[1].product_id + '&time=' + spikeList[1].stop + ''"
  120. :style="'border-radius:'+conStyle">
  121. <view class="info">
  122. <view class="price-box combination-price">
  123. <view v-if="titleShow" class="name line1">{{ spikeList[1].store_name }}</view>
  124. <text class="price">
  125. <text>¥</text>
  126. {{ spikeList[1].price }}
  127. </text>
  128. <text class="gocom_btn">
  129. 去抢购
  130. <text class="iconfont icon-jiantou"></text>
  131. </text>
  132. </view>
  133. </view>
  134. <view class="img-box">
  135. <easy-loadimage mode="widthFix" :image-src="spikeList[1].image"></easy-loadimage>
  136. </view>
  137. </navigator>
  138. </block>
  139. </view>
  140. </view>
  141. </view>
  142. </template>
  143. <script>
  144. import countDown from '@/components/countDown';
  145. import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue';
  146. import {
  147. getSeckillIndexTime,
  148. getSeckillList
  149. } from '@/api/activity.js';
  150. export default {
  151. name: 'seckill',
  152. components:{
  153. countDown,
  154. easyLoadimage
  155. },
  156. props: {
  157. dataConfig: {
  158. type: Object,
  159. default: () => {}
  160. },
  161. merId: {
  162. type: String || Number,
  163. default: ''
  164. }
  165. },
  166. data() {
  167. return {
  168. datatime:0,
  169. spikeList: [],
  170. countDownColor: this.dataConfig.countDownColor.color[0].item,
  171. themeColor: this.dataConfig.themeColor.color[0].item,
  172. styleType: this.dataConfig.tabConfig.tabVal, //单行,多行,板块
  173. mbConfig: this.dataConfig.mbConfig.val*2,
  174. bgStyle: this.dataConfig.bgStyle.type ? 20 : 0,
  175. bgColor: this.dataConfig.bgColor.color[0].item,
  176. conStyle: this.dataConfig.conStyle.type ? 16 : 0,
  177. priceShow: this.dataConfig.priceShow.val,
  178. progressShow: this.dataConfig.progressShow.val,
  179. titleShow: this.dataConfig.titleShow.val
  180. };
  181. },
  182. created() {},
  183. mounted() {
  184. this.getSpikeProduct();
  185. this.getSpeckillCutTime();
  186. },
  187. methods: {
  188. // 获取秒杀截止时间
  189. getSpeckillCutTime() {
  190. getSeckillIndexTime().then(res => {
  191. this.datatime = res.data.seckillEndTime ? res.data.seckillEndTime : '';
  192. });
  193. },
  194. getSpikeProduct() {
  195. let that = this;
  196. getSeckillList({
  197. mer_id:that.merId,limit: that.styleType == 2 ? 3 : 12
  198. }).then(res => {
  199. that.spikeList = res.data.list;
  200. that.spikeList.map(item => {
  201. item.percent = item.stock === 0 ? '0%' : ((item.sales * 100) / item.stock).toFixed(2) + '%';
  202. });
  203. }).catch(e => {});
  204. },
  205. getProduct(){
  206. this.getSpeckillCutTime();
  207. this.getSpikeProduct();
  208. }
  209. }
  210. }
  211. </script>
  212. <style lang="scss">
  213. @import '../style/main.scss';
  214. .seckill-count {
  215. background-color: #fff;
  216. margin: 0 20rpx;
  217. border-radius: 16rpx;
  218. padding: 24rpx 0 26rpx 20rpx;
  219. box-shadow: 4rpx 2rpx 12rpx 2rpx rgba(0, 0, 0, 0.03);
  220. &.wrapper-count2{
  221. padding: 24rpx 20rpx 26rpx;
  222. }
  223. }
  224. </style>