lilei 4 年 前
コミット
6b3d693c12
2 ファイル変更21 行追加13 行削除
  1. 3 10
      components/uni-cart-fix/uni-cart-fix.vue
  2. 18 3
      pages/cart/cart.vue

+ 3 - 10
components/uni-cart-fix/uni-cart-fix.vue

@@ -18,16 +18,9 @@
 			},
 			methods: {
 				toCart() {
-					if(this.count > 0){
-						uni.navigateTo({
-							url:"/pages/cart/cart"
-						})
-					}else{
-						uni.showToast({
-							icon:'none',
-							title:'购物车是空的,请先加入商品'
-						})
-					}
+					uni.navigateTo({
+						url:"/pages/cart/cart"
+					})
 				}
 			},
 		}

+ 18 - 3
pages/cart/cart.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="cart-pages">
-		<view class="cart-bar">
+		<view class="cart-bar" v-if="cartList.length>0">
 			<view>共{{count}}件商品</view>
 			<view @click="editCart">
 				<text class="edit" v-if="!isEdit">管理</text>
@@ -63,8 +63,15 @@
 					</view>
 				</view>
 			</view>
+			<view class="noData" v-if="cartList.length==0">
+				<u-empty mode="car">
+					<view slot="bottom">
+						<u-button size="mini" @click="toBuy">去选商品</u-button>
+					</view>
+				</u-empty>
+			</view>
 		</view>
-		<view class="cart-submit">
+		<view class="cart-submit" v-if="cartList.length>0">
 			<view>
 				<u-checkbox 
 				shape="circle" 
@@ -145,6 +152,11 @@
 			this.hasCheckAll()
 		},
 		methods: {
+			toBuy(){
+				uni.switchTab({
+					url:"/pages/goods/index"
+				})
+			},
 			// 获取当前选择的商品, type: 0 删除,1 立即下单
 			getCheckGoods(type){
 				let arr = this.cartList
@@ -174,7 +186,7 @@
 				let ret = 0
 				let goldLimit = item.goldLimit
 				item.shoppingCartGoodsList.map(good=>{
-					ret = ret + good.goods.sellGold
+					ret = ret + good.goods.sellGold * good.buyQty
 				})
 				console.log(ret , goldLimit)
 				return !this.isEdit ? ret >= goldLimit : true
@@ -296,6 +308,9 @@ page{
 	height: 100%;
 	display: flex;
 	flex-direction: column;
+	.noData{
+		padding-top: 150upx;
+	}
 	.cart-bar{
 		display: flex;
 		justify-content: space-between;