CouponWindow.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div v-if="couponList.length > 0">
  3. <div class="coupon-window" :class="value ? 'on' : ''">
  4. <div class="couponWinList">
  5. <div
  6. class="item acea-row row-between-wrapper"
  7. v-for="(item, index) in couponList"
  8. :key="index"
  9. >
  10. <div class="money font-color-red">
  11. <div>
  12. ¥<span class="num">{{ item.coupon_price }}</span>
  13. </div>
  14. <div class="pic-num">满{{ item.use_min_price }}元可用</div>
  15. </div>
  16. <div class="text acea-row row-between">
  17. <div class="pic acea-row row-column row-center">
  18. <div class="name line1">{{ item.title }}</div>
  19. <div v-if="item.end_time">
  20. {{ item.start_time ? item.start_time + "-" : ""
  21. }}{{ item.end_time }}
  22. </div>
  23. </div>
  24. <div class="type" v-if="item.type === 0">通用劵</div>
  25. <div class="type" v-else-if="item.type === 1">品类券</div>
  26. <div class="type" v-else>商品券</div>
  27. </div>
  28. </div>
  29. <div style="height:1.2rem"></div>
  30. </div>
  31. <div class="lid">
  32. <div class="bnt font-color-red" @click="checked">立即领取</div>
  33. <div class="iconfont icon-guanbi3" @click="close"></div>
  34. </div>
  35. </div>
  36. <div class="mask" @touchmove.prevent :hidden="!value"></div>
  37. </div>
  38. </template>
  39. <script>
  40. import { mapGetters } from "vuex";
  41. import toLogin from "@libs/login";
  42. import { couponReceiveBatch } from "@api/user";
  43. export default {
  44. name: "CouponWindow",
  45. props: {
  46. couponList: {
  47. type: Array,
  48. default: () => []
  49. }
  50. },
  51. computed: mapGetters(["isLogin"]),
  52. data: function() {
  53. return {
  54. value: true
  55. };
  56. },
  57. mounted: function() {},
  58. methods: {
  59. checked() {
  60. const isLogin = this.isLogin;
  61. if (!isLogin) return toLogin();
  62. const ids = this.couponList.reduce((initial, coupon) => {
  63. initial.push(coupon.id);
  64. return initial;
  65. }, []);
  66. couponReceiveBatch(ids)
  67. .then(() => {
  68. this.$emit("success");
  69. this.$dialog.toast({ mes: "领取成功" });
  70. })
  71. .catch(() => {
  72. this.$dialog.toast({ mes: "已领取" });
  73. });
  74. if (isLogin) {
  75. this.value = false;
  76. this.$emit("checked");
  77. }
  78. },
  79. close: function() {
  80. this.value = false;
  81. this.$emit("close");
  82. }
  83. }
  84. };
  85. </script>
  86. <style scoped>
  87. .pic-num {
  88. color: #bbbbbb;
  89. font-size: 0.12rem;
  90. }
  91. </style>