hookehuyr

refactor(checkout): 移除iframe高度自适应逻辑并设置固定高度

不再需要动态调整iframe高度,改为使用固定高度300px
......@@ -86,10 +86,9 @@
:src="iframeInfoSrc"
class="w-full border-0"
ref="infoEntryIframe"
style="width: 100%; border: none; display: block;"
style="width: 100%; height: 300px; border: none; display: block;"
frameborder="0"
scrolling="no"
@load="adjustIframeHeight"
scrolling="auto"
></iframe>
<!-- 编辑按钮 -->
......@@ -282,40 +281,6 @@ const formData = ref({
// 存储当前课程的localStorage键名,用于页面离开时清理
let currentInfoEntryKey = null
// iframe高度自适应函数
const adjustIframeHeight = () => {
const iframe = infoEntryIframe.value
if (iframe) {
try {
// 等待iframe内容加载完成
setTimeout(() => {
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document
if (iframeDoc) {
const body = iframeDoc.body
const html = iframeDoc.documentElement
// 获取内容的实际高度
const height = Math.max(
body.scrollHeight,
body.offsetHeight,
html.clientHeight,
html.scrollHeight,
html.offsetHeight
)
// 设置iframe高度,添加一些padding
iframe.style.height = (height + 20) + 'px'
console.log('调整iframe高度:', height + 20 + 'px')
}
}, 100)
} catch (error) {
console.warn('无法访问iframe内容,可能存在跨域限制:', error)
// 如果无法访问iframe内容,设置一个默认高度
iframe.style.height = '400px'
}
}
}
onMounted(async () => {
const { code, data } = await getUserInfoAPI();
......@@ -350,10 +315,7 @@ onMounted(async () => {
iframeInfoSrc.value = infoData.form_url + '&page_type=info' + '&data_id=' + infoData.customize_id
console.log('从缓存恢复个人信息数据:', infoData)
// 延迟调整iframe高度,等待内容加载
setTimeout(() => {
adjustIframeHeight()
}, 1000)
// 不再需要动态调整iframe高度
} catch (error) {
console.error('解析缓存数据失败:', error)
// 如果解析失败,重新录入
......@@ -523,10 +485,7 @@ const handleInfoEntryClose = () => {
iframeInfoSrc.value = itemWithForm.form_url + '&page_type=info' + '&data_id=' + formData.value.customize_id
console.log('个人信息录入弹窗关闭,iframe地址:', iframeInfoSrc.value)
// 延迟调整iframe高度,等待内容加载
setTimeout(() => {
adjustIframeHeight()
}, 500)
// 不再需要动态调整iframe高度
} else {
console.log('未找到包含form_url的购物车项目')
}
......