Compare commits

..

No commits in common. "main" and "council/FrontendDeveloper" have entirely different histories.

3 changed files with 3 additions and 72 deletions

View File

@ -280,15 +280,11 @@ class Goods
}
try {
// 缓存检查(注意:旧缓存不含 goods 字段,需要补充)
// 缓存检查
$cacheKey = 'vr_tree_v4_' . $goodsId . '_' . md5(implode(',', $groupBy));
$cached = \think\facade\Cache::get($cacheKey);
if ($cached !== null) {
$cached['meta']['cache_hit'] = true;
// 旧缓存不含 goods补充构建
if (!isset($cached['goods'])) {
$cached['goods'] = self::buildGoodsField($goodsId);
}
return self::success($cached);
}
@ -301,7 +297,6 @@ class Goods
'goods_id' => $goodsId,
'group_by' => $groupBy,
'tree' => [],
'goods' => self::buildGoodsField($goodsId),
'seat_templates' => new \stdClass(),
'meta' => [
'seat_count' => 0,
@ -325,7 +320,6 @@ class Goods
'goods_id' => $goodsId,
'group_by' => $groupBy,
'tree' => $treeData['tree'],
'goods' => self::buildGoodsField($goodsId),
'seat_templates' => $seatTemplates,
'session_meta' => $sessionMeta,
'peer_goods' => QueryManager::getPeerGoods($goodsId),
@ -346,47 +340,6 @@ class Goods
}
}
/**
* 构建 goods 字段(包含手机详情 content_app
*
* 复用 GoodsService::GoodsList传入 is_content_app=1 以包含手机端详情数据。
* 这使得 uniapp 可以仅调用 tree API 一次就获取完整数据,无需二次请求 goods/detail。
*
* @param int $goodsId
* @return array
*/
private static function buildGoodsField(int $goodsId): array
{
$isUseMobileDetail = intval(\MyC('common_app_is_use_mobile_detail', 0, true));
$params = [
'where' => [
['id', '=', $goodsId],
['is_delete_time', '=', 0],
],
'is_content_app' => $isUseMobileDetail,
'is_spec' => 1,
'is_params' => 1,
'is_favor' => 1,
'm' => 0,
'n' => 1,
];
$ret = GoodsService::GoodsList($params);
$goods = $ret['data'][0] ?? null;
if (empty($goods)) {
return [];
}
// 手机端详情模式下移除 PC 富文本,减少响应体积
if ($isUseMobileDetail == 1) {
unset($goods['content_web']);
}
return $goods;
}
/**
* 格式化商品列表数据
*/

View File

@ -82,7 +82,7 @@ class AdminGoodsIndex
// 触发chosen组件更新如果已初始化
if ($.fn.chosen && select.classList.contains('chosen-init-success')) {
$(select).trigger('chosen:updated');
select.trigger('chosen:updated');
}
return true;

View File

@ -364,19 +364,11 @@ class AdminGoodsSave
});
};
// 备份原始的 produce_region 选项 HTML
let originalRegionOptionsHtml = '';
// ── 动态替换 produce_region 下拉选项为 level=2 城市 ──
const replaceCityOptions = () => {
const select = document.querySelector('select[name="produce_region"]');
if (!select) return;
// 备份原始选项 HTML仅在第一次被替换前备份
if (!originalRegionOptionsHtml) {
originalRegionOptionsHtml = select.innerHTML;
}
// 优先使用 PHP 传递的保存值(城市 ID这是最可靠的数据源
const savedValue = AppData.savedProduceRegion || 0;
@ -399,18 +391,7 @@ class AdminGoodsSave
// 触发chosen组件更新如果使用了chosen插件
if ($.fn.chosen) {
$(select).trigger('chosen:updated');
}
};
const restoreCityOptions = () => {
const select = document.querySelector('select[name="produce_region"]');
if (!select || !originalRegionOptionsHtml) return;
select.innerHTML = originalRegionOptionsHtml;
if ($.fn.chosen) {
$(select).trigger('chosen:updated');
select.trigger('chosen:updated');
}
};
@ -419,9 +400,6 @@ class AdminGoodsSave
if (val) {
// 票务商品模式:替换城市下拉选项
replaceCityOptions();
} else {
// 恢复原始选项
restoreCityOptions();
}
}, { immediate: true });