Browse Source

feat(profile): 商城订单快捷+推广中心快捷+购物车/订单角标

iwt 1 month ago
parent
commit
309c81563b

+ 116 - 5
cfc-frontend/pages/profile-main/profile.vue

@@ -70,6 +70,58 @@
         </view>
       </view>
 
+      <!-- 商城订单快捷 -->
+      <view class="mall-section" v-if="totalPoints > 0">
+        <view class="mall-header" @click="goToOrders">
+          <text class="mall-title">🛒 商城订单</text>
+          <text class="mall-more">全部订单 ›</text>
+        </view>
+        <view class="mall-grid">
+          <view class="mall-item" @click="goToOrders">
+            <text class="mall-item-num" v-if="orderPending > 0">{{ orderPending }}</text>
+            <text class="mall-item-num" v-else>0</text>
+            <text class="mall-item-label">待审核</text>
+          </view>
+          <view class="mall-item" @click="goToOrders">
+            <text class="mall-item-num" v-if="orderUnpaid > 0">{{ orderUnpaid }}</text>
+            <text class="mall-item-num" v-else>0</text>
+            <text class="mall-item-label">待付款</text>
+          </view>
+          <view class="mall-item" @click="goToOrders">
+            <text class="mall-item-num" v-if="orderShipped > 0">{{ orderShipped }}</text>
+            <text class="mall-item-num" v-else>0</text>
+            <text class="mall-item-label">待发货</text>
+          </view>
+          <view class="mall-item" @click="goToOrders">
+            <text class="mall-item-num" v-if="orderAfterSale > 0">{{ orderAfterSale }}</text>
+            <text class="mall-item-num" v-else>0</text>
+            <text class="mall-item-label">售后</text>
+          </view>
+        </view>
+      </view>
+
+      <!-- 推广中心快捷 -->
+      <view class="mall-section" v-if="commissionBalance > 0 || referralCount > 0 || teamCount > 0">
+        <view class="mall-header" @click="goToPromotion">
+          <text class="mall-title">💰 推广中心</text>
+          <text class="mall-more">进入 ›</text>
+        </view>
+        <view class="mall-grid">
+          <view class="mall-item" @click="goToPromotion">
+            <text class="mall-item-num">{{ commissionBalance }}</text>
+            <text class="mall-item-label">可提现</text>
+          </view>
+          <view class="mall-item" @click="goToPromotion">
+            <text class="mall-item-num">{{ referralCount }}</text>
+            <text class="mall-item-label">邀请人数</text>
+          </view>
+          <view class="mall-item" @click="goToPromotion">
+            <text class="mall-item-num">{{ teamCount }}</text>
+            <text class="mall-item-label">团队人数</text>
+          </view>
+        </view>
+      </view>
+
       <!-- 五维能量 -->
       <view class="energy-section" v-if="sandboxData">
         <view class="section-header">
@@ -158,14 +210,21 @@
         <!-- 商城 -->
         <view class="menu-group" v-if="showServices">
           <view class="menu-group-title">商城</view>
-          <view class="menu-item" @click="goToMembership">
-            <text class="menu-icon">👑</text>
-            <text class="menu-text">会员中心</text>
+          <view class="menu-item" @click="goToPromotion">
+            <text class="menu-icon">💰</text>
+            <text class="menu-text">推广中心</text>
             <text class="arrow">›</text>
           </view>
           <view class="menu-item" @click="goToOrders">
             <text class="menu-icon">🛒</text>
             <text class="menu-text">我的订单</text>
+            <text class="badge" v-if="orderPending + orderUnpaid + orderShipped + orderAfterSale > 0">{{ orderPending + orderUnpaid + orderShipped + orderAfterSale }}</text>
+            <text class="arrow">›</text>
+          </view>
+          <view class="menu-item" @click="goToCart">
+            <text class="menu-icon">🛍️</text>
+            <text class="menu-text">购物车</text>
+            <text class="badge" v-if="cartCount > 0">{{ cartCount }}</text>
             <text class="arrow">›</text>
           </view>
           <view class="menu-item" @click="goToCoupons">
