选择
This commit is contained in:
		
							parent
							
								
									3cf388faed
								
							
						
					
					
						commit
						38280893bd
					
				@ -8,13 +8,15 @@ Page({
 | 
				
			|||||||
    data: {
 | 
					    data: {
 | 
				
			||||||
        list:[],
 | 
					        list:[],
 | 
				
			||||||
        select:[],
 | 
					        select:[],
 | 
				
			||||||
        userid:0
 | 
					        userid:0,
 | 
				
			||||||
 | 
					        price:"0.00"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    sel(a){
 | 
					    sel(a){
 | 
				
			||||||
        console.log(a)
 | 
					        console.log(a)
 | 
				
			||||||
        this.setData({
 | 
					        this.setData({
 | 
				
			||||||
            [`select[${a.detail.index}]`]:!a.detail.select
 | 
					            [`select[${a.detail.index}]`]:!a.detail.select
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
 | 
					        this.num();
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -98,8 +100,52 @@ Page({
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    num(){
 | 
					    num(){
 | 
				
			||||||
 | 
					        let num = 0;
 | 
				
			||||||
 | 
					        let sel = 0;
 | 
				
			||||||
        for(let i in this.data.select){
 | 
					        for(let i in this.data.select){
 | 
				
			||||||
            
 | 
					            console.log(i)
 | 
				
			||||||
 | 
					            if(this.data.select[i]){
 | 
				
			||||||
 | 
					             num += parseFloat(this.data.list[i].goods_price)*100
 | 
				
			||||||
 | 
					             sel++
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if(sel == this.data.list.length){
 | 
				
			||||||
 | 
					            this.setData({
 | 
				
			||||||
 | 
					                all:true
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					        }else{
 | 
				
			||||||
 | 
					            this.setData({
 | 
				
			||||||
 | 
					                all:false
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        this.setData({
 | 
				
			||||||
 | 
					            price:num/100
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    call(){
 | 
				
			||||||
 | 
					        let sel = 0;
 | 
				
			||||||
 | 
					        let select = []
 | 
				
			||||||
 | 
					        for(let i in this.data.list){
 | 
				
			||||||
 | 
					            console.log(i)
 | 
				
			||||||
 | 
					            if(this.data.select[i]){
 | 
				
			||||||
 | 
					            //  num += parseFloat(this.data.list[i].goods_price)*100
 | 
				
			||||||
 | 
					             sel++
 | 
				
			||||||
 | 
					            }else{
 | 
				
			||||||
 | 
					                select[i] = true
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if(sel == this.data.list.length){
 | 
				
			||||||
 | 
					            this.setData({
 | 
				
			||||||
 | 
					                all:false,
 | 
				
			||||||
 | 
					                select:[]
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					        }else{
 | 
				
			||||||
 | 
					            this.setData({
 | 
				
			||||||
 | 
					                all:true,
 | 
				
			||||||
 | 
					                select
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        this.num()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
@ -13,9 +13,9 @@
 | 
				
			|||||||
   </view> -->
 | 
					   </view> -->
 | 
				
			||||||
   <view class="bottom">
 | 
					   <view class="bottom">
 | 
				
			||||||
      <view class="left">
 | 
					      <view class="left">
 | 
				
			||||||
         <view class="select"></view>
 | 
					         <view bind:tap="call" class="select {{all ? 'selects':''}}"></view>
 | 
				
			||||||
         <text class="selectall">全选</text>
 | 
					         <text bind:tap="call" class="selectall">全选</text>
 | 
				
			||||||
         <text class="pri">$0.00</text>
 | 
					         <text class="pri">${{price}}</text>
 | 
				
			||||||
      </view>
 | 
					      </view>
 | 
				
			||||||
      <view class="right">
 | 
					      <view class="right">
 | 
				
			||||||
         <text class="del">删除</text>
 | 
					         <text class="del">删除</text>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,51 +1,54 @@
 | 
				
			|||||||
.shopping{
 | 
					.shopping {
 | 
				
			||||||
    padding-bottom: 128rpx;
 | 
					  padding-bottom: 128rpx;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
.item {
 | 
					.item {
 | 
				
			||||||
        height: 186rpx;
 | 
					  height: 186rpx;
 | 
				
			||||||
        margin-left: 46rpx;
 | 
					  margin-left: 46rpx;
 | 
				
			||||||
        margin-top: 59rpx;
 | 
					  margin-top: 59rpx;
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    .bottom {
 | 
					.bottom {
 | 
				
			||||||
        width: 100%;
 | 
					  width: 100%;
 | 
				
			||||||
        height: 98rpx;
 | 
					  height: 98rpx;
 | 
				
			||||||
        position: fixed;
 | 
					  position: fixed;
 | 
				
			||||||
        bottom: 0;
 | 
					  bottom: 0;
 | 
				
			||||||
        background: linear-gradient(2deg, rgba(250, 250, 250, 0.94), rgba(255, 255, 255, 0.94));
 | 
					  background: linear-gradient(2deg, rgba(250, 250, 250, 0.94), rgba(255, 255, 255, 0.94));
 | 
				
			||||||
        display: flex;
 | 
					  display: flex;
 | 
				
			||||||
        justify-content: space-between;
 | 
					  justify-content: space-between;
 | 
				
			||||||
        font-size: 28rpx;
 | 
					  font-size: 28rpx;
 | 
				
			||||||
        line-height: 98rpx;
 | 
					  line-height: 98rpx;
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    .left {
 | 
					.left {
 | 
				
			||||||
        display: flex;
 | 
					  display: flex;
 | 
				
			||||||
        /* line-height: 26rpx; */
 | 
					  /* line-height: 26rpx; */
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    .select {
 | 
					.select {
 | 
				
			||||||
        width: 26rpx;
 | 
					  width: 26rpx;
 | 
				
			||||||
        height: 26rpx;
 | 
					  height: 26rpx;
 | 
				
			||||||
        background: rgba(234, 234, 234, 1);
 | 
					  background: rgba(234, 234, 234, 1);
 | 
				
			||||||
        border-radius: 50%;
 | 
					  border-radius: 50%;
 | 
				
			||||||
        margin: auto 0;
 | 
					  margin: auto 0;
 | 
				
			||||||
        margin-left: 46rpx;
 | 
					  margin-left: 46rpx;
 | 
				
			||||||
        margin-right: 24rpx;
 | 
					  margin-right: 24rpx;
 | 
				
			||||||
    }
 | 
					}
 | 
				
			||||||
    
 | 
					.selects{
 | 
				
			||||||
    .pri {
 | 
					    background-color: #4cc97d;
 | 
				
			||||||
        color: #E0C79D;
 | 
					}
 | 
				
			||||||
        font-size: 26rpx;
 | 
					
 | 
				
			||||||
        margin-left: 19rpx;
 | 
					.pri {
 | 
				
			||||||
    }
 | 
					  color: #e0c79d;
 | 
				
			||||||
    
 | 
					  font-size: 26rpx;
 | 
				
			||||||
    .right {
 | 
					  margin-left: 19rpx;
 | 
				
			||||||
        color: #BBBBBB;
 | 
					}
 | 
				
			||||||
        margin-right: 31rpx;
 | 
					
 | 
				
			||||||
    }
 | 
					.right {
 | 
				
			||||||
    
 | 
					  color: #bbbbbb;
 | 
				
			||||||
    .sub {
 | 
					  margin-right: 31rpx;
 | 
				
			||||||
        margin-left: 30rpx;
 | 
					}
 | 
				
			||||||
        color: #4CC97D;
 | 
					
 | 
				
			||||||
    }
 | 
					.sub {
 | 
				
			||||||
 | 
					  margin-left: 30rpx;
 | 
				
			||||||
 | 
					  color: #4cc97d;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user