seckillList.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <view class="container">
  3. <view class="tui-bg__box">
  4. <image src="../../static/images/bg_seckill.png" class="tui-bg__img" mode="widthFix" :style="{ opacity: opacity }"></image>
  5. </view>
  6. <view class="tui-header__bg">
  7. <image src="../../static/images/bg_seckill.png" class="tui-bg__img" mode="widthFix"></image>
  8. <scroll-view class="tui-time-slot" scroll-x>
  9. <view class="tui-time__list" :class="{ 'tui-flex__between': timeSlot.length < 6 }">
  10. <view class="tui-time__item" :class="[timeSlot.length < 6 ? 'tui-flex__1' : 'tui-width__min', index == currentTab ? 'tui-time__active' : '']"
  11. v-for="(item, index) in timeSlot" :key="index" @tap="changeTabs(index)">
  12. <view class="tui-time">{{ item.time }}</view>
  13. <view class="tui-status">{{ item.statusText }}</view>
  14. </view>
  15. </view>
  16. </scroll-view>
  17. </view>
  18. <view class="tui-body">
  19. <view class="tui-status__box">
  20. <view class="tui-full__width">
  21. <tui-divider gradual width="80%" backgroundColor="#fff" :height="34">
  22. <view class="tui-divider__status">
  23. <image src="../../static/images/img_seckill.png" mode="widthFix"></image>
  24. <text class="tui-color__red">{{ time }}</text>
  25. <text>{{ status | getStatusText }}</text>
  26. </view>
  27. </tui-divider>
  28. </view>
  29. <view class="tui-countdown__box" v-if="status > 1">
  30. <text>距离{{ status == 2 ? '结束还剩' : '开始还有' }}</text>
  31. <tui-countdown :time="3880" backgroundColor="#4D4D4D" color="#fff"></tui-countdown>
  32. </view>
  33. </view>
  34. <view class="tui-list__goods">
  35. <view class="tui-goods__left" :class="{ 'tui-full__width': status == 3 }">
  36. <block v-for="(item, index) in goodsList" :key="index">
  37. <t-goods-item v-if="index % 2 == 0 || status == 3" :item="item" :status="status" :isList="status == 3"></t-goods-item>
  38. </block>
  39. </view>
  40. <view class="tui-goods__right" v-if="status !== 3">
  41. <block v-for="(item, index) in goodsList" :key="index">
  42. <t-goods-item v-if="index % 2 !== 0" :item="item" :status="status" :isList="status == 3"></t-goods-item>
  43. </block>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import tGoodsItem from '@/components/views/t-goods-item/t-goods-item';
  51. export default {
  52. components: {
  53. tGoodsItem
  54. },
  55. data() {
  56. return {
  57. //status:1-已结束,2-正在进行,3-即将开抢
  58. timeSlot: [{
  59. time: '08:00',
  60. status: 1,
  61. statusText: '已结束'
  62. },
  63. {
  64. time: '10:00',
  65. status: 2,
  66. statusText: '正在疯抢'
  67. },
  68. {
  69. time: '12:00',
  70. status: 3,
  71. statusText: '即将开抢'
  72. },
  73. {
  74. time: '14:00',
  75. status: 3,
  76. statusText: '即将开抢'
  77. },
  78. {
  79. time: '16:00',
  80. status: 3,
  81. statusText: '即将开抢'
  82. }
  83. ],
  84. goodsList:[],
  85. where: {
  86. sid: 0,
  87. keyword: '',
  88. priceOrder: '',
  89. salesOrder: '',
  90. news: 0,
  91. page: 1,
  92. limit: 10,
  93. categoryId: 0,
  94. },
  95. currentTab: 0,
  96. //status:1-已结束,2-正在进行,3-即将开抢
  97. status: 2,
  98. time: '08:00',
  99. opacity: 1
  100. };
  101. },
  102. onLoad(options) {
  103. //展示优先:正在进行,即将开抢,已结束
  104. for (let i = 0, len = this.timeSlot.length; i < len; i++) {
  105. let item = this.timeSlot[i];
  106. if (item.status !== 1) {
  107. this.currentTab = i;
  108. break;
  109. }
  110. }
  111. this.get_product_list();
  112. },
  113. filters: {
  114. getStatusText(status) {
  115. let text = ['活动已结束', '正在疯抢', '即将开抢'][status - 1];
  116. return text;
  117. }
  118. },
  119. methods: {
  120. get_product_list: function(isPage) {
  121. var that = this;
  122. console.log(this.where);
  123. if (that.loadend) return;
  124. if (that.loading) return;
  125. if (isPage === true) {
  126. that.goodsList = [];
  127. that.where.page =1;
  128. }
  129. this.$request.post('miaoshagoods', that.where).then(res => {
  130. if (res.errno == 0) {
  131. that.goodsList = that.goodsList.concat(res.data.data);
  132. that.loadend = that.goodsList.length < that.where.limit;
  133. that.loading = false;
  134. that.where.page = that.where.page + 1
  135. }
  136. })
  137. },
  138. changeTabs(index) {
  139. this.currentTab = index;
  140. let item = this.timeSlot[index];
  141. this.status = item.status;
  142. this.time = item.time;
  143. }
  144. },
  145. onPageScroll(e) {
  146. let scrollTop = e.scrollTop;
  147. if (scrollTop <= 2) {
  148. this.opacity = 1;
  149. } else {
  150. if (this.opacity <= 0) return;
  151. this.opacity = 1 - scrollTop / 40;
  152. }
  153. },
  154. /**
  155. * 页面相关事件处理函数--监听用户下拉动作
  156. */
  157. onPullDownRefresh: function() {
  158. this.where.page = 1;
  159. this.loadend = false;
  160. this.goodsList = [];
  161. this.get_product_list();
  162. uni.stopPullDownRefresh();
  163. },
  164. /**
  165. * 页面上拉触底事件的处理函数
  166. */
  167. onReachBottom: function() {
  168. this.get_product_list();
  169. }
  170. };
  171. </script>
  172. <style>
  173. .tui-bg__box {
  174. width: 100%;
  175. height: 210rpx;
  176. position: fixed;
  177. left: 0;
  178. top: 0;
  179. z-index: 1;
  180. }
  181. .tui-header__bg {
  182. width: 100%;
  183. height: 120rpx;
  184. position: fixed;
  185. left: 0;
  186. top: 0;
  187. z-index: 3;
  188. overflow: hidden;
  189. }
  190. .tui-bg__img {
  191. width: 100%;
  192. height: 210rpx;
  193. display: block;
  194. transition: opacity 0.1s linear;
  195. }
  196. .tui-body {
  197. width: 100%;
  198. position: relative;
  199. margin-top: 120rpx;
  200. z-index: 2;
  201. padding: 0 25rpx;
  202. box-sizing: border-box;
  203. }
  204. .tui-time-slot {
  205. width: 100%;
  206. height: 120rpx;
  207. position: absolute;
  208. left: 0;
  209. top: 0;
  210. }
  211. .tui-time__list {
  212. min-width: 100%;
  213. height: 120rpx;
  214. display: flex;
  215. align-items: center;
  216. }
  217. .tui-flex__between {
  218. justify-content: space-between;
  219. }
  220. .tui-time__item {
  221. flex-shrink: 0;
  222. display: flex;
  223. align-items: center;
  224. flex-direction: column;
  225. justify-content: center;
  226. color: #ffb2b2;
  227. }
  228. .tui-flex__1 {
  229. flex: 1 !important;
  230. }
  231. .tui-width__min {
  232. min-width: 150rpx;
  233. }
  234. .tui-time {
  235. font-size: 32rpx;
  236. line-height: 32rpx;
  237. font-weight: bold;
  238. }
  239. .tui-status {
  240. font-size: 24rpx;
  241. line-height: 24rpx;
  242. font-weight: 500;
  243. padding-top: 16rpx;
  244. }
  245. .tui-time__active .tui-time {
  246. color: #fff;
  247. font-size: 36rpx;
  248. line-height: 36rpx;
  249. }
  250. .tui-time__active .tui-status {
  251. color: #fff;
  252. font-size: 28rpx;
  253. line-height: 28rpx;
  254. font-weight: bold;
  255. }
  256. .tui-status__box {
  257. width: 100%;
  258. height: 146rpx;
  259. background: #fff;
  260. border-radius: 20rpx;
  261. box-shadow: 0 3rpx 20rpx rgba(183, 183, 183, 0.1);
  262. display: flex;
  263. align-items: center;
  264. justify-content: center;
  265. flex-direction: column;
  266. }
  267. .tui-full__width {
  268. width: 100%;
  269. }
  270. .tui-divider__status {
  271. display: flex;
  272. align-items: center;
  273. font-size: 28rpx;
  274. color: #333;
  275. font-weight: bold;
  276. }
  277. .tui-divider__status image {
  278. width: 30rpx;
  279. height: 30rpx;
  280. margin-right: 10rpx;
  281. flex-shrink: 0;
  282. }
  283. .tui-color__red {
  284. color: #eb0909;
  285. padding-right: 6rpx;
  286. font-size: 32rpx;
  287. font-weight: 500;
  288. }
  289. .tui-countdown__box {
  290. display: flex;
  291. align-items: center;
  292. justify-content: center;
  293. color: #333;
  294. font-size: 24rpx;
  295. font-weight: 400;
  296. margin-top: 16rpx;
  297. }
  298. .tui-countdown__box text {
  299. padding-right: 12rpx;
  300. }
  301. /*======商品列表 start=======*/
  302. .tui-list__goods {
  303. width: 100%;
  304. display: flex;
  305. justify-content: space-between;
  306. flex-wrap: wrap;
  307. margin-top: 20rpx;
  308. padding-bottom: 30rpx;
  309. }
  310. .tui-goods__left,
  311. .tui-goods__right {
  312. width: 49%;
  313. }
  314. .tui-full__width {
  315. width: 100% !important;
  316. }
  317. /*======商品列表 end=======*/
  318. </style>