index.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
  5. const sheep_api_pay_order = require("../../sheep/api/pay/order.js");
  6. const sheep_api_pay_channel = require("../../sheep/api/pay/channel.js");
  7. const sheep_platform_pay = require("../../sheep/platform/pay.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/hooks/useModal.js");
  25. require("../../sheep/helper/index.js");
  26. require("../../sheep/helper/test.js");
  27. require("../../sheep/helper/digit.js");
  28. require("../../sheep/api/member/signin.js");
  29. require("../../sheep/helper/throttle.js");
  30. require("../../sheep/url/index.js");
  31. require("../../sheep/store/user.js");
  32. require("../../sheep/store/cart.js");
  33. require("../../sheep/api/trade/cart.js");
  34. require("../../sheep/api/pay/wallet.js");
  35. require("../../sheep/api/trade/order.js");
  36. require("../../sheep/api/promotion/coupon.js");
  37. require("../../sheep/store/sys.js");
  38. require("../../sheep/store/modal.js");
  39. require("../../sheep/api/distri/share.js");
  40. require("../../sheep/api/distri/team.js");
  41. require("../../sheep/api/infra/file.js");
  42. require("../../sheep/api/member/address.js");
  43. require("../../sheep/api/member/point.js");
  44. require("../../sheep/api/migration/app.js");
  45. require("../../sheep/api/migration/chat.js");
  46. require("../../sheep/api/migration/index.js");
  47. require("../../sheep/api/migration/third.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: "index",
  77. setup(__props) {
  78. const userWallet = common_vendor.computed(() => sheep_index.sheep.$store("user").userWallet);
  79. const state = common_vendor.reactive({
  80. orderType: "goods",
  81. // 订单类型; goods - 商品订单, recharge - 充值订单
  82. orderInfo: {},
  83. // 支付单信息
  84. payStatus: 0,
  85. // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付
  86. payMethods: [],
  87. // 可选的支付方式
  88. payment: ""
  89. // 选中的支付方式
  90. });
  91. const onPay = () => {
  92. if (state.payment === "") {
  93. sheep_index.sheep.$helper.toast("请选择支付方式");
  94. return;
  95. }
  96. if (state.payment === "wallet") {
  97. common_vendor.index.showModal({
  98. title: "提示",
  99. content: "确定要支付吗?",
  100. success: function(res) {
  101. if (res.confirm) {
  102. sheep_index.sheep.$platform.pay(state.payment, state.orderType, state.orderInfo.id);
  103. }
  104. }
  105. });
  106. } else {
  107. sheep_index.sheep.$platform.pay(state.payment, state.orderType, state.orderInfo.id);
  108. }
  109. };
  110. const payDescText = common_vendor.computed(() => {
  111. if (state.payStatus === 2) {
  112. return "该订单已支付";
  113. }
  114. if (state.payStatus === 1) {
  115. const time = sheep_hooks_useGoods.useDurationTime(state.orderInfo.expireTime);
  116. if (time.ms <= 0) {
  117. state.payStatus = -1;
  118. return "";
  119. }
  120. return `剩余支付时间 ${time.h}:${time.m}:${time.s} `;
  121. }
  122. if (state.payStatus === -2) {
  123. return "未查询到支付单信息";
  124. }
  125. return "";
  126. });
  127. function checkPayStatus() {
  128. if (state.orderInfo.status === 10 || state.orderInfo.status === 20) {
  129. state.payStatus = 2;
  130. return;
  131. }
  132. if (state.orderInfo.status === 30) {
  133. state.payStatus = -1;
  134. return;
  135. }
  136. state.payStatus = 1;
  137. }
  138. function onTapPay(e) {
  139. state.payment = e.detail.value;
  140. }
  141. async function setOrder(id) {
  142. const { data, code } = await sheep_api_pay_order.PayOrderApi.getOrder(id);
  143. if (code !== 0 || !data) {
  144. state.payStatus = -2;
  145. return;
  146. }
  147. state.orderInfo = data;
  148. await setPayMethods();
  149. checkPayStatus();
  150. }
  151. async function setPayOrder(id) {
  152. const { data, code } = await sheep_api_pay_order.PayOrderApi.getPayOrder(id);
  153. if (code !== 0 || !data) {
  154. state.payStatus = -2;
  155. return;
  156. }
  157. state.orderInfo = data;
  158. await setPayMethods();
  159. checkPayStatus();
  160. }
  161. async function setPayMethods() {
  162. const { data, code } = await sheep_api_pay_channel.PayChannelApi.getEnableChannelCodeList(state.orderInfo.appId);
  163. if (code !== 0) {
  164. return;
  165. }
  166. state.payMethods = sheep_platform_pay.getPayMethods(data);
  167. }
  168. common_vendor.onLoad((options) => {
  169. if (sheep_index.sheep.$platform.name === "WechatOfficialAccount" && sheep_index.sheep.$platform.os === "ios" && !sheep_index.sheep.$platform.landingPage.includes("pages/pay/index")) {
  170. location.reload();
  171. return;
  172. }
  173. console.log(options);
  174. let id = options.id;
  175. if (options.orderType) {
  176. state.orderType = options.orderType;
  177. }
  178. if (options.openType == 2) {
  179. setPayOrder(id);
  180. } else {
  181. console.log(123);
  182. setOrder(id);
  183. }
  184. sheep_index.sheep.$store("user").getWallet();
  185. });
  186. return (_ctx, _cache) => {
  187. return common_vendor.e({
  188. a: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price)),
  189. b: common_vendor.t(payDescText.value),
  190. c: common_vendor.f(state.payMethods, (item, k0, i0) => {
  191. return common_vendor.e({
  192. a: item.disabled
  193. }, item.disabled ? {
  194. b: common_vendor.unref(sheep_index.sheep).$url.static("/static/img/shop/pay/cod_disabled.png")
  195. } : {
  196. c: common_vendor.unref(sheep_index.sheep).$url.static(item.icon)
  197. }, {
  198. d: common_vendor.t(item.title),
  199. e: item.value === "wallet"
  200. }, item.value === "wallet" ? {
  201. f: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(userWallet.value.balance))
  202. } : {}, {
  203. g: item.value,
  204. h: item.disabled,
  205. i: state.payment === item.value,
  206. j: item.disabled ? 1 : "",
  207. k: item.title
  208. });
  209. }),
  210. d: common_vendor.o(onTapPay),
  211. e: state.payStatus === 0
  212. }, state.payStatus === 0 ? {} : state.payStatus === -1 ? {} : {
  213. g: common_vendor.o(onPay),
  214. h: state.payStatus !== 1,
  215. i: state.payStatus !== 1 ? 1 : ""
  216. }, {
  217. f: state.payStatus === -1,
  218. j: common_vendor.p({
  219. title: "收银台"
  220. })
  221. });
  222. };
  223. }
  224. };
  225. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d7fd7b38"], ["__file", "D:/zx/mall-front-app/pages/pay/index.vue"]]);
  226. wx.createPage(MiniProgramPage);