From dd41251a1ff7a37b261eb04978465acb6b96062b Mon Sep 17 00:00:00 2001 From: ywyonui Date: Tue, 5 Aug 2025 20:31:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.ts | 13 +- src/main.ts | 4 +- .../base/course-selection/club-selection.vue | 4 + src/pages/base/course-selection/index.vue | 4 + src/pages/base/course-selection/pay-wait.vue | 388 ++---------------- src/pages/base/course-selection/payment.vue | 2 +- 6 files changed, 63 insertions(+), 352 deletions(-) diff --git a/src/config.ts b/src/config.ts index 321e5e8..ddf376c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,6 +1,8 @@ -const ip: string = "127.0.0.1:8897"; -// const ip: string = "yufangzc.com"; -const fwqip: string = "yufangzc.com"; +// const ip: string = "127.0.0.1:8897"; +const ip: string = "lzcxsx.cn"; +const fwqip: string = "lzcxsx.cn"; +//const ip: string = "zhxy.yufangzc.com"; +//const fwqip: string = "zhxy.yufangzc.com"; //打包服务器接口代理标识 const SERVERAGENT: string = "/jzd-api"; //本地代理url地址,配置了就启动代理,没配置就不启动代理 @@ -9,7 +11,8 @@ export const HOMEAGENT: string = ""; export const BASE_URL: string = process.env.NODE_ENV == "development" ? `http://${ip}/zhxy` : SERVERAGENT; // WebSocket地址 -export const BASE_WS_URL: string = `ws://${ip}`; +export const BASE_WS_URL: string = + process.env.NODE_ENV == "development" ? `ws://${ip}` : `wss://${fwqip}`; //图片地址 // export const BASE_IMAGE_URL: string = process.env.NODE_ENV == "development" ? `https://${ip}` : `http://${fwqip}`; export const BASE_IMAGE_URL: string = `http://${fwqip}`; @@ -25,3 +28,5 @@ export const ISROUTERINTERCEPT: boolean = true; export const WHITELIST: WhiteList = []; //主题颜色 export const THEMECOLOR: string = "#35468C"; +// 启动vconsole +export const ENABLE_VCONSOLE: boolean = false; // process.env.NODE_ENV != "development"; diff --git a/src/main.ts b/src/main.ts index 839ce90..390edba 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,14 +2,14 @@ import {createSSRApp} from "vue"; import App from "./App.vue"; import * as Pinia from 'pinia' import piniaPersist from 'pinia-plugin-persist-uni' -import {ISROUTERINTERCEPT, WHITELIST} from "@/config"; +import {ISROUTERINTERCEPT, WHITELIST, ENABLE_VCONSOLE} from "@/config"; import routingIntercept from "@/utils/permission"; import uviewPlus from 'uview-plus' //#ifdef H5 import VConsole from 'vconsole'; -if ((window as any).log) { +if (ENABLE_VCONSOLE || (window as any).log) { new VConsole(); } //#endif diff --git a/src/pages/base/course-selection/club-selection.vue b/src/pages/base/course-selection/club-selection.vue index f074242..522804a 100644 --- a/src/pages/base/course-selection/club-selection.vue +++ b/src/pages/base/course-selection/club-selection.vue @@ -124,6 +124,10 @@ const submit = async () => { const params = { xsId: curXs.value.id, xm: curXs.value.xm, + njmc: curXs.value.njmc, + njmcId: curXs.value.njmcId, + njId: curXs.value.njId, + bc: (curXs.value.njbc || '') + (curXs.value.bjmc || ''), xkId: curXk.value.id, xkkcIds: selectedXkkcIds.value, jzId: getUser.jzId, diff --git a/src/pages/base/course-selection/index.vue b/src/pages/base/course-selection/index.vue index 1b4abaa..2471310 100644 --- a/src/pages/base/course-selection/index.vue +++ b/src/pages/base/course-selection/index.vue @@ -127,6 +127,10 @@ const submit = async () => { const params = { xsId: curXs.value.id, xm: curXs.value.xm, + njmc: curXs.value.njmc, + njmcId: curXs.value.njmcId, + njId: curXs.value.njId, + bc: (curXs.value.njbc || '') + (curXs.value.bjmc || ''), xkId: curXk.value.id, xkkcIds: selectedXkkcIds.value, jzId: getUser.jzId, diff --git a/src/pages/base/course-selection/pay-wait.vue b/src/pages/base/course-selection/pay-wait.vue index d13a0e9..ca8aae2 100644 --- a/src/pages/base/course-selection/pay-wait.vue +++ b/src/pages/base/course-selection/pay-wait.vue @@ -54,7 +54,6 @@ const { getData } = useDataStore(); const payUrl = ref(""); const isH5 = ref(false); -let webViewObserver: any = null; // 检测是否为H5环境 const checkPlatform = () => { @@ -121,159 +120,7 @@ const handleWebViewError = (e: any) => { }); }; -// 检查并修复z-index冲突 -const fixZIndexConflicts = () => { - // #ifdef H5 - const iframes = document.querySelectorAll('iframe'); - iframes.forEach((iframe) => { - if (iframe.src && iframe.src.includes('payweb')) { - // 确保iframe有最高z-index - (iframe as HTMLElement).style.zIndex = '999999'; - - // 查找所有可能覆盖iframe的元素 - const allElements = document.querySelectorAll('*'); - allElements.forEach((element) => { - const computedStyle = window.getComputedStyle(element); - const zIndex = parseInt(computedStyle.zIndex); - if (zIndex >= 999999 && element !== iframe) { - (element as HTMLElement).style.zIndex = '1'; - console.log('修复z-index冲突:', element.tagName, element.className); - } - }); - } - }); - // #endif -}; -// 修复web-view样式 -const fixWebViewStyle = () => { - // #ifdef H5 - setTimeout(() => { - const iframes = document.querySelectorAll('iframe'); - iframes.forEach((iframe) => { - if (iframe.src && iframe.src.includes('payweb')) { - // 由于iframe被提升到body层级,我们需要计算正确的位置和尺寸 - const appElement = document.getElementById('app'); - const countdownSection = document.querySelector('.countdown-section'); - const paymentFooter = document.querySelector('.payment-footer'); - - if (appElement && countdownSection && paymentFooter) { - const appRect = appElement.getBoundingClientRect(); - const countdownRect = countdownSection.getBoundingClientRect(); - const footerRect = paymentFooter.getBoundingClientRect(); - - // 考虑安全区域和状态栏 - const safeAreaTop = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--status-bar-height') || '0'); - const safeAreaBottom = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--window-bottom') || '0'); - - // 计算iframe应该的位置和尺寸 - const top = countdownRect.bottom + safeAreaTop; - const left = appRect.left; - const width = appRect.width; - const height = footerRect.top - countdownRect.bottom - safeAreaBottom; - - // 设置iframe样式,确保最高层级 - iframe.style.position = 'fixed'; - iframe.style.top = `${top}px`; - iframe.style.left = `${left}px`; - iframe.style.width = `${width}px`; - iframe.style.height = `${Math.max(height, 100)}px`; // 确保最小高度 - iframe.style.border = 'none'; - iframe.style.margin = '0'; - iframe.style.padding = '0'; - iframe.style.zIndex = '999999'; // 使用更高的z-index - iframe.style.backgroundColor = '#fff'; - iframe.style.pointerEvents = 'auto'; - - // 强制设置iframe为最高层级 - iframe.style.zIndex = '999999'; - - // 检查并降低其他可能覆盖的元素层级 - const potentialOverlays = document.querySelectorAll('.payment-footer, .countdown-section, .payment-page, [style*="z-index"]'); - potentialOverlays.forEach((element) => { - const computedStyle = window.getComputedStyle(element); - const currentZIndex = parseInt(computedStyle.zIndex) || 0; - if (currentZIndex >= 999999) { - (element as HTMLElement).style.zIndex = '1'; - console.log('降低元素z-index:', element.tagName, element.className); - } - }); - - // 确保iframe可见 - iframe.style.display = 'block'; - iframe.style.visibility = 'visible'; - iframe.style.opacity = '1'; - - console.log('已修复web-view样式,定位到正确区域', { - top, left, width, height, - zIndex: iframe.style.zIndex, - display: iframe.style.display, - visibility: iframe.style.visibility - }); - } - } - }); - - // 额外检查z-index冲突 - fixZIndexConflicts(); - }, 100); - // #endif -}; - -// 监听DOM变化,持续修复web-view样式 -const observeWebView = () => { - // #ifdef H5 - const observer = new MutationObserver((mutations) => { - mutations.forEach((mutation) => { - if (mutation.type === 'childList') { - mutation.addedNodes.forEach((node) => { - if (node.nodeType === Node.ELEMENT_NODE) { - const element = node as Element; - if (element.tagName === 'IFRAME') { - setTimeout(() => { - fixWebViewStyle(); - }, 50); - } - } - }); - } - }); - }); - - observer.observe(document.body, { - childList: true, - subtree: true - }); - - // 监听窗口大小变化 - const handleResize = () => { - setTimeout(() => { - fixWebViewStyle(); - }, 100); - }; - - // 定期检查z-index冲突 - const checkZIndexConflicts = () => { - fixZIndexConflicts(); - }; - - // 每2秒检查一次z-index冲突 - const zIndexInterval = setInterval(checkZIndexConflicts, 2000); - - window.addEventListener('resize', handleResize); - window.addEventListener('orientationchange', handleResize); - - return { - observer, - cleanup: () => { - observer.disconnect(); - window.removeEventListener('resize', handleResize); - window.removeEventListener('orientationchange', handleResize); - clearInterval(zIndexInterval); - } - }; - // #endif -}; setWsCallback((type: string, res: any) => { console.log('收到WebSocket消息:', type, res.data); @@ -355,71 +202,52 @@ onLoad(async (options: any) => { if (options.payUrl) { payUrl.value = decodeURIComponent(options.payUrl); + console.log('支付URL:', payUrl.value); + const res = await jzGetQkExpiredTime({ xsId: getCurXs.id} ); seconds = res.result; initWs(); startCountdown(); - - // 修复web-view样式 - if (!isH5.value) { - setTimeout(() => { - fixWebViewStyle(); - }, 500); - - // 启动DOM监听 - webViewObserver = observeWebView(); - } } else { uni.showToast({ title: '缺少支付地址', icon: 'none' }) setTimeout(() => { goBack(); }, 1000) - } - try { - const res = await jzXkJfCxjApi({ - orderNumber: getData.orderNumber, - xsId: getData.xsId, - xkId: getData.xkId - }); - // 订单状态,01-交易中,02-交易成功,03-交易失败,04-交易关闭 - const { orderStat, respCode } = res.result; - if ("0000000000" === respCode) { - if ("02" === orderStat) { - uni.reLaunch({ - url: "/pages/base/course-selection/payment-success", - }); - } else if ("03" === orderStat) { - uni.reLaunch({ - url: "/pages/base/course-selection/payment-fail", - }); - } - } else { - uni.showToast({ - title: "订单状态查询失败", - icon: "error", - }); - // setTimeout(() => { - // goBack(); - // }, 2000); - } - } catch (error) { - console.log("订单查询失败", error); - } + } + openPaymentUrl(); + // try { + // const res = await jzXkJfCxjApi({ + // orderNumber: getData.orderNumber, + // xsId: getData.xsId, + // xkId: getData.xkId + // }); + // // 订单状态,01-交易中,02-交易成功,03-交易失败,04-交易关闭 + // const { orderStat, respCode } = res.result; + // if ("0000000000" === respCode) { + // if ("02" === orderStat) { + // uni.reLaunch({ + // url: "/pages/base/course-selection/payment-success", + // }); + // } else if ("03" === orderStat) { + // uni.reLaunch({ + // url: "/pages/base/course-selection/payment-fail", + // }); + // } + // } else { + // uni.showToast({ + // title: "订单状态查询失败", + // icon: "error", + // }); + // } + // } catch (error) { + // console.log("订单查询失败", error); + // } }); onBeforeUnmount(() => { if (timer) { clearInterval(timer); } - - // 清理DOM监听器 - if (webViewObserver) { - if (webViewObserver.cleanup) { - webViewObserver.cleanup(); - } else { - webViewObserver.disconnect(); - } - } }); @@ -432,42 +260,8 @@ onBeforeUnmount(() => { height: 100vh; overflow: hidden; position: relative; - - // 确保布局正确 - .countdown-section { - flex-shrink: 0; - } - - .scrollable-content { - flex: 1; - min-height: 0; - } - - .payment-footer { - flex-shrink: 0; - } } -// 可滚动内容区域样式 -.scrollable-content { - flex: 1; - position: relative; -} - -// web-view样式修复 -.payment-webview { - width: 100% !important; - height: 100% !important; - position: relative !important; - border: none !important; - margin: 0 !important; - padding: 0 !important; - z-index: 1; - flex: 1; - min-height: 0; -} - -// 确保web-view容器正确显示 .scrollable-content { flex: 1; position: relative; @@ -475,21 +269,16 @@ onBeforeUnmount(() => { display: flex; flex-direction: column; min-height: 0; - - // 当显示web-view时,隐藏其他内容 - &:has(.payment-webview) { - .h5-payment-container { - display: none; - } - } - - // web-view容器样式 - .payment-webview { - flex: 1; - min-height: 0; - display: flex; - flex-direction: column; - } +} + +.payment-webview { + width: 100% !important; + height: 100% !important; + border: none !important; + margin: 0 !important; + padding: 0 !important; + flex: 1; + min-height: 0; } // H5支付容器样式 @@ -573,7 +362,7 @@ onBeforeUnmount(() => { align-items: center; padding: 15px; background-color: #2879ff; - z-index: 1; // 确保不会覆盖iframe + flex-shrink: 0; .countdown-icon { margin-right: 10px; @@ -597,82 +386,6 @@ onBeforeUnmount(() => { } } -// H5支付容器样式 -.h5-payment-container { - padding: 20px; - background-color: #fff; - margin: 15px; - border-radius: 8px; - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); -} - -.payment-info { - margin-bottom: 20px; - - .payment-title { - font-size: 18px; - font-weight: bold; - color: #333; - margin-bottom: 10px; - } - - .payment-url { - font-size: 14px; - color: #666; - word-break: break-all; - background-color: #f5f5f5; - padding: 10px; - border-radius: 4px; - border: 1px solid #ddd; - } -} - -.payment-actions { - display: flex; - gap: 10px; - margin-bottom: 20px; - - button { - flex: 1; - height: 44px; - border-radius: 22px; - font-size: 16px; - border: none; - cursor: pointer; - - &.open-payment-btn { - background-color: #2879ff; - color: #fff; - } - - &.copy-url-btn { - background-color: #fff; - color: #333; - border: 1px solid #ddd; - } - } -} - -.payment-tips { - background-color: #fff7e6; - border: 1px solid #ffd591; - border-radius: 4px; - padding: 15px; - - text { - display: block; - font-size: 14px; - color: #d46b08; - line-height: 1.5; - margin-bottom: 5px; - - &:first-child { - font-weight: bold; - margin-bottom: 8px; - } - } -} - .payment-footer { position: sticky; bottom: 0; @@ -681,21 +394,7 @@ onBeforeUnmount(() => { background-color: #fff; padding: 15px; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05); - z-index: 1; // 确保不会覆盖iframe - - .total-amount { - display: flex; - align-items: center; - margin-bottom: 15px; - font-size: 15px; - color: #333; - - .amount-value { - color: #ff6b00; - font-size: 20px; - font-weight: 500; - } - } + flex-shrink: 0; .action-buttons { .cancel-btn { @@ -710,5 +409,4 @@ onBeforeUnmount(() => { } } } - diff --git a/src/pages/base/course-selection/payment.vue b/src/pages/base/course-selection/payment.vue index 66b4441..1462dad 100644 --- a/src/pages/base/course-selection/payment.vue +++ b/src/pages/base/course-selection/payment.vue @@ -94,7 +94,7 @@ const startCountdown = () => { // 返回上一页 const goBack = () => { uni.reLaunch({ - url: getData.backUrl + url: '/pages/base/home/index' }); };