Files
PropertyDeployment/resources/Web/MicroCommunityWeb/html/components/property/payFeeOrderConfirm/payFeeOrderConfirm.js
2025-12-09 20:22:03 +08:00

178 lines
7.7 KiB
JavaScript

(function (vc) {
vc.extends({
data: {
payFeeOrderConfirmInfo: {
totalDiscountMoney: 0.0,
accountAmount: 0.0,
payType: '',
preCheck: true
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('payFeeOrderConfirm', 'openConfirm', function (_data) {
$that.payFeeOrderConfirmInfo = _data;
$("#doPayFeeModal").modal('show');
$that.payFeeOrderConfirmInfo.payType = _data.payType;
if ($that.payFeeOrderConfirmInfo.payType != 'common') {
setTimeout('document.getElementById("authCode").focus()', 1000);
}
$that.$forceUpdate();
})
// 添加新的事件监听器,用于接收其他页面的调用请求
vc.on('payFeeOrderConfirm', 'callPayFee', function (_params) {
// 可以在这里处理从其他页面传递过来的参数
if (_params) {
// 如果需要,可以将外部参数合并到当前组件的数据中
Object.assign($that.payFeeOrderConfirmInfo, _params);
}
// 调用_payFee方法
$that._payFee();
});
// 添加新的事件监听器,用于接收其他页面的调用请求
vc.on('payFeeOrderConfirm', 'check', function (_params) {
// 可以在这里处理从其他页面传递过来的参数
$that.payFeeOrderConfirmInfo.preCheck = true;
// 调用_payFee方法
$that._payFee();
});
},
methods: {
/**
* 点击 “提交缴费”
*/
_closeDoPayFeeModal: function () {
//关闭model
$("#doPayFeeModal").modal('hide');
if (this.pollingTimerId) {
clearInterval(this.pollingTimerId);
console.log("离开页面,已清除 ABA 支付轮询定时器");
this.pollingTimerId = null; // 重置变量,避免内存泄漏
}
},
_qrCodePayFee: function () {
let _printFees = [];
_printFees.push({
feeId: $that.payFeeOrderConfirmInfo.feeId,
squarePrice: $that.payFeeOrderConfirmInfo.squarePrice,
additionalAmount: $that.payFeeOrderConfirmInfo.additionalAmount,
feeName: $that.payFeeOrderConfirmInfo.feeName,
amount: $that.payFeeOrderConfirmInfo.receivedAmount,
authCode: $that.payFeeOrderConfirmInfo.authCode
});
$that.payFeeOrderConfirmInfo.subServiceCode = 'fee.payFee';
vc.http.apiPost(
'/payment.qrCodePayment',
JSON.stringify(vc.component.payFeeOrderConfirmInfo), {
emulateJSON: true
},
function (json, res) {
let _data = JSON.parse(json);
if (_data.code == 404) {
vc.toast(_data.msg);
if (_data.data && _data.data.orderId) {
$that.payFeeOrderConfirmInfo.orderId = _data.data.orderId;
$that.payFeeOrderConfirmInfo.paymentPoolId = _data.data.paymentPoolId;
setTimeout('$that._qrCodeCheckPayFinish()', 5000);
}
return;
}
$that._closeDoPayFeeModal();
vc.emit('payFeeOrderResult', '_loadReceipt', _data)
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
}
);
},
_qrCodeCheckPayFinish: function () {
let _printFees = [];
_printFees.push({
feeId: $that.payFeeOrderConfirmInfo.feeId,
squarePrice: $that.payFeeOrderConfirmInfo.squarePrice,
additionalAmount: $that.payFeeOrderConfirmInfo.additionalAmount,
feeName: $that.payFeeOrderConfirmInfo.feeName,
amount: $that.payFeeOrderConfirmInfo.receivedAmount,
authCode: $that.payFeeOrderConfirmInfo.authCode,
orderId: $that.payFeeOrderConfirmInfo.orderId
});
$that.payFeeOrderConfirmInfo.subServiceCode = 'fee.payFee';
vc.http.apiPost(
'/payment.checkPayFinish',
JSON.stringify(vc.component.payFeeOrderConfirmInfo), {
emulateJSON: true
},
function (json, res) {
let _data = JSON.parse(json);
if (_data.code == 404) {
vc.toast(_data.msg);
return;
} else if (_data.code == 41) {
setTimeout('$that._qrCodeCheckPayFinish()', 5000);
return;
}
$that._closeDoPayFeeModal();
_data = _data.data;
vc.emit('payFeeOrderResult', '_loadReceipt', _data)
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
}
);
},
/**
* 点击模态框 “确定收费”
*/
_payFee: function (_page, _row) {
let _printFees = [];
_printFees.push({
feeId: $that.payFeeOrderConfirmInfo.feeId,
squarePrice: $that.payFeeOrderConfirmInfo.squarePrice,
additionalAmount: $that.payFeeOrderConfirmInfo.additionalAmount,
feeName: $that.payFeeOrderConfirmInfo.feeName,
amount: $that.payFeeOrderConfirmInfo.receivedAmount
});
vc.http.apiPost(
'/fee.payFee',
JSON.stringify(vc.component.payFeeOrderConfirmInfo), {
emulateJSON: true
},
function (json, res) {
let _json = JSON.parse(json)
if (_json.code == 0) {
//查询收据
let _data = _json.data;
$that._closeDoPayFeeModal();
vc.emit('payFeeOrderResult', '_loadReceipt', _data)
return;
} else {
if ($that.payFeeOrderConfirmInfo.preCheck==true){
if (_json.msg == "预检完成,可正常缴费") {
$that.payFeeOrderConfirmInfo.preCheck = false;
}else{
$that.payFeeOrderInfo.ABAQRCode = _json.msg;
}
}
vc.toast(_json.msg);
}
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
}
);
},
//查询收据
}
});
})(window.vc);