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)=>{
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
add() {
|
|
|
|
this.setData({
|
|
|
|
num: this.data.num + 1
|
|
|
|
})
|
|
|
|
request({
|
|
|
|
url:"Cart/updateNum",
|
|
|
|
urldata:{
|
|
|
|
id:this.data.gid,
|
|
|
|
num:this.data.num
|
|
|
|
}
|
|
|
|
}).then((res)=>{
|
|
|
|
|
|
|
|
})
|
|
|
|
},
|
|
|
|
sel(){
|
|
|
|
this.triggerEvent('sel', {index:this.data.index,select:this.data.select})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-12-13 11:59:11 +08:00
|
|
|
})
|