Files
vpUni/.svn/pristine/a6/a6ab3069231b82fa36aa84f07fc8290f47afab88.svn-base
2026-03-09 16:39:03 +08:00

309 lines
6.6 KiB
Plaintext

<template>
<view class="points-mall-page">
<view class="page-content">
<!-- 1. 顶部轮播图 (原生 <swiper> 实现) -->
<view class="swiper-section">
<swiper class="swiper-container" circular autoplay :interval="3000" :duration="500"
@change="e => swiperCurrent = e.detail.current">
<swiper-item v-for="(item, index) in swiperList" :key="index">
<view class="swiper-item">
<view class="image-placeholder swiper-image">
<image :src="item" style="width: 100%; height: 100%;" mode=""></image>
</view>
</view>
</swiper-item>
</swiper>
<!-- 自定义指示点 -->
<view class="swiper-dots">
<view class="dot" :class="{ active: index === swiperCurrent }" v-for="(item, index) in swiperList"
:key="index"></view>
</view>
</view>
<!-- 2. 主体内容:左右联动 -->
<view class="main-content">
<!-- 左侧分类栏 -->
<scroll-view class="left-panel" scroll-y>
<view class="category-item" :class="{ active: currentCategory === cat.typeId }"
v-for="(cat, index) in categories" :key="index" @click="selectCategory(cat)">
<text class="name">{{ cat.name }}</text>
</view>
</scroll-view>
<!-- 右侧商品列表 -->
<scroll-view class="right-panel" @scrolltolower="getList()" scroll-y>
<view class="product-list">
<view class="product-card" v-for="(product,index) in products" :key="index"
@click="Service.GoPage('/pages/goods/integralGoods?id='+product.goodsId)">
<view class="image-placeholder product-image">
<image :src="Service.GetMateUrlByImg(product.img)" style="width: 100%; height: 100%; border-radius: 20rpx;"
mode=""></image>
</view>
<view class="product-info" style="flex: 1;">
<text class="name">{{ product.goodsName }}</text>
<view style=" margin: 10rpx 0; display: flex; align-items: center; color: #999; font-size: 26rpx; " >
<view class="">
销量 {{ product.sale}}
</view>
<view class="">
库存 {{ product.stock}}
</view>
</view>
<view class="price-line" style="display: flex; align-items: center; justify-content: space-between;" >
<text class="points">{{ product.price }} 积分</text>
<view class="">
<u-button type="primary" :custom-style="ButtonStyle">立即兑换</u-button>
</view>
</view>
</view>
</view>
</view>
<up-loadmore status="nomore" nomoreText="没有更多商品了"></up-loadmore>
</scroll-view>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { Service } from "@/Service/Service";
import { vpGoodsService } from '@/Service/vp/vpGoodsService'
const ButtonStyle = ref({
backgroundColor: '#FF6600',
borderColor: '#FF6600',
color: '#FFFFFF',
fontSize: '24rpx',
height: '40rpx',
padding:'24rpx 8rpx',
borderRadius: '45rpx',
});
let keyword=ref('')
const currentCategory = ref('1001');
const swiperCurrent = ref(0);
// 轮播图数据
let swiperList = reactive([
'/static/dele/dele1.jpg',
'/static/dele/dele2.jpg',
'/static/dele/dele3.png',
]);
// 分类数据
const categories = ref<Array<any>>([]);
// 商品数据
const products = ref<Array<any>>([]);
let page=ref(1)
let status=ref('nomore')
onLoad(() => {
getData()
});
onShow(() => { });
const getData=()=>{
page.value=1
status.value='loadmore'
products.value=[]
getList()
}
const getList=()=>{
if(status.value=='nomore'|| status.value=='loading' ){
return
}
status.value='loading'
swiperList=[]
vpGoodsService.GetGoodsList(currentCategory.value,page.value).then(res=>{
if(res.code==0){
categories.value=res.data.goodsType
products.value=[...products.value,...res.data.goodsList]
res.data.bannerList.map(item=>{
swiperList.push(Service.GetMateUrlByImg(item.img))
})
}
})
}
const selectCategory = (cat : any) => {
currentCategory.value = cat.typeId;
getData()
};
</script>
<style lang="scss" scoped>
.points-mall-page {
background-color: #f6f6f6;
height: 100vh;
display: flex;
flex-direction: column;
}
.swiper-section {
padding: 24rpx;
position: relative;
.swiper-container {
height: 300rpx;
border-radius: 16rpx;
overflow: hidden;
}
.swiper-item {
width: 100%;
height: 100%;
.swiper-image {
width: 100%;
height: 100%;
}
}
.swiper-dots {
position: absolute;
bottom: 40rpx;
left: 50%;
transform: translateX(-50%);
display: flex;
gap: 12rpx;
.dot {
width: 12rpx;
height: 12rpx;
border-radius: 50%;
background-color: rgba(255, 255, 255, 0.5);
transition: all 0.3s;
&.active {
width: 30rpx;
background-color: #fff;
}
}
}
}
.main-content {
flex: 1;
display: flex;
overflow: hidden;
}
.left-panel {
width: 180rpx;
background-color: #f7f7f7;
height: 100%;
.category-item {
padding: 30rpx 20rpx;
font-size: 28rpx;
color: #666;
text-align: center;
position: relative;
&.active {
background-color: #fff;
color: #333;
font-weight: bold;
&::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 8rpx;
height: 40rpx;
background-color: #fa6400;
}
}
}
}
.right-panel {
flex: 1;
background-color: #fff;
height: 920rpx;
padding: 30rpx;
.product-list {
display: flex;
flex-direction: column;
gap: 30rpx;
}
.product-card {
display: flex;
gap: 24rpx;
align-items: center;
border-bottom: 1rpx solid #e2e2e2;
padding-bottom: 10rpx;
.product-image {
width: 160rpx;
height: 160rpx;
border-radius: 12rpx;
flex-shrink: 0;
}
.product-info {
flex: 1;
min-width: 0;
.name {
font-size: 34rpx;
color: #333;
font-weight: bold;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.price-line {
display: flex;
align-items: baseline;
.points {
font-size: 32rpx;
font-weight: bold;
color: #fa6400;
}
.original-price {
font-size: 22rpx;
color: #999;
margin-left: 8rpx;
}
}
}
.exchange-btn {
background-color: #fa6400;
color: #fff;
border-radius: 30rpx;
font-size: 24rpx;
padding: 10rpx 24rpx;
margin: 0;
height: fit-content;
line-height: 1.5;
&::after {
border: none;
}
}
}
}
</style>