coupon.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <view class="pageCon">
  3. <view class="list dfsb" v-for="(item, ind) in list" :key="ind">
  4. <view class="left">
  5. <view class="num">
  6. {{ item.reduce }}
  7. <text class="red fontssm">元</text>
  8. </view>
  9. <text class="textgrey fontssm">{{ item.satisfy }}元以上使用</text>
  10. </view>
  11. <view class="center flex1 dffd">
  12. <text class="bold fontbase">{{ item.names }}</text>
  13. <view class="red fontsm">{{ item.content }}</view>
  14. <text class="textgrey fontsm">有效期至{{ item.end_time }}</text>
  15. </view>
  16. <view @click="getHand(item)" class="right red fontssm">立即领取</view>
  17. </view>
  18. <u-empty v-if="list.length<1" text="还没有优惠券" mode="coupon"></u-empty>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. list: [
  26. // {
  27. // money: 5,
  28. // name: '资源通用下载券',
  29. // content: '用于下载5元以内资源1次',
  30. // time: '有效期至2021.11.03'
  31. // },
  32. ],
  33. status: 'loading',
  34. page: 1,
  35. pagenum: 10
  36. };
  37. },
  38. onPullDownRefresh() {
  39. this.page = 1;
  40. this.list = [];
  41. this.onload();
  42. setTimeout(res => {
  43. uni.stopPullDownRefresh();
  44. }, 1000);
  45. },
  46. onReachBottom() {
  47. if (this.status == 'nomore') return;
  48. this.status = 'loading';
  49. this.page = ++this.page;
  50. this.onload();
  51. },
  52. onLoad(opt) {
  53. this.onload();
  54. },
  55. methods: {
  56. getHand(item) {
  57. this.$api
  58. .request('coupon/userReceive', {
  59. coupon_id: item.id
  60. })
  61. .then(data => {
  62. this.$api.toast(data.msg);
  63. if (data.code == '200') {
  64. setTimeout(res => {
  65. this.page = 1;
  66. this.list = [];
  67. this.onload();
  68. }, 600);
  69. }
  70. });
  71. },
  72. onload() {
  73. this.$api
  74. .request('coupon/getCouponList', {
  75. flag: 0,
  76. page: this.page,
  77. limit: this.pagenum
  78. })
  79. .then(data => {
  80. if (data.code == '200') {
  81. this.list = this.list.concat(data.data);
  82. if (data.data.length < this.pagnum) {
  83. this.status = 'nomore';
  84. }
  85. } else {
  86. this.$api.toast(data.msg);
  87. }
  88. });
  89. }
  90. }
  91. };
  92. </script>
  93. <style lang="scss" scoped>
  94. .pageCon {
  95. padding: 20rpx 30rpx;
  96. .list {
  97. background: #ffffff;
  98. border-radius: 24rpx;
  99. padding: 32rpx 30rpx;
  100. margin-bottom: 20rpx;
  101. .left {
  102. padding-right: 29rpx;
  103. border-right: 1rpx solid #dedede;
  104. .num {
  105. font-size: 80rpx;
  106. font-family: PingFangSC-Semibold, PingFang SC;
  107. font-weight: 600;
  108. color: #f03a2f;
  109. line-height: 112rpx;
  110. }
  111. }
  112. .center {
  113. justify-content: space-between;
  114. margin: 0 30rpx;
  115. align-items: flex-start;
  116. .red {
  117. margin: 20rpx 0;
  118. }
  119. }
  120. .right {
  121. padding: 10rpx 20rpx;
  122. border-radius: 28rpx;
  123. border: 1px solid #e93837;
  124. }
  125. }
  126. .tips {
  127. margin-top: 70rpx;
  128. font-size: 26rpx;
  129. justify-content: center;
  130. .prosecond {
  131. font-size: 26rpx;
  132. }
  133. }
  134. }
  135. </style>