deguodaigou/components/shopping/shoppingitem/shoppingitem.js
2020-01-02 18:21:37 +08:00

71 lines
1.7 KiB
JavaScript

// 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,
oprice:String
},
/**
* 组件的初始数据
*/
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)=>{
this.triggerEvent('gai', {id:this.data.gid,num:this.data.num})
})
}
},
add() {
this.setData({
num: this.data.num + 1
})
request({
url:"Cart/updateNum",
urldata:{
id:this.data.gid,
num:this.data.num
}
}).then((res)=>{
this.triggerEvent('gai', {id:this.data.gid,num:this.data.num})
})
},
sel(){
this.triggerEvent('sel', {index:this.data.index,select:this.data.select})
}
}
})