platformDiscount.vue 10 KB

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