小程序端工程代码
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.

75 lines
2.4 KiB

  1. <template>
  2. <view>
  3. <view class="coupon-list-window" :class="coupon.coupon === true ? 'on' : ''">
  4. <view class="title">
  5. 优惠券
  6. <text class="iconfont icon-guanbi" @click="close"></text>
  7. </view>
  8. <view class="coupon-list" v-if="coupon.list.length > 0">
  9. <view
  10. class="item acea-row row-center-wrapper"
  11. v-for="(item, couponpopIndex) in coupon.list"
  12. :key="couponpopIndex"
  13. @click="getCouponUser(couponpopIndex, item.id)"
  14. >
  15. <view class="money">
  16. <text class="num">{{ item.couponPrice }}</text>
  17. </view>
  18. <view class="text">
  19. <view class="condition line1">购物满{{ item.useMinPrice }}元可用</view>
  20. <view class="data acea-row row-between-wrapper">
  21. <view v-if="item.end_time === 0">不限时</view>
  22. <view v-else>{{ item.startTime }}-{{ item.endTime }}</view>
  23. <view
  24. class="bnt acea-row row-center-wrapper"
  25. :class="!item.isUse ? 'bg-color-red' : 'gray'"
  26. >{{ !item.isUse ? "立即领取" : "已领取" }}</view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <!--无优惠券-->
  32. <view class="pictrue" v-else>
  33. <image :src="`${$VUE_APP_RESOURCES_URL}/images/noCoupon.png`" class="image" />
  34. </view>
  35. </view>
  36. <view class="mask" @touchmove.prevent :hidden="coupon.coupon === false" @click="close"></view>
  37. </view>
  38. </template>
  39. <script>
  40. import { getCouponReceive } from "@/api/user";
  41. export default {
  42. name: "CouponPop",
  43. props: {
  44. coupon: {
  45. type: Object,
  46. default: () => {}
  47. }
  48. },
  49. data: function() {
  50. return {};
  51. },
  52. mounted: function() {},
  53. methods: {
  54. close: function() {
  55. this.$emit("changeFun", { action: "changecoupon", value: false }); //$emit():注册事件;
  56. },
  57. getCouponUser: function(index, id) {
  58. let that = this,
  59. list = that.coupon.list;
  60. if (list[index].is_use === true) return;
  61. getCouponReceive(id).then(function() {
  62. uni.showToast({
  63. title: "已领取",
  64. icon: "none",
  65. duration: 2000
  66. });
  67. that.$set(list[index], "is_use", true);
  68. that.$emit("changefun", { action: "currentcoupon", value: index });
  69. that.$emit("changeFun", { action: "changecoupon", value: false });
  70. });
  71. }
  72. }
  73. };
  74. </script>