fix(escort): 陪诊项目下拉按屏高撑开,可完整展示全部项目

This commit is contained in:
lik
2026-11-05 22:22:29 +08:00
parent 11b4b7d697
commit 4834827504
+11 -1
View File
@@ -3,6 +3,8 @@ const { formatDate } = require('../../utils/date.js')
// 陪诊项目下拉单行高度:图标 72rpx + 单行文字 + 上下留白
const SERVICE_OPTION_HEIGHT = 108
// 下拉面板最多占用的屏高:扣掉底部固定操作栏与页面留白,项目再多也能整屏看到
const SERVICE_PANEL_RESERVED = 200
Page({
data: {
@@ -73,7 +75,7 @@ Page({
const serviceList = services.map((item) => ({ ...item, icon: this.getServiceIcon(item.title) }))
this.setData({
services: serviceList,
serviceOptionsHeight: Math.min(serviceList.length, 4) * SERVICE_OPTION_HEIGHT
serviceOptionsHeight: this.getServiceOptionsHeight(serviceList.length)
})
this.applyService(serviceList[serviceIndex], serviceIndex)
this.setData({ pageLoading: false })
@@ -93,6 +95,14 @@ Page({
this.initializePage()
},
// 按屏高算下拉可见高度:项目少时整列铺开,多时撑到屏高上限后在面板内滚动
getServiceOptionsHeight(count) {
const { windowWidth, windowHeight } = wx.getSystemInfoSync()
const availableRpx = (windowHeight * 750) / windowWidth - SERVICE_PANEL_RESERVED
const maxRows = Math.max(1, Math.floor(availableRpx / SERVICE_OPTION_HEIGHT))
return Math.min(count, maxRows) * SERVICE_OPTION_HEIGHT
},
createIdempotencyKey() {
return `order_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 12)}`
},