From 8b2670bf31123f6eff3489b63f53fab0b6ff19e8 Mon Sep 17 00:00:00 2001 From: jing <1683105490@qq.com> Date: Thu, 17 Sep 2026 18:19:30 +0800 Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9A=E5=AE=A2=E6=9C=8D=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=BB=84=E4=BB=B6=E8=BD=AC=E8=8B=B1=E6=96=87=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E6=98=BE=E7=A4=BA=E5=85=A8=E9=83=A8=E8=8B=B1=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .local.config.js | 2 +- components-diy/diy-kefu.vue | 128 +++++++++++++++++++++++++---- components-diy/diy-member-info.vue | 28 ++++++- components-diy/diy-merch-list.vue | 36 ++++++-- 4 files changed, 170 insertions(+), 24 deletions(-) diff --git a/.local.config.js b/.local.config.js index 40d9ad4..dad5c42 100644 --- a/.local.config.js +++ b/.local.config.js @@ -243,7 +243,7 @@ const localDevConfig = ({ // })['local-11']; // 选择要使用的环境配置 // })['2811']; // 本地 //})['5g-317']; // 电磁兼容 -})['5g-312']; // +})['192.168.8.118-1']; // // })['local-2']; // 本地 // })['local-11']; // 本地 // })['1-test']; // test diff --git a/components-diy/diy-kefu.vue b/components-diy/diy-kefu.vue index f65d574..861ac09 100644 --- a/components-diy/diy-kefu.vue +++ b/components-diy/diy-kefu.vue @@ -7,11 +7,17 @@ - {{ item.title }} - {{ item.desc }} + {{ item.title }} + {{ item.desc }} + + + {{ item.title }} + {{ item.desc }} + - + + {{ $lang('components-diy.diy-kefu.addNow') }} @@ -34,15 +40,31 @@ export default { data() { return { loading: true, + // PR-DIY-KEFU-ONE-LINE (2026-09-17): 小程序端实测得出的一行自适应字号(rpx), 0 表示用默认字号 + mpTitleSize: 0, + mpDescSize: 0 }; }, created() { // this.getDataList(); }, + // PR-DIY-KEFU-ONE-LINE (2026-09-17): 英文公司名等长标题一行完整展示(不换行、不省略) + // H5: 挂载/数据变化后实测每个文本的溢出宽度, 逐级缩小 font-size 直到恰好一行放下 —— 保证无省略号; + // 小程序端无法测 DOM, 用字符宽度估算兜底(CJK 1em / 其他 0.6em), 极端超长时仍有省略号兜底 + mounted() { + this.$nextTick(this.fitOneLineText) + }, watch: { // 组件刷新监听 componentRefresh: function (nval) { // this.getDataList(); + this.$nextTick(this.fitOneLineText) + }, + value: { + deep: true, + handler() { + this.$nextTick(this.fitOneLineText) + } } }, computed: { @@ -65,6 +87,74 @@ export default { current: img, urls: [img] }) + }, + // PR-DIY-KEFU-ONE-LINE (2026-09-17): 单行自适应 —— 标题/描述一行完整展示(不换行), 字号取一行能放下的最大值 + // #ifdef H5 + fitOneLineText() { + this.$nextTick(() => { + const root = this.$el && this.$el.querySelectorAll ? this.$el : null + if (!root) return + const nodes = root.querySelectorAll('.title-text, .subtitle') + nodes.forEach((el) => { + // 先还原 CSS 默认字号, 再实测是否溢出; 目标宽度留 3px 右侧空隙, 不贴边 + el.style.fontSize = '' + let size = parseFloat(window.getComputedStyle(el).fontSize) + const MIN_PX = 10 // 下限 10px, 再小可读性太差 + const target = el.clientWidth - 3 + let guard = 0 + while (el.scrollWidth > target && size > MIN_PX && guard < 60) { + size -= 0.5 + el.style.fontSize = size + 'px' + guard++ + } + }) + }) + }, + // #endif + // #ifndef H5 + // 小程序端: 隐藏测量节点以默认字号实测文本宽度, 宽度与字号成线性关系, 反推一行能放下的最大字号 + fitOneLineText() { + uni.createSelectorQuery().in(this) + .select('.fui-list-inner').boundingClientRect() + .select('.measure-title').boundingClientRect() + .select('.measure-desc').boundingClientRect() + .exec((rects) => { + if (!rects || !rects[0]) return + const sys = uni.getSystemInfoSync() + const pxPerRpx = (sys.windowWidth || 375) / 750 + // 可用宽度 = 文字区宽度 - 容器右内边距(8rpx) - 与右侧元素(按钮)之间留 8rpx 空隙 + const avail = rects[0].width - 16 * pxPerRpx + if (avail <= 0) return + // 标题: 默认 28rpx, 最小 16rpx + if (rects[1] && rects[1].width > avail) { + this.mpTitleSize = Math.max(16, Math.floor(28 * avail / rects[1].width)) + } else { + this.mpTitleSize = 0 + } + // 描述: 默认 24rpx, 最小 16rpx + if (rects[2] && rects[2].width > avail) { + this.mpDescSize = Math.max(16, Math.floor(24 * avail / rects[2].width)) + } else { + this.mpDescSize = 0 + } + }) + }, + // #endif + titleStyle() { + // #ifndef H5 + return this.mpTitleSize ? 'font-size:' + this.mpTitleSize + 'rpx;' : '' + // #endif + // #ifdef H5 + return '' + // #endif + }, + descStyle() { + // #ifndef H5 + return this.mpDescSize ? 'font-size:' + this.mpDescSize + 'rpx;' : '' + // #endif + // #ifdef H5 + return '' + // #endif } } }; @@ -73,19 +163,20 @@ export default {