分类完善

This commit is contained in:
pplokijuhyg 2019-12-19 17:22:23 +08:00
parent 0c0acf2540
commit edc8983853
9 changed files with 158 additions and 123 deletions

View File

@ -1,12 +1,13 @@
Component({ Component({
properties: { properties: {
list:Array
}, },
data: {}, data: {},
methods: { methods: {
todetail() { todetail(a) {
console.log(a)
wx.navigateTo({ wx.navigateTo({
url: "/pages/product/product" url: "/pages/product/product?shopid=" + a.currentTarget.dataset.id
}) })
} }
} }

View File

@ -1,52 +1,63 @@
.list{ .list {
padding-left: 20rpx; padding-left: 20rpx;
width: 572rpx; width: 572rpx;
box-sizing: border-box; box-sizing: border-box;
height: 100vh; height: 100vh;
.commodity { .commodity {
width: 552rpx; width: 552rpx;
// height: 143rpx; // height: 143rpx;
// margin-top: 32rpx; // margin-top: 32rpx;
display: flex;
align-items: center;
.content {
width: 552rpx;
height: 100%;
display: flex;
align-items: center;
// box-shadow: 0 0 24rpx 0 rgba(227, 227, 227, 0.4);
border-bottom: 2rpx solid #eaeaea;
padding: 30rpx 0;
.imgthumb {
width: 105rpx;
height: 105rpx;
margin-left: 40rpx;
background-color: #333;
}
.introduce {
width: 336rpx;
margin-left: 40rpx;
display: flex; display: flex;
align-items: center; flex-direction: column;
.content { .towline {
width: 552rpx; overflow: hidden;
height: 100%;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
> text {
font-size: 22rpx;
color: #333;
margin-bottom: 22rpx;
}
> view {
display: flex; display: flex;
align-items: center; align-items: center;
// box-shadow: 0 0 24rpx 0 rgba(227, 227, 227, 0.4); justify-content: space-between;
border-bottom: 2rpx solid #eaeaea; > text:first-child {
padding: 30rpx 0; font-size: 30rpx;
.imgthumb { color: #dec499;
width: 105rpx;
height: 105rpx;
margin-left: 40rpx;
background-color: #333;
} }
.introduce { > text:last-child {
width: 336rpx; font-size: 22rpx;
margin-left: 40rpx; color: #999;
display: flex;
flex-direction: column;
> text {
font-size: 22rpx;
color: #333;
margin-bottom: 22rpx;
}
> view {
display: flex;
align-items: center;
justify-content: space-between;
> text:first-child {
font-size: 30rpx;
color: #dec499;
}
> text:last-child {
font-size: 22rpx;
color: #999;
}
}
} }
} }
} }
} }
}
}

View File

@ -1,5 +1,17 @@
<scroll-view class="list" scroll-y="{{true}}" > <scroll-view class="list" scroll-y="{{true}}" >
<view class="commodity" bindtap="todetail"> <view class="commodity" bindtap="todetail" wx:for="{{list}}" wx:for-index="j" wx:key="{{j}}" data-id="{{item.goods_id}}">
<view class="content">
<image class="imgthumb " src="{{item.image}}"></image>
<view class="introduce">
<text class="towline">{{item.goods_name}}</text>
<view>
<text>¥{{item.shop_price}}</text>
<text>加入购物车</text>
</view>
</view>
</view>
</view>
<!-- <view class="commodity" bindtap="todetail">
<view class="content"> <view class="content">
<image class="imgthumb "></image> <image class="imgthumb "></image>
<view class="introduce"> <view class="introduce">
@ -22,17 +34,5 @@
</view> </view>
</view> </view>
</view> </view>
</view> </view> -->
<view class="commodity" bindtap="todetail">
<view class="content">
<image class="imgthumb "></image>
<view class="introduce">
<text>产品名称产品名称产品名称产品名称产品名称产品</text>
<view>
<text>¥657</text>
<text>加入购物车</text>
</view>
</view>
</view>
</view>
</scroll-view> </scroll-view>

View File

@ -1 +1 @@
.list{padding-left:20rpx;width:572rpx;box-sizing:border-box;height:100vh}.list .commodity{width:552rpx;display:flex;align-items:center}.list .commodity .content{width:552rpx;height:100%;display:flex;align-items:center;border-bottom:2rpx solid #eaeaea;padding:30rpx 0}.list .commodity .content .imgthumb{width:105rpx;height:105rpx;margin-left:40rpx;background-color:#333}.list .commodity .content .introduce{width:336rpx;margin-left:40rpx;display:flex;flex-direction:column}.list .commodity .content .introduce>text{font-size:22rpx;color:#333;margin-bottom:22rpx}.list .commodity .content .introduce>view{display:flex;align-items:center;justify-content:space-between}.list .commodity .content .introduce>view>text:first-child{font-size:30rpx;color:#dec499}.list .commodity .content .introduce>view>text:last-child{font-size:22rpx;color:#999} .list{padding-left:20rpx;width:572rpx;box-sizing:border-box;height:100vh}.list .commodity{width:552rpx;display:flex;align-items:center}.list .commodity .content{width:552rpx;height:100%;display:flex;align-items:center;border-bottom:2rpx solid #eaeaea;padding:30rpx 0}.list .commodity .content .imgthumb{width:105rpx;height:105rpx;margin-left:40rpx;background-color:#333}.list .commodity .content .introduce{width:336rpx;margin-left:40rpx;display:flex;flex-direction:column}.list .commodity .content .introduce .towline{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.list .commodity .content .introduce>text{font-size:22rpx;color:#333;margin-bottom:22rpx}.list .commodity .content .introduce>view{display:flex;align-items:center;justify-content:space-between}.list .commodity .content .introduce>view>text:first-child{font-size:30rpx;color:#dec499}.list .commodity .content .introduce>view>text:last-child{font-size:22rpx;color:#999}

View File

@ -12,6 +12,7 @@ Component({
this.setData({ this.setData({
id: a.target.dataset.id id: a.target.dataset.id
}) })
this.triggerEvent("select",{id:a.target.dataset.id})
} }
} }
}) })

