coupon-list.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view>
  3. <view class="coupon-action" :class="{'coupon-show': value==true}" style="background-color: #f8f8f8">
  4. <view class="coupon-title">选择优惠劵</view>
  5. <view class="coupon-body" :style="{'max-height':maxHeight+'px'}">
  6. <view v-if="coupons.length <= 0" class="coupon-empty">
  7. 暂无优惠劵
  8. </view>
  9. <view class="coupon-list" v-if="coupons.length">
  10. <view class="coupon-box"
  11. v-for="(item,index) in coupons" :key="index"
  12. @click="onCoupon(item)"
  13. >
  14. <view class="coupon-l-box">
  15. <view class="coupon-amount">
  16. {{ item.price }}
  17. <text>元</text>
  18. </view>
  19. <view class="coupon-condition">{{ item.condition }}</view>
  20. </view>
  21. <view class="coupon-r-box">
  22. <view class="coupon-name">{{ item.name }}</view>
  23. <view class="coupon-valid">{{ item.startAt }} - {{ item.endAt }}</view>
  24. </view>
  25. <view class="coupon-corner-checkbox">
  26. <text class="iconfont" :class="{ active: active == item.id }">&#xe641;</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view style="width: 100%;height: 60px; float: left"></view>
  31. </view>
  32. <text class="iconfont close" @click.stop="onClose">&#xe600;</text>
  33. <view class="coupon-button" @click="onCancelBonus"><text>不使用优惠劵</text></view>
  34. </view>
  35. <popup v-model="value"></popup>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. props: {
  41. value: {
  42. type: Boolean,
  43. default: false
  44. },
  45. coupons: {
  46. type: Array,
  47. default: function() {
  48. return []
  49. }
  50. }
  51. },
  52. data(){
  53. return {
  54. maxHeight:0,
  55. active: 0
  56. };
  57. },
  58. mounted() {
  59. let info = this.$utils.getSystemInfo();
  60. this.maxHeight = info.h - this.$utils.px2rpx(200);
  61. },
  62. methods: {
  63. onClose(){
  64. this.$emit("input",!this.value)
  65. },
  66. onCoupon(value){
  67. this.active = value.id;
  68. this.$emit("coupon-event",{
  69. id: value.id,
  70. value: "-¥" + value.valueDesc + value.unitDesc
  71. });
  72. },
  73. onCancelBonus(){
  74. this.active = 0;
  75. this.$emit("coupon-event",{
  76. id: 0,
  77. value: this.coupons.length <= 0 ? "暂无优惠劵" : this.coupons.length + "张可用"
  78. });
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .coupon-action{
  85. position: fixed;
  86. left: 0;
  87. bottom: 0;
  88. background-color: #fff;
  89. width: 100%;
  90. border-radius: 20rpx 20rpx 0 0;
  91. display: flex;
  92. flex-direction: column;
  93. align-items: stretch;
  94. min-height: 50%;
  95. max-height: 80%;
  96. font-size: 28rpx;
  97. z-index: 9999;
  98. overflow: hidden;
  99. transition:all .3s cubic-bezier(.65,.7,.7,.9);
  100. transform:translate3d(0,100%,0);
  101. .coupon-title { font-size: 32rpx; text-align: center; width: 100%; height: 100rpx; background-color: #fff; line-height: 100rpx; }
  102. .coupon-button {
  103. width: 100%; height: 120rpx; line-height: 120rpx; position: absolute; left: 0; bottom: 0; background-color: #fff;
  104. text {
  105. text-align: center; background-color: #c30d24;
  106. width: 90%; height: 100rpx; line-height: 100rpx;
  107. margin: 5px auto; display: block;
  108. font-size: 30rpx; color: #fff; border-radius: 40rpx;
  109. }
  110. }
  111. .coupon-body {
  112. flex: 1 1 auto;
  113. min-height: 88rpx;
  114. overflow-y: scroll;
  115. -webkit-overflow-scrolling: touch;
  116. .coupon-empty { width: 100%; text-align: center; font-size: 36rpx; height: 100rpx; line-height: 100rpx; position: absolute; top: 50%; transform: translateY(-50%) }
  117. .coupon-list {
  118. width: 95%;
  119. margin-left: 2.5%;
  120. float: left;
  121. margin-top: 10px;
  122. .coupon-box {
  123. float: left;
  124. margin-bottom: 20rpx;
  125. width: 100%;
  126. height: 170rpx;
  127. background-color: #fff;
  128. border-radius: 20rpx;
  129. position: relative;
  130. .coupon-l-box {
  131. position: absolute;
  132. left: 0;
  133. top: 0;
  134. height: 170rpx;
  135. width: 220rpx;
  136. padding: 0 10rpx;
  137. .coupon-amount {
  138. width: 100%;
  139. text-align: center;
  140. padding-top: 30rpx;
  141. font-size: 50rpx;
  142. color: #c21313;
  143. text { font-size: 28rpx; }
  144. }
  145. .coupon-condition { text-align: center; color: #c21313; width: 100%; padding-top: 10rpx; }
  146. }
  147. .coupon-r-box {
  148. float: left;
  149. margin-left: 260rpx;
  150. height: 170rpx;
  151. position: relative;
  152. .coupon-name {
  153. font-size: 30rpx;
  154. padding-top: 36rpx;
  155. }
  156. .coupon-valid{
  157. padding-top: 24rpx;
  158. font-size: 28rpx;
  159. }
  160. }
  161. .coupon-corner-checkbox{
  162. position: absolute;
  163. color: #999;
  164. right: 30rpx;
  165. height: 40rpx;
  166. top: 50%;
  167. transform: translateY(-50%);
  168. text { font-size: 40rpx; }
  169. .active { color: #c21313; }
  170. }
  171. }
  172. }
  173. }
  174. .close { position: absolute; top: 30rpx; right: 30rpx; z-index: 1; color: #c8c9cc; font-size: 44rpx; cursor: pointer; }
  175. }
  176. .coupon-show{
  177. transform:translate3d(0,0,0);
  178. }
  179. </style>