index.vue 8.8 KB

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