|
@@ -7,16 +7,16 @@
|
|
|
<view class="pay-top">
|
|
|
<view class="pay-paid">
|
|
|
<text class="txt-m">待付金额</text>
|
|
|
- <text class="txt-b"><text class="small">¥</text>{{payableAmount.toFixed(2)}}</text>
|
|
|
+ <text class="txt-b"><text class="small">¥</text>{{payableAmount|NumFormat}}</text>
|
|
|
</view>
|
|
|
<view class="pay-payd">
|
|
|
<view class="pay-paids">
|
|
|
<text class="txt-m">应付总额</text>
|
|
|
- <text class="txt-b">¥{{payTotalFee.toFixed(2)}}</text>
|
|
|
+ <text class="txt-b">¥{{payTotalFee|NumFormat}}</text>
|
|
|
</view>
|
|
|
<view class="pay-paids">
|
|
|
<text class="txt-m">已支付金额</text>
|
|
|
- <text class="txt-b">¥{{receiptAmount.toFixed(2)}}</text>
|
|
|
+ <text class="txt-b">¥{{receiptAmount|NumFormat}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -37,7 +37,7 @@
|
|
|
placeholder-class="placeholder"/>
|
|
|
</view>
|
|
|
<view class="bot-resid">
|
|
|
- <text>应付剩余¥{{balanceAmount.toFixed(2)}}</text>
|
|
|
+ <text>应付剩余¥{{balanceAmount|NumFormat}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -46,7 +46,7 @@
|
|
|
<view class="record-list">
|
|
|
<view class="list-main" v-if="discernReceipt.length>0">
|
|
|
<view class="list-item" v-for="(item,index) in discernReceipt" :key="index">
|
|
|
- <text class="text row-1">¥{{toFixedFn(item.receiptAmount)}}</text>
|
|
|
+ <text class="text row-1">¥{{item.receiptAmount | NumFormat}}</text>
|
|
|
<text class="text row-2">{{payTypeText(item.payType)}}</text>
|
|
|
<text class="text row-3">{{item.receiptDate}}</text>
|
|
|
</view>
|
|
@@ -126,6 +126,28 @@
|
|
|
onLoad(option) {
|
|
|
this.initData(option)
|
|
|
},
|
|
|
+ filters: {
|
|
|
+ NumFormat(value) {
|
|
|
+ if(!value) return '0.00';
|
|
|
+ /*原来用的是Number(value).toFixed(0),这样取整时有问题,例如0.51取整之后为1,感谢Nils指正*/
|
|
|
+ /*后来改成了 Number(value)|0,但是输入超过十一位就为负数了,具体见评论 */
|
|
|
+ var intPart = Number(value) - Number(value)%1; //获取整数部分(这里是windy93的方法)
|
|
|
+ var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); //将整数部分逢三一断
|
|
|
+ var floatPart = ".00"; //预定义小数部分
|
|
|
+ var value2Array = value.toString().split(".");
|
|
|
+ //=2表示数据有小数位
|
|
|
+ if(value2Array.length == 2) {
|
|
|
+ floatPart = value2Array[1].toString(); //拿到小数部分
|
|
|
+ if(floatPart.length == 1) { //补0,实际上用不着
|
|
|
+ return intPartFormat + "." + floatPart + '0';
|
|
|
+ } else {
|
|
|
+ return intPartFormat + "." + floatPart;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return intPartFormat + floatPart;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
methods:{
|
|
|
initData(e){
|
|
|
this.payType = e.type
|
|
@@ -149,9 +171,9 @@
|
|
|
this.discernReceipt = response.data.discernReceipt //支付记录
|
|
|
this.payTotalFee = response.data.order.payTotalFee //已付金额
|
|
|
this.receiptAmount = response.data.order.receiptAmount //已付金额
|
|
|
- this.payableAmount = response.data.order.payableAmount - this.receiptAmount //待付金额
|
|
|
- this.payAmount = this.payableAmount.toFixed(2) //自定义金额
|
|
|
- this.balanceAmount = this.payableAmount - this.payAmount// 计算剩余支付金额
|
|
|
+ this.payableAmount = (response.data.order.payableAmount - this.receiptAmount).toFixed(2)//待付金额
|
|
|
+ this.payAmount = this.payableAmount //自定义金额
|
|
|
+ this.balanceAmount = (this.payableAmount - this.payAmount).toFixed(2)// 计算剩余支付金额
|
|
|
}).catch(error =>{
|
|
|
this.$util.msg(error.msg,2000)
|
|
|
})
|
|
@@ -212,7 +234,7 @@
|
|
|
wx.reLaunch({url: '/pages/tabBar/user/user'});
|
|
|
},
|
|
|
'fail':function(res){
|
|
|
- self.$util.msg('微信调用支付失败,请重新发起支付~')
|
|
|
+ self.$util.msg('用户取消支付~')
|
|
|
},
|
|
|
'complete':function(res){
|
|
|
|
|
@@ -240,9 +262,9 @@
|
|
|
if(value == "" || value <0 ){
|
|
|
this.payAmount = '';
|
|
|
this.balanceAmount = this.payableAmount;
|
|
|
- }else if(parseInt(value)>this.payableAmount){
|
|
|
+ }else if( value >this.payableAmount){
|
|
|
this.payAmount = this.payableAmount.toFixed(2)
|
|
|
- this.balanceAmount = this.payableAmount - this.payAmount
|
|
|
+ this.balanceAmount = (this.payableAmount - this.payAmount).toFixed(2)
|
|
|
}else{
|
|
|
this.payAmount =Number(value).toFixed(2)
|
|
|
this.balanceAmount = this.payableAmount - this.payAmount
|
|
@@ -280,6 +302,9 @@
|
|
|
if (res) {
|
|
|
this.isShowTip = false;
|
|
|
this.$util.msg("复制成功",2000,true,'success');
|
|
|
+ setTimeout(()=>{
|
|
|
+ this.$api.navigateTo(`/pages/user/order/order-details?state=0&orderID=${this.orderID}`)
|
|
|
+ },2000)
|
|
|
} else {
|
|
|
this.$util.msg("复制失败",2000,true,'none');
|
|
|
}
|