
<view class="cart-list" >
<view class="content" wx:for="{{goods}}" id="{{index}}" data-dish="{{item.id}}" style="display:flex;flex-direction:row">
<view style="width:10%" catchtap="selectState" id="{{index}}"><icon type="success" color="#FF6537" style="margin-top:33px;"></icon></view>
<view style="width:35%"><image src="{{item.imgUrl}}" style="width:90px;height:88px;border:1px solid #ccc"></image></view>
<view style="display:flex;flex-direction:column;width:55%">
<view class="goods-text" style="">
<text class="goods-name">{{item.name}}</text>
<text class="goods-price">{{item.price}}</text>
</view>
<view class="goods-info">{{item.pz}}</view>
<view style="display:flex;flex-direction:row;justify-content: space-between;">
<view class="" style="display:flex;flex-direction:row;border:1px solid #ccc;margin-top:16px;width:70%">
<view class="des">-</view>
<view class="numInput" style=""><input type="text" value="1" style="width:40px;height:30px"/></view>
<view class="add">+</view>
</view>
<view class="remove" style=""><image src="{{item.delImg}}" style="28px;height:32px;"></image></view>
</view>
</view>
</view>
</view>
<loading hidden="{{hiddening}}">加载中..</loading>
|
.cart-list{
margin-top: 10px;
}
.content{
border-bottom: dotted 1px #cccccc;
padding:12px 12px 8px 12px;
}
.goods-text{
display:flex;
flex-direction:row;
justify-content: space-between;
margin-bottom: 5px;
}
.goods-name{
font-size:14px;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 20px;
overflow: hidden;
}
.goods-price{
font-size: 14px;
color:#FF6537;
}
.des{
width:40px;
height:50x;
font-size: 20px;
text-align: center;
}
.add{
width:40px;
height:50x;
font-size: 20px;
text-align: center;
}
.numInput{
width:40px;
box-sizing: border-box;
text-align:center;
border-left:1px solid #ccc;
border-right: 1px solid #ccc;
}
.remove{
display:flex;
flex-direction:row;
width:30%;
margin-top:16px
}
|
Page({
data:{
hiddening:false,
goods:[
{"name":"青菜","pz":"品种:小青菜 产地:四川","imgUrl":"../../image/dining-1-2.jpg","price":"¥8.90","imgSelected":"../../image/s2.png","delImg":"../../image/icon-delete.png"},
{"name":"羊肉","pz":"品种:肥羊卷 产地:澳洲","imgUrl":"../../image/dining-18-2.jpg","price":"¥8.90","imgSelected":"../../image/s2.png","delImg":"../../image/icon-delete.png"},
{"name":"猕猴桃","pz":"品种:黄心猕猴桃 产地:海南","imgUrl":"../../image/imported-14-1.jpg","price":"¥8.90","imgSelected":"../../image/s2.png","delImg":"../../image/icon-delete.png"},
{"name":"红牛","pz":"品种:红牛 产地:中国","imgUrl":"../../image/drank-4.jpg","price":"¥8.90","imgSelected":"../../image/s2.png","delImg":"../../image/icon-delete.png"},
{"name":"腰果","pz":"品种:丹迪腰果 产地:海南","imgUrl":"../../image/local-2-1.jpg","price":"¥8.90","imgSelected":"../../image/s2.png","delImg":"../../image/icon-delete.png"},
{"name":"腰果","pz":"品种:丹迪腰果 产地:海南","imgUrl":"../../image/imported-12.jpg","price":"¥8.90","imgSelected":"../../image/s2.png","delImg":"../../image/icon-delete.png"},
{"name":"腰果","pz":"品种:丹迪腰果 产地:海南","imgUrl":"../../image/imported-18.jpg","price":"¥8.90","imgSelected":"../../image/s2.png","delImg":"../../image/icon-delete.png"},
{"name":"腰果","pz":"品种:丹迪腰果 产地:海南","imgUrl":"../../image/tea-11.png","price":"¥8.90","imgSelected":"../../image/s2.png","delImg":"../../image/icon-delete.png"},
{"name":"腰果","pz":"品种:丹迪腰果 产地:海南","imgUrl":"../../image/tea-13-1.jpg","price":"¥8.90","imgSelected":"../../image/s2.png","delImg":"../../image/icon-delete.png"},
{"name":"腰果","pz":"品种:丹迪腰果 产地:海南","imgUrl":"../../image/tea-17.jpg","price":"¥8.90","imgSelected":"../../image/s2.png","delImg":"../../image/icon-delete.png"},
{"name":"腰果","pz":"品种:丹迪腰果 产地:海南","imgUrl":"../../image/tea-19.jpg","price":"¥8.90","imgSelected":"../../image/s2.png","delImg":"../../image/icon-delete.png"}]
},
selectState(e){
let dish=e.currentTarget.dataset.dish;
this.setStatus(dish)
},
setStatus(dishId){
let dishes = this.data.goods;
for (let dish of dishes){
dish.forEach((item) => {
if(item.id == dishId){
item.status = !item.status || false
}
})
}
},
onLoad:function(options){
// 页面初始化 options为页面跳转所带来的参数
},
onReady:function(){
// 页面渲染完成
var that=this;
setTimeout(function(){
that.setData({
hiddening:true
})
},2000)
},
onShow:function(){
// 页面显示
},
onHide:function(){
// 页面隐藏
},
onUnload:function(){
// 页面关闭
}
})
|
模板简介:该模板名称为【微信小程序生食品类简洁购物车样式模板制作设计下载】,大小是,文档格式为.,推荐使用打开,作品中的图片,文字等数据均可修改,图片请在作品中选中图片替换即可,文字修改直接点击文字修改即可,您也可以新增或修改作品中的内容,该模板来自用户分享,如有侵权行为请联系网站客服处理。欢迎来懒人模板【小程序教程】栏目查找您需要的精美模板。