修改本地生活 付款只能输入大于0的数字,且保留两位小数

This commit is contained in:
赵毅 2025-08-07 18:16:13 +08:00
parent fc9e6b2ff7
commit 29b21d9e53

View File

@ -18,8 +18,8 @@
<div class="Msg"> <div class="Msg">
<div class="payMony"> <div class="payMony">
<input type="text" v-model="Money" placeholder="付款金额" placeholder-style="font-size: 50rpx;"> <input type="number" v-model="Money" placeholder="付款金额" placeholder-style="font-size: 50rpx;"
</div> @blur="handleMoneyInput" step="0.01" min="0.01"> </div>
<div class="payRemark"> <div class="payRemark">
<input type="text" v-model="remarks" placeholder="付款备注"> <input type="text" v-model="remarks" placeholder="付款备注">
</div> </div>
@ -62,7 +62,8 @@
<div class="line"></div> <div class="line"></div>
<div class="btnItem" @click="home">首页</div> <div class="btnItem" @click="home">首页</div>
<div class="btnItem2" @click="changeBoxshadow"> <div class="btnItem2" @click="changeBoxshadow">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/local_qrcode.png" mode="aspectFill"></image> <image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/local_qrcode.png"
mode="aspectFill"></image>
本页二维码 本页二维码
</div> </div>
</div> </div>
@ -135,6 +136,29 @@ export default {
methods: { methods: {
handleMoneyInput() {
//
let value = this.Money.toString().replace(/[^\d.]/g, '');
//
value = value.replace(/\.{2,}/g, '.');
//
value = value.replace(/^(\d+)\.(\d{2}).*$/, '$1.$2');
//
if (value.startsWith('.')) {
value = '0' + value;
}
// 0
const num = parseFloat(value);
if (isNaN(num) || num <= 0) {
value = '';
}
this.Money = value;
},
createQrcode() { createQrcode() {
uni.showLoading({ uni.showLoading({
@ -157,7 +181,7 @@ export default {
}); });
}, },
createQrcode2(e) { createQrcode2(e) {
let that= this let that = this
uni.request({ uni.request({
url: `https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=${e}`, url: `https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=${e}`,
method: 'post', method: 'post',
@ -182,7 +206,7 @@ export default {
} }
}); });
}, },
changeBoxshadow2(){ changeBoxshadow2() {
this.boxShow = !this.boxShow this.boxShow = !this.boxShow
}, },
changeBoxshadow() { changeBoxshadow() {