index.vue 9.2 KB

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