paymentPage.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. orderNo: "",
  7. orderInfo: {}
  8. };
  9. },
  10. onLoad(options) {
  11. if (options.orderNo) {
  12. this.orderNo = options.orderNo;
  13. setTimeout(() => {
  14. this.payEnsure();
  15. }, 200);
  16. }
  17. this.orderInfo = JSON.parse(sessionStorage.getItem("orderInfo"));
  18. },
  19. methods: {
  20. // 检查订单支付状态
  21. checkOrder() {
  22. let _this = this;
  23. _this.$request.get({
  24. url: `api/wx-pay/queryOrder/${_this.orderNo}`,
  25. loadingTip: "加载中...",
  26. data: {}
  27. }).then((res) => {
  28. common_vendor.index.hideLoading();
  29. let resultInfo = JSON.parse(res.data.body);
  30. if (resultInfo.trade_state === "SUCCESS") {
  31. common_vendor.index.navigateTo({
  32. url: `/newScale/EQtest/paySuccess?resultId=${this.orderInfo.resultId}&userId=${this.orderInfo.userId}`
  33. });
  34. } else {
  35. return;
  36. }
  37. });
  38. },
  39. // 拉起微信支付
  40. getH5Pay(params) {
  41. let _this = this;
  42. _this.$request.get({
  43. url: `api/orderInfo/queryOrderByResultIdAndUserId/${this.orderInfo.userId}/${this.orderInfo.resultId}`,
  44. loadingTip: "加载中...",
  45. data: {}
  46. }).then((res) => {
  47. common_vendor.index.hideLoading();
  48. if (res.data && res.data.orderStatus === "支付成功") {
  49. common_vendor.index.navigateTo({
  50. url: `/newScale/EQtest/paySuccess?resultId=${this.orderInfo.resultId}&userId=${this.orderInfo.userId}`
  51. });
  52. } else {
  53. _this.$request.post({
  54. url: "api/wx-pay/h5Pay",
  55. loadingTip: "加载中...",
  56. data: _this.orderInfo
  57. }).then((res2) => {
  58. let redirect_url = encodeURI(
  59. `http://hnhong-duo.com/webo/newScale/EQtest/paymentPage?orderNo=${res2.data.orderNo}`
  60. );
  61. window.location.href = `${res2.data.codeUrl}&redirect_url=${redirect_url}`;
  62. });
  63. }
  64. });
  65. },
  66. payEnsure() {
  67. this.$refs.popup.open();
  68. },
  69. uncompleteHandle() {
  70. this.$refs.popup.close();
  71. },
  72. completeHandle() {
  73. common_vendor.index.showLoading({
  74. title: ""
  75. });
  76. this.checkOrder();
  77. }
  78. }
  79. };
  80. if (!Array) {
  81. const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  82. _easycom_uni_popup2();
  83. }
  84. const _easycom_uni_popup = () => "../../node-modules/@dcloudio/uni-ui/lib/uni-popup/uni-popup.js";
  85. if (!Math) {
  86. _easycom_uni_popup();
  87. }
  88. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  89. return {
  90. a: common_vendor.o(($event) => $options.getH5Pay()),
  91. b: common_vendor.o(($event) => $options.getH5Pay()),
  92. c: common_vendor.o((...args) => $options.completeHandle && $options.completeHandle(...args)),
  93. d: common_vendor.o((...args) => $options.uncompleteHandle && $options.uncompleteHandle(...args)),
  94. e: common_vendor.sr("popup", "cef389e1-0"),
  95. f: common_vendor.p({
  96. type: "center"
  97. })
  98. };
  99. }
  100. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-cef389e1"], ["__file", "E:/psy_web_share/newScale/EQtest/paymentPage.vue"]]);
  101. tt.createPage(MiniProgramPage);