packagePayment.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. var api_packageOrder = require("../api/packageOrder.js");
  4. require("../common/request.js");
  5. const _sfc_main = {
  6. data() {
  7. return {
  8. payMethod: null,
  9. orderId: null,
  10. order: null
  11. };
  12. },
  13. onLoad(option) {
  14. this.orderId = option.orderId;
  15. this.payMethod = option.payMethod;
  16. },
  17. onShow() {
  18. this.getPackageOrderById();
  19. },
  20. methods: {
  21. copyTest(text) {
  22. common_vendor.index.setClipboardData({
  23. data: text,
  24. success: () => {
  25. common_vendor.index.showToast({
  26. title: "\u5185\u5BB9\u5DF2\u6210\u529F\u590D\u5236\u5230\u526A\u5207\u677F",
  27. icon: "none"
  28. });
  29. }
  30. });
  31. },
  32. getPackageOrderById() {
  33. var data = { orderId: this.orderId };
  34. console.log(data);
  35. api_packageOrder.getPackageOrderById(data).then((res) => {
  36. if (res.code == 200) {
  37. this.order = res.order;
  38. if (this.payMethod != null && this.payMethod == "app") {
  39. this.payOrder();
  40. }
  41. }
  42. }, (rej) => {
  43. });
  44. },
  45. payOrder() {
  46. var data = {
  47. orderId: this.orderId
  48. };
  49. var that = this;
  50. common_vendor.index.showLoading();
  51. api_packageOrder.payment(data).then((res) => {
  52. if (res.code == 200) {
  53. if (res.isPay == 0) {
  54. if (res.type == "tz") {
  55. common_vendor.index.setStorageSync("ztPayUrl", res.data.body.url);
  56. common_vendor.index.navigateTo({
  57. url: "/pages_order/tzPay"
  58. });
  59. }
  60. if (res.type == "yb") {
  61. var payData = JSON.parse(res.data.pay_info);
  62. console.log(payData);
  63. common_vendor.index.requestPayment({
  64. provider: "wxpay",
  65. timeStamp: payData.timeStamp,
  66. nonceStr: payData.nonceStr,
  67. package: payData.package,
  68. signType: payData.signType,
  69. paySign: payData.paySign,
  70. success: function(res2) {
  71. console.log(that.order.orderId);
  72. common_vendor.index.hideLoading();
  73. common_vendor.index.redirectTo({
  74. url: "./packageOrderPaySuccess?orderId=" + that.order.orderId
  75. });
  76. },
  77. fail: function(err) {
  78. common_vendor.index.showToast({
  79. icon: "none",
  80. title: "fail:" + JSON.stringify(err)
  81. });
  82. common_vendor.index.hideLoading();
  83. }
  84. });
  85. } else if (res.type == "hf") {
  86. var payData = JSON.parse(res.data.pay_info);
  87. console.log(payData);
  88. common_vendor.index.requestPayment({
  89. provider: "wxpay",
  90. timeStamp: payData.timeStamp,
  91. nonceStr: payData.nonceStr,
  92. package: payData.package,
  93. signType: payData.signType,
  94. paySign: payData.paySign,
  95. success: function(res2) {
  96. console.log(that.order.orderId);
  97. common_vendor.index.hideLoading();
  98. common_vendor.index.redirectTo({
  99. url: "./packageOrderPaySuccess?orderId=" + that.order.orderId
  100. });
  101. },
  102. fail: function(err) {
  103. common_vendor.index.showToast({
  104. icon: "none",
  105. title: "fail:" + JSON.stringify(err)
  106. });
  107. common_vendor.index.hideLoading();
  108. }
  109. });
  110. } else if (res.type == "wx") {
  111. common_vendor.index.requestPayment({
  112. provider: "wxpay",
  113. timeStamp: res.data.timeStamp,
  114. nonceStr: res.data.nonceStr,
  115. package: res.data.packageValue,
  116. signType: res.data.signType,
  117. paySign: res.data.paySign,
  118. success: function(res2) {
  119. console.log(that.order.orderId);
  120. common_vendor.index.hideLoading();
  121. common_vendor.index.redirectTo({
  122. url: "./packageOrderPaySuccess?orderId=" + that.order.orderId
  123. });
  124. },
  125. fail: function(err) {
  126. common_vendor.index.showToast({
  127. icon: "none",
  128. title: "fail:" + JSON.stringify(err)
  129. });
  130. common_vendor.index.hideLoading();
  131. }
  132. });
  133. }
  134. } else {
  135. common_vendor.index.hideLoading();
  136. common_vendor.index.redirectTo({
  137. url: "./packageOrderPaySuccess?orderId=" + that.order.orderId
  138. });
  139. }
  140. } else {
  141. common_vendor.index.showToast({
  142. icon: "none",
  143. title: res.msg
  144. });
  145. }
  146. }, (rej) => {
  147. });
  148. }
  149. }
  150. };
  151. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  152. return common_vendor.e({
  153. a: $data.order != null
  154. }, $data.order != null ? {
  155. b: common_vendor.t($data.order.payMoney.toFixed(2)),
  156. c: common_vendor.t($data.order.orderSn),
  157. d: common_vendor.o(($event) => $options.copyTest($data.order.orderSn)),
  158. e: common_vendor.t($data.order.createTime)
  159. } : {}, {
  160. f: $data.order != null
  161. }, $data.order != null ? {
  162. g: common_vendor.o(($event) => $options.payOrder())
  163. } : {});
  164. }
  165. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages_order/packagePayment.vue"]]);
  166. wx.createPage(MiniProgramPage);