Showing
2 changed files
with
13 additions
and
9 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2024-09-26 13:36:06 | 2 | * @Date: 2024-09-26 13:36:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-10-25 17:48:09 | 4 | + * @LastEditTime: 2024-11-07 18:08:31 |
| 5 | * @FilePath: /hager/src/api/hager.js | 5 | * @FilePath: /hager/src/api/hager.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -13,6 +13,7 @@ const Api = { | ... | @@ -13,6 +13,7 @@ const Api = { |
| 13 | NEWS_DETAIL: '/srv/?a=detail&type=news', | 13 | NEWS_DETAIL: '/srv/?a=detail&type=news', |
| 14 | HOME: '/srv/?a=home', | 14 | HOME: '/srv/?a=home', |
| 15 | PRODUCT_CATE: '/srv/?a=cate&type=product', | 15 | PRODUCT_CATE: '/srv/?a=cate&type=product', |
| 16 | + PRODUCT_MENU: '/srv/?a=cate&type=product_menu', | ||
| 16 | PRODUCT_INFO: '/srv/?a=detail&type=product', | 17 | PRODUCT_INFO: '/srv/?a=detail&type=product', |
| 17 | PRODUCT_SEARCH: '/srv/?a=cate&type=product_search', | 18 | PRODUCT_SEARCH: '/srv/?a=cate&type=product_search', |
| 18 | SOLUTION: '/srv/?a=cate&type=solution', | 19 | SOLUTION: '/srv/?a=cate&type=solution', |
| ... | @@ -38,6 +39,7 @@ export const getNewsDetailAPI = (params) => fn(fetch.get(Api.NEWS_DETAIL, params | ... | @@ -38,6 +39,7 @@ export const getNewsDetailAPI = (params) => fn(fetch.get(Api.NEWS_DETAIL, params |
| 38 | export const getHomeAPI = (params) => fn(fetch.get(Api.HOME, params)); | 39 | export const getHomeAPI = (params) => fn(fetch.get(Api.HOME, params)); |
| 39 | 40 | ||
| 40 | export const getProductCateAPI = (params) => fn(fetch.get(Api.PRODUCT_CATE, params)); | 41 | export const getProductCateAPI = (params) => fn(fetch.get(Api.PRODUCT_CATE, params)); |
| 42 | +export const getProductMenuAPI = (params) => fn(fetch.get(Api.PRODUCT_MENU, params)); | ||
| 41 | 43 | ||
| 42 | export const getProductInfoAPI = (params) => fn(fetch.get(Api.PRODUCT_INFO, params)); | 44 | export const getProductInfoAPI = (params) => fn(fetch.get(Api.PRODUCT_INFO, params)); |
| 43 | 45 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-09-26 13:42:11 | 2 | * @Date: 2024-09-26 13:42:11 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-11-07 14:34:27 | 4 | + * @LastEditTime: 2024-11-07 18:09:11 |
| 5 | * @FilePath: /hager/src/components/common/hagerHeader.vue | 5 | * @FilePath: /hager/src/components/common/hagerHeader.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -138,7 +138,7 @@ import mixin from 'common/mixin'; | ... | @@ -138,7 +138,7 @@ import mixin from 'common/mixin'; |
| 138 | import { parseQueryString } from '@/utils/tools'; | 138 | import { parseQueryString } from '@/utils/tools'; |
| 139 | import $ from 'jquery'; | 139 | import $ from 'jquery'; |
| 140 | import hagerMenu from '../hagerMenu.vue'; | 140 | import hagerMenu from '../hagerMenu.vue'; |
| 141 | -import { getProductCateAPI, getUserInfoAPI } from "@/api/hager.js"; | 141 | +import { getProductMenuAPI, getUserInfoAPI } from "@/api/hager.js"; |
| 142 | 142 | ||
| 143 | // 处理菜单高度被挡住的问题 | 143 | // 处理菜单高度被挡住的问题 |
| 144 | function isElementVisible($element) { | 144 | function isElementVisible($element) { |
| ... | @@ -202,7 +202,7 @@ export default { | ... | @@ -202,7 +202,7 @@ export default { |
| 202 | } | 202 | } |
| 203 | }, | 203 | }, |
| 204 | async mounted () { | 204 | async mounted () { |
| 205 | - const { code, data } = await getProductCateAPI(); | 205 | + const { code, data } = await getProductMenuAPI(); |
| 206 | if (code) { | 206 | if (code) { |
| 207 | this.product_menu = data; | 207 | this.product_menu = data; |
| 208 | // this.product_info = this.product_menu[0]['info']; | 208 | // this.product_info = this.product_menu[0]['info']; |
| ... | @@ -314,17 +314,19 @@ export default { | ... | @@ -314,17 +314,19 @@ export default { |
| 314 | this.show = true; | 314 | this.show = true; |
| 315 | this.$nextTick(() => { | 315 | this.$nextTick(() => { |
| 316 | var $productRightWrapper = $('.product-right-wrapper'); | 316 | var $productRightWrapper = $('.product-right-wrapper'); |
| 317 | - | ||
| 318 | - if (isElementVisible($productRightWrapper)) { | ||
| 319 | - console.log(".product-right-wrapper 完全可见"); | ||
| 320 | - } else { | ||
| 321 | - console.log(".product-right-wrapper 被部分或完全遮挡"); | ||
| 322 | const productRightWrapper = document.querySelector('.product-right-wrapper'); | 317 | const productRightWrapper = document.querySelector('.product-right-wrapper'); |
| 323 | // 获取窗口的高度 | 318 | // 获取窗口的高度 |
| 324 | const windowHeight = $(window).height(); | 319 | const windowHeight = $(window).height(); |
| 325 | // 计算适合的高度,假设元素的 top 值固定,调整高度为可用高度 | 320 | // 计算适合的高度,假设元素的 top 值固定,调整高度为可用高度 |
| 326 | const topOffset = $('.product-right-wrapper').offset().top; // 获取元素距离顶部的偏移量 | 321 | const topOffset = $('.product-right-wrapper').offset().top; // 获取元素距离顶部的偏移量 |
| 327 | const availableHeight = windowHeight - topOffset; | 322 | const availableHeight = windowHeight - topOffset; |
| 323 | + | ||
| 324 | + if (isElementVisible($productRightWrapper)) { | ||
| 325 | + console.log(".product-right-wrapper 完全可见"); | ||
| 326 | + productRightWrapper.style.removeProperty('height'); | ||
| 327 | + productRightWrapper.style.removeProperty('overflow-y'); | ||
| 328 | + } else { | ||
| 329 | + console.log(".product-right-wrapper 被部分或完全遮挡"); | ||
| 328 | // 设置 .product-right-wrapper 的最大高度,确保不会溢出窗口 | 330 | // 设置 .product-right-wrapper 的最大高度,确保不会溢出窗口 |
| 329 | productRightWrapper.style.height = availableHeight + 'px'; | 331 | productRightWrapper.style.height = availableHeight + 'px'; |
| 330 | productRightWrapper.style.overflowY = 'scroll'; | 332 | productRightWrapper.style.overflowY = 'scroll'; | ... | ... |
-
Please register or login to post a comment