Coupon.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_vue2 = require("vue");
  25. var import_utils = require("../utils");
  26. var import_utils2 = require("./utils");
  27. var import_checkbox = require("../checkbox");
  28. const [name, bem, t] = (0, import_utils.createNamespace)("coupon");
  29. var stdin_default = (0, import_vue2.defineComponent)({
  30. name,
  31. props: {
  32. chosen: Boolean,
  33. coupon: (0, import_utils.makeRequiredProp)(Object),
  34. disabled: Boolean,
  35. currency: (0, import_utils.makeStringProp)("\xA5")
  36. },
  37. setup(props) {
  38. const validPeriod = (0, import_vue2.computed)(() => {
  39. const {
  40. startAt,
  41. endAt
  42. } = props.coupon;
  43. return `${(0, import_utils2.getDate)(startAt)} - ${(0, import_utils2.getDate)(endAt)}`;
  44. });
  45. const faceAmount = (0, import_vue2.computed)(() => {
  46. const {
  47. coupon,
  48. currency
  49. } = props;
  50. if (coupon.valueDesc) {
  51. return [coupon.valueDesc, (0, import_vue.createVNode)("span", null, [coupon.unitDesc || ""])];
  52. }
  53. if (coupon.denominations) {
  54. const denominations = (0, import_utils2.formatAmount)(coupon.denominations);
  55. return [(0, import_vue.createVNode)("span", null, [currency]), ` ${denominations}`];
  56. }
  57. if (coupon.discount) {
  58. return t("discount", (0, import_utils2.formatDiscount)(coupon.discount));
  59. }
  60. return "";
  61. });
  62. const conditionMessage = (0, import_vue2.computed)(() => {
  63. const condition = (0, import_utils2.formatAmount)(props.coupon.originCondition || 0);
  64. return condition === "0" ? t("unlimited") : t("condition", condition);
  65. });
  66. return () => {
  67. const {
  68. chosen,
  69. coupon,
  70. disabled
  71. } = props;
  72. const description = disabled && coupon.reason || coupon.description;
  73. return (0, import_vue.createVNode)("div", {
  74. "class": bem({
  75. disabled
  76. })
  77. }, [(0, import_vue.createVNode)("div", {
  78. "class": bem("content")
  79. }, [(0, import_vue.createVNode)("div", {
  80. "class": bem("head")
  81. }, [(0, import_vue.createVNode)("h2", {
  82. "class": bem("amount")
  83. }, [faceAmount.value]), (0, import_vue.createVNode)("p", {
  84. "class": bem("condition")
  85. }, [coupon.condition || conditionMessage.value])]), (0, import_vue.createVNode)("div", {
  86. "class": bem("body")
  87. }, [(0, import_vue.createVNode)("p", {
  88. "class": bem("name")
  89. }, [coupon.name]), (0, import_vue.createVNode)("p", {
  90. "class": bem("valid")
  91. }, [validPeriod.value]), !disabled && (0, import_vue.createVNode)(import_checkbox.Checkbox, {
  92. "class": bem("corner"),
  93. "modelValue": chosen
  94. }, null)])]), description && (0, import_vue.createVNode)("p", {
  95. "class": bem("description")
  96. }, [description])]);
  97. };
  98. }
  99. });