seckill.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view v-if="spikeList.length > 0" class="skeleton-rect" :style="'padding-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="`${domain}/static/images/spike_title.png`"></image>
  7. <view class="spike-distance">
  8. <text :style="'background-color:'+countDownColor" class="text bg-red">距结束</text>
  9. <countDown class="spike-count" :is-day="false" :tip-text="' '" :day-text="' '" :hour-text="':'" :minute-text="':'" :second-text="' '" :datatime="datatime" :colors="color" @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" :style="{ borderColor: themeColor, color: themeColor }">
  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" :style="{ color: themeColor }">
  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. v-if="index<=2"
  52. :key="index"
  53. hover-class="none"
  54. :style="{ 'background-image': `url(${domain}/static/images/combination${index+1}.png)`,'border-radius':`${conStyle}rpx`}"
  55. :url="'/pages/activity/goods_seckill_details/index?id=' + item.product_id + '&time=' + item.stop + ''"
  56. >
  57. <view class="info">
  58. <view class="price-box combination-price">
  59. <view v-if="titleShow" class="name line1">{{ item.store_name }}</view>
  60. <text class="price" :style="{ color: themeColor }">
  61. <text></text>
  62. {{ item.price }}
  63. </text>
  64. <text class="gocom_btn">
  65. 去抢购
  66. <text class="iconfont icon-jiantou"></text>
  67. </text>
  68. </view>
  69. </view>
  70. <view class="img-box" :class="'img-box'+conStyles">
  71. <easy-loadimage mode="widthFix" :image-src="item.image"></easy-loadimage>
  72. </view>
  73. </navigator>
  74. <navigator v-if="spikeList.length == 1"
  75. class="combination-item"
  76. hover-class="none"
  77. :style="{ 'background-image': `url(${domain}/static/images/combination2.png)`}"
  78. :url="'/pages/activity/goods_seckill_details/index?id=' + spikeList[0].product_id + '&time=' + spikeList[0].stop + ''"
  79. >
  80. <view class="info">
  81. <view class="price-box combination-price">
  82. <view v-if="titleShow" class="name line1">{{ spikeList[0].store_name }}</view>
  83. <text class="price" :style="{ color: themeColor }">
  84. <text></text>
  85. {{ spikeList[0].price }}
  86. </text>
  87. <text class="gocom_btn">
  88. 去抢购
  89. <text class="iconfont icon-jiantou"></text>
  90. </text>
  91. </view>
  92. </view>
  93. <view class="img-box" :class="'img-box'+conStyles">
  94. <easy-loadimage mode="widthFix" :image-src="spikeList[0].image"></easy-loadimage>
  95. </view>
  96. </navigator>
  97. <navigator v-if="spikeList.length == 1"
  98. class="combination-item"
  99. hover-class="none"
  100. :style="{ 'background-image': `url(${domain}/static/images/combination3.png)`}"
  101. :url="'/pages/activity/goods_seckill_details/index?id=' + spikeList[0].product_id + '&time=' + spikeList[0].stop + ''"
  102. >
  103. <view class="info">
  104. <view class="price-box combination-price">
  105. <view v-if="titleShow" class="name line1">{{ spikeList[0].store_name }}</view>
  106. <text class="price" :style="{ color: themeColor }">
  107. <text></text>
  108. {{ spikeList[0].price }}
  109. </text>
  110. <text class="gocom_btn">
  111. 去抢购
  112. <text class="iconfont icon-jiantou"></text>
  113. </text>
  114. </view>
  115. </view>
  116. <view class="img-box" :class="'img-box'+conStyles">
  117. <easy-loadimage mode="widthFix" :image-src="spikeList[0].image"></easy-loadimage>
  118. </view>
  119. </navigator>
  120. <navigator v-if="spikeList.length == 2"
  121. class="combination-item"
  122. hover-class="none"
  123. :style="{ 'background-image': `url(${domain}/static/images/combination3.png)`}"
  124. :url="'/pages/activity/goods_seckill_details/index?id=' + spikeList[1].product_id + '&time=' + spikeList[1].stop + ''"
  125. >
  126. <view class="info">
  127. <view class="price-box combination-price">
  128. <view v-if="titleShow" class="name line1">{{ spikeList[1].store_name }}</view>
  129. <text class="price" :style="{ color: themeColor }">
  130. <text></text>
  131. {{ spikeList[1].price }}
  132. </text>
  133. <text class="gocom_btn">
  134. 去抢购
  135. <text class="iconfont icon-jiantou"></text>
  136. </text>
  137. </view>
  138. </view>
  139. <view class="img-box" :class="'img-box'+conStyles">
  140. <easy-loadimage mode="widthFix" :image-src="spikeList[1].image"></easy-loadimage>
  141. </view>
  142. </navigator>
  143. </block>
  144. </view>
  145. </view>
  146. </view>
  147. </template>
  148. <script>
  149. // +----------------------------------------------------------------------
  150. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  151. // +----------------------------------------------------------------------
  152. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  153. // +----------------------------------------------------------------------
  154. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  155. // +----------------------------------------------------------------------
  156. // | Author: CRMEB Team <admin@crmeb.com>
  157. // +----------------------------------------------------------------------
  158. import { HTTP_REQUEST_URL } from '@/config/app';
  159. import countDown from '@/components/countDown';
  160. import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue';
  161. import {
  162. getSeckillData
  163. } from '@/api/api.js';
  164. export default {
  165. name: 'seckill',
  166. components:{
  167. countDown,
  168. easyLoadimage
  169. },
  170. props: {
  171. dataConfig: {
  172. type: Object,
  173. default: () => {}
  174. },
  175. merId: {
  176. type: String || Number,
  177. default: ''
  178. }
  179. },
  180. data() {
  181. return {
  182. domain: HTTP_REQUEST_URL,
  183. datatime:0,
  184. color: "#E93323",
  185. spikeList: [],
  186. countDownColor: this.dataConfig.countDownColor.color[0].item,
  187. themeColor: this.dataConfig.themeColor.color[0].item,
  188. styleType: this.dataConfig.tabConfig.tabVal, //单行,多行,板块
  189. mbConfig: this.dataConfig.mbConfig.val*2,
  190. bgStyle: this.dataConfig.bgStyle.type ? 20 : 0,
  191. bgColor: this.dataConfig.bgColor.color[0].item,
  192. conStyle: this.dataConfig.conStyle.type ? 16 : 0,
  193. conStyles: this.dataConfig.conStyle.type,
  194. priceShow: this.dataConfig.priceShow.val,
  195. progressShow: this.dataConfig.progressShow.val,
  196. titleShow: this.dataConfig.titleShow.val,
  197. diy_id: this.dataConfig.did,
  198. unique: this.dataConfig.timestamp,
  199. };
  200. },
  201. created() {},
  202. mounted() {
  203. this.getSeckillData();
  204. },
  205. methods: {
  206. getSeckillData() {
  207. let that = this;
  208. getSeckillData({
  209. diy_id: that.diy_id,
  210. unique: that.unique,
  211. mer_id: that.merId,
  212. limit: that.styleType == 2 ? 3 : 12
  213. }).then(res => {
  214. that.datatime = res.data&&res.data.stop;
  215. that.spikeList = res.data&&res.data.list || [];
  216. that.spikeList.map(item => {
  217. item.percent = item.stock === 0 ? '100%' : ((item.sales * 100) / (item.sales+item.stock)).toFixed(2) + '%';
  218. });
  219. }).catch(e => {});
  220. },
  221. getProduct(){
  222. this.getSeckillData();
  223. }
  224. }
  225. }
  226. </script>
  227. <style lang="scss" scoped>
  228. @import '../style/main.scss';
  229. .seckill-count {
  230. background-color: #fff;
  231. margin: 0 20rpx;
  232. border-radius: 16rpx;
  233. padding: 24rpx 0 26rpx 20rpx;
  234. box-shadow: 4rpx 2rpx 12rpx 2rpx rgba(0, 0, 0, 0.03);
  235. &.wrapper-count2{
  236. padding: 24rpx 20rpx 26rpx;
  237. }
  238. }
  239. .spike-count{
  240. display: flex;
  241. justify-content: center;
  242. align-items: center;
  243. /*#ifdef MP*/
  244. // width: 180rpx;
  245. /*#endif*/
  246. }
  247. /deep/.spike-bd .red{
  248. color: #e93323!important;
  249. }
  250. </style>