yuminge-app/yun-min-program-plugin-master/packageE/components/good-cell/good-cell.js

46 lines
1.1 KiB
JavaScript

// packageE/components/good-cell/good-cell.js
Component({
/**
* 组件的属性列表
*/
properties: {
item:{
type:Object,
value:{}
},
index:{
type:Number,
value: null
}
},
/**
* 组件的初始数据
*/
data: {
cartTotal: null,
timer: null
},
/**
* 组件的方法列表
*/
methods: {
showGoodDetail() {
this.triggerEvent("show", { id: this.data.item.id, index: this.data.index });
},
addCart() {
if (this.data.timer) clearTimeout(this.data.timer); //防抖
this.data.timer = setTimeout(() => {
this.triggerEvent("add", { id: this.data.item.id, isSpecs: this.data.item.has_option, index: this.data.index });
}, 500);
},
onchange(event) {
if (this.data.timer) clearTimeout(this.data.timer); //防抖
this.data.timer = setTimeout(() => {
this.triggerEvent("change", { id: this.data.item.id, isSpecs: this.data.item.has_option, index: this.data.index, num: event.detail, cartId: this.data.item.card_id });
}, 500);
}
}
});