index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div>
  3. <view class='flash-sale'>
  4. <view class='header'>
  5. <img mode="widthFix" class="presellBg" src="../static/images/presell_bg.png" alt="">
  6. <view class="seckillList acea-row row-between-wrapper">
  7. <view class='timeList'>
  8. <block v-for="(item,index) in timeList" :key='index'>
  9. <view @tap='settimeList(item,index)' class='item' :class="active == index?'on':''">
  10. <view class='time'><text>{{item}}</text></view>
  11. </view>
  12. </block>
  13. </view>
  14. </view>
  15. </view>
  16. <view class='list'>
  17. <block v-for="(item,index) in seckillList" :key='index'>
  18. <view class='item acea-row row-between-wrapper' @tap='goDetails(item)'>
  19. <view class='pictrue'>
  20. <image :src='item.product.image'></image>
  21. </view>
  22. <view class='text acea-row row-column-around'>
  23. <view class='name line1'>{{item.store_name}}</view>
  24. <view class='booking'>
  25. <text class="count">{{item.ot_price ? item.ot_price : 0}}人已预订</text>
  26. </view>
  27. <view class="progress">
  28. <view class='presell_price'></view>
  29. <view class='order_btn'>立即预订</view>
  30. </view>
  31. </view>
  32. </view>
  33. </block>
  34. </view>
  35. </view>
  36. <view class='noCommodity' v-if="seckillList.length == 0 && (page != 1 || active== 0)">
  37. <view class='pictrue'>
  38. <image src='/static/images/noShopper.png'></image>
  39. </view>
  40. </view>
  41. <home></home>
  42. </div>
  43. </template>
  44. <script>
  45. import {
  46. getSeckillIndexTime,
  47. getPresellList
  48. } from '../../../api/activity.js';
  49. import home from '@/components/home/index.vue'
  50. export default {
  51. components: {
  52. home
  53. },
  54. data() {
  55. return {
  56. topImage: '',
  57. seckillList: [],
  58. timeList: [
  59. '未开始',
  60. '正在进行',
  61. '已结束'
  62. ],
  63. active: 0,
  64. type: 0,
  65. scrollLeft: 0,
  66. interval: 0,
  67. status: 1,
  68. page: 1,
  69. limit: 8,
  70. loading: false,
  71. loadend: false,
  72. pageloading: false,
  73. }
  74. },
  75. onLoad() {
  76. this.getPresellProductList();
  77. },
  78. methods: {
  79. getPresellProductList: function() {
  80. var that = this;
  81. var data = {
  82. page: that.page,
  83. limit: that.limit,
  84. type: that.active
  85. };
  86. if (that.loadend) return;
  87. if (that.pageloading) return;
  88. this.pageloading = true
  89. getPresellList(data).then(res => {
  90. console.log(res);
  91. var seckillList = res.data.list;
  92. seckillList.map((item) => {
  93. item.percent = item.stock === 0 ? '0%' : (item.sales * 100 / item.stock).toFixed(2) + '%';
  94. })
  95. var loadend = seckillList.length < that.limit;
  96. that.page++;
  97. that.seckillList = that.seckillList.concat(seckillList),
  98. that.page = that.page;
  99. that.pageloading = false;
  100. that.loadend = loadend;
  101. }).catch(err => {
  102. that.pageloading = false
  103. });
  104. },
  105. settimeList: function(item, index) {
  106. var that = this;
  107. that.active = index
  108. that.type = that.active;
  109. that.loadend = false;
  110. that.page = 1;
  111. that.seckillList = [];
  112. // wxh.time(e.currentTarget.dataset.stop, that);
  113. that.getSeckillList();
  114. },
  115. goDetails(item) {
  116. uni.navigateTo({
  117. url: '/pages/activity/goods_seckill_details/index?id=' + item.product_id + '&time=' + item.stop
  118. })
  119. }
  120. },
  121. /**
  122. * 页面上拉触底事件的处理函数
  123. */
  124. onReachBottom: function() {
  125. this.getSeckillList();
  126. }
  127. }
  128. </script>
  129. <style lang="scss">
  130. page {
  131. background-color: #FF7F21 !important;
  132. }
  133. .flash-sale .header {
  134. width: 100%;
  135. position: relative;
  136. }
  137. .flash-sale .header .presellBg {
  138. width: 750rpx;
  139. }
  140. .flash-sale .seckillList {
  141. padding: 0 20rpx;
  142. position: absolute;
  143. bottom: 0;
  144. left: 30rpx;
  145. width: 690rpx;
  146. background: #fff;
  147. border-radius: 16rpx;
  148. line-height: 80rpx;
  149. height: 80rpx;
  150. }
  151. .flash-sale .seckillList .priceTag {
  152. width: 75rpx;
  153. height: 70rpx;
  154. }
  155. .flash-sale .seckillList .priceTag image {
  156. opacity: 1;
  157. }
  158. .flash-sale .seckillList .priceTag image {
  159. width: 100%;
  160. height: 100%;
  161. }
  162. .flash-sale .timeList {
  163. display: flex;
  164. justify-content: center;
  165. align-items: center;
  166. margin: 0 auto;
  167. }
  168. .flash-sale .timeList .item {
  169. font-size: 20rpx;
  170. color: #666;
  171. text-align: center;
  172. box-sizing: border-box;
  173. width: 224rpx;
  174. }
  175. .flash-sale .timeList .item .time {
  176. font-size: 36rpx;
  177. font-weight: 600;
  178. color: #333;
  179. }
  180. .flash-sale .timeList .item.on .time {
  181. color: #FD6523;
  182. span{
  183. position: relative;
  184. &::after{
  185. content: '';
  186. display: inline-block;
  187. width: 100%;
  188. height: 4rpx;
  189. background: #FD6523;
  190. position: absolute;
  191. left: 0;
  192. bottom: -4rpx;
  193. border-radius: 2rpx;
  194. }
  195. }
  196. }
  197. .flash-sale .list{
  198. margin-top: 24rpx;
  199. }
  200. .flash-sale .list .item {
  201. height: 230rpx;
  202. position: relative;
  203. width: 690rpx;
  204. margin: 0 auto 20rpx auto;
  205. background-color: #fff;
  206. border-radius: 20rpx;
  207. padding: 0 25rpx;
  208. }
  209. .flash-sale .list .item .pictrue {
  210. width: 180rpx;
  211. height: 180rpx;
  212. border-radius: 10rpx;
  213. }
  214. .flash-sale .list .item .pictrue image {
  215. width: 100%;
  216. height: 100%;
  217. border-radius: 10rpx;
  218. }
  219. .flash-sale .list .item .text {
  220. width: 460rpx;
  221. font-size: 30rpx;
  222. color: #333;
  223. height: 166rpx;
  224. }
  225. .flash-sale .list .item .text .name {
  226. width: 100%;
  227. }
  228. .flash-sale .list .item .text .booking {
  229. font-size: 30rpx;
  230. color: #E93323;
  231. }
  232. .flash-sale .list .item .text .booking .count {
  233. font-size: 24rpx;
  234. color: #999;
  235. }
  236. .flash-sale .list .item .text .limit {
  237. font-size: 22rpx;
  238. color: #999;
  239. margin-bottom: 5rpx;
  240. }
  241. .flash-sale .list .item .text .limit .limitPrice {
  242. margin-left: 10rpx;
  243. }
  244. .flash-sale .list .item .text .progress {
  245. width: 392rpx;
  246. height: 76rpx;
  247. background: url(~pages/activity/static/images/yh.png) top left/100% 100% no-repeat;
  248. }
  249. </style>