seckill.vue 6.0 KB

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