60 lines
1.3 KiB
JavaScript
60 lines
1.3 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
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
rm() {
|
|
if (this.data.num == 0) {
|
|
return
|
|
} else {
|
|
request({
|
|
url:"Cart/updateNum",
|
|
urldata:{
|
|
id:this.data.gid,
|
|
num:this.data.num - 1
|
|
}
|
|
}).then((res)=>{
|
|
this.setData({
|
|
num: this.data.num - 1
|
|
})
|
|
})
|
|
|
|
}
|
|
},
|
|
add() {
|
|
request({
|
|
url:"Cart/updateNum",
|
|
urldata:{
|
|
id:this.data.gid,
|
|
num:this.data.num + 1
|
|
}
|
|
}).then((res)=>{
|
|
this.setData({
|
|
num: this.data.num + 1
|
|
})
|
|
})
|
|
}
|
|
|
|
}
|
|
}) |