index.vue 8.8 KB

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