deguodaigou/components/shopping/shoppingitem/shoppingitem.js

70 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-12-23 10:04:09 +08:00
// components/shopping/shoppingitem/shoppingitem.js
import {request} from "../../../utils/bin"
Component({
/**
* 组件的属性列表
*/
properties: {
shopname: String,
shopdesc: String,
price: Number,
pic: String,
gid:Number,
num:Number,
select:Boolean,
index:Number
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
rm() {
if (this.data.num < 2) {
return
} else {
this.setData({
num: this.data.num - 1
})
request({
url:"Cart/updateNum",
urldata:{
id:this.data.gid,
num:this.data.num
}
}).then((res)=>{
2019-12-24 16:32:27 +08:00
this.triggerEvent('gai', {id:this.data.gid,num:this.data.num})
2019-12-23 10:04:09 +08:00
})
}
},
add() {
this.setData({
num: this.data.num + 1
})
request({
url:"Cart/updateNum",
urldata:{
id:this.data.gid,
num:this.data.num
}
}).then((res)=>{
2019-12-24 16:32:27 +08:00
this.triggerEvent('gai', {id:this.data.gid,num:this.data.num})
2019-12-23 10:04:09 +08:00
})
},
sel(){
this.triggerEvent('sel', {index:this.data.index,select:this.data.select})
}
}
2019-12-13 11:59:11 +08:00
})