Ver código fonte

feat(shop): 商城首页搜索栏加购物车入口(带角标) 财富页移除购物车服务项

iwt 1 mês atrás
pai
commit
d07e983e0e

+ 67 - 8
cfc-frontend/pages/shop/index/index.vue

@@ -12,10 +12,16 @@
       <text class="member-banner-action">立即开通 ›</text>
     </view>
 
-    <!-- 搜索栏 -->
-    <view class="search-bar" @click="goSearch">
-      <text class="search-icon">🔍</text>
-      <text class="search-placeholder">搜索商品</text>
+    <!-- 搜索栏 + 购物车 -->
+    <view class="search-row">
+      <view class="search-bar" @click="goSearch">
+        <text class="search-icon">🔍</text>
+        <text class="search-placeholder">搜索商品</text>
+      </view>
+      <view class="cart-btn" @click="goCart">
+        <text class="cart-icon">🛒</text>
+        <text v-if="cartCount > 0" class="cart-badge">{{ cartCount > 99 ? '99+' : cartCount }}</text>
+      </view>
     </view>
 
     <!-- Level 1 分类:2列横排网格 -->
@@ -142,7 +148,7 @@
 </template>
 
 <script>
-import { goodsCategory, productList, getMyMembership } from '@/utils/api.js'
+import { goodsCategory, productList, getMyMembership, cartCount } from '@/utils/api.js'
 import config from '@/config.js'
 export default {
   data() {
@@ -159,7 +165,8 @@ export default {
       noMore: false,
       isLoggedIn: false,
       isMember: false,
-      recommended: []
+      recommended: [],
+      cartCount: 0
     }
   },
   onLoad() {
@@ -168,10 +175,12 @@ export default {
     this.loadCategories()
     this.loadProducts()
     this.loadRecommended()
+    this.loadCartCount()
   },
   onShow() {
     this.checkMemberStatus()
     this.isLoggedIn = !!uni.getStorageSync('token')
+    this.loadCartCount()
   },
   methods: {
     loadCategories() {
@@ -275,6 +284,20 @@ export default {
     goSearch() {
       uni.navigateTo({ url: '/pages/shop/search/search' })
     },
+    goCart() {
+      uni.navigateTo({ url: '/pages/shop/cart/cart' })
+    },
+    loadCartCount() {
+      if (!uni.getStorageSync('token')) {
+        this.cartCount = 0
+        return
+      }
+      cartCount().then(res => {
+        if (res.code === 200) {
+          this.cartCount = res.data || 0
+        }
+      }).catch(() => {})
+    },
     loadRecommended() {
       productList({ page: 1, size: 6, sort: 'sales' }).then(res => {
         if (res.code === 200 && res.data) {
@@ -358,12 +381,18 @@ export default {
   font-weight: bold;
 }
 
-/* 搜索栏 */
+/* 搜索栏 + 购物车 */
+.search-row {
+  display: flex;
+  align-items: center;
+  margin: 16rpx 16rpx 0;
+  gap: 16rpx;
+}
 .search-bar {
+  flex: 1;
   display: flex;
   align-items: center;
   background: #fff;
-  margin: 16rpx 16rpx 0;
   padding: 16rpx 24rpx;
   border-radius: 50rpx;
   border: 1rpx solid #eee;
@@ -376,6 +405,36 @@ export default {
   font-size: 26rpx;
   color: #bbb;
 }
+.cart-btn {
+  position: relative;
+  width: 72rpx;
+  height: 72rpx;
+  border-radius: 50%;
+  background: #fff;
+  border: 1rpx solid #eee;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  flex-shrink: 0;
+}
+.cart-icon {
+  font-size: 36rpx;
+}
+.cart-badge {
+  position: absolute;
+  top: -6rpx;
+  right: -6rpx;
+  min-width: 32rpx;
+  height: 32rpx;
+  line-height: 32rpx;
+  padding: 0 8rpx;
+  border-radius: 16rpx;
+  background: #FF4D4F;
+  color: #fff;
+  font-size: 20rpx;
+  text-align: center;
+  box-sizing: border-box;
+}
 
 /* Member Upgrade Banner */
 .member-banner {

+ 0 - 7
cfc-frontend/pages/wealth/index.vue

@@ -140,10 +140,6 @@
             <text class="service-icon">🏪</text>
             <text class="service-label">商城首页</text>
           </view>
-          <view class="service-item" @click="goToCart">
-            <text class="service-icon">🛒</text>
-            <text class="service-label">购物车</text>
-          </view>
           <view class="service-item" @click="goToOrders">
             <text class="service-icon">📋</text>
             <text class="service-label">我的订单</text>
@@ -472,9 +468,6 @@ export default {
     goToShop() {
       uni.navigateTo({ url: '/pages/shop/index/index' })
     },
-    goToCart() {
-      uni.navigateTo({ url: '/pages/shop/cart/cart' })
-    },
     goToOrders() {
       uni.navigateTo({ url: '/pages/shop/order-list/order-list' })
     },

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-48528f06f580d5dc2a1e5679642f1a47b2a1df93
+48a30dd67acb340b09238ac6e87ad2bb026e4c32