From 0e2819b50be6d3612ec14e18238c7c3dc604a418 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 15:55:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8B=E6=9E=B6=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=9D=83=E9=99=90=E8=A7=84=E5=88=99=E8=A1=A5=E5=85=85=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=BA=BA=E5=92=8C=E8=81=94=E7=B3=BB=E4=BA=BA=E9=AA=8C?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods-update/goods-update.js | 31 ++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/pages/goods-update/goods-update.js b/pages/goods-update/goods-update.js index 98ccf90..bd2f94d 100644 --- a/pages/goods-update/goods-update.js +++ b/pages/goods-update/goods-update.js @@ -888,25 +888,36 @@ Page({ prepareUnpublishSupply: function() { console.log('准备下架商品 - 开始权限验证'); - // 权限控制 + const goodsDetail = this.data.goodsDetail; + const productSellerId = goodsDetail.sellerId || goodsDetail.product?.sellerId || ''; + const contactPhone = goodsDetail.contact_phone || goodsDetail.product_contact || ''; const userPhone = getLocalPhoneNumber(); + const currentUserId = wx.getStorageSync('userId'); + console.log('当前用户手机号:', userPhone); + console.log('当前用户userId:', currentUserId); + console.log('商品sellerId(创建人):', productSellerId); + console.log('商品联系人电话:', contactPhone); - // 先检查是否为管理员 - checkIsAdmin(userPhone) - .then(isAdmin => { - console.log('是否为管理员:', isAdmin); + Promise.all([ + checkIsAdmin(userPhone), + Promise.resolve({ isCreator: currentUserId === productSellerId }) + ]) + .then(([adminResult, creatorResult]) => { + const isAdmin = adminResult; + const isCreator = creatorResult.isCreator; + const isContact = userPhone === contactPhone; - if (isAdmin) { - // 是管理员,允许下架 - console.log('管理员权限验证通过,允许下架'); + console.log('权限检查结果 - 管理员:', isAdmin, '创建人:', isCreator, '联系人:', isContact); + + if (isAdmin || isCreator || isContact) { + console.log('权限验证通过,允许下架'); this.confirmUnpublish(); } else { - // 没有权限 console.log('没有下架权限'); wx.showModal({ title: '权限不足', - content: '你没有权限下架此货源', + content: '您没有权限下架此货源', showCancel: false }); }