CouponListWindow.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <div>
  3. <div class="coupon-list-window" :class="value === true ? 'on' : ''">
  4. <div class="title">
  5. 优惠券
  6. <span class="iconfont icon-guanbi" @click="close"></span>
  7. </div>
  8. <div v-if="couponList.length > 0">
  9. <div class="coupon-list">
  10. <div
  11. class="item acea-row row-center-wrapper"
  12. v-for="coupon in couponList"
  13. :key="coupon.id"
  14. @click="click(coupon)"
  15. >
  16. <div class="money">
  17. <div>
  18. ¥<span class="num">{{ coupon.coupon_price }}</span>
  19. </div>
  20. <div class="pic-num">满{{ coupon.use_min_price }}元可用</div>
  21. </div>
  22. <div class="text">
  23. <div class="condition line1">
  24. <span class="line-title" v-if="coupon.type === 0">通用劵</span>
  25. <span class="line-title" v-else-if="coupon.type === 1"
  26. >品类券</span
  27. >
  28. <span class="line-title" v-else>商品券</span>
  29. <span>{{ coupon.title }}</span>
  30. </div>
  31. <div class="data acea-row row-between-wrapper">
  32. <div>
  33. {{ coupon.start_time ? coupon.start_time + "-" : ""
  34. }}{{ coupon.end_time }}
  35. </div>
  36. <div
  37. class="iconfont icon-xuanzhong1 font-color-red"
  38. v-if="checked === coupon.id"
  39. ></div>
  40. <div class="iconfont icon-weixuanzhong" v-else></div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="couponNo bg-color-red" @click="couponNo">不使用优惠券</div>
  46. </div>
  47. <div v-if="!couponList.length && loaded">
  48. <div class="pictrue">
  49. <img src="@assets/images/noCoupon.png" class="image" />
  50. </div>
  51. </div>
  52. </div>
  53. <div
  54. class="mask"
  55. @touchmove.prevent
  56. :hidden="value === false"
  57. @click="close"
  58. ></div>
  59. </div>
  60. </template>
  61. <style scoped>
  62. .coupon-list-window .iconfont {
  63. font-size: 0.4rem;
  64. }
  65. .couponNo {
  66. font-size: 0.3rem;
  67. font-weight: bold;
  68. color: #fff;
  69. width: 6.9rem;
  70. height: 0.86rem;
  71. border-radius: 0.43rem;
  72. text-align: center;
  73. line-height: 0.86rem;
  74. margin: 0.6rem auto;
  75. }
  76. .condition .line-title {
  77. width: 0.9rem;
  78. padding: 0 0.1rem;
  79. box-sizing: border-box;
  80. background: rgba(255, 247, 247, 1);
  81. border: 1px solid rgba(232, 51, 35, 1);
  82. opacity: 1;
  83. border-radius: 0.22rem;
  84. font-size: 0.2rem;
  85. color: #e83323;
  86. margin-right: 0.12rem;
  87. }
  88. .coupon-list .pic-num {
  89. color: #ffffff;
  90. font-size: 0.24rem;
  91. }
  92. </style>
  93. <script>
  94. import { getOrderCoupon } from "@api/order";
  95. export default {
  96. name: "CouponListWindow",
  97. props: {
  98. value: Boolean,
  99. checked: Number,
  100. price: {
  101. type: [Number, String],
  102. default: undefined
  103. },
  104. cartid: {
  105. type: String,
  106. default: ""
  107. }
  108. },
  109. data: function() {
  110. return {
  111. couponList: [],
  112. loaded: false,
  113. cartids: this.cartid
  114. };
  115. },
  116. watch: {
  117. cartid(n) {
  118. if (n === undefined || n == null) return;
  119. this.cartids = n;
  120. this.getCoupon();
  121. },
  122. price(n) {
  123. if (n === undefined || n == null) return;
  124. this.getCoupon();
  125. }
  126. },
  127. mounted: function() {},
  128. methods: {
  129. close: function() {
  130. this.$emit("input", false);
  131. this.$emit("close");
  132. },
  133. getCoupon() {
  134. let data = {
  135. cartId: this.cartids
  136. };
  137. getOrderCoupon(this.price, data)
  138. .then(res => {
  139. this.couponList = res.data;
  140. this.loaded = true;
  141. })
  142. .catch(err => {
  143. this.$dialog.error(err.msg);
  144. });
  145. },
  146. click(coupon) {
  147. this.$emit("checked", coupon);
  148. this.$emit("input", false);
  149. },
  150. couponNo: function() {
  151. this.$emit("checked", null);
  152. this.$emit("input", false);
  153. }
  154. }
  155. };
  156. </script>