支付宝开发完成

This commit is contained in:
java110 2022-08-28 12:05:40 +08:00
parent a9afac5068
commit 2335a74c68
4 changed files with 141 additions and 3 deletions

View File

@ -207,3 +207,25 @@ 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();
}
});
})
}

View File

@ -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: [

56
factory/AliPayFactory.js Normal file
View File

@ -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();

View File

@ -79,11 +79,17 @@
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() {
@ -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: '支付中'