优化代码

This commit is contained in:
java110 2020-10-18 18:46:29 +08:00
parent e15bcdfb40
commit 27edc8e081
2 changed files with 51 additions and 47 deletions

View File

@ -109,7 +109,10 @@
// pages/payParkingFee/payParkingFee.js // pages/payParkingFee/payParkingFee.js
const context = require("../../context/Java110Context.js"); const context = require("../../context/Java110Context.js");
const constant = context.constant; const constant = context.constant;
import {addMonth,formatDate} from '../../utils/DateUtil.js' import {
addMonth,
formatDate
} from '../../utils/DateUtil.js'
// #ifdef H5 // #ifdef H5
@ -130,16 +133,16 @@
amount: 0, amount: 0,
receivableAmount: 0.00, receivableAmount: 0.00,
additionalAmount: 0, additionalAmount: 0,
num:'', num: '',
feeTypeCdName:'', feeTypeCdName: '',
carNum:'', carNum: '',
feePrice: 0.00, feePrice: 0.00,
communityId: '', communityId: '',
communityName: '', communityName: '',
feeId: '', feeId: '',
appId:'', appId: '',
feeFlag:'', feeFlag: '',
paymentCycle:1, paymentCycle: 1,
}; };
}, },
@ -161,7 +164,7 @@
let _communityInfo = context.getCurrentCommunity(); let _communityInfo = context.getCurrentCommunity();
let _lastDate = new Date(_fee.endTime); let _lastDate = new Date(_fee.endTime);
let _endTime = addMonth(_lastDate, this.feeMonth);
this.receivableAmount = _receivableAmount; this.receivableAmount = _receivableAmount;
this.communityId = _communityInfo.communityId; this.communityId = _communityInfo.communityId;
@ -171,10 +174,10 @@
this.carNum = _fee.carNum; this.carNum = _fee.carNum;
this.feeId = _fee.feeId; this.feeId = _fee.feeId;
this.feePrice = _fee.feePrice; this.feePrice = _fee.feePrice;
this.endTime = formatDate(_endTime);
this.ordEndTime = _fee.endTime; this.ordEndTime = _fee.endTime;
this.feeFlag = _fee.feeFlag; this.feeFlag = _fee.feeFlag;
if(this.feeFlag == '2006012'){ if (this.feeFlag == '2006012') {
return; return;
} }
this.paymentCycle = _fee.paymentCycle; this.paymentCycle = _fee.paymentCycle;
@ -183,7 +186,8 @@
this.feeMonthList.push(_index * this.paymentCycle + '个月') this.feeMonthList.push(_index * this.paymentCycle + '个月')
} }
this.feeMonthName = this.paymentCycle + '个月'; this.feeMonthName = this.paymentCycle + '个月';
let _endTime = addMonth(_lastDate, this.feeMonth);
this.endTime = formatDate(_endTime);
var pages = getCurrentPages(); var pages = getCurrentPages();
var prevPage = pages[pages.length - 2]; // var prevPage = pages[pages.length - 2]; //
//setData() //setData()
@ -200,9 +204,9 @@
console.log("onConfirm", e); console.log("onConfirm", e);
let _feeMonthName = null; let _feeMonthName = null;
_feeMonthName = this.feeMonthList[e.detail.value]; _feeMonthName = this.feeMonthList[e.detail.value];
let _feeMonth = _feeMonthName.replace("个月","");; let _feeMonth = _feeMonthName.replace("个月", "");;
let _receivableAmount = _feeMonth * this.feePrice ; let _receivableAmount = _feeMonth * this.feePrice;
let _lastDate = new Date(this.ordEndTime); let _lastDate = new Date(this.ordEndTime);
let _newDate = addMonth(_lastDate, _feeMonth); let _newDate = addMonth(_lastDate, _feeMonth);
@ -216,8 +220,8 @@
onFeeMonthCancel: function(e) { onFeeMonthCancel: function(e) {
this.showFeeMonth = false; this.showFeeMonth = false;
}, },
_payWxApp:function(_data){ _payWxApp: function(_data) {
let _receivedAmount = this.receivableAmount ; let _receivedAmount = this.receivableAmount;
wx.showLoading({ wx.showLoading({
title: '支付中' title: '支付中'
}); });
@ -228,7 +232,7 @@
feeId: this.feeId, feeId: this.feeId,
feeName: '停车费', feeName: '停车费',
receivedAmount: _receivedAmount, receivedAmount: _receivedAmount,
tradeType:_tradeType, tradeType: _tradeType,
appId: this.appId appId: this.appId
}; };
context.request({ context.request({
@ -255,14 +259,14 @@
uni.requestPayment({ uni.requestPayment({
provider: 'wxpay', provider: 'wxpay',
orderInfo: orderInfo, // orderInfo: orderInfo, //
success: function (res) { success: function(res) {
uni.showToast({ uni.showToast({
title: "支付成功", title: "支付成功",
duration: 2000 duration: 2000
}); });
uni.navigateBack({}); uni.navigateBack({});
}, },
fail: function (err) { fail: function(err) {
console.log('fail:' + JSON.stringify(err)); console.log('fail:' + JSON.stringify(err));
} }
}); });
@ -299,7 +303,7 @@
feeId: this.feeId, feeId: this.feeId,
feeName: '停车费', feeName: '停车费',
receivedAmount: _receivedAmount, receivedAmount: _receivedAmount,
tradeType:_tradeType, tradeType: _tradeType,
appId: this.appId appId: this.appId
} }
@ -332,7 +336,7 @@
}); });
// #endif // #endif
// #ifdef H5 // #ifdef H5
WexinPayFactory.wexinPay(data,function(){ WexinPayFactory.wexinPay(data, function() {
uni.showToast({ uni.showToast({
title: "支付成功", title: "支付成功",
duration: 2000 duration: 2000

View File

@ -184,7 +184,6 @@
let _receivableAmount = (_fee.paymentCycle * _amount).toFixed(2); let _receivableAmount = (_fee.paymentCycle * _amount).toFixed(2);
let _communityInfo = context.getCurrentCommunity(); let _communityInfo = context.getCurrentCommunity();
let _lastDate = new Date(_fee.endTime); let _lastDate = new Date(_fee.endTime);
let _endTime = addMonth(_lastDate, this.feeMonth);
this.receivableAmount = _receivableAmount; this.receivableAmount = _receivableAmount;
this.communityId = _communityInfo.communityId; this.communityId = _communityInfo.communityId;
this.communityName = _communityInfo.communityName; this.communityName = _communityInfo.communityName;
@ -196,7 +195,6 @@
this.feeId = _fee.feeId; this.feeId = _fee.feeId;
this.amount = _amount; this.amount = _amount;
this.additionalAmount = _fee.additionalAmount; this.additionalAmount = _fee.additionalAmount;
this.endTime = formatDate(_endTime);
this.ordEndTime = _fee.endTime; this.ordEndTime = _fee.endTime;
this.feeFlag = _fee.feeFlag; this.feeFlag = _fee.feeFlag;
if(this.feeFlag == '2006012'){ if(this.feeFlag == '2006012'){
@ -208,6 +206,8 @@
} }
this.feeMonthName = this.paymentCycle + '个月'; this.feeMonthName = this.paymentCycle + '个月';
this.feeMonth = this.paymentCycle; this.feeMonth = this.paymentCycle;
let _endTime = addMonth(_lastDate, this.feeMonth);
this.endTime = formatDate(_endTime);
}, },
methods: { methods: {
dateChange: function(e) { dateChange: function(e) {