|
@@ -76,17 +76,29 @@ Component({
|
|
|
} = e.currentTarget.dataset;
|
|
|
wx.hideToast()
|
|
|
item.tips = '';
|
|
|
- item.value = (e.detail.value - 0).toFixed(item.decimalplaces);
|
|
|
- if (item.value > item.max) item.tips = `自定义${item.label}超出可选范围!`;
|
|
|
+ item.value = e.detail.value;
|
|
|
+ if (item.decimalplaces && item.value.includes(".") && item.value.split(".")[1].length > item.decimalplaces) item.tips = `自定义${item.label}仅允许${item.decimalplaces}位小数!`
|
|
|
+ if (item.value > item.max) {
|
|
|
+ item.tips = `自定义${item.label}超出可选范围!`
|
|
|
+ wx.showToast({
|
|
|
+ title: item.tips,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ }
|
|
|
if (item.value < item.min) item.tips = `自定义${item.label}少于可选范围!`;
|
|
|
+ this.setData({
|
|
|
+ [`list[${index}]`]: item
|
|
|
+ })
|
|
|
+ },
|
|
|
+ valueBlur(e) {
|
|
|
+ const {
|
|
|
+ index,
|
|
|
+ item
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
if (item.tips) wx.showToast({
|
|
|
title: item.tips,
|
|
|
icon: "none"
|
|
|
})
|
|
|
-
|
|
|
- this.setData({
|
|
|
- [`list[${index}]`]: item
|
|
|
- })
|
|
|
}
|
|
|
}
|
|
|
})
|