index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view>
  3. <view class='coupon-list' v-if="couponsList.length">
  4. <view class='item acea-row row-center-wrapper' v-for='(item,index) in couponsList' :key="index">
  5. <view class='money' :class='item._type == 0 ? "moneyGray" : ""'>
  6. <view>¥<text class='num'>{{item.coupon_price}}</text></view>
  7. <view class="pic-num">满{{ item.use_min_price }}元可用</view>
  8. </view>
  9. <view class='text'>
  10. <view class='condition line1'>
  11. <view class="line-title" :class="item._type === 0 ? 'bg-color-huic' : 'bg-color-check'" v-if="item.applicable_type === 0">通用劵</view>
  12. <view class="line-title" :class="item._type === 0 ? 'bg-color-huic' : 'bg-color-check'" v-else-if="item.applicable_type === 1">品类券</view>
  13. <view class="line-title" :class="item._type === 0 ? 'bg-color-huic' : 'bg-color-check'" v-else>商品券</view>
  14. <view>{{item.coupon_title}}</view>
  15. </view>
  16. <view class='data acea-row row-between-wrapper'>
  17. <view>{{item._add_time}}-{{item._end_time}}</view>
  18. <view class='bnt gray' v-if="item._type==0">{{item._msg}}</view>
  19. <view class='bnt bg-color' v-else>{{item._msg}}</view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class='noCommodity' v-if="!couponsList.length && loading==true">
  25. <view class='pictrue'>
  26. <image src='../../../static/images/noCoupon.png'></image>
  27. </view>
  28. </view>
  29. <!-- #ifdef MP -->
  30. <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
  31. <!-- #endif -->
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. getUserCoupons
  37. } from '@/api/api.js';
  38. import {
  39. toLogin
  40. } from '@/libs/login.js';
  41. import {
  42. mapGetters
  43. } from "vuex";
  44. // #ifdef MP
  45. import authorize from '@/components/Authorize';
  46. // #endif
  47. export default {
  48. components: {
  49. // #ifdef MP
  50. authorize
  51. // #endif
  52. },
  53. data() {
  54. return {
  55. couponsList: [],
  56. loading: false,
  57. isAuto: false, //没有授权的不会自动授权
  58. isShowAuth: false //是否隐藏授权
  59. };
  60. },
  61. computed: mapGetters(['isLogin']),
  62. onLoad() {
  63. if (this.isLogin) {
  64. this.getUseCoupons();
  65. } else {
  66. // #ifdef H5 || APP-PLUS
  67. toLogin();
  68. // #endif
  69. // #ifdef MP
  70. this.isAuto = true;
  71. this.$set(this, 'isShowAuth', true)
  72. // #endif
  73. }
  74. },
  75. methods: {
  76. /**
  77. * 授权回调
  78. */
  79. onLoadFun: function() {
  80. this.getUseCoupons();
  81. },
  82. // 授权关闭
  83. authColse: function(e) {
  84. this.isShowAuth = e
  85. },
  86. /**
  87. * 获取领取优惠券列表
  88. */
  89. getUseCoupons: function() {
  90. let that = this;
  91. getUserCoupons(0).then(res => {
  92. that.loading = true;
  93. that.$set(that, 'couponsList', res.data);
  94. })
  95. }
  96. }
  97. }
  98. </script>
  99. <style>
  100. .money {
  101. display: flex;
  102. flex-direction: column;
  103. justify-content: center;
  104. }
  105. .pic-num {
  106. color: #ffffff;
  107. font-size: 0.24rem;
  108. }
  109. .coupon-list .item .text .condition{
  110. display: flex;
  111. align-items: center;
  112. }
  113. .condition .line-title {
  114. width: 90rpx;
  115. height: 40rpx !important;
  116. line-height: 1.5 !important;
  117. padding: 0 10rpx;
  118. -webkit-box-sizing: border-box;
  119. box-sizing: border-box;
  120. background: rgba(255, 247, 247, 1);
  121. border: 1px solid rgba(232, 51, 35, 1);
  122. opacity: 1;
  123. border-radius: 22rpx;
  124. font-size: 20rpx !important;
  125. color: #e83323;
  126. margin-right: 12rpx;
  127. }
  128. </style>