修改count-modify组件
This commit is contained in:
parent
9a04d366e4
commit
7ce8182b3d
|
@ -6,7 +6,7 @@
|
||||||
<view class="item-container">
|
<view class="item-container">
|
||||||
<view class="thumb-box" v-for="(item, index) in data.child" :key="index">
|
<view class="thumb-box" v-for="(item, index) in data.child" :key="index">
|
||||||
<service-preview-item :data="item" @clickItem="clickItem" />
|
<service-preview-item :data="item" @clickItem="clickItem" />
|
||||||
<widget-count-modify class="component-add" :initNumber="item.buyNumber" />
|
<widget-count-modify class="component-add" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
|
@ -19,29 +19,47 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
initNumber: {
|
min: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
max: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
init: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {},
|
components: {},
|
||||||
created() {
|
created() {
|
||||||
this.number = this.initNumber;
|
this.number = this.init;
|
||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {},
|
||||||
destroyed() {},
|
destroyed() {},
|
||||||
methods: {
|
methods: {
|
||||||
sub() {
|
sub() {
|
||||||
if (this.number > 0) {
|
if (this.number > this.min) {
|
||||||
this.number--;
|
this.number--;
|
||||||
} else {
|
} else {
|
||||||
this.number = 0;
|
this.number = this.min;
|
||||||
}
|
}
|
||||||
this.$emit("change", this.number);
|
this.$emit("change", {
|
||||||
|
type: "sub",
|
||||||
|
value: this.number,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
add() {
|
add() {
|
||||||
this.number++;
|
if (this.max == 0 || this.number < this.max) {
|
||||||
this.$emit("change", this.number);
|
this.number++;
|
||||||
|
} else {
|
||||||
|
this.number = this.max;
|
||||||
|
}
|
||||||
|
this.$emit("change", {
|
||||||
|
type: "add",
|
||||||
|
value: this.number,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
<text>需要师傅数量</text>
|
<text>需要师傅数量</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="input-box">
|
<view class="input-box">
|
||||||
<widget-count-modify :initNumber="number" @change="changeNumber" />
|
<widget-count-modify :min="1" :init="number" @change="changeNumber" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="input-item carry-style">
|
<view class="input-item carry-style">
|
||||||
|
@ -121,8 +121,8 @@ export default {
|
||||||
onReachBottom() {},
|
onReachBottom() {},
|
||||||
onPullDownRefresh() {},
|
onPullDownRefresh() {},
|
||||||
methods: {
|
methods: {
|
||||||
changeNumber(data) {
|
changeNumber(e) {
|
||||||
this.number = data;
|
this.number = e.value;
|
||||||
},
|
},
|
||||||
save() {
|
save() {
|
||||||
console.log("保存");
|
console.log("保存");
|
||||||
|
|
Loading…
Reference in New Issue