<template> <view> <up-navbar placeholder> <template #left> <view style="display: flex;"> <view class="tabs" :class="{'tabs-active': tabsActive==index}" v-for="(item, index) in list" :key="index" @click="changeTab(index)"> {{item}} </view> </view> </template> </up-navbar> <swiper class="swiper-box" :current="swiperCurrent" @animationfinish="animationfinish"> <swiper-item class="swiper-item"> <scroll-view scroll-y style="height: 100%;width: 100%;"> <view class="page-box1"> <view class="total"> <view>共计<text style="color: #20B128;">3</text>件</view> <view v-if="true">管理</view> <view v-else>完成</view> </view> <view v-if="true" class="list" style="margin-top: 80rpx;"> <view class="shop-item" v-for="(item, index) in 20" :key="index"> <view class="shop-check"> <image v-if="index%3==0" src="@/static/icon/n-check.png"></image> <image v-else src="@/static/icon/check.png"></image> </view> <image class="shop-img" src="https://cdn.uviewui.com/uview/album/1.jpg"></image> <view class="shop-content"> <view class="title"> <view class="name u-line-2">好吃的瓜果</view> <view class="tip u-line-1">香味辛辣|葱香味浓|调味增香香味辛辣|葱香味浓|调味增香</view> </view> <view class="price-btn"> <view class="price">¥12.00</view> <view class="btn"> <u--icon name="minus-circle-fill" size="20" color="#20b128"></u--icon> <view class="num">{{1}}</view> <u--icon name="plus-circle-fill" size="20" color="#20b128"></u--icon> </view> </view> </view> </view> </view> <view v-else style="margin-top: 100rpx;"> <up-empty text="购物车空空如也" icon="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/29955202404260944367594.png"> </up-empty> </view> <view style="width: 100%;height: 200rpx;"></view> </view> </scroll-view> </swiper-item> <swiper-item class="swiper-item"> <scroll-view scroll-y style="height: 100%;width: 100%;"> <view class="page-box1"> <view v-if="true" class="list"> <view class="shop-item" v-for="(item, index) in 20" :key="index"> <image class="shop-img" src="https://cdn.uviewui.com/uview/album/1.jpg"></image> <view class="shop-content" style="width: 490rpx;"> <view class="title"> <view class="name u-line-2">好吃的瓜果</view> <view class="tip u-line-1">香味辛辣|葱香味浓|调味增香香味辛辣|葱香味浓|调味增香</view> </view> <view class="price-btn"> <view class="price">¥12.00</view> <view class="btn"> <up-button size="small" plain color="#20b128" shape="circle">加入购物车</up-button> </view> </view> </view> </view> </view> <view v-else style="margin-top: 100rpx;"> <up-empty text="没有常买的商品" icon="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/29955202404260944367594.png"> </up-empty> </view> <view style="width: 100%;height: 200rpx;"></view> </view> </scroll-view> </swiper-item> </swiper> <up-transition :show="tabsActive==0"> <view class="cart-btn"> <view class="cart-check"> <image v-if="false" src="@/static/icon/n-check.png"></image> <image v-else src="@/static/icon/check.png"></image> <text style="font-size: 24rpx;">全选</text> </view> <view v-if="true" class="btn-boxs"> <view class="all-price"> <view style="width: 80rpx;">合计:</view> <view class="price"> <text style="font-size: 24rpx;">¥</text> <text style="font-size: 34rpx;">20</text> <text style="font-size: 24rpx;">.30</text> </view> </view> <up-button color="#20b128" shape="circle" :disabled="false" @click="settleAccounts">去结算<text>(2)</text></up-button> </view> <view v-else class="btn-boxs"> <!-- <view style="width: 100px;margin-right: 20rpx;"><up-button size="small" plain color="#989898" shape="circle">移入收藏夹</up-button></view> --> <view style="width: 80px;"><up-button size="small" plain color="#989898" shape="circle">删除</up-button></view> </view> </view> </up-transition> </view> </template> <script setup> import { ref } from 'vue'; import { cartListApi } from "@/api/cart.js" // 创建响应式数据 const list = ref(['购物车', '常买']); const tabsActive = ref(0) // 定义方法 const changeTab = (e) => { tabsActive.value = e; swiperCurrent.value = e; } const swiperCurrent = ref(0); const animationfinish = ({ detail: { current } }) => { swiperCurrent.value = current; tabsActive.value = current; } // 结算 const settleAccounts = ()=>{ uni.navigateTo({ url: '/pagesOrder/settle/settle' }) } const cartList = ref([]); const getcartList = ()=>{ cartListApi().then(res=>{ console.log(res); }) } getcartList() </script> <style lang="scss"> .tabs { color: #444444; font-size: 32rpx; margin-right: 30rpx; } .tabs-active { color: #20B128; // font-size: 34rpx; transition: 300ms; } .swiper-box { flex: 1; height: calc(100vh - var(--window-top) - var(--window-bottom)); /* #ifdef H5 */ height: calc(100vh - 96px); /* #endif */ width: 100%; .swiper-item { height: 100%; } } .page-box1 { position: relative; .total { padding: 0 20rpx; display: flex; justify-content: space-between; position: fixed; top: var(--window-top); left: 0; right: 0; background-color: #f6f6f6; z-index: 100; height: 60rpx; line-height: 60rpx; font-size: 26rpx; color: #444; } .list { margin: 20rpx; border-radius: 20rpx; overflow: hidden; .shop-item { padding: 20rpx; border-bottom: 1rpx solid #f6f6f6; background-color: #fff; display: flex; .shop-check { width: 60rpx; height: 160rpx; display: flex; align-items: center; image { width: 40rpx; height: 40rpx; } } .shop-img { height: 160rpx; width: 160rpx; margin-right: 20rpx; border-radius: 14rpx; } .shop-content { width: 430rpx; display: flex; flex-direction: column; justify-content: space-between; .title { .name { font-size: 28rpx; } .tip { color: #999; font-size: 24rpx; margin: 12rpx 0; } } .price { font-size: 30rpx; font-weight: bold; color: #F55726; } .price-btn { display: flex; justify-content: space-between; .btn { display: flex; align-items: center; .num { width: 60rpx; text-align: center; } } } } } } } .cart-btn { width: 100%; height: 50px; box-sizing: border-box; background-color: pink; background-color: #fff; position: fixed; left: 0; bottom: var(--window-bottom); display: flex; align-items: center; justify-content: space-between; padding: 0 20rpx; .cart-check { display: flex; align-items: center; image { width: 40rpx; height: 40rpx; margin: 0 10rpx; } } .btn-boxs { display: flex; .all-price { display: flex; align-items: center; margin-right: 20rpx; .price { color: #20B128; display: table-cell; vertical-align: bottom; font-weight: bold; } } } } </style>