index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <div>
  3. <view class='flash-sale'>
  4. <view class="saleBox"></view>
  5. <view class='header' v-if="timeList.length>0">
  6. <image :src='timeList[active].slide'></image>
  7. </view>
  8. <view class="seckillList acea-row row-between-wrapper">
  9. <view class="priceTag">
  10. <image src="/static/images/priceTag.png"></image>
  11. </view>
  12. <view class='timeLsit'>
  13. <scroll-view class="scroll-view_x" scroll-x scroll-with-animation :scroll-left="scrollLeft" style="width:auto;overflow:hidden;height:106rpx;">
  14. <block v-for="(item,index) in timeList" :key='index'>
  15. <view @tap='settimeList(item,index)' class='item' :class="active == index?'on':''">
  16. <view class='time'>{{item.time}}</view>
  17. <view class="state">{{item.state}}</view>
  18. </view>
  19. </block>
  20. </scroll-view>
  21. </view>
  22. </view>
  23. <view class='list'>
  24. <block v-for="(item,index) in seckillList" :key='index'>
  25. <view class='item acea-row row-between-wrapper' @tap='goDetails(item)'>
  26. <view class='pictrue'>
  27. <image :src='item.image'></image>
  28. </view>
  29. <view class='text acea-row row-column-around'>
  30. <view class='name line1'>{{item.title}}</view>
  31. <view class='money'>¥
  32. <text class='num font-color'>{{item.price}}</text>
  33. <text class="y_money">¥{{item.ot_price}}</text>
  34. </view>
  35. <view class="limit">限量 <text class="limitPrice">{{item.quota}}件</text></view>
  36. <view class="progress">
  37. <view class='bg-reds' :style="'width:'+item.percent+'%;'"></view>
  38. <view class='piece'>已抢{{item.percent}}%</view>
  39. </view>
  40. </view>
  41. <view class='grab bg-color' v-if="status == 1">马上抢</view>
  42. <view class='grab bg-color' v-else-if="status == 2">未开始</view>
  43. <view class='grab bg-color-hui' v-else>已结束</view>
  44. </view>
  45. </block>
  46. </view>
  47. </view>
  48. <view class='noCommodity' v-if="seckillList.length == 0 && (page != 1 || active== 0)">
  49. <view class='pictrue'>
  50. <image src='/static/images/noShopper.png'></image>
  51. </view>
  52. </view>
  53. <home></home>
  54. </div>
  55. </template>
  56. <script>
  57. import {
  58. getSeckillIndexTime,
  59. getSeckillList
  60. } from '../../../api/activity.js';
  61. import home from '@/components/home/index.vue'
  62. export default {
  63. components: {
  64. home
  65. },
  66. data() {
  67. return {
  68. topImage: '',
  69. seckillList: [],
  70. timeList: [],
  71. active: 5,
  72. scrollLeft: 0,
  73. interval: 0,
  74. status: 1,
  75. countDownHour: "00",
  76. countDownMinute: "00",
  77. countDownSecond: "00",
  78. page: 1,
  79. limit: 4,
  80. loading: false,
  81. loadend: false,
  82. pageloading: false,
  83. }
  84. },
  85. onLoad() {
  86. this.getSeckillConfig();
  87. },
  88. methods: {
  89. getSeckillConfig: function() {
  90. let that = this;
  91. getSeckillIndexTime().then(res => {
  92. that.topImage = res.data.lovely;
  93. that.timeList = res.data.seckillTime;
  94. that.active = res.data.seckillTimeIndex;
  95. if (that.timeList.length) {
  96. // wxh.time(that.data.timeList[that.data.active].stop, that);
  97. that.scrollLeft = (that.active - 1.37) * 100
  98. setTimeout(function() {
  99. that.loading = true
  100. }, 2000);
  101. that.seckillList = [],
  102. that.page = 1
  103. that.status = that.timeList[that.active].status
  104. that.getSeckillList();
  105. }
  106. });
  107. },
  108. getSeckillList: function() {
  109. var that = this;
  110. var data = {
  111. page: that.page,
  112. limit: that.limit
  113. };
  114. if (that.loadend) return;
  115. if (that.pageloading) return;
  116. this.pageloading = true
  117. getSeckillList(that.timeList[that.active].id, data).then(res => {
  118. var seckillList = res.data;
  119. var loadend = seckillList.length < that.limit;
  120. that.page++;
  121. that.seckillList = that.seckillList.concat(seckillList),
  122. that.page = that.page;
  123. that.pageloading = false;
  124. that.loadend = loadend;
  125. }).catch(err => {
  126. that.pageloading = false
  127. });
  128. },
  129. settimeList: function(item, index) {
  130. var that = this;
  131. this.active = index
  132. if (that.interval) {
  133. clearInterval(that.interval);
  134. that.interval = null
  135. }
  136. that.interval = 0,
  137. that.countDownHour = "00";
  138. that.countDownMinute = "00";
  139. that.countDownSecond = "00";
  140. that.status = that.timeList[that.active].status;
  141. that.loadend = false;
  142. that.page = 1;
  143. that.seckillList = [];
  144. // wxh.time(e.currentTarget.dataset.stop, that);
  145. that.getSeckillList();
  146. },
  147. goDetails(item){
  148. uni.navigateTo({
  149. url: '/pages/activity/goods_seckill_details/index?id=' + item.id + '&time=' + this.timeList[this.active].stop + '&status=' + this.status
  150. })
  151. }
  152. },
  153. /**
  154. * 页面上拉触底事件的处理函数
  155. */
  156. onReachBottom: function() {
  157. this.getSeckillList();
  158. }
  159. }
  160. </script>
  161. <style>
  162. page {
  163. background-color: #F5F5F5 !important;
  164. }
  165. .flash-sale .header {
  166. width: 710rpx;
  167. height: 300rpx;
  168. margin: -215rpx auto 0 auto;
  169. border-radius: 20rpx;
  170. }
  171. .flash-sale .header image {
  172. width: 100%;
  173. height: 100%;
  174. border-radius: 20rpx;
  175. }
  176. .flash-sale .seckillList {
  177. padding: 0 20rpx;
  178. }
  179. .flash-sale .seckillList .priceTag {
  180. width: 75rpx;
  181. height: 70rpx;
  182. }
  183. .flash-sale .seckillList .priceTag image {
  184. width: 100%;
  185. height: 100%;
  186. }
  187. .flash-sale .timeLsit {
  188. width: 610rpx;
  189. white-space: nowrap;
  190. margin: 10rpx 0;
  191. }
  192. .flash-sale .timeLsit .item {
  193. display: inline-block;
  194. font-size: 20rpx;
  195. color: #666;
  196. text-align: center;
  197. padding: 11rpx 0;
  198. box-sizing: border-box;
  199. height: 96rpx;
  200. margin-right: 35rpx;
  201. }
  202. .flash-sale .timeLsit .item .time {
  203. font-size: 36rpx;
  204. font-weight: 600;
  205. color: #333;
  206. }
  207. .flash-sale .timeLsit .item.on .time {
  208. color: #E93323;
  209. }
  210. .flash-sale .timeLsit .item.on .state {
  211. width: 90rpx;
  212. height: 30rpx;
  213. border-radius: 15rpx;
  214. background: linear-gradient(90deg, rgba(252, 25, 75, 1) 0%, rgba(252, 60, 32, 1) 100%);
  215. color: #fff;
  216. }
  217. .flash-sale .countDown {
  218. height: 92rpx;
  219. border-bottom: 1rpx solid #f0f0f0;
  220. margin-top: -14rpx;
  221. font-size: 28rpx;
  222. color: #282828;
  223. }
  224. .flash-sale .countDown .num {
  225. font-size: 28rpx;
  226. font-weight: bold;
  227. background-color: #ffcfcb;
  228. padding: 4rpx 7rpx;
  229. border-radius: 3rpx;
  230. }
  231. .flash-sale .countDown .text {
  232. font-size: 28rpx;
  233. color: #282828;
  234. margin-right: 13rpx;
  235. }
  236. .flash-sale .list .item {
  237. height: 230rpx;
  238. position: relative;
  239. width: 710rpx;
  240. margin: 0 auto 20rpx auto;
  241. background-color: #fff;
  242. border-radius: 20rpx;
  243. padding: 0 25rpx;
  244. }
  245. .flash-sale .list .item .pictrue {
  246. width: 180rpx;
  247. height: 180rpx;
  248. border-radius: 10rpx;
  249. }
  250. .flash-sale .list .item .pictrue image {
  251. width: 100%;
  252. height: 100%;
  253. border-radius: 10rpx;
  254. }
  255. .flash-sale .list .item .text {
  256. width: 460rpx;
  257. font-size: 30rpx;
  258. color: #333;
  259. height: 166rpx;
  260. }
  261. .flash-sale .list .item .text .name {
  262. width: 100%;
  263. }
  264. .flash-sale .list .item .text .money {
  265. font-size: 30rpx;
  266. color: #E93323;
  267. }
  268. .flash-sale .list .item .text .money .num {
  269. font-size: 40rpx;
  270. font-weight: 500;
  271. font-family: 'Guildford Pro';
  272. }
  273. .flash-sale .list .item .text .money .y_money {
  274. font-size: 24rpx;
  275. color: #999;
  276. text-decoration-line: line-through;
  277. margin-left: 15rpx;
  278. }
  279. .flash-sale .list .item .text .limit {
  280. font-size: 22rpx;
  281. color: #999;
  282. margin-bottom: 5rpx;
  283. }
  284. .flash-sale .list .item .text .limit .limitPrice {
  285. margin-left: 10rpx;
  286. }
  287. .flash-sale .list .item .text .progress {
  288. overflow: hidden;
  289. background-color: #FFEFEF;
  290. width: 260rpx;
  291. border-radius: 18rpx;
  292. height: 18rpx;
  293. position: relative;
  294. }
  295. .flash-sale .list .item .text .progress .bg-reds {
  296. width: 0;
  297. height: 100%;
  298. transition: width 0.6s ease;
  299. background: linear-gradient(90deg, rgba(233, 51, 35, 1) 0%, rgba(255, 137, 51, 1) 100%);
  300. }
  301. .flash-sale .list .item .text .progress .piece {
  302. position: absolute;
  303. left: 8%;
  304. transform: translate(0%, -50%);
  305. top: 49%;
  306. font-size: 16rpx;
  307. color: #FFB9B9;
  308. }
  309. .flash-sale .list .item .grab {
  310. font-size: 28rpx;
  311. color: #fff;
  312. width: 150rpx;
  313. height: 54rpx;
  314. border-radius: 27rpx;
  315. text-align: center;
  316. line-height: 54rpx;
  317. position: absolute;
  318. right: 30rpx;
  319. bottom: 30rpx;
  320. background: #bbbbbb;
  321. }
  322. .flash-sale .saleBox {
  323. width: 100%;
  324. height: 230rpx;
  325. background: rgba(233, 51, 35, 1);
  326. border-radius: 0 0 50rpx 50rpx;
  327. }
  328. </style>