groupBuy.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <template>
  2. <view class="groupBuy">
  3. <JHeader :dark="false" title="拼团专区" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <view class="groupBuyBg">
  5. 拼团专区
  6. </view>
  7. <view v-if="shopShowType == false" class="countdown">
  8. <label v-if="groupDataListState === 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="shop-list-nav">
  13. <view class="nav-item-sort" @click="sortTap(1)">
  14. <text class="nav-title" :class="{ 'active': sortIndex == 1 }">
  15. 综合
  16. </text>
  17. </view>
  18. <view class="nav-item-sort" @click="sortTap(2)">
  19. <text class="nav-title" :class="{ 'active': sortIndex == 2 }">
  20. 价格
  21. </text>
  22. <view class="r">
  23. <view class="arrowUp" :class="{ activeUp: queryInfo.type == 1 }"></view>
  24. <view class="arrowDown" :class="{ activeDown: queryInfo.type == 2 }"></view>
  25. </view>
  26. </view>
  27. <view class="nav-item-sort" @click="sortTap(3)">
  28. <text class="nav-title" :class="{ 'active': sortIndex == 3 }">
  29. 销量
  30. </text>
  31. <view class="r">
  32. <view class="arrowUp" :class="{ activeUp: queryInfo.volume == 1 }"></view>
  33. <view class="arrowDown" :class="{ activeDown: queryInfo.volume == 2 }"></view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="spikeList mar-top-20">
  38. <view v-for="(item, index) in groupBuyList" :key="index" class="listItem">
  39. <view class="itemBox">
  40. <img :src="common.seamingImgUrl(item.image)">
  41. </view>
  42. <view class="itemInfo">
  43. <view class="title">
  44. <p>{{ item.productName }}</p>
  45. <view class="tag-box">
  46. <view v-if="item.person > 0" class="number group-buy-number">
  47. {{ item.person }}人团
  48. </view>
  49. <view v-if="item.limitNumber" class="number">
  50. 限量{{ item.limitNumber }}件 / 剩余{{ item.limitStockNumber }}件
  51. </view>
  52. </view>
  53. </view>
  54. <view class="originalPrice">原价: ¥{{ item.originalPrice }}</view>
  55. <view class="price">
  56. <view class="currentPrice flex-row-plus flex-items-plus font-color-FF7800">
  57. <view class="iconBox">
  58. <image src="../../../static/images/new-business/shop/groupBuyIcon.png"></image>
  59. </view>
  60. <view class="flex-row-plus flex-items priceInfo">
  61. <label class="fs24">¥</label>
  62. <label class="fs36">{{ item.price }}</label>
  63. </view>
  64. </view>
  65. <view
  66. v-if="groupDataListState === 1" class="snapUpBtn"
  67. @click="gogoodsDetails(item.shopId, item.productId, item.skuId)"
  68. >
  69. <view class="btnText">去拼团</view>
  70. <view style="width: 82%;margin: 0 auto">
  71. <progress activeColor="#FFFFFF" :percent="getPercent(5, 10)" active stroke-width="5" />
  72. </view>
  73. </view>
  74. <view v-else class="snapUpBtn btnStyle1">
  75. <view class="btnText">即将开始</view>
  76. <view style="width: 82%;margin: 0 auto">
  77. <progress activeColor="#FFFFFF" :percent="getPercent(5, 10)" active stroke-width="5" />
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <view style="padding-bottom: 45upx;">
  84. <LoadingMore
  85. :status="!isEmpty && !groupBuyList.length
  86. ? 'loading' : !isEmpty && groupBuyList.length && (groupBuyList.length >= groupBuyTotal) ? 'no-more' : ''"
  87. >
  88. </LoadingMore>
  89. <tui-no-data v-if="isEmpty" :fixed="false" style="margin-top: 60upx;">暂无数据</tui-no-data>
  90. </view>
  91. </view>
  92. </view>
  93. </template>
  94. <script>
  95. import { getIndexWorkApi } from '../../../api/anotherTFInterface'
  96. export default {
  97. name: 'GroupBuy',
  98. data() {
  99. return {
  100. isEmpty: false,
  101. groupBuyList: [],
  102. groupBuyTotal: 0,
  103. queryInfo: {
  104. page: 1,
  105. pageSize: 20,
  106. shopId: 0,
  107. type: 0, // 价格
  108. volume: 0, // 销量
  109. shopGroupWorkId: 0
  110. },
  111. groupDataListState: {},
  112. hou: '00',
  113. min: '00',
  114. sec: '00',
  115. shopShowType: false,
  116. sortIndex: 1
  117. }
  118. },
  119. onLoad(options) {
  120. if (options.shopId && options.shopGroupWorkId) {
  121. this.shopShowType = false
  122. this.queryInfo.shopId = options.shopId
  123. this.queryInfo.shopGroupWorkId = options.shopGroupWorkId
  124. } else {
  125. this.shopShowType = true
  126. this.queryInfo.shopId = 0
  127. this.queryInfo.shopGroupWorkId = 0
  128. }
  129. },
  130. onShow() {
  131. this.getGroupBuylist()
  132. },
  133. methods: {
  134. getPercent(num, total) {
  135. num = parseFloat(num)
  136. total = parseFloat(total)
  137. if (isNaN(num) || isNaN(total)) {
  138. return '-'
  139. }
  140. return total <= 0 ? '0%' : Math.round((num / total) * 10000) / 100.0
  141. },
  142. sortTap(index) {
  143. this.queryInfo.page = 1
  144. this.groupBuyList = []
  145. this.sortIndex = index
  146. if (index == 1) {
  147. this.queryInfo.type = 0
  148. this.queryInfo.volume = 0
  149. } else if (index == 2) {
  150. this.queryInfo.volume = 0
  151. if (this.queryInfo.type === 0) {
  152. this.queryInfo.type = 1
  153. } else {
  154. this.queryInfo.type = this.queryInfo.type != 1 ? 1 : 2
  155. }
  156. } else if (index == 3) {
  157. this.queryInfo.type = 0
  158. if (this.queryInfo.volume === 0) {
  159. this.queryInfo.volume = 1
  160. } else {
  161. this.queryInfo.volume = this.queryInfo.volume != 1 ? 1 : 2
  162. }
  163. }
  164. this.getGroupBuylist()
  165. },
  166. gogoodsDetails(shopId, productId, skuId) {
  167. uni.navigateTo({
  168. url: '/another-tf/another-serve/goodsDetails/index?shopId=' + shopId + '&productId=' + productId + '&skuId=' + skuId
  169. })
  170. },
  171. getGroupBuylist(isLoadmore) {
  172. uni.showLoading()
  173. getIndexWorkApi(this.queryInfo).then((res) => {
  174. this.groupDataListState = res.data.state
  175. if (this.shopShowType == false) {
  176. this.dateformat(res.data.time)
  177. this.countDown()
  178. }
  179. this.groupBuyTotal = res.data.page.total
  180. if (isLoadmore) {
  181. this.groupBuyList.push(...res.data.page.list)
  182. } else {
  183. this.groupBuyList = res.data.page.list
  184. }
  185. this.isEmpty = this.groupBuyList.length === 0
  186. uni.hideLoading()
  187. })
  188. .catch((e) => {
  189. uni.hideLoading()
  190. })
  191. },
  192. // 时分秒换算
  193. dateformat(micro_second) {
  194. // 总秒数
  195. const second = Math.floor(micro_second / 1000)
  196. // 天数
  197. const day = Math.floor(second / 3600 / 24)
  198. // 小时
  199. const hr = Math.floor(second / 3600 % 24)
  200. // 分钟
  201. const min = Math.floor(second / 60 % 60)
  202. // 秒
  203. const sec = Math.floor(second % 60)
  204. this.hou = hr + day * 24
  205. this.min = min
  206. this.sec = sec
  207. },
  208. countDown() {
  209. const timeOut = setTimeout(() => {
  210. const hou = parseInt(this.hou)
  211. const min = parseInt(this.min)
  212. const sec = parseInt(this.sec)
  213. let netxSec = sec - 1
  214. let netxMin = min
  215. let netxHou = hou
  216. if (netxHou == 0 && netxMin == 0 && netxSec == -1) {
  217. clearTimeout(timeOut)
  218. this.$switchTab('/')
  219. uni.showToast({
  220. title: '活动结束',
  221. duration: 2000,
  222. icon: 'none'
  223. })
  224. } else {
  225. if (netxSec == -1) {
  226. netxSec = 59
  227. netxMin = netxMin - 1
  228. }
  229. if (netxMin == -1) {
  230. netxMin = 59
  231. netxHou = netxHou - 1
  232. }
  233. // if (netxHou == -1) {
  234. // netxHou = 23
  235. // }
  236. this.hou = this.timeFormat(netxHou),
  237. this.min = this.timeFormat(netxMin),
  238. this.sec = this.timeFormat(netxSec),
  239. this.timeOut = timeOut
  240. this.countDown()
  241. }
  242. }, 1000)
  243. },
  244. timeFormat(param) { // 小于10的格式化函数
  245. return param < 10 ? '0' + param : param
  246. }
  247. },
  248. onReachBottom() {
  249. if (this.groupBuyList.length < this.groupBuyTotal) {
  250. ++this.queryInfo.page
  251. this.getGroupBuylist(true)
  252. }
  253. }
  254. }
  255. </script>
  256. <style lang="less" scoped>
  257. .groupBuy {
  258. min-height: 100vh;
  259. background-color: #333333;
  260. box-sizing: border-box;
  261. .groupBuyBg {
  262. margin: 50rpx auto;
  263. font-size: 40upx;
  264. font-weight: bold;
  265. text-align: center;
  266. color: #ffffff;
  267. }
  268. .countdown {
  269. display: flex;
  270. justify-content: center;
  271. height: 80upx;
  272. align-items: center;
  273. width: 100%;
  274. color: #CCCCCC;
  275. .endDate {
  276. display: flex;
  277. align-items: center;
  278. margin-left: 20upx;
  279. span {
  280. min-width: 44rpx;
  281. padding: 0 8rpx;
  282. height: 52upx;
  283. line-height: 52upx;
  284. background: #999999;
  285. display: block;
  286. font-size: 26upx;
  287. color: #FFEBC4;
  288. text-align: center;
  289. }
  290. i {
  291. font-size: 26upx;
  292. color: #999999;
  293. font-style: normal;
  294. margin: 0 8upx;
  295. }
  296. }
  297. }
  298. .spikeList {
  299. padding: 0upx 30upx 20upx 30upx;
  300. .listItem {
  301. display: flex;
  302. padding: 30upx;
  303. margin-bottom: 30upx;
  304. background: #FFFFFF;
  305. &:last-child {
  306. border-bottom: none;
  307. }
  308. .itemBox {
  309. width: 260upx;
  310. height: 260upx;
  311. margin-right: 30upx;
  312. img {
  313. width: 100%;
  314. height: 100%;
  315. }
  316. }
  317. .itemInfo {
  318. flex: 1;
  319. display: flex;
  320. flex-direction: column;
  321. justify-content: space-between;
  322. .iconBox {
  323. image {
  324. width: 58rpx;
  325. height: 36rpx;
  326. }
  327. }
  328. p {
  329. font-size: 26upx;
  330. color: #333333;
  331. line-height: 40upx;
  332. margin-bottom: 20upx;
  333. text-overflow: -o-ellipsis-lastline;
  334. overflow: hidden;
  335. text-overflow: ellipsis;
  336. display: -webkit-box;
  337. -webkit-line-clamp: 2;
  338. line-clamp: 2;
  339. -webkit-box-orient: vertical;
  340. }
  341. .title {
  342. .number {
  343. color: #C5AA7B;
  344. font-size: 26rpx;
  345. height: 40rpx;
  346. background: #FFFFFF;
  347. border: 2rpx solid #E4E5E6;
  348. font-weight: 400;
  349. display: inline;
  350. padding: 0 5rpx;
  351. }
  352. }
  353. .originalPrice {
  354. font-size: 24upx;
  355. margin-top: 20upx;
  356. text-decoration: line-through;
  357. color: #CCCCCC;
  358. }
  359. .price {
  360. display: flex;
  361. justify-content: space-between;
  362. align-items: center;
  363. .priceInfo {
  364. font-size: 40rpx;
  365. color: #C83732;
  366. }
  367. .snapUpBtn {
  368. width: 160upx;
  369. height: 84upx;
  370. text-align: center;
  371. background: linear-gradient(90deg, #C83732 0%, #E25C44 100%);
  372. box-shadow: 0rpx 6rpx 12rpx rgba(233, 0, 0, 0.3);
  373. opacity: 1;
  374. border-radius: 10rpx;
  375. .btnText {
  376. color: #FFFFFF;
  377. font-weight: 400;
  378. opacity: 0.5;
  379. margin: 10rpx 0;
  380. }
  381. .uni-progress {
  382. border-radius: 10rpx;
  383. }
  384. }
  385. .btnStyle1 {
  386. background: linear-gradient(90deg, #29C790 0%, #75D98C 100%);
  387. box-shadow: 0 6rpx 12rpx rgba(52, 203, 144, 0.3);
  388. }
  389. }
  390. }
  391. }
  392. }
  393. }
  394. .shop-list-nav {
  395. display: flex;
  396. flex-direction: row;
  397. align-items: center;
  398. height: 80rpx;
  399. line-height: 76rpx;
  400. }
  401. .active {
  402. color: #C5AA7B;
  403. }
  404. .nav-item-sort {
  405. flex: 1;
  406. font-size: 24rpx;
  407. color: #999999;
  408. display: flex;
  409. flex-direction: row;
  410. align-items: center;
  411. justify-content: center;
  412. height: 80rpx;
  413. line-height: 80rpx;
  414. }
  415. .nav-item-sort .r {
  416. display: flex;
  417. flex-direction: column;
  418. align-items: center;
  419. justify-content: center;
  420. margin-left: 5rpx;
  421. .arrowDown {
  422. width: 0;
  423. height: 0;
  424. border-width: 10rpx;
  425. border-style: solid;
  426. border-color: #CCCCCC transparent transparent transparent;
  427. margin-top: 2rpx;
  428. }
  429. .arrowUp {
  430. margin-bottom: 2rpx;
  431. width: 0;
  432. height: 0;
  433. border-width: 10rpx;
  434. border-style: solid;
  435. border-color: transparent transparent #CCCCCC transparent;
  436. }
  437. .activeDown {
  438. border-color: #C5AA7B transparent transparent transparent;
  439. }
  440. .activeUp {
  441. border-color: transparent transparent #C5AA7B transparent;
  442. }
  443. }
  444. .tag-box {
  445. display: flex;
  446. align-items: center;
  447. justify-content: flex-start;
  448. flex-wrap: wrap;
  449. .number {
  450. display: inline-block;
  451. padding: 6rpx 16rpx;
  452. border-radius: 4rpx;
  453. border: 1rpx solid #E3928F;
  454. color: #E3928F;
  455. font-size: 14rpx;
  456. }
  457. .group-buy-number {
  458. background-color: #E3928F;
  459. border: none;
  460. color: #fff;
  461. }
  462. }
  463. </style>