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

View File

@ -1,6 +1,6 @@
<view class="shopping"> <view class="shopping">
<view class="item" wx:for="{{list}}" wx:for-index="j" wx:key="{{j}}"> <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>
<!-- <view class="item"> <!-- <view class="item">
<shopping-item shopname="J`adore - Dior" shopdesc="30支 1.30kg" price="61.78"></shopping-item> <shopping-item shopname="J`adore - Dior" shopdesc="30支 1.30kg" price="61.78"></shopping-item>