platCoupon.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. var http = require('../../utils/http.js');
  2. var util = require('../../utils/util.js');
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. item: Object,
  9. type: Number,
  10. order: Boolean,
  11. canUse: Boolean,
  12. index: Number,
  13. showTimeType: Number,
  14. },
  15. /**
  16. * 组件的初始数据
  17. */
  18. data: {
  19. stsType: 4
  20. },
  21. // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
  22. attached: function() {
  23. //console.log(this.data.item);
  24. },
  25. /**
  26. * 组件的方法列表
  27. */
  28. methods: {
  29. receiveCoupon() {
  30. util.checkAuthInfo(() => {
  31. var couponId = this.data.item.couponId;
  32. http.request({
  33. url: "/p/myCoupon/receive",
  34. method: "POST",
  35. data: couponId,
  36. callBack: () => {
  37. var coupon = this.data.item;
  38. coupon.canReceive = false;
  39. this.setData({
  40. item: coupon
  41. })
  42. }
  43. })
  44. })
  45. },
  46. checkCoupon(e) {
  47. // this.triggerEvent('checkCoupon', this.data.index);
  48. this.triggerEvent('checkCoupon', {
  49. couponId: e.currentTarget.dataset.couponid
  50. });
  51. console.log(e.currentTarget.dataset.couponid)
  52. },
  53. /**
  54. * 立即使用
  55. */
  56. useCoupon() {
  57. var url = '/pages/prod-classify/prod-classify?sts=' + this.data.stsType;
  58. var id = this.data.item.couponId;
  59. var title = "优惠券活动商品";
  60. if (id) {
  61. url += "&tagid=" + id + "&title=" + title;
  62. }
  63. wx.navigateTo({
  64. url: url
  65. })
  66. },
  67. }
  68. })