pplok #26

Merged
theluyuan merged 5 commits from pplok into master 2019-12-19 16:00:29 +08:00
2 changed files with 27 additions and 8 deletions
Showing only changes of commit 4c489c632b - Show all commits

View File

@ -1,4 +1,5 @@
// components/shopping/shoppingitem/shoppingitem.js
import {request} from "../../../utils/bin"
Component({
/**
* 组件的属性列表
@ -7,14 +8,16 @@ Component({
shopname: String,
shopdesc: String,
price: Number,
pic: String
pic: String,
gid:Number,
num:Number
},
/**
* 组件的初始数据
*/
data: {
num: 5
},
/**
@ -25,15 +28,31 @@ Component({
if (this.data.num == 0) {
return
} else {
this.setData({
num: this.data.num - 1
request({
url:"Cart/updateNum",
urldata:{
id:this.data.gid,
num:this.data.num - 1
}
}).then((res)=>{
this.setData({
num: this.data.num - 1
})
})
}
},
add() {
this.setData({
num: this.data.num + 1
request({
url:"Cart/updateNum",
urldata:{
id:this.data.gid,
num:this.data.num + 1
}
}).then((res)=>{
this.setData({
num: this.data.num + 1
})
})
}

View File

@ -1,6 +1,6 @@
<view class="shopping">
<view class="item" wx:for="{{list}}" wx:for-index="j" wx:key="{{j}}">
<shopping-item shopname="{{item.goods_name}}" shopdesc="{{item.spec_key_name||'默认规格'}}" price="{{item.goods_price}}" pic="{{item.image}}"></shopping-item>
<shopping-item shopname="{{item.goods_name}}" shopdesc="{{item.spec_key_name||'默认规格'}}" price="{{item.goods_price}}" pic="{{item.image}}" num="{{item.goods_num}}" gid="{{item.id}}"></shopping-item>
</view>
<!-- <view class="item">
<shopping-item shopname="J`adore - Dior" shopdesc="30支 1.30kg" price="61.78"></shopping-item>