discounts.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="pagecon">
  3. <NoData v-if="finish&&discountsList.length<1"></NoData>
  4. <view class="list">
  5. <discountsItem :select="selectIndex == index" :data="item" v-for="(item, index) in discountsList" :key="index" @click="changeDiscount(item, index)"></discountsItem>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import { formatDate } from '@/utils/tools.js'
  11. import discountsItem from '../components/discounts-item.vue'
  12. const app = getApp();
  13. export default {
  14. components: {
  15. discountsItem
  16. },
  17. data() {
  18. return {
  19. topHeight:app.globalData.statusBarHeight + app.globalData.navBarHeight,
  20. selectIndex: -1,
  21. page:1,
  22. loading:false,
  23. finish:false,
  24. discountsList: [
  25. // {
  26. // "id": 1,
  27. // "user_id": 1,
  28. // "title": "新用户注册",
  29. // "amount": "5.00",
  30. // "limit_day": 5,
  31. // "limit_time": 1706600909,
  32. // "status": "2",
  33. // "createtime": 1706168909,
  34. // "updatetime": 1706168909
  35. // },
  36. ]
  37. };
  38. },
  39. onLoad() {
  40. this.getUserCouponList();
  41. },
  42. onReachBottom(){
  43. console.log('滚动到底部')
  44. this.nextPage();
  45. },
  46. methods: {
  47. formatDateF(v){
  48. return formatDate(v);
  49. },
  50. changeDiscount(item, index) {
  51. this.selectIndex = index;
  52. },
  53. getUserCouponList(){
  54. if(this.loading)return false;
  55. this.$u.api.getUserCouponListAjax(this.page).then(({code,data})=>{
  56. console.log(code,data)
  57. this.loading = false;
  58. if(code==1){
  59. if(data.last_page<=data.current_page){
  60. this.finish = true;
  61. }
  62. if(data.current_page==1){
  63. this.discountsList = data.data;
  64. }else{
  65. this.discountsList=this.discountsList.concat(data.data);
  66. }
  67. }else{
  68. this.finish = true;
  69. }
  70. }).catch(()=>{
  71. this.loading = false;
  72. this.finish = true;
  73. })
  74. },
  75. nextPage(e){
  76. if(this.finish){
  77. /* 已滚动到底部,不继续加载 */
  78. return false;
  79. }
  80. console.log(e);
  81. this.page++;
  82. this.getUserCouponList();
  83. },
  84. },
  85. };
  86. </script>
  87. <style lang="scss" scoped>
  88. .pagecon{
  89. padding: 30rpx;
  90. min-height: 100vh;
  91. box-sizing: border-box;
  92. background-color: $app-theme-bg-gray-color;
  93. }
  94. .list {
  95. // margin: 30rpx;
  96. .item {
  97. width: 100%;
  98. height: 174rpx;
  99. background-image: url('@/pages-mine/static/discounts-bg.png');
  100. background-size: cover;
  101. margin-bottom: 30rpx;
  102. display: flex;
  103. justify-content: flex-start;
  104. align-items: flex-end;
  105. padding-bottom: 34rpx;
  106. position: relative;
  107. .left {
  108. margin-right: 60rpx;
  109. margin-left: 50rpx;
  110. .discount {
  111. text:nth-child(1) {
  112. font-size: 22rpx;
  113. color: $app-theme-text-money-color;
  114. }
  115. text:nth-child(2) {
  116. font-size: 64rpx;
  117. color: $app-theme-text-money-color;
  118. }
  119. }
  120. .standard {
  121. font-size: 20rpx;
  122. color: $app-theme-card-gray-color;
  123. }
  124. }
  125. .right {
  126. .title {
  127. font-size: 32rpx;
  128. color: $app-theme-text-black-color;
  129. margin-bottom: 32rpx;
  130. }
  131. .date {
  132. font-size: 20rpx;
  133. color: $app-theme-card-gray-color;
  134. }
  135. }
  136. .select {
  137. height: 60rpx;
  138. width: 60rpx;
  139. background-image: url('@/pages-mine/static/discounts-select.png');
  140. background-size: cover;
  141. position: absolute;
  142. top: 4rpx;
  143. right: 4rpx;
  144. z-index: $app-zIndex-absolute;
  145. }
  146. }
  147. }
  148. </style>