acdr-ui/dist/dev/mp-weixin/logic/pay.js.map

1 line
3.3 KiB
Plaintext
Raw Normal View History

2024-09-19 07:20:14 +08:00
{"version":3,"file":"pay.js","sources":["../../../../src/logic/pay.js"],"sourcesContent":["import { httpPost } from '@/utils/http'\r\n\r\nexport const pay = async (order) => {\r\n // 调用支付接口\r\n // #ifdef MP-WEIXIN\r\n // 调用接口创建订单\r\n try {\r\n const createOrder = await httpPost('/order/create', order)\r\n if (createOrder.code === 200) {\r\n const orderData = createOrder.data\r\n // 请求微信支付\r\n const wxres = await requestPayment(orderData.payData)\r\n if (wxres.errMsg === 'requestPayment:ok') {\r\n // 支付成功\r\n uni.showToast({ title: '支付成功', icon: 'success' })\r\n } else {\r\n // 支付失败\r\n uni.showToast({ title: '支付失败', icon: 'none' })\r\n }\r\n }\r\n } catch (err) {\r\n uni.showToast({ title: '创建订单失败', icon: 'none' })\r\n }\r\n // #endif\r\n // #ifdef H5\r\n // uni.showModal({\r\n // title: '提示',\r\n // content: 'h5不支持支付功能',\r\n // showCancel: false,\r\n // success: function (res) {},\r\n // })\r\n // h5 模拟支付功能\r\n try {\r\n const createOrder = await httpPost('/order/create', order)\r\n if (createOrder.code === 200) {\r\n const orderData = createOrder.data\r\n const payRes = await httpPost('/order/pay/' + orderData.orderData.id)\r\n if (!payRes.code === 200) {\r\n uni.showToast({ title: '支付失败: ' + payRes.message, icon: 'none' })\r\n return false\r\n }\r\n uni.showToast({ title: '支付成功', icon: 'success' })\r\n return true\r\n }\r\n toast(createOrder.message)\r\n } catch (err) {\r\n uni.showToast({ title: '创建订单失败', icon: 'none' })\r\n }\r\n return false\r\n // #endif\r\n}\r\n\r\nexport const payOrder = async (orderId) => {\r\n const payRes = await httpPost('/order/pay/' + orderId, {})\r\n return payRes\r\n}\r\n\r\n// 将微信小程序支付请求接口封装\r\nfunction requestPayment(paymentData) {\r\n return new Promise((resolve, reject) => {\r\n uni.requestPayment({\r\n provider: 'wxpay', // 微信支付\r\n timeStamp: paymentData.timeStamp,\r\n nonceStr: paymentData.nonceStr,\r\n package: paymentData.package,\r\n signType: paymentData.signType,\r\n paySign: paymentData.paySign,\r\n success: function (res) {\r\n resolve(res)\r\n },\r\n fail: function (err) {\r\n reject(err)\r\n },\r\n })\r\n })\r\n}\r\n"],"names":["httpPost","uni"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEY,MAAC,MAAM,CAAO,UAAU;AAIlC,MAAI;AACF,UAAM,cAAc,MAAMA,oBAAS,iBAAiB,KAAK;AACzD,QAAI,YAAY,SAAS,KAAK;AAC5B,YAAM,YAAY,YAAY;AAE9B,YAAM,QAAQ,MAAM,eAAe,UAAU,OAAO;AACpD,UAAI,MAAM,WAAW,qBAAqB;AAExCC,sBAAG,MAAC,UAAU,EAAE,OAAO,QAAQ,MAAM,WAAW;AAAA,MACxD,OAAa;AAELA,sBAAG,MAAC,UAAU,EAAE,OAAO,QAAQ,MAAM,QAAQ;AAAA,MAC9C;AAAA,IACF;AAAA,EACF,SAAQ,KAAK;AACZA,kBAAG,MAAC,UAAU,EAAE,OAAO,UAAU,MAAM,QAAQ;AAAA,EAChD;AA4BH;AAEY,MAAC,WAAW,CAAO,YAAY;AACzC,QAAM,SAAS,MAAMD,WAAAA,SAAS,gBAAgB,SAAS,CAAA,CAAE;AACzD,SAAO;AACT;AAGA,SAAS,eAAe,aAAa;AACnC,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtCC,kBAAAA,MAAI,eAAe;AAAA,MACjB,UAAU;AAAA;AAAA,MACV,WAAW,YAAY;AAAA,MACvB,UAAU,YAAY;AAAA,MACtB,SAAS,YAAY;AAAA,MACrB,UAAU,YAAY;AAAA,MACtB,SAAS,YAAY;AAAA,MACrB,SAAS,SAAU,KAAK;AACtB,gBAAQ,GAAG;AAAA,MACZ;AAAA,MACD,MAAM,SAAU,KAAK;AACnB,eAAO,GAAG;AAAA,MACX;AAAA,IACP,CAAK;AAAA,EACL,CAAG;AACH;;;"}