You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

453 lines
11 KiB

3 months ago
  1. <template>
  2. <view :data-theme="theme">
  3. <skeleton :show="showSkeleton" :isNodes="isNodes" ref="skeleton" loading="chiaroscuro" selector="skeleton"
  4. bgcolor="#FFF"></skeleton>
  5. <view class="skeleton" :style="{visibility: showSkeleton ? 'hidden' : 'visible'}">
  6. <view class="combinationBj"></view>
  7. <view class='flash-sale'>
  8. <!-- #ifdef H5 -->
  9. <view class='iconfont icon-xiangzuo' @tap='goBack' :style="'top:'+ (navH/2) +'rpx'" v-if="returnShow"></view>
  10. <!-- #endif -->
  11. <view class="saleBox"></view>
  12. <view class="header skeleton-rect" v-if="dataList.length">
  13. <swiper indicator-dots="true" autoplay="true" :circular="circular" interval="3000" duration="1500"
  14. indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff">
  15. <block v-for="(items,index) in dataList[active].slide" :key="index">
  16. <swiper-item class="borRadius14">
  17. <image :src="items.sattDir" class="slide-image borRadius14" lazy-load></image>
  18. </swiper-item>
  19. </block>
  20. </swiper>
  21. </view>
  22. <view class="seckillList acea-row row-between-wrapper">
  23. <view class="priceTag skeleton-rect">
  24. <image :src="urlDomain+'crmebimage/perset/staticImg/priceTag.png'"></image>
  25. </view>
  26. <view class='timeLsit'>
  27. <scroll-view class="scroll-view_x" scroll-x scroll-with-animation :scroll-left="scrollLeft"
  28. style="width:auto;overflow:hidden;">
  29. <block v-for="(item,index) in dataList" :key='index'>
  30. <view @tap='settimeList(item,index)' class='item' :class="active == index?'on':''">
  31. <view class='time'>{{item.time.split(',')[0]}}</view>
  32. <view class="state">{{item.statusName}}</view>
  33. </view>
  34. </block>
  35. </scroll-view>
  36. </view>
  37. </view>
  38. <view class='list pad30' v-if='seckillList.length>0'>
  39. <block v-for="(item,index) in seckillList" :key='index'>
  40. <view class='item acea-row row-between-wrapper' @tap='goDetails(item)'>
  41. <view class='pictrue skeleton-rect'>
  42. <image :src='item.image'></image>
  43. </view>
  44. <view class='text acea-row row-column-around'>
  45. <view class='name line1 skeleton-rect'>{{item.title}}</view>
  46. <view class='money skeleton-rect'><text class="font_color"></text>
  47. <text class='num font_color'>{{item.price}}</text>
  48. <text class="y_money">{{item.otPrice}}</text>
  49. </view>
  50. <view class="limit skeleton-rect">限量 <text class="limitPrice">{{item.quota}} {{item.unitName}}</text>
  51. </view>
  52. <view class="progress skeleton-rect">
  53. <view class='bg-reds' :style="'width:'+item.percent+'%;'"></view>
  54. <view class='piece'>已抢{{item.percent}}%</view>
  55. </view>
  56. </view>
  57. <view class='grab bg_color' v-if="status == 2">马上抢</view>
  58. <view class='grab bg_color' v-else-if="status == 1">未开始</view>
  59. <view class='grab bg-color-hui' v-else>已结束</view>
  60. </view>
  61. </block>
  62. </view>
  63. </view>
  64. <view class='noCommodity' v-if="seckillList.length == 0 && (page != 1 || active== 0)">
  65. <view class='pictrue'>
  66. <image :src="urlDomain+'crmebimage/perset/staticImg/noShopper.png'"></image>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import {
  74. getSeckillHeaderApi,
  75. getSeckillList
  76. } from '../../../api/activity.js';
  77. import animationType from '@/utils/animationType.js'
  78. let app = getApp();
  79. export default {
  80. data() {
  81. return {
  82. urlDomain: this.$Cache.get("imgHost"),
  83. showSkeleton: true, //骨架屏显示隐藏
  84. isNodes: 0, //控制什么时候开始抓取元素节点,只要数值改变就重新抓取
  85. circular: true,
  86. autoplay: true,
  87. interval: 500,
  88. topImage: '',
  89. seckillList: [],
  90. timeList: [],
  91. active: 0,
  92. scrollLeft: 0,
  93. interval: 0,
  94. status: 1,
  95. countDownHour: "00",
  96. countDownMinute: "00",
  97. countDownSecond: "00",
  98. page: 1,
  99. limit: 10,
  100. loading: false,
  101. loadend: false,
  102. pageloading: false,
  103. dataList: [],
  104. returnShow: true,
  105. navH: '',
  106. theme:app.globalData.theme
  107. }
  108. },
  109. onLoad() {
  110. let that = this;
  111. setTimeout(() => {
  112. this.isNodes++;
  113. }, 500);
  114. var pages = getCurrentPages();
  115. this.returnShow = pages.length===1?false:true;
  116. // #ifdef H5
  117. this.navH = app.globalData.navHeight-18;
  118. // #endif
  119. this.getSeckillConfig();
  120. },
  121. methods: {
  122. goBack: function() {
  123. uni.navigateBack();
  124. },
  125. getSeckillConfig: function() {
  126. let that = this;
  127. //if(that.showSkeleton) that.dataList = [{slide:''}]
  128. that.seckillList = [{image:'',otPrice:'',percent:'',price:'',title:''}];
  129. getSeckillHeaderApi().then(res => {
  130. if(res.data == ''){
  131. this.$util.Tips({
  132. title: '暂无秒杀活动'
  133. }, {
  134. url: '/pages/index/index'
  135. });
  136. return;
  137. }
  138. that.seckillList = [];
  139. res.data.map(item => {
  140. item.slide = JSON.parse(item.slide)
  141. })
  142. that.dataList = res.data;
  143. that.page = 1;
  144. that.status = that.dataList[that.active].status;
  145. that.getSeckillList();
  146. });
  147. },
  148. getSeckillList: function() {
  149. var that = this;
  150. var data = {
  151. page: that.page,
  152. limit: that.limit
  153. };
  154. if (that.loadend) return;
  155. if (that.pageloading) return;
  156. that.pageloading = true
  157. getSeckillList(that.dataList[that.active].id, data).then(res => {
  158. // that.seckillList = [];
  159. var seckillList = res.data.list;
  160. var loadend = seckillList.length < that.limit;
  161. that.seckillList = that.seckillList.concat(seckillList);
  162. that.page++;
  163. that.page = that.page;
  164. that.pageloading = false;
  165. that.loadend = loadend;
  166. // #ifdef H5
  167. that.setShare();
  168. // #endif
  169. setTimeout(() => {
  170. that.showSkeleton = false
  171. }, 1000)
  172. }).catch(err => {
  173. that.pageloading = false
  174. });
  175. },
  176. settimeList: function(item, index) {
  177. if(index !== this.active){
  178. var that = this;
  179. this.active = index
  180. if (that.interval) {
  181. clearInterval(that.interval);
  182. that.interval = null
  183. }
  184. that.interval = 0,
  185. that.countDownHour = "00";
  186. that.countDownMinute = "00";
  187. that.countDownSecond = "00";
  188. that.status = that.dataList[that.active].status;
  189. that.loadend = false;
  190. that.page = 1;
  191. that.seckillList = [];
  192. // wxh.time(e.currentTarget.dataset.stop, that);
  193. that.getSeckillList();
  194. }
  195. },
  196. goDetails(item) {
  197. uni.navigateTo({
  198. animationType: animationType.type, animationDuration: animationType.duration,
  199. url: '/pages/activity/goods_seckill_details/index?id=' + item.id
  200. })
  201. },
  202. setShare: function() {
  203. this.$wechat.isWeixin() &&
  204. this.$wechat.wechatEvevt([
  205. "updateAppMessageShareData",
  206. "updateTimelineShareData",
  207. "onMenuShareAppMessage",
  208. "onMenuShareTimeline"
  209. ], {
  210. desc: this.seckillList[0].title,
  211. title: this.seckillList[0].title,
  212. link: location.href,
  213. imgUrl:this.seckillList[0].image
  214. }).then(res => {
  215. }).catch(err => {
  216. console.log(err);
  217. });
  218. },
  219. },
  220. /**
  221. * 页面上拉触底事件的处理函数
  222. */
  223. onReachBottom: function() {
  224. var that = this;
  225. that.getSeckillList();
  226. }
  227. }
  228. </script>
  229. <style>
  230. page {
  231. background-color: #F5F5F5 !important;
  232. }
  233. </style>
  234. <style scoped lang="scss">
  235. .icon-xiangzuo {
  236. font-size: 40rpx;
  237. color: #fff;
  238. position: fixed;
  239. left: 30rpx;
  240. z-index: 99;
  241. transform: translateY(-20%);
  242. }
  243. .flash-sale .header {
  244. width: 710rpx;
  245. height: 330rpx;
  246. margin: -276rpx auto 0 auto;
  247. border-radius: 14rpx;
  248. overflow: hidden;
  249. swiper{
  250. height: 330rpx !important;
  251. border-radius: 14rpx;
  252. overflow: hidden;
  253. }
  254. }
  255. .flash-sale .header image {
  256. width: 100%;
  257. height: 100%;
  258. border-radius: 14rpx;
  259. overflow: hidden;
  260. img{
  261. border-radius: 14rpx;
  262. }
  263. }
  264. .flash-sale .seckillList {
  265. padding: 25rpx;
  266. }
  267. .flash-sale .seckillList .priceTag {
  268. width: 75rpx;
  269. height: 70rpx;
  270. }
  271. .flash-sale .seckillList .priceTag image {
  272. width: 100%;
  273. height: 100%;
  274. }
  275. .flash-sale .timeLsit {
  276. width: 596rpx;
  277. white-space: nowrap;
  278. }
  279. .flash-sale .timeLsit .item {
  280. display: inline-block;
  281. font-size: 20rpx;
  282. color: #666;
  283. text-align: center;
  284. box-sizing: border-box;
  285. margin-right: 30rpx;
  286. width: 130rpx;
  287. }
  288. .flash-sale .timeLsit .item .time {
  289. font-size: 36rpx;
  290. font-weight: 600;
  291. color: #333;
  292. }
  293. .flash-sale .timeLsit .item.on .time {
  294. @include main_color(theme);
  295. }
  296. .flash-sale .timeLsit .item.on .state {
  297. height: 30rpx;
  298. line-height: 30rpx;
  299. border-radius: 15rpx;
  300. width: 128rpx;
  301. @include main_bg_color(theme);
  302. color: #fff;
  303. }
  304. .flash-sale .countDown {
  305. height: 92rpx;
  306. border-bottom: 1rpx solid #f0f0f0;
  307. margin-top: -14rpx;
  308. font-size: 28rpx;
  309. color: #282828;
  310. }
  311. .flash-sale .countDown .num {
  312. font-size: 28rpx;
  313. font-weight: bold;
  314. background-color: #ffcfcb;
  315. padding: 4rpx 7rpx;
  316. border-radius: 3rpx;
  317. }
  318. .flash-sale .countDown .text {
  319. font-size: 28rpx;
  320. color: #282828;
  321. margin-right: 13rpx;
  322. }
  323. .flash-sale .list .item {
  324. height: 230rpx;
  325. position: relative;
  326. /* width: 710rpx; */
  327. margin: 0 auto 20rpx auto;
  328. background-color: #fff;
  329. border-radius: 14rpx;
  330. padding: 25rpx 24rpx;
  331. }
  332. .flash-sale .list .item .pictrue {
  333. width: 180rpx;
  334. height: 180rpx;
  335. border-radius: 10rpx;
  336. background-color: #F5F5F5;
  337. }
  338. .flash-sale .list .item .pictrue image {
  339. width: 100%;
  340. height: 100%;
  341. border-radius: 10rpx;
  342. }
  343. .flash-sale .list .item .text {
  344. width: 440rpx;
  345. font-size: 30rpx;
  346. color: #333;
  347. height: 166rpx;
  348. }
  349. .flash-sale .list .item .text .name {
  350. width: 100%;
  351. }
  352. .flash-sale .list .item .text .money {
  353. font-size: 30rpx;
  354. @include price_color(theme);
  355. }
  356. .flash-sale .list .item .text .money .num {
  357. font-size: 40rpx;
  358. font-weight: 500;
  359. font-family: 'Guildford Pro';
  360. }
  361. .flash-sale .list .item .text .money .y_money {
  362. font-size: 24rpx;
  363. color: #999;
  364. text-decoration-line: line-through;
  365. margin-left: 15rpx;
  366. }
  367. .flash-sale .list .item .text .limit {
  368. font-size: 22rpx;
  369. color: #999;
  370. margin-bottom: 5rpx;
  371. }
  372. .flash-sale .list .item .text .limit .limitPrice {
  373. margin-left: 10rpx;
  374. }
  375. .flash-sale .list .item .text .progress {
  376. overflow: hidden;
  377. background-color: #EEEEEE;
  378. width: 260rpx;
  379. border-radius: 18rpx;
  380. height: 18rpx;
  381. position: relative;
  382. }
  383. .flash-sale .list .item .text .progress .bg-reds {
  384. width: 0;
  385. height: 100%;
  386. transition: width 0.6s ease;
  387. @include second-gradient(theme);
  388. }
  389. .flash-sale .list .item .text .progress .piece {
  390. position: absolute;
  391. left: 8%;
  392. transform: translate(0%, -50%);
  393. top: 49%;
  394. font-size: 16rpx;
  395. color: #FFB9B9;
  396. }
  397. .flash-sale .list .item .grab {
  398. font-size: 28rpx;
  399. color: #fff;
  400. width: 150rpx;
  401. height: 54rpx;
  402. border-radius: 27rpx;
  403. text-align: center;
  404. line-height: 54rpx;
  405. position: absolute;
  406. right: 30rpx;
  407. bottom: 30rpx;
  408. background: #bbbbbb;
  409. }
  410. .bg_color{
  411. @include main_bg_color(theme);
  412. }
  413. .flash-sale .saleBox {
  414. width: 100%;
  415. height: 298rpx;
  416. /* #ifdef MP */
  417. height: 300rpx;
  418. /* #endif */
  419. @include main_bg_color(theme);
  420. border-radius: 0 0 50rpx 50rpx;
  421. }
  422. </style>