|
|
@@ -10,7 +10,7 @@
|
|
|
</view>
|
|
|
<view class="row">
|
|
|
<text class="label">餐盒价格</text>
|
|
|
- <input class="input" v-model="form.price" type="digit" placeholder="请输入金额 元" placeholder-class="ph" />
|
|
|
+ <input class="input" v-model="form.price" type="digit" placeholder="请输入金额 元" placeholder-class="ph" @blur="onPriceBlur" />
|
|
|
</view>
|
|
|
<view class="row link" @click="goBind">
|
|
|
<text class="label">已绑商品</text>
|
|
|
@@ -68,6 +68,10 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ onPriceBlur(event) {
|
|
|
+ const value = String((event.detail && event.detail.value) || '');
|
|
|
+ this.form.price = value.replace(/-/g, '');
|
|
|
+ },
|
|
|
/** 供绑定页回写选中商品 */
|
|
|
applyBindIds(ids) {
|
|
|
this.form.bindIds = ids || [];
|
|
|
@@ -161,12 +165,17 @@ export default {
|
|
|
uni.showToast({ title: '请输入餐盒名称', icon: 'none' });
|
|
|
return;
|
|
|
}
|
|
|
+ const boxPrice = Number(this.form.price || 0);
|
|
|
+ if (!Number.isFinite(boxPrice) || boxPrice < 0) {
|
|
|
+ uni.showToast({ title: '餐盒价格不能为负数', icon: 'none' });
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (this.saving) return;
|
|
|
this.saving = true;
|
|
|
const packageIds = this.form.bindIds || [];
|
|
|
const base = {
|
|
|
boxName: this.form.name,
|
|
|
- boxPrice: Number(this.form.price || 0),
|
|
|
+ boxPrice,
|
|
|
boxImage: this.form.image || '',
|
|
|
status: this.form.status != null ? this.form.status : 1,
|
|
|
sort: this.form.sort || 0
|