diff --git a/api/fee/feeApi.js b/api/fee/feeApi.js index 0b3551b..ab52ce6 100755 --- a/api/fee/feeApi.js +++ b/api/fee/feeApi.js @@ -206,4 +206,26 @@ export function toPayTempCarFee(_objData){ } }); }) +} + + +export function toAliPayTempCarFee(_objData){ + return new Promise((resolve, reject) => { + requestNoAuth({ + url: url.payTempCarFee, + method: "POST", + data: JSON.stringify(_objData), //动态数据 + success: function(res) { + if (res.statusCode == 200) { + //成功情况下跳转 + resolve(res.data); + return; + } + reject(); + }, + fail: function(e) { + reject(); + } + }); + }) } \ No newline at end of file diff --git a/constant/url.js b/constant/url.js index fed5cab..896eb05 100755 --- a/constant/url.js +++ b/constant/url.js @@ -149,6 +149,9 @@ export default { listOwnerVisit: baseUrl + "app/visit.listVisits", listSystemInfo:baseUrl+"app/system.listSystemInfo", queryWaitPayFeeTempCar:baseUrl+"app/car.queryWaitPayFeeTempCar", + payTempCarFee:baseUrl+"app/alipay.payTempCarFee", + + NEED_NOT_LOGIN_PAGE: [ diff --git a/factory/AliPayFactory.js b/factory/AliPayFactory.js new file mode 100644 index 0000000..1e2dea4 --- /dev/null +++ b/factory/AliPayFactory.js @@ -0,0 +1,56 @@ +/** + 微信支付方法(uni-app h5)适用 + 获取微信加签信息 + @param{data}:获取的微信加签 + @param{res}:成功回调 + @param{fail}:失败回调 + + @warn:因为package为严格模式下的保留字,不能用作变量. + @use + + wPay({ + appId, + timeStamp, + nonceStr, + signature, + package, + paySign + },res=>{ + console.log(‘调用成功!‘); + },fail=>{ + console.log(‘调用失败!‘); + }) +**/ +//const wx = require('jweixin-module'); + +class AliPayFactory { + aliPay(data, successCallBack) { + if (!window.AlipayJSBridge) { + document.addEventListener('AlipayJSBridgeReady', function(){ + AlipayJSBridge.call("tradePay", { + tradeNO: data.tradeNO + }, function(data) { + log(JSON.stringify(data)); + if ("9000" == data.resultCode) { + successCallBack(); + } + }); + }, false); + return ; + } + + AlipayJSBridge.call("tradePay", { + tradeNO: data.tradeNO + }, function(data) { + log(JSON.stringify(data)); + if ("9000" == data.resultCode) { + successCallBack(); + } + }); + } + + + +}; + +module.exports = new AliPayFactory(); diff --git a/pages/tempCarFee/tempCarFee.vue b/pages/tempCarFee/tempCarFee.vue index ff9b4be..c23bd69 100644 --- a/pages/tempCarFee/tempCarFee.vue +++ b/pages/tempCarFee/tempCarFee.vue @@ -79,12 +79,18 @@ const constant = context.constant; // #ifdef H5 const WexinPayFactory = require('../../factory/WexinPayFactory.js'); + const AliPayFactory = require('../../factory/AliPayFactory.js'); // #endif import { getTempCarFeeOrder, - toPayTempCarFee - } from '../../api/fee/feeApi.js' - + toPayTempCarFee, + toAliPayTempCarFee + } from '../../api/fee/feeApi.js'; + + import { + isWxOrAli + } from '../../lib/java110/utils/EnvUtil.js'; + export default { data() { return { @@ -166,6 +172,57 @@ }) }, onPayFee: function() { + if(isWxOrAli == 'ALIPAY'){ + onAliPayPayFee(); + }else{ + onWxPayFee(); + } + }, + onAliPayPayFee:function(){ + let _receivedAmount = this.receivableAmount; + wx.showLoading({ + title: '支付中' + }); + let _tradeType = 'JSAPI'; + let _objData = { + carNum: this.carNum, + openId: this.openId, + paId: this.paId, + feeName: '停车费', + tradeType: _tradeType, + appId: this.appId, + inoutId: this.inoutId, + couponList: this.couponList, + machineId:this.machineId + }; + toAliPayTempCarFee(_objData) + .then(_data=>{ + if (_data.code == '0') { + // #ifdef H5 + AliPayFactory.aliPay({ + tradeNO:_data.data + }, function() { + uni.showToast({ + title: "支付成功", + duration: 2000 + }); + uni.navigateBack({ + delta:1 + }); + }); + // #endif + wx.hideLoading(); + return; + } + wx.hideLoading(); + wx.showToast({ + title: "缴费失败", + icon: 'none', + duration: 2000 + }); + }) + }, + onWxPayFee:function(){ let _receivedAmount = this.receivableAmount; wx.showLoading({ title: '支付中'