coupon-find-list.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 CmDrawer from '@/components/cm-module/cm-drawer/cm-drawer.vue'
  58. import CmCoupon from '@/components/cm-module/cm-coupon/cm-coupon.vue'
  59. import CmEmpty from '@/components/cm-module/cm-empty/cm-empty.vue'
  60. import { mapGetters } from 'vuex'
  61. export default {
  62. components: {
  63. MessagePopup,
  64. CmCoupon,
  65. CmEmpty,
  66. CmDrawer
  67. },
  68. data() {
  69. return {
  70. baseUrl: this.$Static,
  71. popupVisible: false,
  72. listQuery: {
  73. pageNum: 1,
  74. pageSize: 6,
  75. userId: ''
  76. },
  77. couponList: [],
  78. hasNextPage: false,
  79. total: 0,
  80. isScrollTop: false,
  81. isRequest: true,
  82. loadmore: false, // 正在加载更多
  83. timer: null
  84. }
  85. },
  86. computed: {
  87. ...mapGetters(['userId']),
  88. loadingText() {
  89. return this.hasNextPage ? '上拉加载更多' : '没有更多了'
  90. }
  91. },
  92. onLoad() {
  93. this.listQuery.userId = this.userId
  94. this.getCouponList()
  95. },
  96. methods: {
  97. // 关闭信息弹窗
  98. closePopup() {
  99. this.popupVisible = false
  100. },
  101. // 获取待优惠券列表
  102. getCouponList() {
  103. this.loadmore = true
  104. this.CouponService.GetCouponCenterInfo(this.listQuery).then(res => {
  105. this.couponList = res.data.list
  106. this.hasNextPage = res.data.hasNextPage
  107. this.total = res.data.total
  108. this.isRequest = false
  109. this.listQuery.pageNum++
  110. this.loadmore = false
  111. })
  112. },
  113. // 操作优惠券
  114. couponClick() {
  115. this.listQuery.pageNum = 1
  116. this.getCouponList()
  117. }
  118. },
  119. onPageScroll(e) {
  120. this.isScrollTop = e.scrollTop > 400
  121. },
  122. onReachBottom() {
  123. if (!this.hasNextPage) return
  124. clearTimeout(this.timer)
  125. this.timer = setTimeout(() => {
  126. console.log('触底了')
  127. this.getCouponList()
  128. }, 200)
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. $tip-height: 80rpx;
  134. $grid: 24rpx;
  135. .coupon-find-list {
  136. min-height: 100vh;
  137. box-sizing: border-box;
  138. padding-top: $tip-height;
  139. background: #f7f7f7;
  140. overflow: hidden;
  141. }
  142. .top-tip {
  143. position: fixed;
  144. top: 0;
  145. left: 0;
  146. z-index: 99;
  147. display: flex;
  148. justify-content: space-between;
  149. align-items: center;
  150. width: 750rpx;
  151. height: $tip-height;
  152. padding: 0 $grid;
  153. background: #fff3f7;
  154. box-sizing: border-box;
  155. .tip-text {
  156. font-size: 26rpx;
  157. color: #ff457b;
  158. }
  159. .tip-btn {
  160. width: 128rpx;
  161. height: 48rpx;
  162. border: 1rpx solid #ff457b;
  163. border-radius: 24rpx;
  164. text-align: center;
  165. line-height: 48rpx;
  166. font-size: 26rpx;
  167. color: #ff457b;
  168. }
  169. }
  170. .message-popup {
  171. .title {
  172. font-size: 30rpx;
  173. font-weight: 600;
  174. color: #333333;
  175. }
  176. .content {
  177. .row {
  178. padding-left: 32rpx;
  179. margin: $grid 0;
  180. .dt {
  181. position: relative;
  182. font-size: 26rpx;
  183. font-weight: 600;
  184. line-height: 40rpx;
  185. color: #333333;
  186. &::before {
  187. content: '';
  188. display: block;
  189. position: absolute;
  190. left: -$grid;
  191. top: 50%;
  192. transform: translateY(-50%);
  193. width: 10rpx;
  194. height: 10rpx;
  195. background: #ff457b;
  196. }
  197. }
  198. .dd {
  199. font-size: 26rpx;
  200. line-height: 40rpx;
  201. color: #666666;
  202. margin-top: $grid;
  203. }
  204. }
  205. }
  206. }
  207. </style>