小程序端工程代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
3.1 KiB

  1. <template>
  2. <view>
  3. <view class="coupon-list-window" :class="value === true ? 'on' : ''">
  4. <view class="title">
  5. 优惠券
  6. <text class="iconfont icon-guanbi" @click="close"></text>
  7. </view>
  8. <view v-if="couponList.length > 0">
  9. <view 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.couponPrice }}</span>
  19. </div>
  20. <div class="pic-num">{{ coupon.useMinPrice }}元可用</div>
  21. </div>
  22. <div class="text">
  23. <div class="condition line1">{{ coupon.couponTitle }}</div>
  24. <div class="data acea-row row-between-wrapper">
  25. <div v-if="coupon.endTime === 0">不限时</div>
  26. <div v-else>截止:{{ coupon.endTime }}</div>
  27. <div
  28. class="iconfont icon-xuanzhong1 font-color-red"
  29. v-if="checked === coupon.id"
  30. ></div>
  31. <div class="iconfont icon-weixuanzhong" v-else></div>
  32. </div>
  33. </div>
  34. </div>
  35. </view>
  36. <view class="couponNo bg-color-red" @click="couponNo">不使用优惠券</view>
  37. </view>
  38. <view v-if="!couponList.length && loaded">
  39. <view class="pictrue">
  40. <image :src="`${$VUE_APP_RESOURCES_URL}/images/noCoupon.png`" class="image" />
  41. </view>
  42. </view>
  43. </view>
  44. <view class="mask" @touchmove.prevent :hidden="value === false" @click="close"></view>
  45. </view>
  46. </template>
  47. <style scoped lang="less">
  48. .coupon-list-window .iconfont {
  49. font-size: 40rpx;
  50. }
  51. .couponNo {
  52. font-size: 30rpx;
  53. font-weight: bold;
  54. color: #fff;
  55. width: 690rpx;
  56. height: 86rpx;
  57. border-radius: 43rpx;
  58. text-align: center;
  59. line-height: 86rpx;
  60. margin: 60rpx auto;
  61. }
  62. </style>
  63. <script>
  64. import { getOrderCoupon } from "@/api/order";
  65. import DataFormatT from "@/components/DataFormatT";
  66. export default {
  67. name: "CouponListWindow",
  68. components: {
  69. DataFormatT
  70. },
  71. props: {
  72. value: Boolean,
  73. checked: Number,
  74. price: {
  75. type: [Number, String],
  76. default: undefined
  77. },
  78. cartid: {
  79. type: String,
  80. default: ""
  81. }
  82. },
  83. data: function() {
  84. return {
  85. couponList: [],
  86. loaded: false
  87. };
  88. },
  89. watch: {
  90. price(n) {
  91. if (n === undefined || n == null) return;
  92. this.getCoupon();
  93. },
  94. cartid(n) {
  95. if (n === undefined || n == null) return;
  96. this.getCoupon();
  97. }
  98. },
  99. mounted: function() {},
  100. methods: {
  101. close: function() {
  102. this.$emit("input", false);
  103. this.$emit("close");
  104. },
  105. getCoupon() {
  106. getOrderCoupon(this.cartid).then(res => {
  107. this.couponList = res.data;
  108. this.loaded = true;
  109. });
  110. },
  111. click(coupon) {
  112. this.$emit("checked", coupon);
  113. this.$emit("input", false);
  114. },
  115. couponNo: function() {
  116. this.$emit("checked", null);
  117. this.$emit("input", false);
  118. }
  119. }
  120. };
  121. </script>