couponDetails.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. var api_coupon = require("../api/coupon.js");
  4. require("../common/request.js");
  5. const _sfc_main = {
  6. name: "getCoupon",
  7. props: {},
  8. data: function() {
  9. return {
  10. couponId: null,
  11. item: null,
  12. isShare: null,
  13. code: null
  14. };
  15. },
  16. onLoad(options) {
  17. this.couponId = options.couponId;
  18. this.code = options.code;
  19. if (!this.$isEmpty(options.isShare)) {
  20. this.isShare = options.isShare;
  21. this.genCode();
  22. } else {
  23. common_vendor.index.hideShareMenu();
  24. }
  25. console.log(options.couponId);
  26. this.companyId = common_vendor.index.getStorageSync("companyId");
  27. this.companyUserId = common_vendor.index.getStorageSync("companyUserId");
  28. this.getCouponById();
  29. },
  30. onShareAppMessage(res) {
  31. common_vendor.index.showShareMenu({
  32. withShareTicket: true
  33. });
  34. wx.updateShareMenu({
  35. isPrivateMessage: true,
  36. withShareTicket: true,
  37. success(res2) {
  38. console.log("updateShareMenu: ", res2);
  39. },
  40. fail() {
  41. }
  42. });
  43. return {
  44. title: this.item.title,
  45. path: "/pages_company/couponDetails?couponId=" + this.item.couponId + "&companyId=" + this.companyId + "&companyUserId=" + this.companyUserId + "&code=" + this.code
  46. };
  47. },
  48. mounted: function() {
  49. },
  50. onShow() {
  51. },
  52. methods: {
  53. genCode: function() {
  54. let that = this;
  55. var data = { couponId: this.couponId };
  56. api_coupon.genCode(data).then(function(res) {
  57. that.code = res.data;
  58. }).catch(function(err) {
  59. });
  60. },
  61. getCouponById: function() {
  62. let that = this;
  63. var data = {
  64. couponId: this.couponId
  65. };
  66. api_coupon.getCouponById(data).then(function(res) {
  67. that.item = res.data;
  68. }).catch(function(err) {
  69. common_vendor.index.showToast({
  70. title: err.msg,
  71. icon: "none",
  72. duration: 2e3
  73. });
  74. });
  75. },
  76. receive: function() {
  77. var data = {
  78. couponId: this.item.couponId,
  79. companyId: this.companyId,
  80. companyUserId: this.companyUserId,
  81. code: this.code
  82. };
  83. api_coupon.receive(data).then(function(res) {
  84. if (res.code == 200) {
  85. common_vendor.index.showToast({
  86. title: "\u9886\u53D6\u6210\u529F",
  87. icon: "success",
  88. duration: 2e3
  89. });
  90. } else {
  91. common_vendor.index.showToast({
  92. title: res.msg,
  93. duration: 2e3
  94. });
  95. }
  96. }).catch(function(err) {
  97. common_vendor.index.showToast({
  98. title: err.msg,
  99. icon: "none",
  100. duration: 2e3
  101. });
  102. });
  103. }
  104. }
  105. };
  106. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  107. return common_vendor.e({
  108. a: _ctx.item != null
  109. }, _ctx.item != null ? common_vendor.e({
  110. b: common_vendor.t(_ctx.item.price.toFixed(2)),
  111. c: common_vendor.t(_ctx.item.minPrice.toFixed(2)),
  112. d: common_vendor.t(_ctx.item.title),
  113. e: common_vendor.t(_ctx.item.limitTime),
  114. f: _ctx.item.remainNumber > 0
  115. }, _ctx.item.remainNumber > 0 ? {
  116. g: common_vendor.o(($event) => $options.receive())
  117. } : _ctx.item.remainNumber == 0 ? {} : {}, {
  118. h: _ctx.item.remainNumber == 0
  119. }) : {});
  120. }
  121. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-660e495e"], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages_company/couponDetails.vue"]]);
  122. _sfc_main.__runtimeHooks = 2;
  123. wx.createPage(MiniProgramPage);