Browse Source

Merge branch 'Xfy' of http://8.137.125.67:4000/SwtTt29/Mini-Program into Xfy

pull/9/head
Default User 2 months ago
parent
commit
b2add3c89f
  1. 35
      pages/goods-update/goods-update.js

35
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();
console.log('当前用户手机号:', userPhone);
const currentUserId = wx.getStorageSync('userId');
// 先检查是否为管理员
checkIsAdmin(userPhone)
.then(isAdmin => {
console.log('是否为管理员:', isAdmin);
if (isAdmin) {
// 是管理员,允许下架
console.log('管理员权限验证通过,允许下架');
console.log('当前用户手机号:', userPhone);
console.log('当前用户userId:', currentUserId);
console.log('商品sellerId(创建人):', productSellerId);
console.log('商品联系人电话:', contactPhone);
Promise.all([
checkIsAdmin(userPhone),
Promise.resolve({ isCreator: currentUserId === productSellerId })
])
.then(([adminResult, creatorResult]) => {
const isAdmin = adminResult;
const isCreator = creatorResult.isCreator;
const isContact = userPhone === contactPhone;
console.log('权限检查结果 - 管理员:', isAdmin, '创建人:', isCreator, '联系人:', isContact);
if (isAdmin || isCreator || isContact) {
console.log('权限验证通过,允许下架');
this.confirmUnpublish();
} else {
// 没有权限
console.log('没有下架权限');
wx.showModal({
title: '权限不足',
content: '你没有权限下架此货源',
content: '没有权限下架此货源',
showCancel: false
});
}

Loading…
Cancel
Save