|
|
|
@ -65,7 +65,7 @@ |
|
|
|
|
<view class="width90 mart15 font16 fcor666">加油金额</view> |
|
|
|
|
<view class="width90 height40 mart10" style="border: 1px solid #f2f2f2;"> |
|
|
|
|
<view class="width8 flleft">¥</view> |
|
|
|
|
<input type="digit" class="font16 width60 flleft height40" placeholder="输入金额(保留1位小数)" v-model="inputMoney" |
|
|
|
|
<input type="digit" class="font16 width60 flleft height40" placeholder="输入金额(保留2位小数)" v-model="inputMoney" |
|
|
|
|
@blur="Listeningfocus" /> |
|
|
|
|
<view class="width30 height40 flright font14 fcor999 fotct" |
|
|
|
|
style="border-left: 1px solid #f2f2f2;line-height: 40px;"> |
|
|
|
@ -302,7 +302,7 @@ |
|
|
|
|
select(amount) { |
|
|
|
|
this.inputMoney = amount.price; |
|
|
|
|
this.litre = parseFloat(amount.price / this.priceGun).toFixed(2); |
|
|
|
|
this.totalPrice = parseFloat(amount.price / this.priceGun * this.priceVip).toFixed(1); |
|
|
|
|
this.totalPrice = parseFloat(amount.price / this.priceGun * this.priceVip).toFixed(2); |
|
|
|
|
if (this.priceVip != this.priceGun) { |
|
|
|
|
let gbprice = parseFloat(this.litre * this.priceOfficial).toFixed(2); |
|
|
|
|
this.discountPrice = parseFloat(gbprice - this.inputMoney).toFixed(2); |
|
|
|
@ -318,8 +318,8 @@ |
|
|
|
|
Listeningfocus() { |
|
|
|
|
var a = /^[0-9]+(\.[0-9]{1})?$/; |
|
|
|
|
var b = /^[0-9]+(.[0-9]{1})?$/; |
|
|
|
|
if (this.inputMoney == '' || this.inputMoney < 10 || !(b.test(this.inputMoney)) || !(a.test(this |
|
|
|
|
.inputMoney))) { |
|
|
|
|
var c = /^([1-9][0-9]*)+(\.[0-9]{1,2})?$/; |
|
|
|
|
if (this.inputMoney == '' || this.inputMoney < 10 || !(c.test(this.inputMoney))) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '请输入正确加油金额', |
|
|
|
|
icon: "none", |
|
|
|
@ -328,6 +328,7 @@ |
|
|
|
|
this.totalPrice = '0.00'; |
|
|
|
|
this.discountPrice = '0.00'; |
|
|
|
|
this.litre = ''; |
|
|
|
|
this.inputMoney = ''; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -340,24 +341,24 @@ |
|
|
|
|
// }); |
|
|
|
|
// return; |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.inputMoney > this.xzMoney) { |
|
|
|
|
if (parseInt(this.inputMoney) > parseInt(this.xzMoney)) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '加油金额不能超过' + this.xzMoney + '元', |
|
|
|
|
icon: "none", |
|
|
|
|
duration: 2000 |
|
|
|
|
}); |
|
|
|
|
this.inputMoney = this.xzMoney; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//原来计算方式 |
|
|
|
|
this.litre = parseFloat(this.inputMoney / this.priceOfficial).toFixed(2); |
|
|
|
|
this.totalPrice = parseFloat(this.inputMoney / this.priceOfficial * this.priceVip).toFixed(1); |
|
|
|
|
var arr1 = parseFloat(this.inputMoney / this.priceOfficial * this.priceVip).toFixed(4); |
|
|
|
|
this.totalPrice = this.numFilter(arr1); |
|
|
|
|
if (this.priceVip != this.priceOfficial) { |
|
|
|
|
let gbprice = parseFloat(this.litre * this.priceOfficial).toFixed(2); |
|
|
|
|
this.discountPrice = parseFloat(gbprice - this.totalPrice).toFixed(1); |
|
|
|
|
// let gbprice = parseFloat(this.litre * this.priceOfficial).toFixed(2); |
|
|
|
|
// this.discountPrice = parseFloat(gbprice - this.totalPrice).toFixed(2); |
|
|
|
|
this.discountPrice = parseFloat(this.inputMoney - this.totalPrice).toFixed(2); |
|
|
|
|
} |
|
|
|
|
//目前计算方式 |
|
|
|
|
// this.litre = parseFloat(this.inputMoney / this.priceGun).toFixed(2); |
|
|
|
@ -373,6 +374,13 @@ |
|
|
|
|
url: '../../userLogin/userLogin' |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 保留小数点后两位的,不会四舍五入 |
|
|
|
|
numFilter(tempVal) { |
|
|
|
|
// 截取当前数据到小数点后三位 |
|
|
|
|
// let tempVal = parseFloat(value).toFixed(3) |
|
|
|
|
let realVal = tempVal.substring(0, tempVal.length - 2) |
|
|
|
|
return realVal |
|
|
|
|
}, |
|
|
|
|
/** |
|
|
|
|
* 定位 |
|
|
|
|
*/ |
|
|
|
|