acdr-ui/dist/build/mp-weixin/logic/pay.js

2 lines
962 B
JavaScript

"use strict";var e=(e,t,n)=>new Promise(((o,r)=>{var s=e=>{try{i(n.next(e))}catch(t){r(t)}},a=e=>{try{i(n.throw(e))}catch(t){r(t)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(s,a);i((n=n.apply(e,t)).next())}));const t=require("../common/vendor.js"),n=require("../utils/http.js");exports.pay=o=>e(exports,null,(function*(){try{const r=yield n.httpPost("/order/create",o);if(200===r.code){const n=r.data;"requestPayment:ok"===(yield(e=n.payData,new Promise(((n,o)=>{t.index.requestPayment({provider:"wxpay",timeStamp:e.timeStamp,nonceStr:e.nonceStr,package:e.package,signType:e.signType,paySign:e.paySign,success:function(e){n(e)},fail:function(e){o(e)}})})))).errMsg?t.index.showToast({title:"支付成功",icon:"success"}):t.index.showToast({title:"支付失败",icon:"none"})}}catch(r){t.index.showToast({title:"创建订单失败",icon:"none"})}var e})),exports.payOrder=t=>e(exports,null,(function*(){return yield n.httpPost("/order/pay/"+t,{})}));