seckill.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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" 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:'+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. data.forEach((item) => {
  109. let num = 0
  110. if (item.price > 0 && item.ot_price > 0) num = ((parseFloat(item.price) / parseFloat(item.ot_price)).toFixed(
  111. 2))
  112. item.discountNum = this.$util.$h.Mul(num, 10)
  113. })
  114. this.spikeList = data
  115. })
  116. })
  117. },
  118. }
  119. }
  120. </script>
  121. <style lang="scss">
  122. .spike{
  123. padding: 20rpx;
  124. }
  125. .spike-box {
  126. padding: 23rpx 20rpx 18rpx 20rpx;
  127. background-color: #fff;
  128. overflow: hidden;
  129. box-shadow: 0px 0px 16px 3px rgba(0, 0, 0, 0.04);
  130. .hd {
  131. display: flex;
  132. align-items: center;
  133. justify-content: space-between;
  134. .left {
  135. display: flex;
  136. align-items: center;
  137. width: 500rpx;
  138. .name{
  139. font-size: 32rpx;
  140. font-weight: 600;
  141. }
  142. .icon {
  143. width: 36rpx;
  144. height: 36rpx;
  145. margin-right: 12rpx;
  146. }
  147. .title {
  148. width: 134rpx;
  149. height: 33rpx;
  150. }
  151. }
  152. .more {
  153. font-size: 26rpx;
  154. color: #999;
  155. .iconfont {
  156. margin-left: 6rpx;
  157. font-size: 25rpx;
  158. }
  159. }
  160. }
  161. .spike-wrapper {
  162. width: 100%;
  163. margin-top: 27rpx;
  164. .spike-item {
  165. display: inline-block;
  166. width: 222rpx;
  167. background-color: #fff;
  168. border-radius: 16rpx;
  169. padding-bottom: 8rpx;
  170. .img-box {
  171. position: relative;
  172. height: 222rpx;
  173. image {
  174. width: 100%;
  175. height: 222rpx;
  176. border-radius: 16rpx;
  177. }
  178. .msg {
  179. position: absolute;
  180. left: 10rpx;
  181. bottom: 16rpx;
  182. width: 86rpx;
  183. height: 30rpx;
  184. background: rgba(255, 255, 255, 1);
  185. border: 1px solid rgba(255, 109, 96, 1);
  186. border-radius: 6rpx;
  187. font-size: 20rpx;
  188. color: $theme-color;
  189. }
  190. }
  191. .info {
  192. margin-top: 10rpx;
  193. padding: 0 10rpx;
  194. .name {
  195. font-size: 26rpx;
  196. }
  197. .price-box {
  198. display: flex;
  199. align-items: center;
  200. justify-content: start;
  201. margin-top: 4rpx;
  202. .tips {
  203. display: flex;
  204. align-items: center;
  205. justify-content: center;
  206. width: 28rpx;
  207. height: 28rpx;
  208. background-color: $theme-color;
  209. color: #fff;
  210. font-size: 20rpx;
  211. border-radius: 2px;
  212. }
  213. .price {
  214. display: flex;
  215. margin-left: 10rpx;
  216. color: $theme-color;
  217. font-size: 28rpx;
  218. font-weight: bold;
  219. text {
  220. font-size: 18rpx;
  221. }
  222. }
  223. }
  224. }
  225. }
  226. }
  227. }
  228. </style>