uni-app 小程序实现购物车,功能完整。
展示效果图
部分
<template>
<view class="container">
<!-- 空白页 -->
<view v-if="empty===true || cartList =='' " class="empty">
<image src="/static/emptyCart.png" mode="aspectFit"></image>
<view v-if="hasLogin" class="empty-tips">
空空如也
<navigator class="navigator" v-if="hasLogin" url="../index/index" open-type="switchTab">随便逛逛></navigator>
</view>
<view v-else class="empty-tips">
空空如也
<view class="navigator" @click="navToLogin">去购物吧></view>
</view>
</view>
<view v-else>
<!-- 列表 -->
<view class="cat_sp">
<text>已加入商品</text>
</view>
<view class="cart-list">
<block v-for="(item, index) in cartList" :key="item" >
<view
class="cart-item"
>
<view class="image-wrapper">
<view v-if="item.upperShelves == 0" class="upperShelves"
>
<image style="width: 40rpx;height: 40rpx;" src="../../static/select.png" mode=""></image>
</view>
<view v-else
class="yticon icon-xuanzhong2 checkbox"
:class="{checked: item.checked}"
@click="check('item', index,item)"
></view>
<view class="position_sp" v-if="item.upperShelves == 0">
<image :src="item.titlePicStr" @click="cats(item,index)"
mode="aspectFill"
lazy-load
@load="onImageLoad('cartList', index)"
@error="onImageError('cartList', index)"
>
</image>
<image class="LOVE_position_sp" src="../../static/xj.png" mode=""></image>
</view>
<image v-else :src="item.titlePicStr" @click="cats(item,index)"
mode="aspectFill"
lazy-load
@load="onImageLoad('cartList', index)"
@error="onImageError('cartList', index)"
></image>
</view>
<view class="item-right"