|
@@ -21,7 +21,7 @@
|
|
|
@scrolltolower="onreachBottom">
|
|
|
<sticky-header>
|
|
|
<!-- 头部 -->
|
|
|
- <view class="cart-head">
|
|
|
+ <view class="cart-head" v-if="total>0">
|
|
|
<view class="cart-head-left">共<text>{{total}}</text>款商品</view>
|
|
|
<view class="cart-head-right">
|
|
|
<view class="cart-head-btton blue" @click="editAll">
|
|
@@ -40,14 +40,14 @@
|
|
|
@remove="removeCart">
|
|
|
</productItem>
|
|
|
<!-- loading -->
|
|
|
- <view class="loading-bar" v-if="list.length==0 && status!='loading'">{{noDataText}}</view>
|
|
|
- <view class="empty-bar" v-if="(total>=list.length&&list.length)||status!='loading'">
|
|
|
+ <view class="loading-bar" v-if="total>0 && status!='loading'">{{noDataText}}</view>
|
|
|
+ <view class="empty-bar" v-if="total==0 && status!='loading'">
|
|
|
<image mode="aspectFit" :src="empty.imgUrl"></image>
|
|
|
<view>{{empty.tip}}</view>
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
<!-- 底部 -->
|
|
|
- <view class="cart-footer">
|
|
|
+ <view class="cart-footer" v-if="total>0">
|
|
|
<view class="cart-footer-box">
|
|
|
<view class="cart-footer-left">
|
|
|
<view class="cart-footer-left-all" @click="chooseAll">
|
|
@@ -60,7 +60,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="cart-footer-right">
|
|
|
- <view class="cart-footer-left-price" v-if="!editFlag">
|
|
|
+ <view class="cart-footer-left-price" v-if="!editFlag && totalAmount">
|
|
|
<view class="cart-footer-left-price-text">
|
|
|
<text>合计:</text>
|
|
|
</view>
|
|
@@ -72,7 +72,7 @@
|
|
|
<text>清空购物车</text>
|
|
|
</view> -->
|
|
|
<view class="cart-footer-right-button">
|
|
|
- <button class="btns" v-if="!editFlag" type="warn" size="mini" @click="settlement">去结算</button>
|
|
|
+ <button class="btns" v-if="!editFlag" type="warn" size="mini" @click="settlement">去结算({{totalNum}})</button>
|
|
|
<button v-else class="btns" type="warn" plain size="mini" @click="batchRemove">删除</button>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -157,10 +157,24 @@
|
|
|
getCartList(params).then(res => {
|
|
|
if (res.status == 200) {
|
|
|
const list = res.data.list
|
|
|
+ const ret = []
|
|
|
list.forEach(key => {
|
|
|
- key.checked = this.allChecked
|
|
|
+ ret.push({
|
|
|
+ id: key.id,
|
|
|
+ checked: this.allChecked,
|
|
|
+ cartSn: key.cartSn,
|
|
|
+ price: key.price,
|
|
|
+ qty: key.qty,
|
|
|
+ productSn: key.productSn,
|
|
|
+ productName: key.productEntity.productName,
|
|
|
+ productImage: key.productEntity.images,
|
|
|
+ productCode: key.productEntity.code,
|
|
|
+ productOrigCode: key.productEntity.origCode,
|
|
|
+ unit: key.productEntity.unit,
|
|
|
+ enabledFlag: key.enabledFlag
|
|
|
+ })
|
|
|
})
|
|
|
- _this.list.push(list)
|
|
|
+ _this.list.push(ret)
|
|
|
_this.total = res.data.count || 0
|
|
|
} else {
|
|
|
_this.list = []
|
|
@@ -172,11 +186,14 @@
|
|
|
},
|
|
|
// scroll-view到底部加载更多
|
|
|
onreachBottom() {
|
|
|
- if(this.list.length < this.total){
|
|
|
+ // 判断是否最后一页
|
|
|
+ const maxPages = Math.ceil(this.total / this.pageSize)
|
|
|
+ if(this.pageNo >= maxPages){
|
|
|
+ this.status = "nomore"
|
|
|
+ this.noDataText = '没有更多了'
|
|
|
+ }else{
|
|
|
this.pageNo += 1
|
|
|
this.getRow()
|
|
|
- }else{
|
|
|
- this.status = "nomore"
|
|
|
}
|
|
|
},
|
|
|
// 根据cartSn查找
|
|
@@ -187,6 +204,9 @@
|
|
|
},
|
|
|
// 已选产品变更数量
|
|
|
changeQty(val,cartSn){
|
|
|
+ uni.showLoading({
|
|
|
+ title: '加载中'
|
|
|
+ })
|
|
|
updateCart({
|
|
|
cartSn: cartSn,
|
|
|
qty: val
|
|
@@ -200,6 +220,7 @@
|
|
|
this.getChooseHeji()
|
|
|
}
|
|
|
}
|
|
|
+ uni.hideLoading()
|
|
|
})
|
|
|
},
|
|
|
// 选择
|
|
@@ -287,37 +308,42 @@
|
|
|
const snList = []
|
|
|
_this.list.forEach(item => {
|
|
|
item.filter(k=>k.checked).forEach(s=>{
|
|
|
- snList.push(s.cartSns)
|
|
|
+ snList.push(s.cartSn)
|
|
|
})
|
|
|
})
|
|
|
+
|
|
|
// 删除购物车
|
|
|
- this.removeCart(snList)
|
|
|
+ _this.removeCart(snList,true)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
// 删除商品
|
|
|
- removeCart(snList){
|
|
|
+ removeCart(snList,isBatch){
|
|
|
const _this = this
|
|
|
+ uni.showLoading({
|
|
|
+ title: '删除中'
|
|
|
+ })
|
|
|
deleteCart({cartSns:snList}).then(ret => {
|
|
|
if(ret.status == 200){
|
|
|
uni.showToast({
|
|
|
title: '删除成功',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
- // 如果全选
|
|
|
- if(_this.allChecked){
|
|
|
- _this.list = []
|
|
|
- _this.allChecked = false
|
|
|
- }
|
|
|
snList.forEach(sn => {
|
|
|
- _this.removeChoose(sn,snList.length>1)
|
|
|
+ _this.removeChoose(sn,isBatch)
|
|
|
})
|
|
|
- // 合计
|
|
|
- if(snList.length>1){
|
|
|
+ // 合计,批量操作
|
|
|
+ if(isBatch){
|
|
|
+ // 如果全选
|
|
|
+ if(_this.allChecked){
|
|
|
+ _this.list = []
|
|
|
+ _this.allChecked = false
|
|
|
+ }
|
|
|
_this.getChooseHeji()
|
|
|
}
|
|
|
}
|
|
|
+ uni.hideLoading()
|
|
|
})
|
|
|
},
|
|
|
// 去结算
|
|
@@ -337,7 +363,7 @@
|
|
|
this.totalNum = 0
|
|
|
this.list.forEach(key => {
|
|
|
key.filter(item=>item.checked).forEach(item => {
|
|
|
- this.totalAmount += item.cost * item.qty // 总金额
|
|
|
+ this.totalAmount += item.price * item.qty // 总金额
|
|
|
this.totalNum += item.qty // 总数量
|
|
|
})
|
|
|
})
|
|
@@ -501,7 +527,6 @@
|
|
|
margin-left: 20rpx;
|
|
|
text-align: right;
|
|
|
.btns{
|
|
|
- width: 120rpx;
|
|
|
border-radius: 100rpx;
|
|
|
height: 36px;
|
|
|
}
|