myCoup.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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="useHandle(item)" class="right red fontssm">立即使用</view>
  17. </view>
  18. <u-empty v-if="list.length<1" text="还没有优惠券" mode="coupon"></u-empty>
  19. <navigator url="/pages/user/coupon/coupon" class="tips textgrey dffs">
  20. 去领取更多
  21. <view class="prosecond dffs">
  22. 优惠券
  23. <u-icon size="14" color="#ED742E" name="arrow-right"></u-icon>
  24. </view>
  25. </navigator>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. money:'', //文档 商品使用优惠券时带来的价格
  33. list: [
  34. // {
  35. // money: 5,
  36. // name: '资源通用下载券',
  37. // content: '用于下载5元以内资源1次',
  38. // time: '有效期至2021.11.03'
  39. // },
  40. ],
  41. status: 'loading',
  42. page: 1,
  43. pagenum: 10
  44. };
  45. },
  46. onPullDownRefresh() {
  47. this.page = 1;
  48. this.list = [];
  49. this.onload();
  50. setTimeout(res => {
  51. uni.stopPullDownRefresh();
  52. }, 1000);
  53. },
  54. onReachBottom() {
  55. if (this.status == 'nomore') return;
  56. this.status = 'loading';
  57. this.page = ++this.page;
  58. this.onload();
  59. },
  60. onLoad(opt) {
  61. this.money=opt.money||0;
  62. this.onload();
  63. },
  64. methods: {
  65. // 立即使用
  66. useHandle(item){
  67. if(this.money){
  68. if(Number(this.money)<Number(item.satisfy)) return this.$api.toast('满'+item.satisfy+'元使用')
  69. this.$api.prePage().coupon=item;
  70. uni.navigateBack({
  71. delta:1
  72. })
  73. }else{
  74. uni.redirectTo({
  75. url:'/pages/index/index'
  76. })
  77. }
  78. },
  79. onload() {
  80. this.$api
  81. .request('coupon/userCoupon', {
  82. page: this.page,
  83. limit: this.pagenum
  84. })
  85. .then(data => {
  86. if (data.code == '200') {
  87. this.list = this.list.concat(data.data);
  88. if (data.data.length < this.pagnum) {
  89. this.status = 'nomore';
  90. }
  91. } else {
  92. this.$api.toast(data.msg);
  93. }
  94. });
  95. }
  96. }
  97. };
  98. </script>
  99. <style lang="scss" scoped>
  100. .pageCon {
  101. padding: 20rpx 30rpx;
  102. .list {
  103. background: #ffffff;
  104. border-radius: 24rpx;
  105. padding: 32rpx 30rpx;
  106. margin-bottom: 20rpx;
  107. .left {
  108. padding-right: 29rpx;
  109. border-right: 1rpx solid #dedede;
  110. .num {
  111. font-size: 80rpx;
  112. font-family: PingFangSC-Semibold, PingFang SC;
  113. font-weight: 600;
  114. color: #f03a2f;
  115. line-height: 112rpx;
  116. }
  117. }
  118. .center {
  119. justify-content: space-between;
  120. margin: 0 30rpx;
  121. align-items: flex-start;
  122. .red {
  123. margin: 20rpx 0;
  124. }
  125. }
  126. .right {
  127. padding: 10rpx 20rpx;
  128. border-radius: 28rpx;
  129. border: 1px solid #e93837;
  130. }
  131. }
  132. .tips {
  133. margin-top: 70rpx;
  134. font-size: 26rpx;
  135. justify-content: center;
  136. .prosecond {
  137. font-size: 26rpx;
  138. }
  139. }
  140. }
  141. </style>