多租户商城-商户小程序端
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.

702 lines
16 KiB

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