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

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