Coupon.js 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. var __defProp = Object.defineProperty;
  2. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  3. var __getOwnPropNames = Object.getOwnPropertyNames;
  4. var __hasOwnProp = Object.prototype.hasOwnProperty;
  5. var __export = (target, all) => {
  6. for (var name2 in all)
  7. __defProp(target, name2, { get: all[name2], enumerable: true });
  8. };
  9. var __copyProps = (to, from, except, desc) => {
  10. if (from && typeof from === "object" || typeof from === "function") {
  11. for (let key of __getOwnPropNames(from))
  12. if (!__hasOwnProp.call(to, key) && key !== except)
  13. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  14. }
  15. return to;
  16. };
  17. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  18. var stdin_exports = {};
  19. __export(stdin_exports, {
  20. default: () => stdin_default
  21. });
  22. module.exports = __toCommonJS(stdin_exports);
  23. var import_vue = require("vue");
  24. var import_utils = require("../utils");
  25. var import_utils2 = require("./utils");
  26. var import_checkbox = require("../checkbox");
  27. const [name, bem, t] = (0, import_utils.createNamespace)("coupon");
  28. var stdin_default = (0, import_vue.defineComponent)({
  29. name,
  30. props: {
  31. chosen: Boolean,
  32. coupon: (0, import_utils.makeRequiredProp)(Object),
  33. disabled: Boolean,
  34. currency: (0, import_utils.makeStringProp)("\xA5")
  35. },
  36. setup(props) {
  37. const validPeriod = (0, import_vue.computed)(() => {
  38. const {
  39. startAt,
  40. endAt
  41. } = props.coupon;
  42. return `${(0, import_utils2.getDate)(startAt)} - ${(0, import_utils2.getDate)(endAt)}`;
  43. });
  44. const faceAmount = (0, import_vue.computed)(() => {
  45. const {
  46. coupon,
  47. currency
  48. } = props;
  49. if (coupon.valueDesc) {
  50. return [coupon.valueDesc, (0, import_vue.createVNode)("span", null, [coupon.unitDesc || ""])];
  51. }
  52. if (coupon.denominations) {
  53. const denominations = (0, import_utils2.formatAmount)(coupon.denominations);
  54. return [(0, import_vue.createVNode)("span", null, [currency]), ` ${denominations}`];
  55. }
  56. if (coupon.discount) {
  57. return t("discount", (0, import_utils2.formatDiscount)(coupon.discount));
  58. }
  59. return "";
  60. });
  61. const conditionMessage = (0, import_vue.computed)(() => {
  62. const condition = (0, import_utils2.formatAmount)(props.coupon.originCondition || 0);
  63. return condition === "0" ? t("unlimited") : t("condition", condition);
  64. });
  65. return () => {
  66. const {
  67. chosen,
  68. coupon,
  69. disabled
  70. } = props;
  71. const description = disabled && coupon.reason || coupon.description;
  72. return (0, import_vue.createVNode)("div", {
  73. "class": bem({
  74. disabled
  75. })
  76. }, [(0, import_vue.createVNode)("div", {
  77. "class": bem("content")
  78. }, [(0, import_vue.createVNode)("div", {
  79. "class": bem("head")
  80. }, [(0, import_vue.createVNode)("h2", {
  81. "class": bem("amount")
  82. }, [faceAmount.value]), (0, import_vue.createVNode)("p", {
  83. "class": bem("condition")
  84. }, [coupon.condition || conditionMessage.value])]), (0, import_vue.createVNode)("div", {
  85. "class": bem("body")
  86. }, [(0, import_vue.createVNode)("p", {
  87. "class": bem("name")
  88. }, [coupon.name]), (0, import_vue.createVNode)("p", {
  89. "class": bem("valid")
  90. }, [validPeriod.value]), !disabled && (0, import_vue.createVNode)(import_checkbox.Checkbox, {
  91. "class": bem("corner"),
  92. "modelValue": chosen
  93. }, null)])]), description && (0, import_vue.createVNode)("p", {
  94. "class": bem("description")
  95. }, [description])]);
  96. };
  97. }
  98. });