coupon.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <view>
  3. <view @click="showAct" >
  4. <text v-if="showType == 0" class="ft14 cl-notice">暂无券可用</text>
  5. <text v-if="showType == 1" class="ft14 cl-notice">有{{coupons.length}}张可选</text>
  6. <text v-if="showType == 2" class="ft14 cl-price">-¥{{getSelectItem.num}}</text>
  7. <text v-if="showType != 2" class="iconfont iconicon_arrow_small cl-notice ft14 ml10"></text>
  8. </view>
  9. <view v-show="showCoupon" class="coupon-modal">
  10. <view class="modal-bg"></view>
  11. <view class="modal-box animated fast" :class="show ? 'slideInUp' : 'slideOutDown'">
  12. <view class="modal-main">
  13. <view class="closed">
  14. <text @click="closed()" class="iconfont ft20 cl-notice iconbtn_close"></text>
  15. </view>
  16. <view class="lh20 ft16 cl-main ftw600 text-center">选择优惠券</view>
  17. <view class="pd16_15" style="min-height:600rpx;max-height: 1000rpx; overflow-y: scroll;">
  18. <view v-for="(item,index) in coupons" :key="index" class="coupon-box" :class="index > 0 ? 'mt16' : ''">
  19. <view class="pd16_15 bg-w flex alcenter space" style="border-bottom: 2rpx dashed #E4E6ED;">
  20. <view class="flex alcenter">
  21. <view class="cl-orange" style="width: 96rpx;">
  22. <text class="ft12">¥</text>
  23. <text class="ft24 ftw600 ml4">{{item.num}}</text>
  24. </view>
  25. <view class="ml15">
  26. <view class="ft14 ftw600 cl-main">普通洗剪吹优惠券</view>
  27. <view class="mt12 ft12 cl-info2">2020-09-22到期</view>
  28. </view>
  29. </view>
  30. <view class="btn-mini" @click="usedAct" :data-id="item.coupon_id" :style="value == item.coupon_id ? getBtnDisStyle : getBtnStyle">{{value == item.coupon_id ? '已选' : '使用'}}</view>
  31. </view>
  32. <view class="pd16_15 ft12 cl-notice">满50元可用,不可与其他优惠活动同时使用</view>
  33. <view class="coupon-yl"></view>
  34. <view class="coupon-yr"></view>
  35. <view class="coupon-vip-tag">会员专享</view>
  36. </view>
  37. </view>
  38. <view @click="noUseAct" class="pd16_15 mt30 bg-w text-center ft16 cl-main" style="box-shadow: 0rpx -4rpx 16rpx 0rpx rgba(0, 0, 0, 0.04);">不使用优惠</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. export default{
  46. props:{
  47. value:{
  48. type:Number,
  49. default:0
  50. },
  51. coupons:{
  52. type:Array,
  53. default:function(){
  54. return new Array;
  55. }
  56. }
  57. },
  58. data(){
  59. return {
  60. show:false,
  61. showCoupon:false,
  62. isSelect:false,
  63. selectId:0,
  64. }
  65. },
  66. computed:{
  67. showType(){
  68. if(this.coupons.length == 0) return 0;
  69. if(this.value == 0) return 1;
  70. if(this.getSelectItem == null) return 1;
  71. return 2;
  72. },
  73. getSelectItem(){
  74. for(var a in this.coupons){
  75. if(this.coupons[a].coupon_id == this.value) return this.coupons[a];
  76. }
  77. return null;
  78. }
  79. },
  80. created(){
  81. },
  82. methods:{
  83. noUseAct(){
  84. this.$emit('input',0);
  85. this.closed();
  86. },
  87. usedAct(e){
  88. let id = parseInt(e.currentTarget.dataset.id);
  89. if(id == this.value) return;
  90. this.$emit('input',id);
  91. this.closed();
  92. },
  93. showAct(){
  94. this.showCoupon = true;
  95. this.show = true;
  96. },
  97. closed(){
  98. this.show = false;
  99. setTimeout(()=>{
  100. this.showCoupon = false;
  101. },400);
  102. }
  103. }
  104. }
  105. </script>
  106. <style>
  107. .coupon-modal{
  108. position: relative;
  109. z-index: 400;
  110. }
  111. .coupon-modal .modal-bg{
  112. position: fixed;
  113. z-index: 400;
  114. left: 0;
  115. top: 0;
  116. width: 100%;
  117. height: 100vh;
  118. background: rgba(0,0,0,.5);
  119. }
  120. .coupon-modal .modal-box{
  121. position: fixed;
  122. z-index: 401;
  123. background:#F5F6FA;
  124. left: 0;
  125. bottom: 0;
  126. width: 100%;
  127. padding-bottom:0rpx;
  128. padding-bottom:constant(safe-area-inset-bottom);
  129. padding-bottom:env(safe-area-inset-bottom);
  130. border-radius:32rpx 32rpx 0rpx 0rpx;
  131. }
  132. .coupon-modal .modal-main{
  133. position: relative;
  134. height: auto;
  135. overflow: hidden;
  136. padding-top: 64rpx;
  137. }
  138. .coupon-modal .modal-main .closed{
  139. position: absolute;
  140. right: 40rpx;
  141. top: 40rpx;
  142. }
  143. .coupon-box{
  144. background: #FAFAFA;
  145. border-radius: 16rpx;
  146. overflow: hidden;
  147. position: relative;
  148. height: 252rpx;
  149. }
  150. .coupon-box .coupon-yl,.coupon-box .coupon-yr{
  151. width: 20rpx;
  152. height: 20rpx;
  153. border-radius: 10rpx;
  154. position: absolute;
  155. top: 148rpx;
  156. background: #F5F6FA;
  157. z-index: 2;
  158. }
  159. .coupon-box .coupon-yl{
  160. left: -10rpx;
  161. }
  162. .coupon-box .coupon-yr{
  163. right: -10rpx;
  164. }
  165. </style>