web-zk-h5/pages/shareArea/hiList.vue

638 lines
14 KiB
Vue
Raw Normal View History

2025-03-23 09:29:40 +08:00
<template>
<view class="contain">
<!-- Tab选项卡 -->
<view class="tab-container">
<view class="tab-wrapper">
<view
v-for="tab in tabs"
:key="tab.value"
class="tab-item"
:class="{ 'tab-active': activeTab === tab.value }"
@click="switchTab(tab.value)"
>
<text class="tab-text">{{ tab.label }}</text>
<view class="tab-line" v-if="activeTab === tab.value"></view>
2025-09-16 17:21:20 +08:00
</view>
</view>
</view>
<view class="goods-container">
<scroll-view
class="goodList"
scroll-y="true"
enhanced
:show-scrollbar="false"
>
<view v-for="item in goodList" :key="item.waresCode" class="goodList_i">
<img :src="item.cover1" class="cover" alt="" />
<view class="goodList_ir">
<view class="tit1">
{{ item.waresName }}
</view>
<view class="goodList_ib">
<view class="price-container">
<!-- <text class="currency"></text> -->
<text class="price">{{ formatCurrency(item.waresPrice) }}</text>
<text v-if="item.isSale === 1" class="sale-status">已售罄</text>
2025-03-23 09:29:40 +08:00
</view>
2025-09-16 17:21:20 +08:00
<!-- <img @click.stop="addCar(item)"
src="@/static/images/cart.png"
alt=""> -->
2025-03-23 09:29:40 +08:00
</view>
<!-- 数量控制区域 -->
<view class="quantity-section" v-if="item.isSale !== 1">
<view class="quantity-control">
<view
class="quantity-btn minus"
:class="{ disabled: item.quantity <= 1 }"
@click.stop="updateQuantity(item, -1)"
>
<text class="quantity-icon"></text>
</view>
<view class="quantity-display">
<text class="quantity-text">{{ item.quantity || 1 }}</text>
</view>
<view
class="quantity-btn plus"
@click.stop="updateQuantity(item, 1)"
>
<text class="quantity-icon">+</text>
</view>
</view>
<view class="toBuy" @click.stop="goBuy(item)">购买</view>
</view>
<!-- 禁售状态 -->
<view class="sold-out-section" v-if="item.isSale === 1">
<view class="sold-out-btn">暂时缺货</view>
</view>
2025-03-23 09:29:40 +08:00
</view>
</view>
2025-09-16 17:21:20 +08:00
<view class="list-bottom">
<text class="bottom-text"> 已显示全部商品 </text>
</view>
</scroll-view>
</view>
2025-03-23 09:29:40 +08:00
</view>
</template>
<script>
import * as api from '@/config/login.js'
import { setToken } from '@/config/auth.js'
import { formatCurrency } from '@/util/index.js'
2025-03-23 09:29:40 +08:00
export default {
2025-09-16 17:21:20 +08:00
data() {
return {
pkParent: '',
goodList: [],
placeParent: '',
activeTab: 41, // 默认选中精品专区
tabs: [
{
label: '精品专区',
value: 41,
},
{
label: '商城专区',
value: 43,
},
],
2025-03-23 09:29:40 +08:00
}
},
onLoad(options) {
this.pkParent = options.pkParent
this.getToken()
},
2025-09-16 17:21:20 +08:00
methods: {
formatCurrency,
2025-09-16 17:21:20 +08:00
getToken() {
api
.autoLogin({
pkParent: this.pkParent,
})
.then(res => {
setToken(res.data.access_token, res.data.expires_in)
uni.setStorageSync('regiest-login', '1')
this.getList()
this.getCode()
})
2025-03-23 09:29:40 +08:00
},
2025-09-16 17:21:20 +08:00
getCode() {
api.fansConvertCode(this.pkParent).then(res => {
this.placeParent = res.data
uni.setStorageSync('placeParent', this.placeParent)
2025-03-23 09:29:40 +08:00
})
},
2025-09-16 17:21:20 +08:00
getList() {
api
.queryWares({
shareMemberCode: this.pkParent,
specialArea: this.activeTab,
2025-09-16 17:21:20 +08:00
})
.then(res => {
// 为每个商品初始化quantity字段
this.goodList = res.data.map(item => ({
...item,
quantity: item.quantity || 1,
}))
2025-09-16 17:21:20 +08:00
})
},
switchTab(value) {
if (this.activeTab !== value) {
this.activeTab = value
this.goodList = [] // 清空当前列表
this.getList() // 重新获取数据
}
},
updateQuantity(item, change) {
const newQuantity = (item.quantity || 1) + change
if (newQuantity >= 1) {
// 使用Vue.set或直接赋值来确保响应式更新
this.$set(item, 'quantity', newQuantity)
}
},
2025-09-16 17:21:20 +08:00
goBuy(item) {
const params = {
...item,
pkParent: this.pkParent,
specialArea: this.activeTab,
2025-09-16 17:21:20 +08:00
}
uni.navigateTo({
url: '/pages/shareArea/hiOrder?allData=' + JSON.stringify(item),
2025-03-23 09:29:40 +08:00
})
},
2025-09-16 17:21:20 +08:00
},
2025-03-23 09:29:40 +08:00
}
</script>
<style lang="scss" scoped>
2025-09-16 17:21:20 +08:00
.contain {
background: #f8fafc;
2025-09-16 17:21:20 +08:00
min-height: 100vh;
display: flex;
flex-direction: column;
2025-03-23 09:29:40 +08:00
}
2025-09-16 17:21:20 +08:00
2025-10-13 11:39:18 +08:00
// Tab选项卡样式 - 简约大气设计
.tab-container {
2025-10-13 11:39:18 +08:00
// background: #ffffff;
padding: 0;
position: relative;
z-index: 4;
2025-09-16 17:21:20 +08:00
2025-10-13 11:39:18 +08:00
// 顶部装饰线
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 3rpx;
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}
.tab-wrapper {
display: flex;
position: relative;
2025-10-13 11:39:18 +08:00
// background: #ffffff;
// padding: 32rpx 24rpx 24rpx;
2025-09-16 17:21:20 +08:00
.tab-item {
2025-10-13 11:39:18 +08:00
flex: 1;
position: relative;
cursor: pointer;
2025-10-13 11:39:18 +08:00
padding: 24rpx 32rpx;
text-align: center;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
.tab-text {
2025-10-13 11:39:18 +08:00
font-size: 32rpx;
font-weight: 500;
2025-10-13 11:39:18 +08:00
color: #64748b;
transition: all 0.3s ease;
2025-10-13 11:39:18 +08:00
position: relative;
z-index: 2;
2025-09-16 17:21:20 +08:00
}
.tab-line {
2025-10-13 11:39:18 +08:00
display: none;
}
// 悬停效果
&:hover:not(.tab-active) {
.tab-text {
color: #475569;
transform: translateY(-1rpx);
}
2025-09-16 17:21:20 +08:00
}
&.tab-active {
2025-10-13 11:39:18 +08:00
background: rgba(102, 126, 234, 0.08);
.tab-text {
2025-10-13 11:39:18 +08:00
color: #667eea;
font-weight: 600;
}
2025-10-13 11:39:18 +08:00
// 选中指示器 - 底部完整宽度线条
&::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 3rpx;
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}
2025-09-16 17:21:20 +08:00
}
&:active {
2025-10-13 11:39:18 +08:00
transform: scale(0.98);
2025-09-16 17:21:20 +08:00
}
}
}
2025-03-23 09:29:40 +08:00
}
2025-09-16 17:21:20 +08:00
// 商品容器区域
.goods-container {
2025-09-18 16:39:00 +08:00
// flex: 1;
2025-09-16 17:21:20 +08:00
background: #f8fafc;
padding: 24rpx 24rpx 0;
2025-09-16 17:21:20 +08:00
position: relative;
z-index: 3;
.section-title {
text-align: center;
margin-bottom: 24rpx;
padding: 20rpx 0;
.title-text {
display: block;
color: #1e293b;
font-size: 32rpx;
font-weight: 600;
margin-bottom: 8rpx;
}
.title-desc {
display: block;
color: #64748b;
font-size: 24rpx;
}
}
}
// 商品列表滚动区域
2025-03-23 09:29:40 +08:00
.goodList {
2025-09-18 16:39:00 +08:00
// height: calc(100vh - 400rpx);
2025-09-16 17:21:20 +08:00
padding: 0 8rpx;
2025-03-23 09:29:40 +08:00
.goodList_i {
display: flex;
2025-09-16 17:21:20 +08:00
background: #ffffff;
border-radius: 24rpx;
2025-09-16 17:21:20 +08:00
margin-bottom: 24rpx;
padding: 32rpx;
box-shadow: 0 4rpx 20rpx rgba(102, 126, 234, 0.08);
border: 1rpx solid rgba(102, 126, 234, 0.08);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
2025-09-16 17:21:20 +08:00
animation: slideInUp 0.6s ease-out both;
opacity: 0;
&:hover {
transform: translateY(-6rpx);
box-shadow: 0 16rpx 40rpx rgba(102, 126, 234, 0.2);
border-color: rgba(102, 126, 234, 0.15);
2025-09-16 17:21:20 +08:00
}
.cover {
width: 240rpx;
height: 240rpx;
background: #f8fafc;
border: 1rpx solid #e2e8f0;
border-radius: 16rpx;
flex-shrink: 0;
overflow: hidden;
}
2025-03-23 09:29:40 +08:00
.goodList_ir {
2025-09-16 17:21:20 +08:00
margin-left: 24rpx;
2025-03-23 09:29:40 +08:00
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
2025-09-16 17:21:20 +08:00
.tit1 {
color: #1e293b;
font-size: 32rpx;
2025-03-23 09:29:40 +08:00
font-weight: 600;
2025-09-16 17:21:20 +08:00
line-height: 1.4;
margin-bottom: 16rpx;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.sales {
color: #64748b;
font-size: 24rpx;
font-weight: 400;
margin-bottom: 16rpx;
}
.goodList_ib {
margin-bottom: 24rpx;
.price-container {
display: flex;
align-items: baseline;
justify-content: space-between;
2025-09-16 17:21:20 +08:00
.currency {
color: #ff6b35;
font-size: 24rpx;
font-weight: 600;
margin-right: 4rpx;
}
.price {
color: #ff6b35;
font-size: 36rpx;
font-weight: 700;
}
.sale-status {
color: #ef4444;
font-size: 24rpx;
font-weight: 500;
background: rgba(239, 68, 68, 0.1);
padding: 4rpx 12rpx;
border-radius: 12rpx;
border: 1rpx solid rgba(239, 68, 68, 0.2);
}
2025-09-16 17:21:20 +08:00
}
2025-03-23 09:29:40 +08:00
img {
width: 56rpx;
height: 56rpx;
}
}
2025-09-16 17:21:20 +08:00
// 数量控制区域
.quantity-section {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
.quantity-control {
display: flex;
align-items: center;
background: #f8fafc;
border-radius: 20rpx;
border: 1rpx solid #e2e8f0;
overflow: hidden;
.quantity-btn {
width: 60rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
background: #ffffff;
transition: all 0.2s ease;
cursor: pointer;
.quantity-icon {
font-size: 32rpx;
font-weight: 600;
color: #667eea;
}
&.minus {
&.disabled {
opacity: 0.3;
cursor: not-allowed;
.quantity-icon {
color: #9ca3af;
}
}
}
&:not(.disabled):active {
background: #f1f5f9;
transform: scale(0.95);
}
}
.quantity-display {
min-width: 80rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
background: #ffffff;
border-left: 1rpx solid #e2e8f0;
border-right: 1rpx solid #e2e8f0;
.quantity-text {
font-size: 28rpx;
font-weight: 600;
color: #1f2937;
}
}
}
}
// 禁售状态区域
.sold-out-section {
display: flex;
justify-content: flex-end;
.sold-out-btn {
background: #f3f4f6;
color: #9ca3af;
padding: 16rpx 32rpx;
text-align: center;
border-radius: 12rpx;
font-size: 24rpx;
font-weight: 500;
border: 1rpx solid #e5e7eb;
cursor: not-allowed;
}
}
2025-09-16 17:21:20 +08:00
.toBuy {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
2025-09-16 17:21:20 +08:00
color: #ffffff;
padding: 16rpx 24rpx;
2025-09-16 17:21:20 +08:00
text-align: center;
border-radius: 12rpx;
font-size: 24rpx;
2025-09-16 17:21:20 +08:00
font-weight: 600;
border: none;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
2025-09-16 17:21:20 +08:00
position: relative;
overflow: hidden;
box-shadow: 0 2rpx 8rpx rgba(102, 126, 234, 0.2);
flex-shrink: 0;
min-width: 120rpx;
2025-09-16 17:21:20 +08:00
&::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(
90deg,
transparent,
rgba(255, 255, 255, 0.2),
transparent
);
transition: left 0.5s;
}
&:hover {
background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
transform: translateY(-1rpx);
box-shadow: 0 4rpx 12rpx rgba(102, 126, 234, 0.3);
2025-09-16 17:21:20 +08:00
&::before {
left: 100%;
}
}
&:active {
transform: scale(0.95) translateY(0);
2025-09-16 17:21:20 +08:00
}
}
2025-03-23 09:29:40 +08:00
}
}
2025-09-16 17:21:20 +08:00
.list-bottom {
2025-03-23 09:29:40 +08:00
text-align: center;
2025-09-16 17:21:20 +08:00
padding: 40rpx 0 60rpx;
.bottom-text {
color: #64748b;
font-size: 24rpx;
}
}
}
// 动画定义
@keyframes slideIn {
from {
transform: scaleX(0);
opacity: 0;
}
to {
transform: scaleX(1);
opacity: 1;
}
}
2025-09-16 17:21:20 +08:00
@keyframes slideDown {
from {
opacity: 0;
transform: translateY(-50rpx);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30rpx);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes slideInUp {
from {
opacity: 0;
transform: translateY(40rpx);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes pulse {
0%,
100% {
transform: scale(1);
}
50% {
transform: scale(1.02);
2025-03-23 09:29:40 +08:00
}
}
2025-09-16 17:21:20 +08:00
@keyframes promoBreathe {
0%,
100% {
transform: scale(1);
box-shadow: 0 8rpx 24rpx rgba(255, 107, 53, 0.4);
}
50% {
transform: scale(1.05);
box-shadow: 0 12rpx 32rpx rgba(255, 107, 53, 0.6);
}
2025-03-23 09:29:40 +08:00
}
2025-09-16 17:21:20 +08:00
@keyframes shimmer {
0% {
left: -100%;
}
50% {
left: -100%;
}
100% {
left: 100%;
}
}
// 商品卡片延迟动画
.goodList_i:nth-child(1) {
animation-delay: 0.1s;
}
.goodList_i:nth-child(2) {
animation-delay: 0.2s;
}
.goodList_i:nth-child(3) {
animation-delay: 0.3s;
}
.goodList_i:nth-child(4) {
animation-delay: 0.4s;
}
.goodList_i:nth-child(5) {
animation-delay: 0.5s;
}
.goodList_i:nth-child(n + 6) {
animation-delay: 0.6s;
}
</style>