优化代码

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

View File

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