2019-12-13 11:59:11 +08:00
|
|
|
// components/shopping/shoppingitem/shoppingitem.js
|
2019-12-19 15:59:01 +08:00
|
|
|
import {request} from "../../../utils/bin"
|
2019-12-13 11:59:11 +08:00
|
|
|
Component({
|
|
|
|
/**
|
|
|
|
* 组件的属性列表
|
|
|
|
*/
|
|
|
|
properties: {
|
2019-12-19 15:27:30 +08:00
|
|
|
shopname: String,
|
2019-12-13 11:59:11 +08:00
|
|
|
shopdesc: String,
|
|
|
|
price: Number,
|
2019-12-19 15:59:01 +08:00
|
|
|
pic: String,
|
|
|
|
gid:Number,
|
2019-12-20 09:51:28 +08:00
|
|
|
num:Number,
|
|
|
|
select:Boolean,
|
|
|
|
index:Number
|
2019-12-13 11:59:11 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 组件的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
2019-12-19 15:59:01 +08:00
|
|
|
|
2019-12-13 11:59:11 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 组件的方法列表
|
|
|
|
*/
|
|
|
|
methods: {
|
2019-12-17 09:54:17 +08:00
|
|
|
rm() {
|
2019-12-19 17:22:23 +08:00
|
|
|
|
2019-12-17 09:54:17 +08:00
|
|
|
if (this.data.num == 0) {
|
2019-12-19 17:22:23 +08:00
|
|
|
|
2019-12-17 09:54:17 +08:00
|
|
|
return
|
|
|
|
} else {
|
2019-12-19 17:22:23 +08:00
|
|
|
this.setData({
|
|
|
|
num: this.data.num - 1
|
|
|
|
})
|
2019-12-19 15:59:01 +08:00
|
|
|
request({
|
|
|
|
url:"Cart/updateNum",
|
|
|
|
urldata:{
|
|
|
|
id:this.data.gid,
|
|
|
|
num:this.data.num - 1
|
|
|
|
}
|
|
|
|
}).then((res)=>{
|
2019-12-19 17:22:23 +08:00
|
|
|
|
2019-12-17 09:54:17 +08:00
|
|
|
})
|
2019-12-19 15:59:01 +08:00
|
|
|
|
2019-12-17 09:54:17 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
add() {
|
2019-12-19 17:22:23 +08:00
|
|
|
this.setData({
|
|
|
|
num: this.data.num + 1
|
|
|
|
})
|
2019-12-19 15:59:01 +08:00
|
|
|
request({
|
|
|
|
url:"Cart/updateNum",
|
|
|
|
urldata:{
|
|
|
|
id:this.data.gid,
|
|
|
|
num:this.data.num + 1
|
|
|
|
}
|
|
|
|
}).then((res)=>{
|
2019-12-19 17:22:23 +08:00
|
|
|
|
2019-12-17 09:54:17 +08:00
|
|
|
})
|
2019-12-20 09:51:28 +08:00
|
|
|
},
|
|
|
|
sel(){
|
|
|
|
this.triggerEvent('sel', {index:this.data.index,select:this.data.select})
|
2019-12-17 09:54:17 +08:00
|
|
|
}
|
2019-12-13 11:59:11 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
})
|