index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <view :style="viewColor">
  3. <view class='flash-sale'>
  4. <!-- #ifdef H5 -->
  5. <view v-if='!$wechat.isWeixin()' class="fixed-head">
  6. <view class="sys-head" :style="{height:statusBarHeight}"></view>
  7. <view class="tool-bar">
  8. <view class='iconfont icon-xiangzuo' @tap='goBack'></view>
  9. </view>
  10. </view>
  11. <!-- #endif -->
  12. <view class="saleBox"></view>
  13. <view class='header' v-if="timeList.length>0">
  14. <image :src='timeList[active].pic'></image>
  15. </view>
  16. <view class="seckillList acea-row row-between-wrapper">
  17. <view class="priceTag">
  18. <image :src="`${domain}/static/diy/priceTag${keyColor}.png`"></image>
  19. </view>
  20. <view class='timeLsit'>
  21. <scroll-view class="scroll-view_x" scroll-x scroll-with-animation style="width:auto;overflow:hidden;height:106rpx;" :scroll-into-view="intoindex">
  22. <block v-for="(item,index) in timeList" :key='index'>
  23. <view @tap='settimeList(item,index)' class='item' :class="active == index?'on':''" :id='"sort"+index'>
  24. <view class='time'>{{item.time}}</view>
  25. <view class="state">{{item.state}}</view>
  26. </view>
  27. </block>
  28. </scroll-view>
  29. </view>
  30. </view>
  31. <view class='list'>
  32. <block v-for="(item,index) in seckillList" :key='index'>
  33. <view class='item acea-row row-between-wrapper' @tap='goDetails(item)'>
  34. <view class='pictrue'>
  35. <image :src='item.image'></image>
  36. </view>
  37. <view class='text acea-row row-column-around'>
  38. <view class='name line1'>{{item.store_name}}</view>
  39. <view class='money'>¥
  40. <text class='num'>{{item.price}}</text>
  41. <text class="y_money">¥{{item.ot_price}}</text>
  42. </view>
  43. <view class="limit">限量 <text class="limitPrice">{{item.stock}}{{item.unit_name || ''}}</text></view>
  44. <view class="progress">
  45. <view class='bg-reds' :style="'width:'+item.percent+';'"></view>
  46. <view class='piece'>已抢{{item.percent}}</view>
  47. </view>
  48. </view>
  49. <view class='grab b-color' v-if="item.skill_status == 1">马上抢</view>
  50. <view class='grab b-color bg-color-hui' v-else-if="item.skill_status == 0">待开始</view>
  51. <view class='grab bg-color-hui' v-else>已结束</view>
  52. </view>
  53. </block>
  54. </view>
  55. </view>
  56. <view class='noCommodity' v-if="seckillList.length == 0 && (page != 1 || active== 0) && loadend">
  57. <view class='pictrue'>
  58. <image :src="`${domain}/static/images/noCart.png`"></image>
  59. <view>暂无商品,去看点什么吧</view>
  60. </view>
  61. </view>
  62. <home></home>
  63. <!-- #ifndef H5 -->
  64. <passwordPopup></passwordPopup>
  65. <!-- #endif -->
  66. </view>
  67. </template>
  68. <script>
  69. // +----------------------------------------------------------------------
  70. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  71. // +----------------------------------------------------------------------
  72. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  73. // +----------------------------------------------------------------------
  74. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  75. // +----------------------------------------------------------------------
  76. // | Author: CRMEB Team <admin@crmeb.com>
  77. // +----------------------------------------------------------------------
  78. import {
  79. getSeckillIndexTime,
  80. getSeckillList
  81. } from '../../../api/activity.js';
  82. import home from '@/components/home/index.vue'
  83. // #ifndef H5
  84. import passwordPopup from '@/components/passwordPopup';
  85. // #endif
  86. import { mapGetters } from "vuex";
  87. import { configMap } from "@/utils";
  88. import { HTTP_REQUEST_URL } from '@/config/app';
  89. export default {
  90. components: {
  91. // #ifndef H5
  92. passwordPopup,
  93. // #endif
  94. home
  95. },
  96. computed: configMap({statusBarHeight:0},mapGetters(['viewColor','keyColor'])),
  97. data() {
  98. return {
  99. domain: HTTP_REQUEST_URL,
  100. seckillList: [],
  101. timeList: [],
  102. time_id: "",
  103. active: 5,
  104. scrollLeft: 0,
  105. interval: 0,
  106. countDownHour: "00",
  107. countDownMinute: "00",
  108. countDownSecond: "00",
  109. page: 1,
  110. limit: 10,
  111. loading: false,
  112. loadend: false,
  113. pageloading: false,
  114. intoindex:'',
  115. }
  116. },
  117. /**
  118. * 用户点击右上角分享
  119. */
  120. // #ifdef MP
  121. onShareAppMessage: function() {
  122. wx.showShareMenu({
  123. withShareTicket: true,
  124. menus: ['shareAppMessage', 'shareTimeline']
  125. })
  126. return {
  127. title: '秒杀活动',
  128. path: 'pages/activity/goods_seckill/index',
  129. }
  130. },
  131. onShareTimeline: function() {
  132. return {
  133. title: '秒杀活动',
  134. query: {
  135. key: ''
  136. },
  137. imageUrl: ''
  138. }
  139. },
  140. // #endif
  141. onLoad() {
  142. this.getSeckillConfig();
  143. },
  144. methods: {
  145. goBack: function() {
  146. uni.navigateBack();
  147. },
  148. getSeckillConfig: function() {
  149. let that = this;
  150. getSeckillIndexTime().then(res => {
  151. that.timeList = res.data.seckillTime;
  152. that.active = res.data.seckillTimeIndex;
  153. that.time_id = that.timeList[that.active].seckill_time_id;
  154. that.$nextTick(()=>{
  155. that.intoindex = 'sort'+res.data.seckillTimeIndex
  156. })
  157. let time;
  158. that.timeList.map((item) => {
  159. time = item.start_time > 9 ? item.start_time + ':00' : '0' + item.start_time + ':00';
  160. item.time = time;
  161. })
  162. if (that.timeList.length) {
  163. setTimeout(function() {
  164. that.loading = true
  165. }, 2000);
  166. that.seckillList = [],
  167. that.page = 1
  168. that.getSeckillList();
  169. // 不用延时 app不会自动滚动到当前时间
  170. setTimeout(()=>{
  171. // that.scrollLeft = (that.active - 1.37) * 100
  172. },500)
  173. }
  174. });
  175. },
  176. getSeckillList: function() {
  177. var that = this;
  178. var data = {
  179. page: that.page,
  180. limit: that.limit,
  181. start_time: that.timeList[that.active].start_time,
  182. end_time: that.timeList[that.active].end_time
  183. };
  184. if (that.loadend) return;
  185. if (that.pageloading) return;
  186. this.pageloading = true
  187. uni.showLoading({
  188. title: '正在加载',
  189. })
  190. getSeckillList(data).then(res => {
  191. var seckillList = res.data.list;
  192. seckillList.map((item) => {
  193. item.percent = item.stock === 0 ? '100%' : (item.sales*100 / (item.sales+item.stock)).toFixed(2) + '%';
  194. })
  195. var loadend = seckillList.length < that.limit;
  196. that.page++;
  197. that.seckillList = that.seckillList.concat(seckillList);
  198. uni.stopPullDownRefresh(); //结束下拉刷新
  199. that.pageloading = false;
  200. that.loadend = loadend;
  201. uni.hideLoading()
  202. }).catch(err => {
  203. that.pageloading = false
  204. uni.hideLoading()
  205. });
  206. },
  207. settimeList: function(item, index) {
  208. var that = this;
  209. this.active = index
  210. if (that.interval) {
  211. clearInterval(that.interval);
  212. that.interval = null
  213. }
  214. that.interval = 0;
  215. that.countDownHour = "00";
  216. that.countDownMinute = "00";
  217. that.countDownSecond = "00";
  218. that.loadend = false;
  219. that.time_id = that.timeList[that.active].seckill_time_id;
  220. that.page = 1;
  221. that.seckillList = [];
  222. that.getSeckillList();
  223. },
  224. goDetails(item) {
  225. uni.navigateTo({
  226. url: '/pages/activity/goods_seckill_details/index?id='+item.product_id+'&time_id='+this.time_id
  227. })
  228. }
  229. },
  230. onPullDownRefresh: function(){
  231. this.page = 1;
  232. this.pageloading = false;
  233. this.loadend = false;
  234. this.seckillList = []
  235. this.getSeckillList();
  236. },
  237. /**
  238. * 页面上拉触底事件的处理函数
  239. */
  240. onReachBottom: function() {
  241. this.getSeckillList();
  242. }
  243. }
  244. </script>
  245. <style lang="scss" scoped>
  246. page {
  247. background-color: #F5F5F5 !important;
  248. }
  249. .flash-sale .header {
  250. width: 710rpx;
  251. height: 300rpx;
  252. margin: -215rpx auto 0 auto;
  253. border-radius: 20rpx;
  254. }
  255. .flash-sale .header image {
  256. width: 100%;
  257. height: 100%;
  258. border-radius: 20rpx;
  259. }
  260. .flash-sale .seckillList {
  261. padding: 0 20rpx;
  262. }
  263. .flash-sale .seckillList .priceTag {
  264. width: 76rpx;
  265. height: 70rpx;
  266. }
  267. .flash-sale .seckillList .priceTag image {
  268. opacity: 1;
  269. }
  270. .flash-sale .seckillList .priceTag image {
  271. width: 100%;
  272. height: 100%;
  273. }
  274. .flash-sale .timeLsit {
  275. width: 610rpx;
  276. white-space: nowrap;
  277. margin: 10rpx 0;
  278. }
  279. .flash-sale .timeLsit .item {
  280. display: inline-block;
  281. font-size: 20rpx;
  282. color: #666;
  283. text-align: center;
  284. padding: 11rpx 0;
  285. box-sizing: border-box;
  286. height: 96rpx;
  287. margin-right: 35rpx;
  288. }
  289. .flash-sale .timeLsit .item .time {
  290. font-size: 36rpx;
  291. font-weight: 600;
  292. color: #333;
  293. }
  294. .flash-sale .timeLsit .item.on .time {
  295. color: var(--view-theme);
  296. }
  297. .flash-sale .timeLsit .item.on .state {
  298. width: 90rpx;
  299. display: flex;
  300. align-items: center;
  301. justify-content: center;
  302. height: 30rpx;
  303. border-radius: 15rpx;
  304. background-image: linear-gradient(90deg, var(--view-bntColor11) 0%, var(--view-bntColor12) 100%);
  305. color: #fff;
  306. }
  307. .flash-sale .countDown {
  308. height: 92rpx;
  309. border-bottom: 1px solid #f0f0f0;
  310. margin-top: -14rpx;
  311. font-size: 28rpx;
  312. color: #282828;
  313. }
  314. .flash-sale .countDown .num {
  315. font-size: 28rpx;
  316. font-weight: bold;
  317. background-color: #ffcfcb;
  318. padding: 4rpx 7rpx;
  319. border-radius: 3rpx;
  320. }
  321. .flash-sale .countDown .text {
  322. font-size: 28rpx;
  323. color: #282828;
  324. margin-right: 13rpx;
  325. }
  326. .flash-sale .list .item {
  327. height: 230rpx;
  328. position: relative;
  329. width: 710rpx;
  330. margin: 0 auto 20rpx auto;
  331. background-color: #fff;
  332. border-radius: 20rpx;
  333. padding: 0 25rpx;
  334. }
  335. .flash-sale .list .item .pictrue {
  336. width: 180rpx;
  337. height: 180rpx;
  338. border-radius: 10rpx;
  339. }
  340. .flash-sale .list .item .pictrue image {
  341. width: 100%;
  342. height: 100%;
  343. border-radius: 10rpx;
  344. }
  345. .flash-sale .list .item .text {
  346. width: 460rpx;
  347. font-size: 30rpx;
  348. color: #333;
  349. height: 166rpx;
  350. }
  351. .flash-sale .list .item .text .name {
  352. width: 100%;
  353. }
  354. .flash-sale .list .item .text .money {
  355. font-size: 30rpx;
  356. color: var(--view-priceColor);
  357. }
  358. .flash-sale .list .item .text .money .num {
  359. font-size: 40rpx;
  360. font-weight: 500;
  361. }
  362. .flash-sale .list .item .text .money .y_money {
  363. font-size: 24rpx;
  364. color: #999;
  365. text-decoration-line: line-through;
  366. margin-left: 15rpx;
  367. }
  368. .flash-sale .list .item .text .limit {
  369. font-size: 22rpx;
  370. color: #999;
  371. margin-bottom: 5rpx;
  372. }
  373. .flash-sale .list .item .text .limit .limitPrice {
  374. margin-left: 10rpx;
  375. }
  376. .flash-sale .list .item .text .progress {
  377. overflow: hidden;
  378. background-color: var(--view-bgColor);
  379. width: 260rpx;
  380. border-radius: 18rpx;
  381. height: 18rpx;
  382. position: relative;
  383. }
  384. .flash-sale .list .item .text .progress .bg-reds {
  385. width: 0;
  386. height: 100%;
  387. transition: width 0.6s ease;
  388. background: linear-gradient(90deg, var(--view-bntColor11) 0%, var(--view-bntColor12) 100%);
  389. }
  390. .flash-sale .list .item .text .progress .piece {
  391. position: absolute;
  392. left: 8%;
  393. transform: translate(0%, -50%);
  394. top: 49%;
  395. font-size: 16rpx;
  396. color: var(--view-theme);
  397. }
  398. .flash-sale .list .item .grab {
  399. font-size: 28rpx;
  400. color: #fff;
  401. width: 150rpx;
  402. height: 54rpx;
  403. border-radius: 27rpx;
  404. text-align: center;
  405. line-height: 54rpx;
  406. position: absolute;
  407. right: 30rpx;
  408. bottom: 30rpx;
  409. background: #bbbbbb;
  410. &.b-color {
  411. background: var(--view-theme);
  412. }
  413. }
  414. .flash-sale .saleBox {
  415. width: 100%;
  416. height: 230rpx;
  417. background: var(--view-theme);
  418. border-radius: 0 0 50rpx 50rpx;
  419. }
  420. .tool-bar{
  421. display: flex;
  422. align-items: center;
  423. height: 40px;
  424. }
  425. .fixed-head{
  426. position: absolute;
  427. left: 0;
  428. top: 20px;
  429. width: 100%;
  430. z-index: 10;
  431. .icon-xiangzuo {
  432. margin-right: 40rpx;
  433. margin-left: 20rpx;
  434. font-size: 40rpx;
  435. color: #fff;
  436. }
  437. }
  438. </style>