coupon.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <!-- 优惠券列表 -->
  2. <template>
  3. <view class="container">
  4. <global-loading />
  5. <view class="list">
  6. <view v-for="(item, index) in list" v-if="item.state === 0" class="item">
  7. <view class="info-box">
  8. <view v-if="item.couponType == 1" class="discoun">
  9. <text style="font-size: 28rpx">¥</text>{{ item.reduceMoney }}
  10. </view>
  11. <view v-if="item.couponType == 2" class="discoun">{{ item.reduceMoney }}折</view>
  12. <view class="info-date">{{ getDate(item.startTime) }}-{{ getDate(item.endTime) }}</view>
  13. <view v-if="item.couponType == 1" class="info-condition">满{{ item.fullMoney }}元减{{ item.reduceMoney }}元</view>
  14. <view v-if="item.couponType == 2" class="info-condition">{{ item.reduceMoney }}折优惠</view>
  15. <view class="use-btn" @click="useTap(item)">立即使用</view>
  16. </view>
  17. </view>
  18. <view v-if="ifEmpty" class="emptyOrder-box flex-items-plus flex-column">
  19. <image class="emptyOrder-img" src="../../static/images/origin/bgnull.png"></image>
  20. <label class="font-color-999 fs26 mar-top-30">你还没有优惠券哦~</label>
  21. </view>
  22. </view>
  23. <!-- 触底 -->
  24. <view v-if="topLeft > 400 && list.length > 0" class="reachBottom">
  25. <image class="reach-icon" src="../../static/images/origin/reachBottom.png" mode="widthFix"></image>
  26. <text class="reach-text">这里到底了哦~~</text>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. const NET = require('../../utils/request')
  32. const API = require('../../config/api')
  33. export default {
  34. data() {
  35. return {
  36. list: [],
  37. // page:1,
  38. // pageSize:20,
  39. total: 0,
  40. availableList: [],
  41. // loadingType:0,
  42. topLeft: 0,
  43. ifEmpty: false
  44. }
  45. },
  46. onShow() {
  47. this.getFindCouponList()
  48. },
  49. onPageScroll(e) {
  50. this.topLeft = e.scrollTop
  51. },
  52. methods: {
  53. getFindCouponList() {
  54. // uni.showLoading({
  55. // mask: true,
  56. // title: '加载中...',
  57. // })
  58. NET.request(API.FindCouponList, 'GET').then((res) => {
  59. uni.hideLoading()
  60. this.list = res.data
  61. if (this.list.length === 0) {
  62. this.ifEmpty = true
  63. }
  64. this.list.forEach((item) => {
  65. if (item.state === 0) {
  66. this.availableList.push(item)
  67. }
  68. })
  69. })
  70. .catch((res) => {
  71. uni.hideLoading()
  72. })
  73. },
  74. getDate(time) {
  75. if (!time) return ''
  76. return time.split(' ')[0].split('-').join('.')
  77. },
  78. useTap(item) {
  79. uni.navigateTo({
  80. url: `../../pages_category_page1/goodsModule/couponShopList?activityId=${item.activityId}&shopCouponId=${item.shopCouponId}`
  81. })
  82. }
  83. }
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .emptyOrder-box {
  88. margin: 70upx auto 0 auto;
  89. .emptyOrder-img {
  90. margin-top: 45%;
  91. width: 113upx;
  92. height: 98upx;
  93. }
  94. }
  95. .list {
  96. display: flex;
  97. flex-wrap: wrap;
  98. }
  99. .item {
  100. width: 50%;
  101. height: 291rpx;
  102. background: url("../../static/images/origin/couponsIcon.png") no-repeat center top;
  103. border-radius: 10rpx;
  104. margin-top: 20rpx;
  105. display: flex;
  106. flex-direction: row;
  107. position: relative;
  108. background-size: contain;
  109. padding: 0 56rpx;
  110. margin-bottom: 30rpx;
  111. }
  112. .discoun {
  113. display: flex;
  114. flex-direction: row;
  115. align-items: baseline;
  116. font-size: 40rpx;
  117. color: #C5AA7B;
  118. margin: 0 auto;
  119. padding-top: 50rpx;
  120. }
  121. .discoun text {
  122. display: inline-block;
  123. }
  124. .info-box {
  125. width: 100%;
  126. display: flex;
  127. flex-direction: column;
  128. align-items: flex-start;
  129. }
  130. .info-condition {
  131. font-size: 20rpx;
  132. font-weight: 400;
  133. color: #999999;
  134. margin: 0 auto;
  135. }
  136. .info-date {
  137. font-size: 20rpx;
  138. font-family: PingFang SC;
  139. font-weight: 400;
  140. color: #999999;
  141. margin: 0 auto;
  142. }
  143. .use-btn {
  144. height: 48rpx;
  145. border: 2rpx solid #C5AA7B;
  146. line-height: 48rpx;
  147. text-align: center;
  148. font-size: 24rpx;
  149. font-weight: 500;
  150. background-color: #C5AA7B;
  151. color: #FFFFFF;
  152. margin: 50rpx auto 0 auto;
  153. padding: 0 5rpx;
  154. }
  155. // 触底样式
  156. .reachBottom {
  157. margin-top: 30rpx;
  158. display: flex;
  159. flex-direction: column;
  160. align-items: center;
  161. .reach-icon {
  162. width: 150rpx;
  163. height: 150rpx;
  164. }
  165. .reach-text {
  166. margin: 20rpx 0;
  167. color: #CCCCCC;
  168. }
  169. }
  170. </style>