Browse Source

花掌柜小程序-售后记录加角标

ouyang 13 giờ trước cách đây
mục cha
commit
b3c3ec46b0

+ 11 - 1
hdApp/src/admin/billing/freeRefundList.vue

@@ -240,7 +240,17 @@ export default {
       return tab ? tab.id : -1
     }
   },
-  onLoad() {
+  onLoad(option) {
+    this.option = option || {}
+    // 应用页「退款记录」带 tab=pending:默认切到待审核(tabs 下标 1)
+    if (this.option.tab === 'pending' || String(this.option.status) === '0') {
+      this.tabIndex = 1
+    } else if (this.option.tabIndex != null && this.option.tabIndex !== '') {
+      const idx = Number(this.option.tabIndex)
+      if (idx >= 0 && idx < this.tabs.length) {
+        this.tabIndex = idx
+      }
+    }
     this.resetList()
     this._list()
   },

+ 65 - 1
hdApp/src/admin/home/apply.vue

@@ -27,6 +27,10 @@
                 mode="aspectFit"
               />
               <view v-else class="icon-empty"></view>
+              <!-- 退款记录:有待审核时红角标提示数量 -->
+              <view v-if="menuBadgeCount(s) > 0" class="menu-badge">
+                {{ formatMenuBadge(menuBadgeCount(s)) }}
+              </view>
             </view>
             <view class="icon-text">{{ s.name }}</view>
           </view>
@@ -40,12 +44,15 @@
 import { mapGetters } from 'vuex'
 import NotLogin from '@/components/not-login'
 import { iconSrc } from '@/utils/iconSrc'
+import { refundList } from '@/api/refund'
 
 export default {
   name: 'apply',
   components: { NotLogin },
   data() {
     return {
+      /** 售后待审核条数,供「退款记录」角标 */
+      pendingRefundCount: 0,
       /** 应用页菜单分组(写死) */
       applyMenuList: [
         {
@@ -64,7 +71,8 @@ export default {
             { name: '开单', icon: 'plant-billing', action: 'goItemKd', pf: 1 },
             { name: '快捷开单', icon: 'plant-quick-billing', action: 'goItemKjKd', pf: 1 },
             { name: '退款', icon: 'order-filled', url: '/admin/custom/selectCustom?style=1&refund=1', pf: 1 },
-            { name: '退款记录', icon: 'order-filled', url: '/admin/billing/freeRefundList', pf: 1 },
+            // badge=pendingRefund:角标挂待审核数;进列表默认待审核 Tab
+            { name: '退款记录', icon: 'order-filled', url: '/admin/billing/freeRefundList?tab=pending', badge: 'pendingRefund', pf: 1 },
             { name: '花材排序', icon: 'sort-filled', url: '/admin/itemClass/sort', pf: 1 },
             { name: '改价', icon: 'change-price-filled', url: '/admin/changePrice/list2', pf: 1 },
             { name: '报损', icon: 'breakage', url: '/admin/breakage/list', pf: 1 },
@@ -144,9 +152,45 @@ export default {
   computed: {
     ...mapGetters({ loginInfo: 'getLoginInfo', myShopInfo: 'getMyShopInfo' })
   },
+  onShow() {
+    // 从售后详情返回时刷新待审核角标
+    this.loadPendingRefundCount()
+  },
   methods: {
     iconSrc,
     init() {},
+    /**
+     * 菜单角标数量:目前仅退款记录挂待审核数
+     * @param {Object} item 菜单项
+     */
+    menuBadgeCount(item) {
+      if (item && item.badge === 'pendingRefund') {
+        return Number(this.pendingRefundCount) || 0
+      }
+      return 0
+    },
+    /** 角标展示:超过 99 显示 99+ */
+    formatMenuBadge(n) {
+      const num = Number(n) || 0
+      return num > 99 ? '99+' : String(num)
+    },
+    /**
+     * 拉取待审核售后条数,用于「退款记录」入口角标。
+     * 参数与 freeRefundList 待审核 Tab 一致:近30天 + status=0,避免角标与列表对不上。
+     */
+    loadPendingRefundCount() {
+      refundList({
+        page: 1,
+        useDefaultLast30: 1,
+        refundSearchTime: 'last30Days',
+        sameDay: -1,
+        status: 0
+      }).then(res => {
+        if (res.code == 1 && res.data) {
+          this.pendingRefundCount = Number(res.data.totalNum) || 0
+        }
+      }).catch(() => {})
+    },
     goItemKjKd() {
       if (this.myShopInfo && Number(this.myShopInfo.defaultCustomId) > 0) {
         this.$util.pageTo({ url: '/admin/billing/index2?customId=' + this.myShopInfo.defaultCustomId })
@@ -171,6 +215,7 @@ export default {
     }
   },
   onPullDownRefresh() {
+    this.loadPendingRefundCount()
     uni.stopPullDownRefresh()
   }
 }
@@ -243,6 +288,7 @@ export default {
         border-radius: 12upx;
 
         .icon-wrapper {
+          position: relative;
           width: 96upx;
           height: 96upx;
           box-sizing: border-box;
@@ -266,6 +312,24 @@ export default {
             border-radius: 16upx;
             background: rgba(9, 197, 103, 0.12);
           }
+
+          /* 菜单角标:右上角红底白字 */
+          .menu-badge {
+            position: absolute;
+            top: -8upx;
+            right: -10upx;
+            min-width: 32upx;
+            height: 32upx;
+            padding: 0 8upx;
+            box-sizing: border-box;
+            border-radius: 16upx;
+            background: #ff2842;
+            color: #fff;
+            font-size: 20upx;
+            font-weight: bold;
+            line-height: 32upx;
+            text-align: center;
+          }
         }
 
         .icon-text {

+ 67 - 1
hdApp/src/admin/home/components/mall-home-panel.vue

@@ -83,6 +83,10 @@
                 :src="iconSrc(item.icon)"
                 mode="aspectFit"
               />
+              <!-- 菜单角标(如退款待审核) -->
+              <view v-if="menuBadgeCount(item) > 0" class="menu-badge">
+                {{ formatMenuBadge(menuBadgeCount(item)) }}
+              </view>
             </view>
             <view class="home-menu-text">{{ item.name }}</view>
           </view>
@@ -112,6 +116,10 @@
                 :src="iconSrc(item.icon)"
                 mode="aspectFit"
               />
+              <!-- 退款记录:有待审核时红角标提示数量 -->
+              <view v-if="menuBadgeCount(item) > 0" class="menu-badge">
+                {{ formatMenuBadge(menuBadgeCount(item)) }}
+              </view>
             </view>
             <view class="home-menu-text">{{ item.name }}</view>
           </view>
@@ -163,10 +171,12 @@ import { currentShop } from "@/api/shop";
 import { unReadMsgCount } from "@/api/chat";
 import { getWorkbenchSummary } from '@/api/birthday';
 import { iconSrc } from "@/utils/iconSrc";
+import { refundList } from '@/api/refund'
 
 /**
  * 工作台首页面板
  * 用途:店铺首页快捷操作 / 业务菜单 / 更多功能;菜单项直接写死,不走配置文件与本地缓存。
+ * 含「退款记录」待审核角标,与应用页 apply 行为一致。
  */
 export default {
   name: "MallHomePanel",
@@ -198,6 +208,8 @@ export default {
       unReadMsgNum: 0,
       currentDate: '',
       birthdaySummary: { today: 0, tomorrow: 0, week: 0 },
+      /** 售后待审核条数,供「退款记录」角标 */
+      pendingRefundCount: 0,
       // 快捷操作(写死)
       quickMenuList: [
         { name: '开单', icon: 'plant-billing', action: 'goItemKd', pf: 1 },
@@ -216,7 +228,8 @@ export default {
         { name: '首页配置', icon: 'settings-filled', url: '/admin/homePageConfig/index', pf: 1 },
         { name: '公告', icon: 'notice', url: '/admin/shopNotice/list', pf: 1 },
         { name: '退款', icon: 'order-filled', url: '/admin/custom/selectCustom?style=1&refund=1', pf: 1 },
-        { name: '退款记录', icon: 'order-filled', url: '/admin/billing/freeRefundList', pf: 1 },
+        // badge=pendingRefund:角标挂待审核数;进列表默认待审核 Tab
+        { name: '退款记录', icon: 'order-filled', url: '/admin/billing/freeRefundList?tab=pending', badge: 'pendingRefund', pf: 1 },
         { name: '拆散', icon: 'disassemble', url: '/admin/part/list', pf: 1 },
         { name: '改价', icon: 'change-price-filled', url: '/admin/changePrice/list2', pf: 1 },
         { name: '报损', icon: 'breakage', url: '/admin/breakage/list', pf: 1 },
@@ -354,8 +367,42 @@ export default {
         }
       })
       this.getUnReadMsgCount()
+      // 与聊天未读一并刷新:退款待审核角标
+      this.loadPendingRefundCount()
       return Promise.all([p1, p2, p3])
     },
+    /**
+     * 菜单角标数量:目前仅退款记录挂待审核数
+     * @param {Object} item 菜单项
+     */
+    menuBadgeCount(item) {
+      if (item && item.badge === 'pendingRefund') {
+        return Number(this.pendingRefundCount) || 0
+      }
+      return 0
+    },
+    /** 角标展示:超过 99 显示 99+ */
+    formatMenuBadge(n) {
+      const num = Number(n) || 0
+      return num > 99 ? '99+' : String(num)
+    },
+    /**
+     * 拉取待审核售后条数,用于「退款记录」入口角标。
+     * 参数与 freeRefundList 待审核 Tab 一致:近30天 + status=0,避免角标与列表对不上。
+     */
+    loadPendingRefundCount() {
+      refundList({
+        page: 1,
+        useDefaultLast30: 1,
+        refundSearchTime: 'last30Days',
+        sameDay: -1,
+        status: 0
+      }).then(res => {
+        if (res.code == 1 && res.data) {
+          this.pendingRefundCount = Number(res.data.totalNum) || 0
+        }
+      }).catch(() => {})
+    },
     showShopName() {
 			currentShop().then(res => {
 				if(res.code == 1){
@@ -796,6 +843,7 @@ export default {
 }
 
 .home-icon-box {
+  position: relative;
   width: 96upx;
   height: 96upx;
   border-radius: 18upx;
@@ -807,6 +855,24 @@ export default {
   line-height: 0;
 }
 
+/* 菜单角标:右上角红底白字(与 apply 页一致) */
+.menu-badge {
+  position: absolute;
+  top: -8upx;
+  right: -10upx;
+  min-width: 32upx;
+  height: 32upx;
+  padding: 0 8upx;
+  box-sizing: border-box;
+  border-radius: 16upx;
+  background: #ff2842;
+  color: #fff;
+  font-size: 20upx;
+  font-weight: bold;
+  line-height: 32upx;
+  text-align: center;
+}
+
 .quick-menu-icon-img,
 .home-menu-icon-img {
   display: block;