This commit is contained in:
pplokijuhyg 2019-12-20 11:09:15 +08:00
parent 3cf388faed
commit 38280893bd
3 changed files with 103 additions and 54 deletions

View File

@ -8,13 +8,15 @@ Page({
data: {
list:[],
select:[],
userid:0
userid:0,
price:"0.00"
},
sel(a){
console.log(a)
this.setData({
[`select[${a.detail.index}]`]:!a.detail.select
})
this.num();
},
/**
@ -98,8 +100,52 @@ Page({
},
num(){
let num = 0;
let sel = 0;
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()
}
}
})

View File

@ -13,9 +13,9 @@
</view> -->
<view class="bottom">
<view class="left">
<view class="select"></view>
<text class="selectall">全选</text>
<text class="pri">$0.00</text>
<view bind:tap="call" class="select {{all ? 'selects':''}}"></view>
<text bind:tap="call" class="selectall">全选</text>
<text class="pri">${{price}}</text>
</view>
<view class="right">
<text class="del">删除</text>

View File

@ -1,13 +1,13 @@
.shopping{
.shopping {
padding-bottom: 128rpx;
}
.item {
height: 186rpx;
margin-left: 46rpx;
margin-top: 59rpx;
}
}
.bottom {
.bottom {
width: 100%;
height: 98rpx;
position: fixed;
@ -17,14 +17,14 @@
justify-content: space-between;
font-size: 28rpx;
line-height: 98rpx;
}
}
.left {
.left {
display: flex;
/* line-height: 26rpx; */
}
}
.select {
.select {
width: 26rpx;
height: 26rpx;
background: rgba(234, 234, 234, 1);
@ -32,20 +32,23 @@
margin: auto 0;
margin-left: 46rpx;
margin-right: 24rpx;
}
}
.selects{
background-color: #4cc97d;
}
.pri {
color: #E0C79D;
.pri {
color: #e0c79d;
font-size: 26rpx;
margin-left: 19rpx;
}
}
.right {
color: #BBBBBB;
.right {
color: #bbbbbb;
margin-right: 31rpx;
}
}
.sub {
.sub {
margin-left: 30rpx;
color: #4CC97D;
}
color: #4cc97d;
}