my_coupon.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="coupon">
  3. <x-header></x-header>
  4. <div class="coupon-list">
  5. <template v-if="enableList.length > 0">
  6. <div class="coupon-item" v-for="coupon in enableList">
  7. <p class="coupon-item__amount">
  8. <span>&yen;</span>{{ coupon.price }}
  9. </p>
  10. <div class="coupon-item__info">
  11. <div class="info-amount">
  12. <p class="title">大于{{ coupon.use_condition }}元可用</p>
  13. <p class="desc">
  14. {{ coupon.expire_time && coupon.expire_time.slice(0, 16) }}到期
  15. </p>
  16. </div>
  17. <v-touch class="info-button" @tap="goPay">
  18. 立即使用
  19. </v-touch>
  20. </div>
  21. </div>
  22. </template>
  23. <template v-else>
  24. <div class="no-coupon">
  25. <img src="../assets/no_coupon.png" />
  26. </div>
  27. </template>
  28. </div>
  29. <div class="show-disabled">
  30. <p @click="showDisabled">查看已失效的券</p>
  31. </div>
  32. <mt-popup v-model="popupVisible" position="right" closeOnClickModal="false">
  33. <div class="pop-page">
  34. <div class="x-header">
  35. <header>
  36. <a href="javascript:;" @click="popupVisible = false">
  37. <img src="../assets/书库-返回.png" />
  38. </a>
  39. <span>失效优惠券</span>
  40. <div style="height: 0.35rem; width: 0.35rem;"></div>
  41. </header>
  42. </div>
  43. <div class="coupon-list">
  44. <template v-if="disableList.length > 0">
  45. <div
  46. class="coupon-item disabled"
  47. :class="`disable-${coupon.use_status}`"
  48. v-for="coupon in disableList"
  49. >
  50. <p class="coupon-item__amount">
  51. <span>&yen;</span>{{ coupon.price }}
  52. </p>
  53. <div class="coupon-item__info">
  54. <div class="info-amount">
  55. <p class="title">大于{{ coupon.use_condition }}元可用</p>
  56. <p class="desc">
  57. {{
  58. coupon.expire_time && coupon.expire_time.slice(0, 16)
  59. }}到期
  60. </p>
  61. </div>
  62. </div>
  63. </div>
  64. </template>
  65. <template v-else>
  66. <div class="no-coupon">
  67. <img src="../assets/no_coupon.png" />
  68. </div>
  69. </template>
  70. </div>
  71. </div>
  72. </mt-popup>
  73. </div>
  74. </template>
  75. <script>
  76. import { Coupon, Pay } from "./namespace.js";
  77. import { getUserCoupon } from "../api";
  78. export default {
  79. name: Coupon.name,
  80. data() {
  81. return {
  82. enableList: [],
  83. disableList: [],
  84. popupVisible: false
  85. };
  86. },
  87. created() {
  88. getUserCoupon().then(r => {
  89. this.enableList = r.enabled;
  90. this.disableList = r.expired;
  91. });
  92. },
  93. methods: {
  94. goPay() {
  95. this.$router.push({ name: Pay.name });
  96. },
  97. showDisabled() {
  98. this.popupVisible = true;
  99. }
  100. },
  101. mounted() {}
  102. };
  103. </script>
  104. <style scoped lang="scss"></style>