|
|
|
@ -404,6 +404,18 @@ Page({ |
|
|
|
if (res && res.code === 200 && res.data) { |
|
|
|
const product = res.data; |
|
|
|
|
|
|
|
console.log('=== API返回的product原始数据 ==='); |
|
|
|
console.log('product对象的所有key:', Object.keys(product)); |
|
|
|
console.log('product中是否包含seller相关字段:'); |
|
|
|
console.log(' - sellerId:', product.sellerId); |
|
|
|
console.log(' - seller_id:', product.seller_id); |
|
|
|
console.log(' - seller:', product.seller); |
|
|
|
console.log(' - userId:', product.userId); |
|
|
|
console.log(' - user_id:', product.user_id); |
|
|
|
console.log(' - creator:', product.creator); |
|
|
|
console.log(' - 创建人ID:', product.creatorId); |
|
|
|
console.log(' - 创建人ID:', product.creator_id); |
|
|
|
|
|
|
|
// 只过滤hidden状态的商品
|
|
|
|
if (product.status === 'hidden') { |
|
|
|
wx.showToast({ |
|
|
|
@ -771,8 +783,8 @@ Page({ |
|
|
|
// 隐藏编辑弹窗
|
|
|
|
this.hideEditModal(); |
|
|
|
|
|
|
|
// 重新加载商品详情
|
|
|
|
this.loadGoodsDetail(productId); |
|
|
|
// 重新加载商品详情,传入当前数据保持创建人和创建时间不变
|
|
|
|
this.loadGoodsDetail(productId, this.data.goodsDetail); |
|
|
|
} else { |
|
|
|
wx.showToast({ |
|
|
|
title: '更新失败', |
|
|
|
@ -889,19 +901,23 @@ Page({ |
|
|
|
console.log('准备下架商品 - 开始权限验证'); |
|
|
|
|
|
|
|
const goodsDetail = this.data.goodsDetail; |
|
|
|
const productSellerId = goodsDetail.sellerId || goodsDetail.product?.sellerId || ''; |
|
|
|
console.log('完整goodsDetail结构:', JSON.stringify(goodsDetail, null, 2)); |
|
|
|
|
|
|
|
const productSellerId = goodsDetail.sellerId || goodsDetail.seller_id || goodsDetail.userId || goodsDetail.user_id || |
|
|
|
goodsDetail.creatorId || goodsDetail.creator_id || goodsDetail.product?.sellerId || |
|
|
|
goodsDetail.product?.seller_id || goodsDetail.product?.userId || goodsDetail.seller?.userId || ''; |
|
|
|
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('当前用户userId:', currentUserId, '(类型:', typeof currentUserId, ')'); |
|
|
|
console.log('商品sellerId(创建人):', productSellerId, '(类型:', typeof productSellerId, ')'); |
|
|
|
console.log('商品联系人电话:', contactPhone); |
|
|
|
|
|
|
|
Promise.all([ |
|
|
|
checkIsAdmin(userPhone), |
|
|
|
Promise.resolve({ isCreator: currentUserId === productSellerId }) |
|
|
|
Promise.resolve({ isCreator: String(currentUserId) === String(productSellerId) }) |
|
|
|
]) |
|
|
|
.then(([adminResult, creatorResult]) => { |
|
|
|
const isAdmin = adminResult; |
|
|
|
|