From 3bc5ea70fe58a121f03ded5208edc271578e4258 Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 15 Oct 2026 15:16:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/application/api/controller/Common.php | 2 ++ .../miniapp/components/goods-card/index.js | 5 ++++ .../miniapp/components/goods-card/index.wxml | 6 ++--- .../miniapp/components/goods-list/index.js | 5 ++++ .../miniapp/components/goods-list/index.wxml | 2 +- frontend/miniapp/pages/goods/details/index.js | 14 +++++++++++ .../miniapp/pages/goods/details/index.wxml | 6 ++--- .../miniapp/pages/goods/details/index.wxss | 4 +++ frontend/miniapp/pages/goods/list/index.js | 12 +++++++++ frontend/miniapp/pages/goods/list/index.wxml | 2 +- frontend/miniapp/services/home/home.js | 25 +++++++++++++++++++ 11 files changed, 75 insertions(+), 8 deletions(-) diff --git a/backend/application/api/controller/Common.php b/backend/application/api/controller/Common.php index bfa679e..85cfd1f 100644 --- a/backend/application/api/controller/Common.php +++ b/backend/application/api/controller/Common.php @@ -195,6 +195,8 @@ class Common extends Api 'platform_commission_ratio' => (float)DemandService::getPlatformCommissionRatio(), // 推广分享卡片预览图,未配置时为空 'promotion_share_image' => $shareImage ? cdnurl($shareImage, true) : '', + // 商品按案例展示:不显示价格和购买入口 + 'goods_case_view' => (string)(config('site.miniapp_review_mode') ?? '0') === '1', ]; $this->success('', $config); diff --git a/frontend/miniapp/components/goods-card/index.js b/frontend/miniapp/components/goods-card/index.js index c5bdc68..d52b82b 100644 --- a/frontend/miniapp/components/goods-card/index.js +++ b/frontend/miniapp/components/goods-card/index.js @@ -37,6 +37,11 @@ Component({ type: Boolean, value: false, }, + // 是否展示价格(案例展示时关闭) + showPrice: { + type: Boolean, + value: true, + }, thresholds: { type: Array, diff --git a/frontend/miniapp/components/goods-card/index.wxml b/frontend/miniapp/components/goods-card/index.wxml index ddd1d2f..807fec7 100644 --- a/frontend/miniapp/components/goods-card/index.wxml +++ b/frontend/miniapp/components/goods-card/index.wxml @@ -16,9 +16,9 @@ {{ tag }} - - - + + + diff --git a/frontend/miniapp/components/goods-list/index.js b/frontend/miniapp/components/goods-list/index.js index 71c4a5b..02bc61c 100644 --- a/frontend/miniapp/components/goods-list/index.js +++ b/frontend/miniapp/components/goods-list/index.js @@ -22,6 +22,11 @@ Component({ type: Boolean, value: false, }, + // 是否展示价格(案例展示时关闭) + showPrice: { + type: Boolean, + value: true, + }, }, data: { diff --git a/frontend/miniapp/components/goods-list/index.wxml b/frontend/miniapp/components/goods-list/index.wxml index 11a74f0..4625abc 100644 --- a/frontend/miniapp/components/goods-list/index.wxml +++ b/frontend/miniapp/components/goods-list/index.wxml @@ -1,5 +1,5 @@ - + diff --git a/frontend/miniapp/pages/goods/details/index.js b/frontend/miniapp/pages/goods/details/index.js index c5dd6e0..6824617 100644 --- a/frontend/miniapp/pages/goods/details/index.js +++ b/frontend/miniapp/pages/goods/details/index.js @@ -6,6 +6,7 @@ import { } from '../../../services/good/fetchGoodsDetailsComments'; import { cdnBase } from '../../../config/index'; +import { fetchGoodsCaseView } from '../../../services/home/home'; import { withPromoter, promoterQuery } from '../../../utils/promoter'; const imgPrefix = `${cdnBase}/`; @@ -74,6 +75,7 @@ Page({ duration: 500, interval: 5000, soldNum: 0, // 已售数量 + caseView: wx.getStorageSync('goodsCaseView') === true, // 案例展示:使用默认标题,不显示购买和规格 }, handlePopupHide() { @@ -409,8 +411,20 @@ Page({ this.setData({ spuId: spuId, }); + this.applyCaseView(); this.getDetail(spuId); this.getCommentsList(spuId); this.getCommentsStatistics(spuId); }, + + async applyCaseView() { + if (this.data.caseView) { + wx.setNavigationBarTitle({ title: '' }); + } + const caseView = await fetchGoodsCaseView(); + this.setData({ caseView }); + if (caseView) { + wx.setNavigationBarTitle({ title: '' }); + } + }, }); diff --git a/frontend/miniapp/pages/goods/details/index.wxml b/frontend/miniapp/pages/goods/details/index.wxml index 653c6be..32e171c 100644 --- a/frontend/miniapp/pages/goods/details/index.wxml +++ b/frontend/miniapp/pages/goods/details/index.wxml @@ -1,4 +1,4 @@ - + @@ -45,7 +45,7 @@ {{details.intro}} - + 已选 @@ -97,7 +97,7 @@ - + diff --git a/frontend/miniapp/pages/goods/details/index.wxss b/frontend/miniapp/pages/goods/details/index.wxss index aae4479..30a845b 100644 --- a/frontend/miniapp/pages/goods/details/index.wxss +++ b/frontend/miniapp/pages/goods/details/index.wxss @@ -11,6 +11,10 @@ page { background-color: var(--bg-page); } +.goods-detail-page--case { + padding-bottom: calc(env(safe-area-inset-bottom) + 32rpx); +} + .goods-head { --td-swiper-radius: 0; } diff --git a/frontend/miniapp/pages/goods/list/index.js b/frontend/miniapp/pages/goods/list/index.js index 0275744..da029ce 100644 --- a/frontend/miniapp/pages/goods/list/index.js +++ b/frontend/miniapp/pages/goods/list/index.js @@ -1,5 +1,6 @@ import { fetchGoodsList } from '../../../services/good/fetchGoodsList'; import { getCategoryList } from '../../../services/good/fetchCategoryList'; +import { fetchGoodsCaseView } from '../../../services/home/home'; import Toast from 'tdesign-miniprogram/toast/index'; const initFilters = { @@ -27,6 +28,7 @@ Page({ loadMoreStatus: 0, loading: true, tabList: [], + caseView: wx.getStorageSync('goodsCaseView') === true, // 案例展示:标题改为软件案例,不显示价格和购物车 }, handleFilterChange(e) { @@ -147,10 +149,20 @@ Page({ onLoad() { + this.applyCaseView(); this.init(); this.loadGoodsList(true); }, + async applyCaseView() { + if (this.data.caseView) { + wx.setNavigationBarTitle({ title: '软件案例' }); + } + const caseView = await fetchGoodsCaseView(); + this.setData({ caseView }); + wx.setNavigationBarTitle({ title: caseView ? '软件案例' : '软件列表' }); + }, + onReachBottom() { const { goodsList, total } = this.data; if (goodsList.length === total) { diff --git a/frontend/miniapp/pages/goods/list/index.wxml b/frontend/miniapp/pages/goods/list/index.wxml index 3f3981f..ed9f3de 100644 --- a/frontend/miniapp/pages/goods/list/index.wxml +++ b/frontend/miniapp/pages/goods/list/index.wxml @@ -29,7 +29,7 @@ - + diff --git a/frontend/miniapp/services/home/home.js b/frontend/miniapp/services/home/home.js index 46de38b..e479a7a 100644 --- a/frontend/miniapp/services/home/home.js +++ b/frontend/miniapp/services/home/home.js @@ -82,6 +82,31 @@ export async function fetchPlatformCommissionRatio() { return DEFAULT_COMMISSION_RATIO; } +const CASE_VIEW_STORAGE_KEY = 'goodsCaseView'; +let caseViewCache = null; + +/** + * 商品是否按案例展示(不显示价格和购买入口) + * 成功后缓存;失败时用上次成功的本地记录 + * @returns {Promise} + */ +export async function fetchGoodsCaseView() { + if (caseViewCache !== null) { + return caseViewCache; + } + try { + const res = await fetchConfig(); + if (res.code === 1) { + caseViewCache = res.data?.goods_case_view === true || res.data?.goods_case_view === 1; + wx.setStorageSync(CASE_VIEW_STORAGE_KEY, caseViewCache); + return caseViewCache; + } + } catch (err) { + console.error('fetchGoodsCaseView failed:', err); + } + return wx.getStorageSync(CASE_VIEW_STORAGE_KEY) === true; +} + /** * 计算扣除平台服务费后的预计到手金额(保留两位小数) * @param {number|string} amount 报价/总费用(元)