View File

@ -1,59 +1,58 @@
.commodity { .commodity {
width: 623rpx; width: 623rpx;
height: 143rpx; height: 143rpx;
margin-top: 32rpx; margin-top: 32rpx;
display: flex;
align-items: center;
.content {
width: 614rpx;
height: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
.content { box-shadow: 0 0 24rpx 0 rgba(227, 227, 227, 0.4);
width: 614rpx; .imgthumb {
height: 100%; width: 105rpx;
height: 105rpx;
margin-left: 40rpx;
background-color: #333;
}
.introduce {
width: 410rpx;
margin-left: 40rpx;
display: flex; display: flex;
align-items: center; flex-direction: column;
box-shadow: 0 0 24rpx 0 rgba(227, 227, 227, 0.4); > text {
.imgthumb { font-size: 26rpx;
width: 105rpx; color: #333;
height: 105rpx; margin-bottom: 22rpx;
margin-left: 40rpx; overflow: hidden;
background-color: #333;
}
.introduce {
width: 410rpx;
margin-left: 40rpx;
display: flex;
flex-direction: column;
> text {
font-size: 26rpx;
color: #333;
margin-bottom: 22rpx;
overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-box; display: -webkit-box;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
}
> view {
display: flex;
align-items: center;
justify-content: space-between;
> text:first-child {
font-size: 30rpx;
color: #dec499;
} }
> view { > text:last-child {
display: flex; font-size: 22rpx;
align-items: center; color: #999;
justify-content: space-between;
> text:first-child {
font-size: 30rpx;
color: #dec499;
}
> text:last-child {
font-size: 22rpx;
color: #999;
}
} }
} }
} }
.decorate { }
width: 9rpx; .decorate {
height: 102rpx; width: 9rpx;
background-color: #3fb66e; height: 102rpx;
} background-color: #3fb66e;
} }
}

View File

@ -25,9 +25,14 @@ Component({
*/ */
methods: { methods: {
rm() { rm() {
if (this.data.num == 0) { if (this.data.num == 0) {
return return
} else { } else {
this.setData({
num: this.data.num - 1
})
request({ request({
url:"Cart/updateNum", url:"Cart/updateNum",
urldata:{ urldata:{
@ -35,14 +40,15 @@ Component({
num:this.data.num - 1 num:this.data.num - 1
} }
}).then((res)=>{ }).then((res)=>{
this.setData({
num: this.data.num - 1
})
}) })
} }
}, },
add() { add() {
this.setData({
num: this.data.num + 1
})
request({ request({
url:"Cart/updateNum", url:"Cart/updateNum",
urldata:{ urldata:{
@ -50,9 +56,7 @@ Component({
num:this.data.num + 1 num:this.data.num + 1
} }
}).then((res)=>{ }).then((res)=>{
this.setData({
num: this.data.num + 1
})
}) })
} }

View File

@ -6,7 +6,8 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
type: [] type: [],
list:[]
}, },
/** /**
@ -23,11 +24,29 @@ Page({
this.setData({ this.setData({
type: res.data.result type: res.data.result
}) })
this.select({detail:{id:res.data.result[0].id}})
console.log(this.data.type, 150) console.log(this.data.type, 150)
}) })
}, },
select(a){
// console.log(a)
// a.detail.id
request({
url:'Goods/goodsList',
urldata:{
id:a.detail.id,
sort:'shop_price',
sort_asc:'desc',
p:0
}
}).then((res)=>{
console.log(res)
this.setData({
list:res.data.result.goods_list
})
})
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */

View File

@ -1,4 +1,4 @@
<view class="box"> <view class="box">
<navigation types="{{type}}"></navigation> <navigation bindselect="select" types="{{type}}"></navigation>
<list ></list> <list list="{{list}}"></list>
</view> </view>