| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- <template>
- <view class="points-mall">
- <!-- 顶部导航栏 -->
- <view class="header">
- <view class="back-icon" @click="handleBack"></view>
- <text class="header-title">积分商城</text>
- <view class="header-right">
- <view class="search-icon"></view>
- <view class="cart-icon">
- <text class="cart-badge">{{ cartCount }}</text>
- </view>
- </view>
- </view>
- <!-- 积分显示区域 -->
- <view class="points-section">
- <view class="points-header">
- <text class="points-label">我的积分</text>
- <text class="points-value">{{ userPoints }}</text>
- <text class="points-icon">💰</text>
- </view>
- <view class="points-actions">
- <view class="action-btn" @click="handlePointsDetail">积分明细</view>
- <view class="action-btn" @click="handleEarnPoints">赚取积分</view>
- </view>
- </view>
- <!-- 分类标签 -->
- <view class="category-tabs">
- <view
- v-for="(category, index) in categories"
- :key="index"
- class="category-tab"
- :class="{ active: activeCategory === index }"
- @click="activeCategory = index"
- >
- {{ category }}
- </view>
- </view>
- <!-- 推荐商品区域 -->
- <scroll-view scroll-y class="products-container">
- <!-- 推荐商品标题 -->
- <view class="section-header">
- <text class="section-title">推荐商品</text>
- <view class="view-more" @click="handleViewMore">
- <text class="view-more-text">查看更多</text>
- <text class="arrow">›</text>
- </view>
- </view>
- <!-- 商品网格 -->
- <view class="products-grid">
- <view
- v-for="(product, index) in recommendedProducts"
- :key="index"
- class="product-card"
- @click="handleProductClick(product)"
- >
- <view class="product-image">
- <image :src="product.image" mode="aspectFill"></image>
- </view>
- <view class="product-info">
- <text class="product-name">{{ product.name }}</text>
- <view class="product-price">
- <text class="price-value">{{ product.points }}</text>
- <text class="price-unit">💰</text>
- </view>
- </view>
- </view>
- </view>
- <!-- 底部空白 -->
- <view class="bottom-spacer"></view>
- </scroll-view>
- </view>
- </template>
- <script>
- export default {
- name: 'points-mall',
- data() {
- return {
- userPoints: 5000,
- cartCount: 0,
- activeCategory: 0,
- categories: ['全部', '实物商品', '虚拟商品'],
- recommendedProducts: [
- {
- id: 1,
- name: '清风原色无尘纸',
- points: 1000,
- image: 'https://via.placeholder.com/200x200?text=纸巾'
- },
- {
- id: 2,
- name: 'OPPO Enco Air2耳机',
- points: 7000,
- image: 'https://via.placeholder.com/200x200?text=耳机'
- },
- {
- id: 3,
- name: '五常大米',
- points: 3000,
- image: 'https://via.placeholder.com/200x200?text=大米'
- },
- {
- id: 4,
- name: '脸盆',
- points: 30,
- image: 'https://via.placeholder.com/200x200?text=脸盆'
- }
- ]
- }
- },
- methods: {
- // 返回上一页
- handleBack() {
- uni.navigateBack()
- },
- // 查看积分明细
- handlePointsDetail() {
- uni.showToast({
- title: '查看积分明细',
- icon: 'none'
- })
- },
- // 赚取积分
- handleEarnPoints() {
- uni.showToast({
- title: '赚取积分',
- icon: 'none'
- })
- },
- // 查看更多
- handleViewMore() {
- uni.showToast({
- title: '查看更多商品',
- icon: 'none'
- })
- },
- // 商品点击
- handleProductClick(product) {
- uni.showToast({
- title: `已添加 ${product.name} 到购物车`,
- icon: 'success'
- })
- this.cartCount++
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .points-mall {
- min-height: 100vh;
- background: #FFF9F9;
- display: flex;
- flex-direction: column;
- }
- /* 顶部导航栏 */
- .header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 25rpx 30rpx;
- padding-top: calc(25rpx + env(safe-area-inset-top));
- background: #FFF9F9;
- border-bottom: 1rpx solid #F0F0F0;
- .back-icon {
- width: 44rpx;
- height: 44rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 32rpx;
- color: #333;
- &::before {
- content: '‹';
- }
- }
- .header-title {
- font-size: 38rpx;
- font-weight: bold;
- color: #333;
- }
- .header-right {
- display: flex;
- align-items: center;
- gap: 20rpx;
- .search-icon {
- width: 44rpx;
- height: 44rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 32rpx;
- color: #999;
- &::before {
- content: '🔍';
- }
- }
- .cart-icon {
- width: 44rpx;
- height: 44rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 32rpx;
- color: #999;
- position: relative;
- &::before {
- content: '🛒';
- }
- .cart-badge {
- position: absolute;
- top: -8rpx;
- right: -8rpx;
- width: 32rpx;
- height: 32rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #FF4444;
- color: #FFFFFF;
- font-size: 20rpx;
- font-weight: bold;
- border-radius: 50%;
- }
- }
- }
- }
- /* 积分显示区域 */
- .points-section {
- background: linear-gradient(135deg, #FCE4EC 0%, #F8BBD0 100%);
- padding: 40rpx 30rpx;
- border-radius: 0 0 30rpx 30rpx;
- .points-header {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 20rpx;
- margin-bottom: 30rpx;
- .points-label {
- font-size: 28rpx;
- color: #666666;
- }
- .points-value {
- font-size: 64rpx;
- font-weight: bold;
- color: #333333;
- }
- .points-icon {
- font-size: 48rpx;
- }
- }
- .points-actions {
- display: flex;
- justify-content: space-around;
- .action-btn {
- padding: 15rpx 40rpx;
- background-color: rgba(255, 255, 255, 0.8);
- color: #9C27B0;
- border-radius: 30rpx;
- font-size: 28rpx;
- font-weight: bold;
- transition: all 0.3s;
- &:active {
- background-color: rgba(255, 255, 255, 1);
- }
- }
- }
- }
- /* 分类标签 */
- .category-tabs {
- display: flex;
- gap: 20rpx;
- padding: 20rpx 30rpx;
- background: #FFFFFF;
- overflow-x: auto;
- white-space: nowrap;
- .category-tab {
- padding: 12rpx 24rpx;
- background: #F5F5F5;
- color: #666;
- border-radius: 20rpx;
- font-size: 26rpx;
- white-space: nowrap;
- transition: all 0.3s;
- &.active {
- background: #9C27B0;
- color: #FFFFFF;
- font-weight: bold;
- }
- }
- }
- /* 商品容器 */
- .products-container {
- flex: 1;
- background: #FFFFFF;
- padding: 20rpx 30rpx;
- }
- /* 分类标题 */
- .section-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 20rpx;
- .section-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- }
- .view-more {
- display: flex;
- align-items: center;
- gap: 5rpx;
- .view-more-text {
- font-size: 24rpx;
- color: #9C27B0;
- }
- .arrow {
- font-size: 28rpx;
- color: #9C27B0;
- }
- }
- }
- /* 商品网格 */
- .products-grid {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 20rpx;
- margin-bottom: 20rpx;
- .product-card {
- background: #FFFFFF;
- border-radius: 16rpx;
- overflow: hidden;
- box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
- transition: all 0.3s;
- &:active {
- transform: translateY(-4rpx);
- box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.12);
- }
- .product-image {
- width: 100%;
- height: 200rpx;
- background: #F5F5F5;
- overflow: hidden;
- image {
- width: 100%;
- height: 100%;
- object-fit: cover;
- }
- }
- .product-info {
- padding: 15rpx;
- .product-name {
- display: block;
- font-size: 24rpx;
- color: #333;
- margin-bottom: 10rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .product-price {
- display: flex;
- align-items: center;
- gap: 5rpx;
- .price-value {
- font-size: 28rpx;
- font-weight: bold;
- color: #9C27B0;
- }
- .price-unit {
- font-size: 24rpx;
- }
- }
- }
- }
- }
- /* 底部空白 */
- .bottom-spacer {
- height: 40rpx;
- }
- </style>
|