From fa5badc9933a739cb39684fb6d82dcbbe5213ae2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?=
<15778543+xufeiyang6017@user.noreply.gitee.com>
Date: Tue, 6 Jan 2026 10:15:38 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=89=8B=E6=9C=BA?=
=?UTF-8?q?=E5=8F=B7=E9=AA=8C=E8=AF=81=E6=98=BE=E7=A4=BA=E8=B4=A7=E6=BA=90?=
=?UTF-8?q?=E7=AE=A1=E7=90=86=E6=8C=89=E9=92=AE=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/index/index.js | 42 +++++++++++++++++++++++++++++++++++++++++-
pages/index/index.wxml | 2 +-
utils/api.js | 38 +++++++++++++++++++++++++++++++++++++-
3 files changed, 79 insertions(+), 3 deletions(-)
diff --git a/pages/index/index.js b/pages/index/index.js
index d9e4024..5add9aa 100644
--- a/pages/index/index.js
+++ b/pages/index/index.js
@@ -68,6 +68,7 @@ Page({
sidebarBtnTop: 500,
sidebarBtnHidden: false,
isPageHidden: false,
+ hasGoodsManagePermission: false,
// 搜索区域相关
searchSectionVisible: true,
@@ -176,8 +177,47 @@ Page({
if (this.data.isDragging) {
return;
}
+
+ const newShowSidebar = !this.data.showSidebar;
+
+ if (newShowSidebar) {
+ this.checkGoodsManagePermission();
+ }
+
this.setData({
- showSidebar: !this.data.showSidebar
+ showSidebar: newShowSidebar
+ });
+ },
+
+ // 检查用户是否有货源管理权限
+ checkGoodsManagePermission() {
+ const users = wx.getStorageSync('users') || {};
+ const userId = wx.getStorageSync('userId');
+ let userPhone = null;
+
+ if (userId && users[userId] && users[userId].phoneNumber) {
+ userPhone = users[userId].phoneNumber;
+ } else {
+ const userInfo = wx.getStorageSync('userInfo');
+ if (userInfo && userInfo.phoneNumber) {
+ userPhone = userInfo.phoneNumber;
+ } else {
+ userPhone = wx.getStorageSync('phoneNumber');
+ }
+ }
+
+ if (!userPhone) {
+ console.log('用户未绑定手机号,无货源管理权限');
+ this.setData({ hasGoodsManagePermission: false });
+ return;
+ }
+
+ API.checkPersonnelByPhone(userPhone).then(res => {
+ console.log('货源管理权限检查结果:', res);
+ this.setData({ hasGoodsManagePermission: res.exists });
+ }).catch(err => {
+ console.error('检查货源管理权限失败:', err);
+ this.setData({ hasGoodsManagePermission: false });
});
},
diff --git a/pages/index/index.wxml b/pages/index/index.wxml
index 5f57b78..f23f843 100644
--- a/pages/index/index.wxml
+++ b/pages/index/index.wxml
@@ -100,7 +100,7 @@
-