From 2f15e034154ae04721cdc3db19c357be1d4b5103 Mon Sep 17 00:00:00 2001 From: Default User Date: Fri, 23 Jan 2026 10:11:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E7=82=B9=E5=87=BB=E4=B8=8B?= =?UTF-8?q?=E6=9E=B6=E6=8C=89=E9=92=AE=E6=97=B6=E9=BB=98=E8=AE=A4=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E6=89=80=E6=9C=89=E6=9C=AA=E5=94=AE=E7=A9=BA=E8=A7=84?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods-update/goods-update.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/pages/goods-update/goods-update.js b/pages/goods-update/goods-update.js index 73512dc..9219da6 100644 --- a/pages/goods-update/goods-update.js +++ b/pages/goods-update/goods-update.js @@ -1647,10 +1647,32 @@ Page({ // 确认下架(实际执行下架确认的内部方法) confirmUnpublish: function() { - // 显示规格选择弹窗,让用户选择要下架的规格 + const goodsDetail = this.data.goodsDetail; + const weightQuantityData = goodsDetail.weightQuantityData || []; + + // 计算所有未售空的规格索引 + let selectedSpecIndices = []; + let isSelected = []; + + // 遍历规格数据,找出所有未售空的规格 + weightQuantityData.forEach((item, index) => { + // 如果规格状态不是1(未售空),则默认选中 + if (item.specStatus !== '1') { + selectedSpecIndices.push(index); + isSelected[index] = true; + } else { + isSelected[index] = false; + } + }); + + console.log('默认选中的规格索引:', selectedSpecIndices); + console.log('默认选中的状态数组:', isSelected); + + // 显示规格选择弹窗,默认选中所有未售空的规格 this.setData({ showSpecUnpublishModal: true, - selectedSpecIndex: -1 // 重置选中索引 + selectedSpecIndices: selectedSpecIndices, + isSelected: isSelected }); },