coupon-find-list.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <!-- TODO -->
  3. <view class="coupon-find-list">
  4. <tui-skeleton v-if="isRequest" loadingType="2"></tui-skeleton>
  5. <template v-else>
  6. <!-- 顶部提示 -->
  7. <view class="top-tip" v-if="couponList.length > 0">
  8. <view class="tip-text">如何领取更多优惠券?</view>
  9. <view class="tip-btn" @click="popupVisible = true">去了解</view>
  10. </view>
  11. <!-- 优惠券列表 -->
  12. <view class="coupon-list">
  13. <template v-for="(coupon, index) in couponList">
  14. <cm-coupon :key="index" :couponData="coupon" @btnClick="couponClick"></cm-coupon>
  15. </template>
  16. </view>
  17. <template v-if="couponList.length >= 6">
  18. <tui-loadmore :index="3" :visible="loadmore"></tui-loadmore>
  19. <tui-nomore :text="loadingText" :visible="!loadmore" backgroundColor="#f7f7f7"></tui-nomore>
  20. </template>
  21. <!-- 优惠券列表为空 -->
  22. <cm-empty
  23. v-if="couponList.length <= 0"
  24. message="暂无任何优惠券~"
  25. :image="baseUrl + 'icon-coupon-empty.png'"
  26. :offset="100"
  27. ></cm-empty>
  28. <!-- 侧边 -->
  29. <scroll-top :isScrollTop="isScrollTop" :bottom="160"></scroll-top>
  30. </template>
  31. <!-- 如何获取更多优惠券 -->
  32. <message-popup @close="closePopup" :visible="popupVisible" class="message-popup">
  33. <template v-slot:title>
  34. <view class="title"> 如何获取更多优惠券? </view>
  35. </template>
  36. <template v-slot:content>
  37. <view class="content">
  38. <view class="row">
  39. <view class="dt">好友分享券</view>
  40. <view class="dd">
  41. 登录用户可通过分享商城给好友,当好友成功登录后,您可以领取一张好友分享券。
  42. </view>
  43. </view>
  44. <view class="row">
  45. <view class="dt">好友消费券</view>
  46. <view class="dd">
  47. 登录用户可通过分享商城给好友,当好友成功消费一笔订单后,您将可以领取一张好友消费券。
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. </message-popup>
  53. </view>
  54. </template>
  55. <script>
  56. import MessagePopup from '@/components/message-popup/message-popup.vue'
  57. import CmCoupon from '@/components/cm-module/cm-coupon/cm-coupon.vue'
  58. import CmEmpty from '@/components/cm-module/cm-empty/cm-empty.vue'
  59. import { mapGetters } from 'vuex'
  60. export default {
  61. components: {
  62. MessagePopup,
  63. CmCoupon,
  64. CmEmpty
  65. },
  66. data() {
  67. return {
  68. baseUrl: this.$Static,
  69. popupVisible: false,
  70. listQuery: {
  71. pageNum: 1,
  72. pageSize: 6,
  73. userId: ''
  74. },
  75. couponList: [],
  76. hasNextPage: false,
  77. total: 0,
  78. isScrollTop: false,
  79. isRequest: true,
  80. loadmore: false, // 正在加载更多
  81. timer: null
  82. }
  83. },
  84. computed: {
  85. ...mapGetters(['userId']),
  86. loadingText() {
  87. return this.hasNextPage ? '上拉加载更多' : '没有更多了'
  88. }
  89. },
  90. onLoad() {
  91. this.listQuery.userId = this.userId
  92. this.getCouponList()
  93. },
  94. methods: {
  95. // 关闭信息弹窗
  96. closePopup() {
  97. this.popupVisible = false
  98. },
  99. // 获取待优惠券列表
  100. getCouponList() {
  101. this.loadmore = true
  102. this.CouponService.GetCouponCenterInfo(this.listQuery).then(res => {
  103. this.couponList = res.data.list
  104. this.hasNextPage = res.data.hasNextPage
  105. this.total = res.data.total
  106. this.isRequest = false
  107. this.listQuery.pageNum++
  108. this.loadmore = false
  109. })
  110. },
  111. // 操作优惠券
  112. couponClick() {
  113. this.getCouponList()
  114. }
  115. },
  116. onPageScroll(e) {
  117. this.isScrollTop = e.scrollTop > 400
  118. },
  119. onReachBottom() {
  120. if (!this.hasNextPage) return
  121. clearTimeout(this.timer)
  122. this.timer = setTimeout(() => {
  123. console.log('触底了')
  124. this.getCouponList()
  125. }, 200)
  126. }
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. $tip-height: 80rpx;
  131. $grid: 24rpx;
  132. .coupon-find-list {
  133. min-height: 100%;
  134. box-sizing: border-box;
  135. padding-top: $tip-height;
  136. background: #f7f7f7;
  137. }
  138. .top-tip {
  139. position: fixed;
  140. top: 0;
  141. left: 0;
  142. z-index: 99;
  143. display: flex;
  144. justify-content: space-between;
  145. align-items: center;
  146. width: 750rpx;
  147. height: $tip-height;
  148. padding: 0 $grid;
  149. background: #fff3f7;
  150. box-sizing: border-box;
  151. .tip-text {
  152. font-size: 26rpx;
  153. color: #ff457b;
  154. }
  155. .tip-btn {
  156. width: 128rpx;
  157. height: 48rpx;
  158. border: 1rpx solid #ff457b;
  159. border-radius: 24rpx;
  160. text-align: center;
  161. line-height: 48rpx;
  162. font-size: 26rpx;
  163. color: #ff457b;
  164. }
  165. }
  166. .message-popup {
  167. .title {
  168. font-size: 30rpx;
  169. font-weight: 600;
  170. color: #333333;
  171. }
  172. .content {
  173. .row {
  174. padding-left: 32rpx;
  175. margin: $grid 0;
  176. .dt {
  177. position: relative;
  178. font-size: 26rpx;
  179. font-weight: 600;
  180. line-height: 40rpx;
  181. color: #333333;
  182. &::before {
  183. content: '';
  184. display: block;
  185. position: absolute;
  186. left: -$grid;
  187. top: 50%;
  188. transform: translateY(-50%);
  189. width: 10rpx;
  190. height: 10rpx;
  191. background: #ff457b;
  192. }
  193. }
  194. .dd {
  195. font-size: 26rpx;
  196. line-height: 40rpx;
  197. color: #666666;
  198. margin-top: $grid;
  199. }
  200. }
  201. }
  202. }
  203. </style>