调整支付

This commit is contained in:
ywyonui 2025-08-05 20:31:37 +08:00
parent 50493a570a
commit dd41251a1f
6 changed files with 63 additions and 352 deletions

View File

@ -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";

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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')) {
// iframez-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')) {
// iframebody
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
};
// DOMweb-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();
};
// 2z-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();
}
}
});
</script>
@ -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 {
width: 100% !important;
height: 100% !important;
border: none !important;
margin: 0 !important;
padding: 0 !important;
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
}
// 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(() => {
}
}
}
</style>

View File

@ -94,7 +94,7 @@ const startCountdown = () => {
//
const goBack = () => {
uni.reLaunch({
url: getData.backUrl
url: '/pages/base/home/index'
});
};