seckill.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <!-- 秒杀列表 -->
  3. <view v-show="!isSortType" v-if="spikeList.length>0">
  4. <view class="spike-box" :class="conStyle?'borderRadius20':''" :style="{background:bgColor,margin:'0 '+prConfig*2+'rpx',marginTop:mbConfig*2+'rpx'}">
  5. <view class="hd">
  6. <view class="left">
  7. <image :src="imgUrl" class="icon" v-if="imgUrl"></image>
  8. <image src="/static/images/spike-icon-002.gif" class="icon" v-else></image>
  9. <view class="name">限时秒杀</view>
  10. <!-- <image src="/static/images/spike-icon-001.png" class="title"></image> -->
  11. <countDown :is-day="false" :tip-text="' '" :day-text="' '" :hour-text="' : '" :minute-text="' : '" :second-text="' '"
  12. :datatime="datatime" :bgColor="countDownColor" :colors="themeColor"></countDown>
  13. </view>
  14. <navigator class="more" url="/pages/activity/goods_seckill/index">更多 <text class="iconfont icon-jiantou"
  15. hover-class='none'></text></navigator>
  16. </view>
  17. <view class="spike-wrapper">
  18. <scroll-view scroll-x="true" style="white-space: nowrap; display: flex" show-scrollbar="false">
  19. <navigator class="spike-item" :style="'margin-right:'+ lrConfig*2 +'rpx;'" v-for="(item,index) in spikeList" :key="index" :url="'/pages/activity/goods_seckill_details/index?id='+item.id+'&time='+datatime+'&status=1'"
  20. hover-class='none'>
  21. <view class="img-box">
  22. <image :src="item.image" mode="aspectFill"></image>
  23. <view v-if="discountShow" class="msg flex-aj-center" :style="'color:'+ themeColor +';border-color:'+ themeColor +';'">{{item.discountNum}}折起</view>
  24. </view>
  25. <view class="info">
  26. <view v-if="titleShow" class="name line1">{{item.title}}</view>
  27. <!-- #ifdef H5 || APP-PLUS -->
  28. <slot name="center" :item="item"></slot>
  29. <!-- #endif -->
  30. <!-- #ifdef MP -->
  31. <slot name="center{{index}}"></slot>
  32. <!-- #endif -->
  33. <view class="price-box">
  34. <text v-if="seckillShow" class="tips" :style="'background-color:'+ themeColor +';'">抢</text>
  35. <text v-if="priceShow" class="price" :style="'color:'+themeColor+';'"><text>¥</text>{{item.price}}</text>
  36. </view>
  37. </view>
  38. </navigator>
  39. </scroll-view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import countDown from '@/components/countDown';
  46. import {
  47. getSeckillIndexTime,
  48. getSeckillList
  49. } from '@/api/activity.js';
  50. export default {
  51. name: 'seckill',
  52. components:{
  53. countDown
  54. },
  55. props: {
  56. dataConfig: {
  57. type: Object,
  58. default: () => {}
  59. },
  60. isSortType:{
  61. type: String | Number,
  62. default:0
  63. }
  64. },
  65. data() {
  66. return {
  67. datatime:'',
  68. spikeList: [],
  69. countDownColor: this.dataConfig.countDownColor.color[0].item,
  70. themeColor: this.dataConfig.themeColor.color[0].item,
  71. numberConfig: this.dataConfig.numberConfig.val,
  72. lrConfig:this.dataConfig.lrConfig.val,
  73. mbConfig:this.dataConfig.mbConfig.val,
  74. imgUrl:this.dataConfig.imgConfig.url,
  75. priceShow:this.dataConfig.priceShow.val,
  76. discountShow:this.dataConfig.discountShow.val,
  77. titleShow:this.dataConfig.titleShow.val,
  78. seckillShow:this.dataConfig.seckillShow.val,
  79. conStyle:this.dataConfig.conStyle.type,
  80. prConfig:this.dataConfig.prConfig.val,
  81. bgColor:this.dataConfig.bgColor.color[0].item
  82. };
  83. },
  84. created() {
  85. },
  86. mounted() {
  87. this.getSeckillIndexTime();
  88. },
  89. methods: {
  90. getSeckillIndexTime() {
  91. let limit = this.$config.LIMIT;
  92. let params = {
  93. page: 1,
  94. limit: this.numberConfig>=limit?limit:this.numberConfig,
  95. type: 'index'
  96. }
  97. getSeckillIndexTime().then(res => {
  98. if (res.data.seckillTimeIndex === -1) {
  99. return;
  100. }
  101. this.datatime = res.data.seckillTime[res.data.seckillTimeIndex].stop
  102. let id = res.data.seckillTime[res.data.seckillTimeIndex].id
  103. getSeckillList(id, params).then(({
  104. data
  105. }) => {
  106. data.forEach((item) => {
  107. let num = 0
  108. if (item.price > 0 && item.ot_price > 0) num = ((parseFloat(item.price) / parseFloat(item.ot_price)).toFixed(
  109. 2))
  110. item.discountNum = this.$util.$h.Mul(num, 10)
  111. })
  112. this.spikeList = data
  113. })
  114. })
  115. },
  116. }
  117. }
  118. </script>
  119. <style lang="scss">
  120. .spike{
  121. padding: 20rpx;
  122. }
  123. .spike-box {
  124. padding: 23rpx 20rpx 18rpx 20rpx;
  125. background-color: #fff;
  126. overflow: hidden;
  127. box-shadow: 0px 0px 16px 3px rgba(0, 0, 0, 0.04);
  128. .hd {
  129. display: flex;
  130. align-items: center;
  131. justify-content: space-between;
  132. .left {
  133. display: flex;
  134. align-items: center;
  135. width: 500rpx;
  136. .name{
  137. font-size: 32rpx;
  138. font-weight: 600;
  139. }
  140. .icon {
  141. width: 36rpx;
  142. height: 36rpx;
  143. margin-right: 12rpx;
  144. }
  145. .title {
  146. width: 134rpx;
  147. height: 33rpx;
  148. }
  149. }
  150. .more {
  151. font-size: 26rpx;
  152. color: #999;
  153. .iconfont {
  154. margin-left: 6rpx;
  155. font-size: 25rpx;
  156. }
  157. }
  158. }
  159. .spike-wrapper {
  160. width: 100%;
  161. margin-top: 27rpx;
  162. .spike-item {
  163. display: inline-block;
  164. width: 222rpx;
  165. background-color: #fff;
  166. border-radius: 16rpx;
  167. padding-bottom: 8rpx;
  168. .img-box {
  169. position: relative;
  170. height: 222rpx;
  171. image {
  172. width: 100%;
  173. height: 222rpx;
  174. border-radius: 16rpx;
  175. }
  176. .msg {
  177. position: absolute;
  178. left: 10rpx;
  179. bottom: 16rpx;
  180. width: 86rpx;
  181. height: 30rpx;
  182. background: rgba(255, 255, 255, 1);
  183. border: 1px solid rgba(255, 109, 96, 1);
  184. border-radius: 6rpx;
  185. font-size: 20rpx;
  186. color: $theme-color;
  187. }
  188. }
  189. .info {
  190. margin-top: 10rpx;
  191. padding: 0 10rpx;
  192. .name {
  193. font-size: 26rpx;
  194. }
  195. .price-box {
  196. display: flex;
  197. align-items: center;
  198. justify-content: start;
  199. margin-top: 4rpx;
  200. .tips {
  201. display: flex;
  202. align-items: center;
  203. justify-content: center;
  204. width: 28rpx;
  205. height: 28rpx;
  206. background-color: $theme-color;
  207. color: #fff;
  208. font-size: 20rpx;
  209. border-radius: 2px;
  210. }
  211. .price {
  212. display: flex;
  213. margin-left: 10rpx;
  214. color: $theme-color;
  215. font-size: 28rpx;
  216. font-weight: bold;
  217. text {
  218. font-size: 18rpx;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. }
  225. }
  226. </style>