seckill.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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" :style="'color:'+titleColor">限时秒杀</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 && item.discount_num>0 && item.discount_num<10" class="msg flex-aj-center" :style="'color:'+ themeColor +';border-color:'+ themeColor +';'">{{item.discount_num}}折起</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:'+fontColor+';'"><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. fontColor:this.dataConfig.fontColor.color[0].item,
  83. titleColor:this.dataConfig.titleColor.color[0].item,
  84. };
  85. },
  86. created() {
  87. },
  88. mounted() {
  89. this.getSeckillIndexTime();
  90. },
  91. methods: {
  92. getSeckillIndexTime() {
  93. let limit = this.$config.LIMIT;
  94. let params = {
  95. page: 1,
  96. limit: this.numberConfig>=limit?limit:this.numberConfig,
  97. type: 'index'
  98. }
  99. getSeckillIndexTime().then(res => {
  100. if (res.data.seckillTimeIndex === -1) {
  101. return;
  102. }
  103. this.datatime = res.data.seckillTime[res.data.seckillTimeIndex].stop
  104. let id = res.data.seckillTime[res.data.seckillTimeIndex].id
  105. getSeckillList(id, params).then(({
  106. data
  107. }) => {
  108. this.spikeList = data
  109. })
  110. })
  111. },
  112. }
  113. }
  114. </script>
  115. <style lang="scss">
  116. .spike{
  117. padding: 20rpx;
  118. }
  119. .spike-box {
  120. padding: 23rpx 20rpx 18rpx 20rpx;
  121. background-color: #fff;
  122. overflow: hidden;
  123. box-shadow: 0px 0px 16px 3px rgba(0, 0, 0, 0.04);
  124. .hd {
  125. display: flex;
  126. align-items: center;
  127. justify-content: space-between;
  128. .left {
  129. display: flex;
  130. align-items: center;
  131. width: 500rpx;
  132. .name{
  133. font-size: 32rpx;
  134. font-weight: 600;
  135. }
  136. .icon {
  137. width: 36rpx;
  138. height: 36rpx;
  139. margin-right: 12rpx;
  140. }
  141. .title {
  142. width: 134rpx;
  143. height: 33rpx;
  144. }
  145. }
  146. .more {
  147. font-size: 26rpx;
  148. color: #999;
  149. .iconfont {
  150. margin-left: 6rpx;
  151. font-size: 25rpx;
  152. }
  153. }
  154. }
  155. .spike-wrapper {
  156. width: 100%;
  157. margin-top: 27rpx;
  158. .spike-item {
  159. display: inline-block;
  160. width: 222rpx;
  161. background-color: #fff;
  162. border-radius: 16rpx;
  163. padding-bottom: 8rpx;
  164. .img-box {
  165. position: relative;
  166. height: 222rpx;
  167. image {
  168. width: 100%;
  169. height: 222rpx;
  170. border-radius: 16rpx;
  171. }
  172. .msg {
  173. position: absolute;
  174. left: 10rpx;
  175. bottom: 16rpx;
  176. width: 86rpx;
  177. height: 30rpx;
  178. background: rgba(255, 255, 255, 1);
  179. border: 1px solid rgba(255, 109, 96, 1);
  180. border-radius: 6rpx;
  181. font-size: 20rpx;
  182. color: $theme-color;
  183. }
  184. }
  185. .info {
  186. margin-top: 10rpx;
  187. padding: 0 10rpx;
  188. .name {
  189. font-size: 26rpx;
  190. }
  191. .price-box {
  192. display: flex;
  193. align-items: center;
  194. justify-content: start;
  195. margin-top: 4rpx;
  196. .tips {
  197. display: flex;
  198. align-items: center;
  199. justify-content: center;
  200. width: 28rpx;
  201. height: 28rpx;
  202. background-color: $theme-color;
  203. color: #fff;
  204. font-size: 20rpx;
  205. border-radius: 2px;
  206. }
  207. .price {
  208. display: flex;
  209. margin-left: 10rpx;
  210. color: $theme-color;
  211. font-size: 28rpx;
  212. font-weight: bold;
  213. text {
  214. font-size: 18rpx;
  215. }
  216. }
  217. }
  218. }
  219. }
  220. }
  221. }
  222. </style>