index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view>
  3. <view class='coupon-list-window' :class='coupon.coupon==true?"on":""'>
  4. <view class='title'>优惠券<text class='iconfont icon-guanbi' @click='close'></text></view>
  5. <view class='coupon-list' v-if="coupon.list.length">
  6. <view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list" @click="getCouponUser(index,item.id)" :key='index'>
  7. <view class='money acea-row row-column row-center-wrapper' :class='item.is_use?"moneyGray":""'>
  8. <view>¥<text class='num'>{{item.coupon_price}}</text></view>
  9. <view class="pic-num">满{{item.use_min_price}}元可用</view>
  10. </view>
  11. <view class='text'>
  12. <view class='condition line1'>
  13. <span class='line-title' :class='item.is_use?"gray":""' v-if='item.type===0'>通用劵</span>
  14. <span class='line-title' :class='item.is_use?"gray":""' v-else-if='item.type===1'>品类券</span>
  15. <span class='line-title' :class='item.is_use?"gray":""' v-else>商品券</span>
  16. <span>{{item.title}}</span>
  17. </view>
  18. <view class='data acea-row row-between-wrapper'>
  19. <view>{{ item.start_time ? item.start_time + "-" : ""}}{{ item.end_time }}</view>
  20. <view class='bnt gray' v-if="item.is_use">{{item.use_title || '已领取'}}</view>
  21. <view class='bnt bg-color' v-else>{{coupon.statusTile || '立即领取'}}</view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 无优惠券 -->
  27. <view class='pictrue' v-else><image src='../../static/images/noCoupon.png'></image></view>
  28. </view>
  29. <view class='mask' catchtouchmove="true" :hidden='coupon.coupon==false' @click='close'></view>
  30. </view>
  31. </template>
  32. <script>
  33. import { setCouponReceive } from '@/api/api.js';
  34. export default {
  35. props: {
  36. //打开状态 0=领取优惠券,1=使用优惠券
  37. openType: {
  38. type: Number,
  39. default: 0,
  40. },
  41. coupon: {
  42. type: Object,
  43. default: function(){
  44. return {};
  45. }
  46. }
  47. },
  48. data() {
  49. return {
  50. };
  51. },
  52. methods: {
  53. close: function () {
  54. this.$emit('ChangCouponsClone');
  55. },
  56. getCouponUser:function(index,id){
  57. let that = this;
  58. let list = that.coupon.list;
  59. if (list[index].is_use == true && this.openType==0) return true;
  60. switch (this.openType){
  61. case 0:
  62. //领取优惠券
  63. setCouponReceive(id).then(res=>{
  64. that.$emit('ChangCouponsUseState', index);
  65. that.$util.Tips({title: "领取成功"});
  66. that.$emit('ChangCoupons', list[index]);
  67. })
  68. break;
  69. case 1:
  70. that.$emit('ChangCoupons',index);
  71. break;
  72. }
  73. }
  74. }
  75. }
  76. </script>
  77. <style scoped lang="scss">
  78. .coupon-list-window{position:fixed;bottom:0;left:0;width:100%;background-color:#f5f5f5;border-radius:16rpx 16rpx 0 0;z-index:555;transform:translate3d(0,100%,0);transition:all .3s cubic-bezier(.25,.5,.5,.9);}
  79. .coupon-list-window.on{transform:translate3d(0,0,0);}
  80. .coupon-list-window .title{height:124rpx;width:100%;text-align:center;line-height:124rpx;font-size:32rpx;font-weight:bold;position:relative;}
  81. .coupon-list-window .title .iconfont{position:absolute;right:30rpx;top:50%;transform:translateY(-50%);font-size:35rpx;color:#8a8a8a;font-weight:normal;}
  82. .coupon-list-window .coupon-list{margin:0 0 50rpx 0;height:550rpx;overflow:auto;}
  83. .coupon-list-window .pictrue{width:414rpx;height:336rpx;margin:0 auto 50rpx auto;}
  84. .coupon-list-window .pictrue image{width:100%;height:100%;}
  85. .pic-num{color: #fff;font-size: 24rpx;}
  86. .line-title{
  87. width:90rpx;
  88. padding: 0 10rpx;
  89. box-sizing: border-box;
  90. background:rgba(255,247,247,1);
  91. border:1px solid rgba(232,51,35,1);
  92. opacity:1;
  93. border-radius:20rpx;
  94. font-size:20rpx;
  95. color: #E83323;
  96. margin-right: 12rpx;
  97. }
  98. .line-title.gray{
  99. border-color:#BBB;
  100. color:#bbb;
  101. background-color:#F5F5F5;
  102. }
  103. </style>