result.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_api_pay_order = require("../../sheep/api/pay/order.js");
  5. const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
  6. const sheep_api_trade_order = require("../../sheep/api/trade/order.js");
  7. const sheep_hooks_useModal = require("../../sheep/hooks/useModal.js");
  8. require("../../sheep/api/index.js");
  9. require("../../sheep/api/distri/score.js");
  10. require("../../sheep/request/index.js");
  11. require("../../sheep/config/index.js");
  12. require("../../sheep/store/index.js");
  13. require("../../sheep/store/app.js");
  14. require("../../sheep/api/promotion/diy.js");
  15. require("../../sheep/platform/index.js");
  16. require("../../sheep/platform/provider/wechat/index.js");
  17. require("../../sheep/platform/provider/wechat/miniProgram.js");
  18. require("../../sheep/api/member/auth.js");
  19. require("../../sheep/api/member/social.js");
  20. require("../../sheep/api/member/user.js");
  21. require("../../sheep/platform/provider/apple/index.js");
  22. require("../../sheep/platform/share.js");
  23. require("../../sheep/router/index.js");
  24. require("../../sheep/helper/throttle.js");
  25. require("../../sheep/url/index.js");
  26. require("../../sheep/platform/pay.js");
  27. require("../../sheep/helper/index.js");
  28. require("../../sheep/helper/test.js");
  29. require("../../sheep/helper/digit.js");
  30. require("../../sheep/store/user.js");
  31. require("../../sheep/store/cart.js");
  32. require("../../sheep/api/trade/cart.js");
  33. require("../../sheep/api/pay/wallet.js");
  34. require("../../sheep/api/promotion/coupon.js");
  35. require("../../sheep/store/sys.js");
  36. require("../../sheep/store/modal.js");
  37. require("../../sheep/api/distri/share.js");
  38. require("../../sheep/api/distri/team.js");
  39. require("../../sheep/api/infra/file.js");
  40. require("../../sheep/api/member/address.js");
  41. require("../../sheep/api/member/point.js");
  42. require("../../sheep/api/member/signin.js");
  43. require("../../sheep/api/migration/app.js");
  44. require("../../sheep/api/migration/chat.js");
  45. require("../../sheep/api/migration/index.js");
  46. require("../../sheep/api/migration/third.js");
  47. require("../../sheep/api/pay/channel.js");
  48. require("../../sheep/api/product/category.js");
  49. require("../../sheep/api/product/comment.js");
  50. require("../../sheep/api/product/favorite.js");
  51. require("../../sheep/api/product/history.js");
  52. require("../../sheep/api/product/spu.js");
  53. require("../../sheep/api/promotion/activity.js");
  54. require("../../sheep/api/promotion/article.js");
  55. require("../../sheep/api/promotion/bargain.js");
  56. require("../../sheep/api/promotion/combination.js");
  57. require("../../sheep/api/promotion/rewardActivity.js");
  58. require("../../sheep/api/promotion/seckill.js");
  59. require("../../sheep/api/system/area.js");
  60. require("../../sheep/api/system/voice.js");
  61. require("../../sheep/api/trade/afterSale.js");
  62. require("../../sheep/api/trade/brokerage.js");
  63. require("../../sheep/api/trade/config.js");
  64. require("../../sheep/api/trade/delivery.js");
  65. require("../../sheep/config/zIndex.js");
  66. require("../../sheep/util/index.js");
  67. if (!Array) {
  68. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  69. _easycom_s_layout2();
  70. }
  71. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  72. if (!Math) {
  73. _easycom_s_layout();
  74. }
  75. const _sfc_main = {
  76. __name: "result",
  77. setup(__props) {
  78. const state = common_vendor.reactive({
  79. id: 0,
  80. // 支付单号
  81. orderType: "goods",
  82. // 订单类型
  83. result: "unpaid",
  84. // 支付状态
  85. orderInfo: {},
  86. // 支付订单信息
  87. tradeOrder: {},
  88. // 商品订单信息,只有在 orderType 为 goods 才会请求。目的:【我的拼团】按钮的展示
  89. counter: 0
  90. // 获取结果次数
  91. });
  92. const payResult = common_vendor.computed(() => {
  93. if (state.result === "unpaid") {
  94. return "waiting";
  95. }
  96. if (state.result === "paid") {
  97. return "success";
  98. }
  99. if (state.result === "failed") {
  100. return "failed";
  101. }
  102. if (state.result === "closed") {
  103. return "closed";
  104. }
  105. });
  106. common_vendor.watchEffect(() => {
  107. if (payResult.value == "success") {
  108. sheep_hooks_useModal.showWalletModal({ points: state.orderInfo.jf, socialStatus: state.orderInfo.sj });
  109. }
  110. });
  111. async function getOrderInfo(id) {
  112. state.counter++;
  113. const {
  114. data,
  115. code
  116. } = await sheep_api_pay_order.PayOrderApi.getByStatus(id);
  117. if (code === 0) {
  118. state.orderInfo = data;
  119. if (!state.orderInfo || state.orderInfo.status === 30) {
  120. state.result = "closed";
  121. return;
  122. }
  123. if (state.orderInfo.status !== 0) {
  124. state.result = "paid";
  125. subscribeMessage();
  126. if (state.orderType === "goods") {
  127. const {
  128. data: data2,
  129. code: code2
  130. } = await sheep_api_trade_order.OrderApi.getByStatus(state.orderInfo.merchantOrderId);
  131. if (code2 === 0) {
  132. state.tradeOrder = data2;
  133. }
  134. }
  135. return;
  136. }
  137. }
  138. if (state.counter < 3 && state.result === "unpaid") {
  139. setTimeout(() => {
  140. getOrderInfo(id);
  141. }, 1500);
  142. }
  143. if (state.counter >= 3) {
  144. state.result = "failed";
  145. }
  146. }
  147. function onOrder() {
  148. if (state.orderType === "recharge") {
  149. sheep_index.sheep.$router.redirect("/pages/pay/recharge-log");
  150. } else {
  151. sheep_index.sheep.$router.redirect("/pages/order/list");
  152. }
  153. }
  154. function subscribeMessage() {
  155. let event = ["order_dispatched"];
  156. if (state.tradeOrder.type === 3) {
  157. event.push("groupon_finish");
  158. event.push("groupon_fail");
  159. }
  160. sheep_index.sheep.$platform.useProvider("wechat").subscribeMessage(event);
  161. }
  162. common_vendor.onLoad(async (options) => {
  163. if (options.id) {
  164. state.id = options.id;
  165. }
  166. if (options.orderType) {
  167. state.orderType = options.orderType;
  168. }
  169. await getOrderInfo(state.id);
  170. });
  171. common_vendor.onShow(() => {
  172. if (common_vendor.lodashExports.isEmpty(state.orderInfo)) {
  173. return;
  174. }
  175. getOrderInfo(state.id);
  176. });
  177. common_vendor.onHide(() => {
  178. state.result = "unpaid";
  179. state.counter = 0;
  180. });
  181. return (_ctx, _cache) => {
  182. return common_vendor.e({
  183. a: payResult.value === "waiting"
  184. }, payResult.value === "waiting" ? {} : {}, {
  185. b: payResult.value === "success"
  186. }, payResult.value === "success" ? {
  187. c: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/order_pay_success.gif")
  188. } : {}, {
  189. d: ["failed", "closed"].includes(payResult.value)
  190. }, ["failed", "closed"].includes(payResult.value) ? {
  191. e: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/order_paty_fail.gif")
  192. } : {}, {
  193. f: payResult.value === "success"
  194. }, payResult.value === "success" ? {} : {}, {
  195. g: payResult.value === "failed"
  196. }, payResult.value === "failed" ? {} : {}, {
  197. h: payResult.value === "closed"
  198. }, payResult.value === "closed" ? {} : {}, {
  199. i: payResult.value === "waiting"
  200. }, payResult.value === "waiting" ? {} : {}, {
  201. j: payResult.value === "success"
  202. }, payResult.value === "success" ? {
  203. k: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price))
  204. } : {}, {
  205. l: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/index/index")),
  206. m: payResult.value === "failed"
  207. }, payResult.value === "failed" ? {
  208. n: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.redirect("/pages/pay/index", {
  209. id: state.id,
  210. orderType: state.orderType
  211. }))
  212. } : {}, {
  213. o: payResult.value === "success"
  214. }, payResult.value === "success" ? {
  215. p: common_vendor.o(onOrder)
  216. } : {}, {
  217. q: payResult.value === "success" && state.tradeOrder.type === 3
  218. }, payResult.value === "success" && state.tradeOrder.type === 3 ? {
  219. r: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.redirect("/pages/activity/groupon/order"))
  220. } : {}, {
  221. s: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/cargo.png"),
  222. t: common_vendor.o(subscribeMessage),
  223. v: common_vendor.p({
  224. title: "支付结果",
  225. bgStyle: {
  226. color: "#FFF"
  227. }
  228. })
  229. });
  230. };
  231. }
  232. };
  233. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-42b1ec48"], ["__file", "D:/zx/mall-front-app/pages/pay/result.vue"]]);
  234. wx.createPage(MiniProgramPage);