purchase-let/pages/cart/cart.vue

293 lines
8.3 KiB
Vue
Raw Normal View History

2024-04-25 18:02:30 +08:00
<template>
<view>
<up-navbar placeholder>
<template #left>
<view style="display: flex;">
2024-04-26 18:04:56 +08:00
<view class="tabs" :class="{'tabs-active': tabsActive==index}" v-for="(item, index) in list" :key="index"
2024-04-25 18:02:30 +08:00
@click="changeTab(index)">
{{item}}
</view>
</view>
</template>
</up-navbar>
2024-04-26 18:04:56 +08:00
2024-04-25 18:02:30 +08:00
<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>
2024-04-26 18:04:56 +08:00
<view v-if="true" class="list" style="margin-top: 80rpx;">
2024-04-25 18:02:30 +08:00
<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>
2024-04-26 18:04:56 +08:00
<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>
2024-04-25 18:02:30 +08:00
<view style="width: 100%;height: 200rpx;"></view>
</view>
</scroll-view>
</swiper-item>
</swiper>
2024-04-26 18:04:56 +08:00
<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="false" class="btn-box">
<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>去结算<text>(2)</text></up-button>
</view>
<view v-else class="btn-box">
<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>
2024-04-25 18:02:30 +08:00
</view>
</template>
<script setup>
import { ref } from 'vue';
// 创建响应式数据
2024-04-26 18:04:56 +08:00
const list = ref(['购物车', '常买']);
2024-04-25 18:02:30 +08:00
const tabsActive = ref(0)
// 定义方法
const changeTab = (e) => {
tabsActive.value = e;
2024-04-26 18:04:56 +08:00
swiperCurrent.value = e;
2024-04-25 18:02:30 +08:00
}
const swiperCurrent = ref(0);
const animationfinish = ({ detail: { current } }) => {
swiperCurrent.value = current;
tabsActive.value = current;
}
</script>
<style lang="scss">
.tabs {
color: #444444;
font-size: 32rpx;
margin-right: 30rpx;
}
.tabs-active {
color: #20B128;
2024-04-26 18:04:56 +08:00
// font-size: 34rpx;
2024-04-25 18:02:30 +08:00
transition: 300ms;
}
.swiper-box {
flex: 1;
height: calc(100vh - var(--window-top) - var(--window-bottom));
/* #ifdef H5 */
height: calc(100vh - 96px);
/* #endif */
width: 100%;
2024-04-26 18:04:56 +08:00
2024-04-25 18:02:30 +08:00
.swiper-item {
height: 100%;
}
}
2024-04-26 18:04:56 +08:00
.page-box1 {
2024-04-25 18:02:30 +08:00
position: relative;
2024-04-26 18:04:56 +08:00
.total {
2024-04-25 18:02:30 +08:00
padding: 0 20rpx;
display: flex;
justify-content: space-between;
position: fixed;
top: var(--window-top);
left: 0;
right: 0;
background-color: #eee;
z-index: 100;
height: 60rpx;
line-height: 60rpx;
font-size: 26rpx;
color: #444;
}
2024-04-26 18:04:56 +08:00
.list {
2024-04-25 18:02:30 +08:00
margin: 20rpx;
border-radius: 20rpx;
overflow: hidden;
2024-04-26 18:04:56 +08:00
2024-04-25 18:02:30 +08:00
.shop-item {
padding: 20rpx;
border-bottom: 1rpx solid #eee;
background-color: #fff;
display: flex;
2024-04-26 18:04:56 +08:00
.shop-check {
2024-04-25 18:02:30 +08:00
width: 60rpx;
height: 160rpx;
display: flex;
align-items: center;
2024-04-26 18:04:56 +08:00
image {
2024-04-25 18:02:30 +08:00
width: 40rpx;
height: 40rpx;
}
}
2024-04-26 18:04:56 +08:00
2024-04-25 18:02:30 +08:00
.shop-img {
height: 160rpx;
width: 160rpx;
margin-right: 20rpx;
border-radius: 14rpx;
}
2024-04-26 18:04:56 +08:00
2024-04-25 18:02:30 +08:00
.shop-content {
width: 430rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
2024-04-26 18:04:56 +08:00
2024-04-25 18:02:30 +08:00
.title {
.name {
font-size: 28rpx;
}
2024-04-26 18:04:56 +08:00
2024-04-25 18:02:30 +08:00
.tip {
color: #999;
font-size: 24rpx;
margin: 12rpx 0;
}
}
2024-04-26 18:04:56 +08:00
2024-04-25 18:02:30 +08:00
.price {
font-size: 30rpx;
font-weight: bold;
color: #F55726;
}
2024-04-26 18:04:56 +08:00
2024-04-25 18:02:30 +08:00
.price-btn {
display: flex;
justify-content: space-between;
2024-04-26 18:04:56 +08:00
2024-04-25 18:02:30 +08:00
.btn {
display: flex;
align-items: center;
2024-04-26 18:04:56 +08:00
2024-04-25 18:02:30 +08:00
.num {
width: 60rpx;
text-align: center;
}
}
}
}
}
}
}
2024-04-26 18:04:56 +08:00
.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-box {
display: flex;
.all-price {
display: flex;
align-items: center;
margin-right: 20rpx;
.price {
color: #20B128;
display: table-cell;
vertical-align: bottom;
font-weight: bold;
}
}
}
2024-04-25 18:02:30 +08:00
}
</style>