index.vue 8.3 KB

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