CouponModal.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const utils_file = require("../../../utils/file.js");
  4. if (!Math) {
  5. BasicModal();
  6. }
  7. const BasicModal = () => "../../../components/Modal/BasicModal.js";
  8. const _sfc_main = {
  9. __name: "CouponModal",
  10. props: {
  11. open: {
  12. type: Boolean,
  13. default: false
  14. },
  15. couponList: {
  16. type: Array,
  17. default: () => []
  18. }
  19. },
  20. emits: ["update:open", "receive", "close"],
  21. setup(__props, { emit: __emit }) {
  22. const props = __props;
  23. const emit = __emit;
  24. const getOpen = common_vendor.computed({
  25. get: () => props.open,
  26. set: (val) => emit("update:open", val)
  27. });
  28. const formatExpireDate = (date) => {
  29. if (!date)
  30. return "";
  31. if (typeof date === "string") {
  32. const d = new Date(date);
  33. if (!isNaN(d.getTime())) {
  34. const year = d.getFullYear();
  35. const month = String(d.getMonth() + 1).padStart(2, "0");
  36. const day = String(d.getDate()).padStart(2, "0");
  37. return `${year}/${month}/${day}`;
  38. }
  39. if (date.includes("/")) {
  40. return date;
  41. }
  42. }
  43. return date;
  44. };
  45. const handleClose = () => {
  46. getOpen.value = false;
  47. emit("close");
  48. };
  49. const handleReceive = (coupon, index) => {
  50. emit("receive", { coupon, index });
  51. };
  52. const copyUrl = () => {
  53. common_vendor.index.setClipboardData({
  54. data: "http:https://modao.cc/proto/KQv3fh5Kt7fy7tfvLMTCx/sharing?view_mode=read_only",
  55. success: () => {
  56. common_vendor.index.showToast({
  57. title: "复制成功",
  58. icon: "none"
  59. });
  60. }
  61. });
  62. };
  63. return (_ctx, _cache) => {
  64. return common_vendor.e({
  65. a: common_vendor.unref(utils_file.getFileUrl)("img/icon/close.png"),
  66. b: common_vendor.o(handleClose),
  67. c: __props.couponList.length > 0
  68. }, __props.couponList.length > 0 ? {
  69. d: common_vendor.f(__props.couponList, (coupon, index, i0) => {
  70. return common_vendor.e({
  71. a: common_vendor.t(coupon.amount),
  72. b: common_vendor.t(coupon.minAmount),
  73. c: common_vendor.t(coupon.name),
  74. d: common_vendor.t(formatExpireDate(coupon.expireDate)),
  75. e: !coupon.isReceived
  76. }, !coupon.isReceived ? {
  77. f: common_vendor.o(($event) => handleReceive(coupon, index), coupon.id || index)
  78. } : {
  79. g: common_vendor.unref(utils_file.getFileUrl)("img/icon/ylq.png")
  80. }, {
  81. h: coupon.id || index,
  82. i: common_vendor.n({
  83. "coupon-card--received": coupon.isReceived
  84. })
  85. });
  86. })
  87. } : {}, {
  88. e: __props.couponList.length === 0
  89. }, __props.couponList.length === 0 ? {
  90. f: common_vendor.unref(utils_file.getFileUrl)("img/icon/noCoupon.png"),
  91. g: common_vendor.o(copyUrl)
  92. } : {}, {
  93. h: common_vendor.o(($event) => getOpen.value = $event),
  94. i: common_vendor.p({
  95. type: "bottom",
  96. isMack: true,
  97. open: getOpen.value
  98. })
  99. });
  100. };
  101. }
  102. };
  103. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c66d46bb"]]);
  104. wx.createComponent(Component);
  105. //# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/orderFood/components/CouponModal.js.map