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

587 lines
15 KiB

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