inquiryPayment.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. var api_inquiryOrder = require("../api/inquiryOrder.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.getInquiryOrderById();
  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. getInquiryOrderById() {
  33. var data = { orderId: this.orderId };
  34. console.log(data);
  35. api_inquiryOrder.getInquiryOrderById(data).then((res) => {
  36. if (res.code == 200) {
  37. this.order = res.data;
  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_inquiryOrder.payment(data).then((res) => {
  52. if (res.code == 200) {
  53. if (res.isPay == 1) {
  54. common_vendor.index.redirectTo({
  55. url: "/pages_order/inquiryOrderPaySuccess?orderId=" + that.order.orderId
  56. });
  57. } else {
  58. if (res.type == "tz") {
  59. common_vendor.index.setStorageSync("ztPayUrl", res.data.body.url);
  60. common_vendor.index.redirectTo({
  61. url: "/pages_order/tzPay"
  62. });
  63. } else if (res.type == "yb") {
  64. var payData = JSON.parse(res.data.pay_info);
  65. console.log(payData);
  66. common_vendor.index.requestPayment({
  67. provider: "wxpay",
  68. timeStamp: payData.timeStamp,
  69. nonceStr: payData.nonceStr,
  70. package: payData.package,
  71. signType: payData.signType,
  72. paySign: payData.paySign,
  73. success: function(res2) {
  74. console.log(that.order.orderId);
  75. common_vendor.index.hideLoading();
  76. common_vendor.index.redirectTo({
  77. url: "/pages_order/inquiryOrderPaySuccess?orderId=" + that.order.orderId
  78. });
  79. },
  80. fail: function(err) {
  81. common_vendor.index.showToast({
  82. icon: "none",
  83. title: "fail:" + JSON.stringify(err)
  84. });
  85. common_vendor.index.hideLoading();
  86. }
  87. });
  88. } else if (res.type == "hf") {
  89. var payData = JSON.parse(res.data.pay_info);
  90. console.log(payData);
  91. common_vendor.index.requestPayment({
  92. provider: "wxpay",
  93. timeStamp: payData.timeStamp,
  94. nonceStr: payData.nonceStr,
  95. package: payData.package,
  96. signType: payData.signType,
  97. paySign: payData.paySign,
  98. success: function(res2) {
  99. console.log(that.order.orderId);
  100. common_vendor.index.hideLoading();
  101. common_vendor.index.redirectTo({
  102. url: "/pages_order/inquiryOrderPaySuccess?orderId=" + that.order.orderId
  103. });
  104. },
  105. fail: function(err) {
  106. common_vendor.index.showToast({
  107. icon: "none",
  108. title: "fail:" + JSON.stringify(err)
  109. });
  110. common_vendor.index.hideLoading();
  111. }
  112. });
  113. } else if (res.type == "wx") {
  114. common_vendor.index.requestPayment({
  115. provider: "wxpay",
  116. timeStamp: res.data.timeStamp,
  117. nonceStr: res.data.nonceStr,
  118. package: res.data.packageValue,
  119. signType: res.data.signType,
  120. paySign: res.data.paySign,
  121. success: function(res2) {
  122. console.log(that.order.orderId);
  123. common_vendor.index.hideLoading();
  124. common_vendor.index.redirectTo({
  125. url: "/pages_order/inquiryOrderPaySuccess?orderId=" + that.order.orderId
  126. });
  127. },
  128. fail: function(err) {
  129. common_vendor.index.showToast({
  130. icon: "none",
  131. title: "fail:" + JSON.stringify(err)
  132. });
  133. common_vendor.index.hideLoading();
  134. }
  135. });
  136. }
  137. }
  138. } else {
  139. common_vendor.index.showToast({
  140. icon: "none",
  141. title: res.msg
  142. });
  143. }
  144. }, (rej) => {
  145. });
  146. }
  147. }
  148. };
  149. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  150. return common_vendor.e({
  151. a: $data.order != null
  152. }, $data.order != null ? {
  153. b: common_vendor.t($data.order.payMoney.toFixed(2)),
  154. c: common_vendor.t($data.order.orderSn),
  155. d: common_vendor.o(($event) => $options.copyTest($data.order.orderSn)),
  156. e: common_vendor.t($data.order.createTime)
  157. } : {}, {
  158. f: $data.order != null
  159. }, $data.order != null ? {
  160. g: common_vendor.o(($event) => $options.payOrder())
  161. } : {});
  162. }
  163. 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/inquiryPayment.vue"]]);
  164. wx.createPage(MiniProgramPage);