@@ -206,7 +265,8 @@ import AIFloatingAvatar from '../../components/AIFloatingAvatar.vue'
 import {
   getChildren, getVisibleFamilyMembers, getFamilyEnergySandbox,
   getTodayTasksByCategory, getChallengeList, getMyMembership,
-  verifyPassword, getPointsBalance, getUserInfo
+  verifyPassword, getPointsBalance, getUserInfo,
+  cartCount, getOrderCounts, getCommissionSummary, getReferralSummary
 } from '../../utils/api.js'
 
 export default {
@@ -227,7 +287,17 @@ export default {
       activeChallenges: 0,
       profileProgress: 0,
       sandboxData: null,
-      energyDims: []
+      energyDims: [],
+      // 商城
+      cartCount: 0,
+      orderPending: 0,
+      orderUnpaid: 0,
+      orderShipped: 0,
+      orderAfterSale: 0,
+      // 推广中心
+      commissionBalance: 0,
+      referralCount: 0,
+      teamCount: 0
     }
   },
   computed: {
@@ -278,6 +348,9 @@ export default {
       this.loadSandbox()
       this.loadTasks()
       this.loadChallenges()
+      this.loadOrderCounts()
+      this.loadCartCount()
+      this.loadPromotion()
     },
     loadUserInfo() {
       var self = this
@@ -358,6 +431,38 @@ export default {
         }
       }).catch(function() {})
     },
+    loadOrderCounts() {
+      var self = this
+      getOrderCounts().then(function(res) {
+        if (res && res.data) {
+          self.orderPending = res.data.pending || 0
+          self.orderUnpaid = res.data.unpaid || res.data.paid || 0
+          self.orderShipped = res.data.shipped || 0
+          self.orderAfterSale = res.data.refunding || res.data.afterSale || 0
+        }
+      }).catch(function() {})
+    },
+    loadCartCount() {
+      var self = this
+      cartCount().then(function(res) {
+        if (res && res.data != null) {
+          self.cartCount = res.data || 0
+        }
+      }).catch(function() {})
+    },
+    loadPromotion() {
+      var self = this
+      getCommissionSummary().then(function(res) {
+        if (res && res.data) {
+          self.commissionBalance = res.data.availableAmount || res.data.balance || 0
+        }
+      }).catch(function() {})
+      getReferralSummary().then(function(res) {
+        if (res && res.data) {
+          self.referralCount = res.data.totalCount || res.data.count || 0
+        }
+      }).catch(function() {})
+    },
     getDimColor: function(code) {
       var map = {
         body: '#FF8C42', mind: '#FF6B9D', wisdom: '#6366F1',
@@ -401,6 +506,12 @@ export default {
     goToMembership: function() {
       uni.navigateTo({ url: '/pages/membership/index' })
     },
+    goToPromotion: function() {
+      uni.navigateTo({ url: '/pages/promotion/index' })
+    },
+    goToCart: function() {
+      uni.navigateTo({ url: '/pages/shop/cart/cart' })
+    },
     goToOrders: function() {
       uni.navigateTo({ url: '/pages/shop/order-list/order-list' })
     },

+ 4 - 0
cfc-frontend/utils/api.js

@@ -2316,6 +2316,10 @@ export const cartAdd = (data) => request('/api/cart/add', 'POST', data)
 export const cartList = (data) => request('/api/cart/list', 'POST', data)
 export const cartUpdate = (data) => request('/api/cart/update', 'POST', data)
 export const cartRemove = (data) => request('/api/cart/remove', 'POST', data)
+export const cartCount = () => request('/api/cart/count', 'POST', {})
+
+// ===== 我的订单 =====
+export const getOrderCounts = () => request('/api/product-order/my/counts', 'POST', {})
 
 // ===== 收货人管理 =====
 export const consigneeList = () => request('/api/consignee/list', 'POST', {})

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-86e112e67e30b29ca6a9e015a53dc77a4b6da97b
+e37f80ded1363e2f08d3596fd569776bd6df9b8f

+ 2 - 2
cfc-web/package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "cfc-web",
-  "version": "1.0.886",
+  "version": "1.0.887",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "cfc-web",
-      "version": "1.0.886",
+      "version": "1.0.887",
       "dependencies": {
         "@wangeditor/editor": "^5.1.23",
         "@wangeditor/editor-for-vue": "^1.0.2",