groupBuy.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <template>
  2. <view class="groupBuy">
  3. <global-loading />
  4. <view class="groupBuyBg">
  5. <image src="../../static/images/origin/groupBuyLogo.png"></image>
  6. </view>
  7. <view v-if="shopShowType == false" class="countdown">
  8. <label v-if="groupDataList.state === 1">距结束剩余</label>
  9. <label v-else>即将开始</label>
  10. <view class="endDate"><span>{{ hou }}</span><i>:</i><span>{{ min }}</span><i>:</i><span>{{ sec }}</span></view>
  11. </view>
  12. <!-- <view class="filterBox" v-else> -->
  13. <!-- <view class="item" :class="selectIndex == 0 ? 'selected' : ''" @click="synthesize"><span>综合</span></view> -->
  14. <!-- <view class="item" :class="selectIndex == 1 ? 'selected' : ''" @click="sales"><span>销量</span></view> -->
  15. <!-- <view class="item" :class="selectIndex == 2 ? 'selected' : ''" @click="priceClick"><span>价格</span></view> -->
  16. <!-- </view> -->
  17. <view class="shop-list-nav">
  18. <view class="nav-item-sort" @click="sortTap(1)">
  19. <text class="nav-title" :class="{ 'active': sortIndex == 1 }">
  20. 综合
  21. </text>
  22. </view>
  23. <view class="nav-item-sort" @click="sortTap(2)">
  24. <text class="nav-title" :class="{ 'active': sortIndex == 2 }">
  25. 价格
  26. </text>
  27. <view class="r">
  28. <view class="arrowUp" :class="{ activeUp: type == 1 }"></view>
  29. <view class="arrowDown" :class="{ activeDown: type == 2 }"></view>
  30. </view>
  31. </view>
  32. <view class="nav-item-sort" @click="sortTap(3)">
  33. <text class="nav-title" :class="{ 'active': sortIndex == 3 }">
  34. 销量
  35. </text>
  36. <view class="r">
  37. <view class="arrowUp" :class="{ activeUp: volume == 1 }"></view>
  38. <view class="arrowDown" :class="{ activeDown: volume == 2 }"></view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="spikeList mar-top-20">
  43. <view v-for="(item, index) in groupBuy" :key="index" class="listItem">
  44. <view class="itemBox">
  45. <img :src="item.image">
  46. </view>
  47. <view class="itemInfo">
  48. <view class="title">
  49. <p>{{ item.productName }}</p>
  50. <view class="tag-box">
  51. <view v-if="item.person > 0" class="number group-buy-number">
  52. {{ item.person }}人团
  53. </view>
  54. <view v-if="item.limitNumber" class="number">
  55. 限量{{ item.limitNumber }}件 / 剩余{{ item.limitStockNumber }}件
  56. </view>
  57. </view>
  58. </view>
  59. <view class="originalPrice">原价: ¥{{ item.originalPrice }}</view>
  60. <view class="price">
  61. <view class="currentPrice flex-row-plus flex-items-plus font-color-FF7800">
  62. <view class="iconBox">
  63. <image src="../../static/images/origin/groupBuyIcon.png"></image>
  64. </view>
  65. <view class="flex-row-plus flex-items priceInfo">
  66. <label class="fs24">¥</label>
  67. <label class="fs36">{{ item.price }}</label>
  68. </view>
  69. </view>
  70. <view
  71. v-if="groupDataList.state === 1" class="snapUpBtn"
  72. @click="gogoodsDetails(item.shopId, item.productId, item.skuId)"
  73. >
  74. <view class="btnText">去拼团</view>
  75. <view style="width: 82%;margin: 0 auto">
  76. <progress activeColor="#FFFFFF" :percent="getPercent(5, 10)" active stroke-width="5" />
  77. </view>
  78. </view>
  79. <view v-else class="snapUpBtn btnStyle1">
  80. <view class="btnText">即将开始</view>
  81. <view style="width: 82%;margin: 0 auto">
  82. <progress activeColor="#FFFFFF" :percent="getPercent(5, 10)" active stroke-width="5" />
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <view v-if="ifEmpty" class="emptyOrder-box flex-items-plus flex-column">
  89. <image class="emptyOrder-img" src="../../static/images/origin/bgnull.png"></image>
  90. <label class="font-color-999 fs26 mar-top-30">暂无活动商品~</label>
  91. </view>
  92. </view>
  93. </view>
  94. </template>
  95. <script>
  96. const NET = require('../../utils/request')
  97. const API = require('../../config/api')
  98. export default {
  99. data() {
  100. return {
  101. pageType: true,
  102. groupBuy: [],
  103. page: 1,
  104. pageSize: 10,
  105. loadingType: 0,
  106. hou: '00',
  107. min: '00',
  108. sec: '00',
  109. shopId: 0,
  110. shopGroupWorkId: 0,
  111. type: 0, // 价格
  112. volume: 0, // 销量
  113. shopShowType: false,
  114. selectIndex: 0,
  115. sortIndex: 1,
  116. ifEmpty: false,
  117. groupDataList: {}
  118. }
  119. },
  120. onLoad(options) {
  121. if (options.shopId && options.shopGroupWorkId) {
  122. this.shopShowType = false
  123. this.shopId = options.shopId
  124. this.shopGroupWorkId = options.shopGroupWorkId
  125. } else {
  126. this.shopShowType = true
  127. this.shopId = 0
  128. this.shopGroupWorkId = 0
  129. }
  130. },
  131. onShow() {
  132. this.groupBuy = []
  133. this.getGroupBuylist()
  134. },
  135. onReachBottom() {
  136. if (this.loadingType == 1) {
  137. uni.stopPullDownRefresh()
  138. } else {
  139. this.page = this.page + 1
  140. this.getGroupBuylist()
  141. }
  142. },
  143. methods: {
  144. // synthesize(){
  145. // this.volume =1//销量
  146. // this.type = 1//价格
  147. // this.page = 1
  148. // this.selectIndex = 0
  149. // this.groupBuy = []
  150. // this.getGroupBuylist()
  151. // },
  152. // sales(){
  153. // //销量
  154. // if(this.volume == 1){
  155. // this.volume = 2
  156. // }else{
  157. // this.volume = 1
  158. // }
  159. // this.type = 1//价格
  160. // this.page = 1
  161. // this.selectIndex = 1
  162. // this.groupBuy = []
  163. // this.getGroupBuylist()
  164. // },
  165. // priceClick(){
  166. // this.volume =1//销量
  167. // //价格
  168. // if(this.type == 1){
  169. // this.type = 2
  170. // }else{
  171. // this.type = 1
  172. // }
  173. // this.page = 1
  174. // this.selectIndex = 2
  175. // this.groupBuy = []
  176. // this.getGroupBuylist()
  177. // },
  178. getPercent(num, total) {
  179. num = parseFloat(num)
  180. total = parseFloat(total)
  181. if (isNaN(num) || isNaN(total)) {
  182. return '-'
  183. }
  184. return total <= 0 ? '0%' : Math.round((num / total) * 10000) / 100.0
  185. },
  186. sortTap(index) {
  187. this.page = 1
  188. this.groupBuy = []
  189. this.sortIndex = index
  190. if (index == 1) {
  191. this.type = 0
  192. this.volume = 0
  193. } else if (index == 2) {
  194. this.volume = 0
  195. if (this.type === 0) {
  196. this.type = 1
  197. } else {
  198. this.type = this.type != 1 ? 1 : 2
  199. }
  200. } else if (index == 3) {
  201. this.type = 0
  202. if (this.volume === 0) {
  203. this.volume = 1
  204. } else {
  205. this.volume = this.volume != 1 ? 1 : 2
  206. }
  207. }
  208. this.getGroupBuylist()
  209. },
  210. gogoodsDetails(shopId, productId, skuId) {
  211. uni.navigateTo({
  212. url: '../goodsModule/goodsDetails?shopId=' + shopId + '&productId=' + productId + '&skuId=' + skuId
  213. })
  214. },
  215. getGroupBuylist() {
  216. // uni.showLoading({
  217. // mask: true,
  218. // title: '加载中...',
  219. // })
  220. const param = {
  221. page: this.page,
  222. pageSize: this.pageSize,
  223. shopId: this.shopId,
  224. shopGroupWorkId: this.shopGroupWorkId,
  225. type: this.type,
  226. volume: this.volume
  227. }
  228. NET.request(API.getGroupBuyList, param, 'GET').then((res) => {
  229. uni.hideLoading()
  230. if (res.data.page.list.length == 0) {
  231. this.loadingType = 1
  232. this.page = this.page
  233. } else {
  234. this.groupDataList = res.data
  235. this.groupBuy = this.groupBuy.concat(res.data.page.list)
  236. if (this.groupBuy.length === 0) {
  237. this.ifEmpty = true
  238. }
  239. }
  240. if (this.shopShowType == false) {
  241. this.dateformat(res.data.time)
  242. this.countDown()
  243. }
  244. })
  245. .catch((res) => {
  246. uni.showToast({
  247. title: '失败',
  248. icon: 'none'
  249. })
  250. })
  251. },
  252. // 时分秒换算
  253. dateformat(micro_second) {
  254. // 总秒数
  255. const second = Math.floor(micro_second / 1000)
  256. // 天数
  257. const day = Math.floor(second / 3600 / 24)
  258. // 小时
  259. const hr = Math.floor(second / 3600 % 24)
  260. // 分钟
  261. const min = Math.floor(second / 60 % 60)
  262. // 秒
  263. const sec = Math.floor(second % 60)
  264. this.hou = hr + day * 24
  265. this.min = min
  266. this.sec = sec
  267. },
  268. countDown() {
  269. const timeOut = setTimeout(() => {
  270. const hou = parseInt(this.hou)
  271. const min = parseInt(this.min)
  272. const sec = parseInt(this.sec)
  273. let netxSec = sec - 1
  274. let netxMin = min
  275. let netxHou = hou
  276. if (netxHou == 0 && netxMin == 0 && netxSec == -1) {
  277. clearTimeout(timeOut)
  278. uni.switchTab({
  279. url: '../../pages/tabbar/index/index'
  280. })
  281. uni.showToast({
  282. title: '活动结束',
  283. duration: 2000,
  284. icon: 'none'
  285. })
  286. } else {
  287. if (netxSec == -1) {
  288. netxSec = 59
  289. netxMin = netxMin - 1
  290. }
  291. if (netxMin == -1) {
  292. netxMin = 59
  293. netxHou = netxHou - 1
  294. }
  295. // if (netxHou == -1) {
  296. // netxHou = 23
  297. // }
  298. this.hou = this.timeFormat(netxHou),
  299. this.min = this.timeFormat(netxMin),
  300. this.sec = this.timeFormat(netxSec),
  301. this.timeOut = timeOut
  302. this.countDown()
  303. }
  304. }, 1000)
  305. },
  306. timeFormat(param) { // 小于10的格式化函数
  307. return param < 10 ? '0' + param : param
  308. }
  309. }
  310. }
  311. </script>
  312. <style>
  313. page {
  314. background: #333333;
  315. }
  316. </style>
  317. <style
  318. lang="scss"
  319. scoped
  320. >
  321. page {
  322. background: #333333;
  323. }
  324. .groupBuy {
  325. .selected {
  326. color: #FE6F52;
  327. }
  328. .groupBuyBg {
  329. text-align: center;
  330. margin: 50rpx auto;
  331. image {
  332. width: 262rpx;
  333. height: 52rpx;
  334. }
  335. }
  336. .countdown {
  337. display: flex;
  338. justify-content: center;
  339. height: 80upx;
  340. align-items: center;
  341. width: 100%;
  342. color: #CCCCCC;
  343. .endDate {
  344. display: flex;
  345. align-items: center;
  346. margin-left: 20upx;
  347. span {
  348. min-width: 44rpx;
  349. padding: 0 8rpx;
  350. height: 52upx;
  351. line-height: 52upx;
  352. background: #999999;
  353. display: block;
  354. font-size: 26upx;
  355. color: #FFEBC4;
  356. text-align: center;
  357. }
  358. i {
  359. font-size: 26upx;
  360. color: #999999;
  361. font-style: normal;
  362. margin: 0 8upx;
  363. }
  364. }
  365. }
  366. .spikeList {
  367. padding: 0upx 30upx 20upx 30upx;
  368. .listItem {
  369. display: flex;
  370. padding: 30upx;
  371. margin-bottom: 30upx;
  372. background: #FFFFFF;
  373. &:last-child {
  374. border-bottom: none;
  375. }
  376. .itemBox {
  377. width: 260upx;
  378. height: 260upx;
  379. margin-right: 30upx;
  380. img {
  381. width: 100%;
  382. height: 100%;
  383. }
  384. }
  385. .itemInfo {
  386. flex: 1;
  387. display: flex;
  388. flex-direction: column;
  389. justify-content: space-between;
  390. .iconBox {
  391. image {
  392. width: 58rpx;
  393. height: 36rpx;
  394. }
  395. }
  396. p {
  397. font-size: 26upx;
  398. color: #333333;
  399. line-height: 40upx;
  400. margin-bottom: 20upx;
  401. text-overflow: -o-ellipsis-lastline;
  402. overflow: hidden;
  403. text-overflow: ellipsis;
  404. display: -webkit-box;
  405. -webkit-line-clamp: 2;
  406. line-clamp: 2;
  407. -webkit-box-orient: vertical;
  408. }
  409. .tilte {
  410. .number {
  411. color: #C5AA7B;
  412. font-size: 26rpx;
  413. height: 40rpx;
  414. background: #FFFFFF;
  415. border: 2rpx solid #E4E5E6;
  416. font-weight: 400;
  417. display: inline;
  418. padding: 0 5rpx;
  419. }
  420. }
  421. .originalPrice {
  422. font-size: 24upx;
  423. margin-top: 20upx;
  424. text-decoration: line-through;
  425. color: #CCCCCC;
  426. }
  427. .price {
  428. display: flex;
  429. justify-content: space-between;
  430. align-items: center;
  431. .priceInfo {
  432. font-size: 40rpx;
  433. color: #C83732;
  434. }
  435. .snapUpBtn {
  436. width: 160upx;
  437. height: 84upx;
  438. text-align: center;
  439. background: linear-gradient(90deg, #C83732 0%, #E25C44 100%);
  440. box-shadow: 0rpx 6rpx 12rpx rgba(233, 0, 0, 0.3);
  441. opacity: 1;
  442. border-radius: 10rpx;
  443. .btnText {
  444. color: #FFFFFF;
  445. font-weight: 400;
  446. opacity: 0.5;
  447. margin: 10rpx 0;
  448. }
  449. .uni-progress {
  450. border-radius: 10rpx;
  451. }
  452. }
  453. .btnStyle1 {
  454. background: linear-gradient(90deg, #29C790 0%, #75D98C 100%);
  455. box-shadow: 0 6rpx 12rpx rgba(52, 203, 144, 0.3);
  456. }
  457. }
  458. }
  459. }
  460. }
  461. .filterBox {
  462. display: flex;
  463. height: 80upx;
  464. align-items: center;
  465. width: 100%;
  466. background: #FFFFFF;
  467. left: 0;
  468. .item {
  469. flex: 0 0 33.33%;
  470. text-align: center;
  471. }
  472. }
  473. }
  474. .shop-list-nav {
  475. display: flex;
  476. flex-direction: row;
  477. align-items: center;
  478. height: 80rpx;
  479. line-height: 76rpx;
  480. }
  481. .nav-item {
  482. flex: 1;
  483. font-size: 30rpx;
  484. color: #666;
  485. display: flex;
  486. flex-direction: column;
  487. align-items: center;
  488. height: 80rpx;
  489. line-height: 76rpx;
  490. }
  491. .nav-item.active {
  492. color: #C5AA7B;
  493. }
  494. .nav-item .line {
  495. display: inline-block;
  496. width: 80rpx;
  497. height: 4rpx;
  498. background: #fff;
  499. border-radius: 2rpx;
  500. }
  501. .nav-item.active .line {
  502. background: #C5AA7B;
  503. }
  504. .nav-item.padd-l {
  505. padding-left: 20%;
  506. box-sizing: border-box;
  507. }
  508. .active {
  509. color: #C5AA7B;
  510. }
  511. .nav-item.padd-r {
  512. padding-right: 20%;
  513. box-sizing: border-box;
  514. }
  515. .nav-item-sort {
  516. flex: 1;
  517. font-size: 24rpx;
  518. color: #999999;
  519. display: flex;
  520. flex-direction: row;
  521. align-items: center;
  522. justify-content: center;
  523. height: 80rpx;
  524. line-height: 80rpx;
  525. }
  526. .nav-item-sort .r {
  527. display: flex;
  528. flex-direction: column;
  529. align-items: center;
  530. justify-content: center;
  531. margin-left: 5rpx;
  532. .arrowDown {
  533. width: 0;
  534. height: 0;
  535. border-width: 10rpx;
  536. border-style: solid;
  537. border-color: #CCCCCC transparent transparent transparent;
  538. margin-top: 2rpx;
  539. }
  540. .arrowUp {
  541. margin-bottom: 2rpx;
  542. width: 0;
  543. height: 0;
  544. border-width: 10rpx;
  545. border-style: solid;
  546. border-color: transparent transparent #CCCCCC transparent;
  547. }
  548. .activeDown {
  549. border-color: #C5AA7B transparent transparent transparent;
  550. }
  551. .activeUp {
  552. border-color: transparent transparent #C5AA7B transparent;
  553. }
  554. }
  555. .emptyOrder-box {
  556. margin-top: 70upx;
  557. .emptyOrder-img {
  558. margin-top: 45%;
  559. width: 113upx;
  560. height: 98upx;
  561. }
  562. }
  563. .tag-box {
  564. display: flex;
  565. align-items: center;
  566. justify-content: flex-start;
  567. flex-wrap: wrap;
  568. .number {
  569. display: inline-block;
  570. padding: 6rpx 16rpx;
  571. border-radius: 4rpx;
  572. border: 1rpx solid #E3928F;
  573. color: #E3928F;
  574. font-size: 14rpx;
  575. }
  576. .group-buy-number {
  577. background-color: #E3928F;
  578. border: none;
  579. color: #fff;
  580. }
  581. }
  582. </style>
  583. <style scoped>
  584. .snapUpBtn /deep/ .uni-progress-bar {
  585. border-radius: 10rpx;
  586. height: 8rpx;
  587. background-color: #deabab !important;
  588. }
  589. .snapUpBtn /deep/ .uni-progress-inner-bar {
  590. border-radius: 10rpx;
  591. }
  592. .spikeNav /deep/ .tabs-nav {}
  593. </style>