index.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. Component({
  2. options: {
  3. addGlobalClass: true,
  4. multipleSlots: true,
  5. },
  6. externalClasses: ['coupon-class'],
  7. properties: {
  8. mask: {
  9. type: Boolean,
  10. value: false, // 是否添加遮罩
  11. },
  12. superposable: {
  13. type: Boolean,
  14. value: false, // 是否可叠加
  15. },
  16. type: {
  17. type: String,
  18. value: '', // 优惠券类型:CouponType
  19. },
  20. value: {
  21. type: String,
  22. value: '', // 优惠金额
  23. },
  24. tag: {
  25. type: String,
  26. value: '', // 优惠标签,优惠券名字标签,img
  27. },
  28. desc: {
  29. type: String,
  30. value: '', // 优惠金额描述,金额下方
  31. },
  32. title: {
  33. type: String, // 优惠券名称
  34. value: '',
  35. },
  36. timeLimit: {
  37. type: String, // 优惠券时限
  38. value: '',
  39. },
  40. ruleDesc: {
  41. type: String, // 优惠券适用规则描述
  42. value: '',
  43. },
  44. currency: {
  45. type: String,
  46. value: '¥', // 优惠货币
  47. },
  48. status: {
  49. type: String,
  50. value: 'default',
  51. },
  52. image: {
  53. type: String,
  54. value: '',
  55. },
  56. },
  57. data: {
  58. CouponType: {
  59. MJ_COUPON: 1,
  60. ZK_COUPON: 2,
  61. MJF_COUPON: 3,
  62. GIFT_COUPON: 4,
  63. },
  64. theme: 'primary',
  65. },
  66. observers: {
  67. status: function (value) {
  68. let theme = 'primary';
  69. // 已过期或已使用的券 颜色置灰
  70. if (value === 'useless' || value === 'disabled') {
  71. theme = 'weak';
  72. }
  73. this.setData({ theme });
  74. },
  75. },
  76. attached() {
  77. this.setData({
  78. color: `color${this.properties.colorStyle}`,
  79. });
  80. },
  81. });