FEAT => 本次更新项目为:

初始化appbuild
This commit is contained in:
2025-07-31 17:41:43 +08:00
parent c5d4e80e7c
commit 9193bda39f
125 changed files with 12385 additions and 15 deletions

View File

@@ -0,0 +1,11 @@
var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var require_app_css = __commonJS({
"app.css.js"(exports) {
const _style_0 = {};
exports.styles = [_style_0];
}
});
export default require_app_css();

View File

@@ -0,0 +1,2 @@
Promise.resolve("./app.css.js").then(() => {
});

View File

@@ -0,0 +1 @@
{"version":3,"file":"app.js","sources":["App.vue","main.js"],"sourcesContent":["<script>\nexport default {}\n</script>\n\n<style>\n/*每个页面公共css */\n</style>\n","import App from './App'\n\n// #ifndef VUE3\nimport Vue from 'vue'\nimport './uni.promisify.adaptor'\nVue.config.productionTip = false\nApp.mpType = 'app'\nconst app = new Vue({\n ...App\n})\napp.$mount()\n// #endif\n\n// #ifdef VUE3\nimport { createSSRApp } from 'vue'\nexport function createApp() {\n const app = createSSRApp(App)\n return {\n app\n }\n}\n// #endif"],"names":["createSSRApp","App"],"mappings":";;;;;;AACA,MAAO,YAAS,CAAA;ACcT,SAAS,YAAY;AAC1B,QAAM,MAAMA,cAAY,aAACC,SAAG;AAC5B,SAAO;AAAA,IACL;AAAA,EACD;AACH;;;"}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"version":3,"file":"config.js","sources":["config.js"],"sourcesContent":["// 应用配置文件\r\nconst config = {\r\n // 目标网站配置\r\n webConfig: {\r\n // 主要目标网站URL请替换为您的实际网站\r\n mainUrl: \"http://localhost:3000\",\r\n\r\n // // 备用网站URL如果主网站无法访问\r\n fallbackUrl: \"https://kr-op.quwanzhi.com\",\r\n\r\n // 测试页面URL用于开发测试\r\n testUrl: \"http://localhost:3000/test/postMessage\",\r\n\r\n // 是否启用HTTPS强制跳转\r\n forceHttps: false,\r\n\r\n // 是否允许跨域请求\r\n allowCrossOrigin: true,\r\n },\r\n\r\n // 应用配置\r\n appConfig: {\r\n // 应用名称\r\n appName: \"存客宝\",\r\n\r\n // 应用版本\r\n version: \"1.0.0\",\r\n\r\n // 是否启用超时检测\r\n enableTimeout: false, // 设为 false 禁用超时检测\r\n\r\n // 加载超时时间(毫秒)- 设为0禁用超时检测\r\n loadingTimeout: 30000, // 增加到30秒\r\n\r\n // 是否启用调试模式\r\n debug: true, // 开发时设为 true生产时设为 false\r\n\r\n // 是否使用测试页面\r\n useTestPage: true, // 开发时设为 true生产时设为 false\r\n },\r\n\r\n // 通信配置\r\n communication: {\r\n // 消息类型定义\r\n messageTypes: {\r\n GET_USER_INFO: \"getUserInfo\",\r\n GET_DEVICE_INFO: \"getDeviceInfo\",\r\n NAVIGATE: \"navigate\",\r\n SHARE: \"share\",\r\n PAYMENT: \"payment\",\r\n TOAST: \"toast\",\r\n ALERT: \"alert\",\r\n CONFIRM: \"confirm\",\r\n },\r\n\r\n // 允许的域名白名单\r\n allowedDomains: [\"kr-op.quwanzhi.com\", \"quwanzhi.com\", \"localhost\"],\r\n },\r\n\r\n // 用户配置\r\n userConfig: {\r\n // 默认用户信息\r\n defaultUser: {\r\n id: \"user123\",\r\n name: \"测试用户\",\r\n avatar: \"https://example.com/avatar.jpg\",\r\n phone: \"13800138000\",\r\n email: \"test@example.com\",\r\n },\r\n },\r\n};\r\n\r\nexport default config;\r\n"],"names":[],"mappings":";AACK,MAAC,SAAS;AAAA;AAAA,EAEb,WAAW;AAAA;AAAA,IAET,SAAS;AAAA;AAAA,IAGT,aAAa;AAAA;AAAA,IAGb,SAAS;AAAA;AAAA,IAGT,YAAY;AAAA;AAAA,IAGZ,kBAAkB;AAAA,EACnB;AAAA;AAAA,EAGD,WAAW;AAAA;AAAA,IAET,SAAS;AAAA;AAAA,IAGT,SAAS;AAAA;AAAA,IAGT,eAAe;AAAA;AAAA;AAAA,IAGf,gBAAgB;AAAA;AAAA;AAAA,IAGhB,OAAO;AAAA;AAAA;AAAA,IAGP,aAAa;AAAA;AAAA,EACd;AAAA;AAAA,EAGD,eAAe;AAAA;AAAA,IAEb,cAAc;AAAA,MACZ,eAAe;AAAA,MACf,iBAAiB;AAAA,MACjB,UAAU;AAAA,MACV,OAAO;AAAA,MACP,SAAS;AAAA,MACT,OAAO;AAAA,MACP,OAAO;AAAA,MACP,SAAS;AAAA,IACV;AAAA;AAAA,IAGD,gBAAgB,CAAC,sBAAsB,gBAAgB,WAAW;AAAA,EACnE;AAAA;AAAA,EAGD,YAAY;AAAA;AAAA,IAEV,aAAa;AAAA,MACX,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,OAAO;AAAA,IACR;AAAA,EACF;AACH;;"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>View</title>
<link rel="icon" href="data:,">
<link rel="stylesheet" href="app.css" />
<script>var __uniConfig = {"globalStyle":{},"darkmode":false}</script>
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
</head>
<body>
<div id="app"></div>
<script src="uni-app-view.umd.js"></script>
</body>
</html>

View File

@@ -0,0 +1,11 @@
;(function(){
let u=void 0,isReady=false,onReadyCallbacks=[],isServiceReady=false,onServiceReadyCallbacks=[];
const __uniConfig = {"pages":[],"globalStyle":{"backgroundColor":"#F8F8F8","titleNView":false,"bounce":"none","background":"transparent","navigationBar":{"backgroundColor":"#F8F8F8","titleText":"存客宝","style":"custom","type":"default","titleColor":"#000000"},"isNVue":false},"nvue":{"compiler":"uni-app","styleCompiler":"uni-app","flex-direction":"column"},"renderer":"auto","appname":"存客宝","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":true},"compilerVersion":"4.75","entryPagePath":"pages/index/index","entryPageQuery":"","realEntryPagePath":"","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000},"locales":{},"darkmode":false,"themeConfig":{}};
const __uniRoutes = [{"path":"pages/index/index","meta":{"isQuit":true,"isEntry":true,"titleNView":false,"bounce":"none","navigationBar":{"titleText":"存客宝","style":"custom","type":"default"},"isNVue":false}}].map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
__uniConfig.styles=[];//styles
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:16})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,global:u,window:u,document:u,frames:u,self:u,location:u,navigator:u,localStorage:u,history:u,Caches:u,screen:u,alert:u,confirm:u,prompt:u,fetch:u,XMLHttpRequest:u,WebSocket:u,webkit:u,print:u}}}});
})();

View File

@@ -0,0 +1 @@
(function(){})();

View File

@@ -0,0 +1,834 @@
if (typeof Promise !== "undefined" && !Promise.prototype.finally) {
Promise.prototype.finally = function(callback) {
const promise = this.constructor;
return this.then(
(value) => promise.resolve(callback()).then(() => value),
(reason) => promise.resolve(callback()).then(() => {
throw reason;
})
);
};
}
;
if (typeof uni !== "undefined" && uni && uni.requireGlobal) {
const global = uni.requireGlobal();
ArrayBuffer = global.ArrayBuffer;
Int8Array = global.Int8Array;
Uint8Array = global.Uint8Array;
Uint8ClampedArray = global.Uint8ClampedArray;
Int16Array = global.Int16Array;
Uint16Array = global.Uint16Array;
Int32Array = global.Int32Array;
Uint32Array = global.Uint32Array;
Float32Array = global.Float32Array;
Float64Array = global.Float64Array;
BigInt64Array = global.BigInt64Array;
BigUint64Array = global.BigUint64Array;
}
;
if (uni.restoreGlobal) {
uni.restoreGlobal(Vue, weex, plus, setTimeout, clearTimeout, setInterval, clearInterval);
}
(function(vue) {
"use strict";
function formatAppLog(type, filename, ...args) {
if (uni.__log__) {
uni.__log__(type, filename, ...args);
} else {
console[type].apply(console, [...args, filename]);
}
}
const config = {
// 目标网站配置
webConfig: {
// 主要目标网站URL请替换为您的实际网站
mainUrl: "https://kr-op.quwanzhi.com",
// // 备用网站URL如果主网站无法访问
fallbackUrl: "https://kr-op.quwanzhi.com",
// 测试页面URL用于开发测试
testUrl: "https://kr-op.quwanzhi.com",
// testUrl: "http://localhost:3000/test/postMessage",
// 是否启用HTTPS强制跳转
forceHttps: false,
// 是否允许跨域请求
allowCrossOrigin: true
},
// 应用配置
appConfig: {
// 应用名称
appName: "存客宝",
// 应用版本
version: "1.0.0",
// 是否启用超时检测
enableTimeout: false,
// 设为 false 禁用超时检测
// 加载超时时间(毫秒)- 设为0禁用超时检测
loadingTimeout: 3e4,
// 增加到30秒
// 是否启用调试模式
debug: true,
// 开发时设为 true生产时设为 false
// 是否使用测试页面
useTestPage: true
// 开发时设为 true生产时设为 false
},
// 通信配置
communication: {
// 消息类型定义
messageTypes: {
GET_USER_INFO: "getUserInfo",
GET_DEVICE_INFO: "getDeviceInfo",
NAVIGATE: "navigate",
SHARE: "share",
PAYMENT: "payment",
TOAST: "toast",
ALERT: "alert",
CONFIRM: "confirm"
},
// 允许的域名白名单
allowedDomains: ["kr-op.quwanzhi.com", "quwanzhi.com", "localhost"]
},
// 用户配置
userConfig: {
// 默认用户信息
defaultUser: {
id: "user123",
name: "测试用户",
avatar: "https://example.com/avatar.jpg",
phone: "13800138000",
email: "test@example.com"
}
}
};
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const _sfc_main$1 = {
data() {
return {
config,
currentUrl: "",
// 初始化为空字符串
loading: false,
error: "",
loadingTimer: null,
messageQueue: []
};
},
onLoad() {
this.initApp();
},
onShow() {
this.resumeMessageQueue();
},
onHide() {
formatAppLog("log", "at pages/index/index.vue:52", "WebView页面隐藏");
},
onUnload() {
this.cleanup();
},
computed: {
navBarHeight() {
return (this.getSafeAreaHeight().navBarHeight || 44) + "px";
},
webViewStyle() {
const safeArea = this.getSafeAreaHeight();
return {
position: "absolute",
top: safeArea.navBarHeight + "px",
left: "0px",
right: "0px",
bottom: "0px",
width: "100%",
height: `calc(100vh - ${safeArea.navBarHeight}px)`,
zIndex: 1
};
}
},
methods: {
// 获取初始URL
getInitialUrl() {
formatAppLog("log", "at pages/index/index.vue:79", "获取初始URLconfig:", this.config);
if (this.config && this.config.appConfig && this.config.appConfig.useTestPage) {
return this.config.webConfig.testUrl;
}
return this.config.webConfig.mainUrl;
},
// 初始化应用
initApp() {
formatAppLog("log", "at pages/index/index.vue:88", "UniApp: 开始初始化应用");
this.currentUrl = this.getInitialUrl();
formatAppLog("log", "at pages/index/index.vue:91", "UniApp: 设置URL:", this.currentUrl);
this.setupLoadingTimeout();
this.initMessageHandler();
formatAppLog("log", "at pages/index/index.vue:97", "UniApp: 立即注入桥接代码");
this.injectBridgeCode();
},
// 设置加载超时
setupLoadingTimeout() {
if (this.loadingTimer) {
clearTimeout(this.loadingTimer);
}
if (!this.config.appConfig.enableTimeout) {
formatAppLog("log", "at pages/index/index.vue:110", "超时检测已禁用");
return;
}
if (this.config.appConfig.loadingTimeout > 0) {
formatAppLog("log", "at pages/index/index.vue:115", "设置加载超时:", this.config.appConfig.loadingTimeout + "ms");
this.loadingTimer = setTimeout(() => {
if (this.loading) {
formatAppLog("warn", "at pages/index/index.vue:118", "页面加载超时,当前状态:", this.loading);
this.handleTimeout();
}
}, this.config.appConfig.loadingTimeout);
}
},
// 处理加载超时
handleTimeout() {
formatAppLog("warn", "at pages/index/index.vue:127", "触发页面加载超时处理");
this.error = "页面加载超时,请检查网络连接";
this.loading = false;
if (this.loadingTimer) {
clearTimeout(this.loadingTimer);
this.loadingTimer = null;
}
},
// 初始化消息处理器
initMessageHandler() {
formatAppLog("log", "at pages/index/index.vue:139", "UniApp: 初始化消息处理器");
window.addEventListener("message", (event) => {
formatAppLog("log", "at pages/index/index.vue:142", "UniApp: 收到window.message事件:", event.data);
this.handleIframeMessage(event);
});
},
// 设置WebView桥接
setupWebViewBridge() {
this.injectBridgeCode();
},
// 注入桥接代码
injectBridgeCode() {
formatAppLog("log", "at pages/index/index.vue:155", "UniApp: 开始注入桥接代码");
const bridgeCode = `
// UniApp WebView 桥接代码
__f__('log','at pages/index/index.vue:159','开始注入UniApp桥接代码...');
// 检查是否已经存在桥接
if (window.uniAppBridge) {
__f__('log','at pages/index/index.vue:163','UniApp桥接已存在跳过注入');
return;
}
window.uniAppBridge = {
// 发送消息到UniApp
postMessage: function(type, data) {
__f__('log','at pages/index/index.vue:170','UniApp桥接发送消息:', type, data);
window.parent.postMessage({
type: type,
data: data,
timestamp: Date.now()
}, '*');
},
// 获取用户信息
getUserInfo: function() {
__f__('log','at pages/index/index.vue:180','UniApp桥接: 请求用户信息');
this.postMessage('getUserInfo', {});
},
// 获取设备信息
getDeviceInfo: function() {
__f__('log','at pages/index/index.vue:186','UniApp桥接: 请求设备信息');
this.postMessage('getDeviceInfo', {});
},
// 显示Toast
showToast: function(message, duration = 2000) {
__f__('log','at pages/index/index.vue:192','UniApp桥接: 显示Toast', message, duration);
this.postMessage('toast', { message, duration });
},
// 显示Alert
showAlert: function(title, content) {
__f__('log','at pages/index/index.vue:198','UniApp桥接: 显示Alert', title, content);
this.postMessage('alert', { title, content });
},
// 显示Confirm
showConfirm: function(title, content) {
__f__('log','at pages/index/index.vue:204','UniApp桥接: 显示Confirm', title, content);
this.postMessage('confirm', { title, content });
},
// 分享
share: function(data) {
__f__('log','at pages/index/index.vue:210','UniApp桥接: 分享', data);
this.postMessage('share', data);
},
// 支付
payment: function(data) {
__f__('log','at pages/index/index.vue:216','UniApp桥接: 支付', data);
this.postMessage('payment', data);
},
// 页面导航
navigate: function(url) {
__f__('log','at pages/index/index.vue:222','UniApp桥接: 导航', url);
this.postMessage('navigate', { url });
},
// 自定义消息
sendCustomMessage: function(type, data) {
__f__('log','at pages/index/index.vue:228','UniApp桥接: 自定义消息', type, data);
this.postMessage(type, data);
},
// 页面准备就绪
notifyPageReady: function(data) {
__f__('log','at pages/index/index.vue:234','UniApp桥接: 页面准备就绪', data);
this.postMessage('pageReady', data);
}
};
// 监听来自UniApp的消息
window.addEventListener('message', function(event) {
__f__('log','at pages/index/index.vue:241','UniApp桥接收到消息:', event.data);
if (event.data && event.data.type) {
// 触发自定义事件
const customEvent = new CustomEvent('uniAppMessage', {
detail: event.data
});
window.dispatchEvent(customEvent);
}
});
__f__('log','at pages/index/index.vue:251','UniApp桥接代码注入成功');
// 通知UniApp页面已加载完成
window.parent.postMessage({
type: 'pageLoaded',
data: { url: window.location.href },
timestamp: Date.now()
}, '*');
`;
formatAppLog("log", "at pages/index/index.vue:262", "UniApp: 立即注入桥接代码");
this.evalJS(bridgeCode);
setTimeout(() => {
formatAppLog("log", "at pages/index/index.vue:267", "UniApp: 延迟500ms后再次注入");
this.evalJS(bridgeCode);
}, 500);
setTimeout(() => {
formatAppLog("log", "at pages/index/index.vue:273", "UniApp: 延迟1000ms后备用注入");
this.evalJS(bridgeCode);
}, 1e3);
},
// 执行JavaScript代码
evalJS(code) {
formatAppLog("log", "at pages/index/index.vue:280", "UniApp: 执行JavaScript代码");
formatAppLog("log", "at pages/index/index.vue:281", "UniApp: 当前平台:", uni.getSystemInfoSync().platform);
const webview = this.$refs.webview;
formatAppLog("log", "at pages/index/index.vue:284", "UniApp: webview引用:", webview);
if (webview && webview.evalJS) {
try {
webview.evalJS(code);
formatAppLog("log", "at pages/index/index.vue:291", "UniApp: JavaScript代码执行成功 (App环境)");
} catch (error) {
formatAppLog("error", "at pages/index/index.vue:293", "UniApp: JavaScript代码执行失败:", error);
}
} else {
formatAppLog("warn", "at pages/index/index.vue:296", "UniApp: webview或evalJS方法不存在 (App环境)");
this.tryAlternativeInjection(code);
}
},
// 备用注入方案
tryAlternativeInjection(code) {
formatAppLog("log", "at pages/index/index.vue:315", "UniApp: 尝试备用注入方案");
try {
window.postMessage({
type: "injectCode",
data: { code },
timestamp: Date.now()
}, "*");
formatAppLog("log", "at pages/index/index.vue:323", "UniApp: 备用方案1执行成功");
} catch (error) {
formatAppLog("error", "at pages/index/index.vue:325", "UniApp: 备用方案1失败:", error);
try {
const webview = this.$refs.webview;
if (webview && webview.postMessage) {
webview.postMessage({
type: "injectCode",
data: { code }
});
formatAppLog("log", "at pages/index/index.vue:335", "UniApp: 备用方案2执行成功");
} else {
formatAppLog("error", "at pages/index/index.vue:337", "UniApp: 备用方案2失败 - webview.postMessage不存在");
}
} catch (error2) {
formatAppLog("error", "at pages/index/index.vue:340", "UniApp: 备用方案2失败:", error2);
}
}
},
// 处理web-view组件的消息
handleMessage(event) {
formatAppLog("log", "at pages/index/index.vue:347", "收到web-view消息:", event.detail);
try {
const data = event.detail.data;
if (data && data.type) {
this.processMessage(data);
}
} catch (error) {
formatAppLog("error", "at pages/index/index.vue:354", "处理消息失败:", error);
}
},
// 处理iframe消息
handleIframeMessage(event) {
formatAppLog("log", "at pages/index/index.vue:360", "收到iframe消息:", event.data);
try {
if (event.data && event.data.type) {
if (event.data.type === "pageLoaded") {
formatAppLog("log", "at pages/index/index.vue:365", "收到页面加载完成消息:", event.data.data);
if (this.loadingTimer) {
clearTimeout(this.loadingTimer);
this.loadingTimer = null;
}
this.loading = false;
this.processMessageQueue();
return;
}
this.processMessage(event.data);
}
} catch (error) {
formatAppLog("error", "at pages/index/index.vue:380", "处理iframe消息失败:", error);
}
},
// 处理消息
processMessage(data) {
formatAppLog("log", "at pages/index/index.vue:386", "UniApp处理消息:", data.type, data);
switch (data.type) {
case this.config.communication.messageTypes.GET_USER_INFO:
formatAppLog("log", "at pages/index/index.vue:390", "UniApp: 处理获取用户信息请求");
this.sendUserInfo();
break;
case this.config.communication.messageTypes.GET_DEVICE_INFO:
formatAppLog("log", "at pages/index/index.vue:394", "UniApp: 处理获取设备信息请求");
this.sendDeviceInfo();
break;
case this.config.communication.messageTypes.NAVIGATE:
formatAppLog("log", "at pages/index/index.vue:398", "UniApp: 处理导航请求");
this.handleNavigation(data);
break;
case this.config.communication.messageTypes.SHARE:
formatAppLog("log", "at pages/index/index.vue:402", "UniApp: 处理分享请求");
this.handleShare(data);
break;
case this.config.communication.messageTypes.PAYMENT:
formatAppLog("log", "at pages/index/index.vue:406", "UniApp: 处理支付请求");
this.handlePayment(data);
break;
case this.config.communication.messageTypes.TOAST:
formatAppLog("log", "at pages/index/index.vue:410", "UniApp: 处理Toast请求");
this.handleToast(data);
break;
case this.config.communication.messageTypes.ALERT:
formatAppLog("log", "at pages/index/index.vue:414", "UniApp: 处理Alert请求");
this.handleAlert(data);
break;
case this.config.communication.messageTypes.CONFIRM:
formatAppLog("log", "at pages/index/index.vue:418", "UniApp: 处理Confirm请求");
this.handleConfirm(data);
break;
case "pageReady":
formatAppLog("log", "at pages/index/index.vue:422", "UniApp: 处理页面准备就绪消息");
break;
default:
formatAppLog("log", "at pages/index/index.vue:426", "UniApp: 未知消息类型:", data.type);
}
},
// 发送用户信息到iframe
sendUserInfo() {
formatAppLog("log", "at pages/index/index.vue:432", "UniApp: 发送用户信息");
const userInfo = {
type: "userInfo",
data: this.config.userConfig.defaultUser
};
this.sendMessageToIframe(userInfo);
},
// 发送设备信息到iframe
sendDeviceInfo() {
formatAppLog("log", "at pages/index/index.vue:442", "UniApp: 发送设备信息");
const systemInfo = uni.getSystemInfoSync();
const deviceInfo = {
type: "deviceInfo",
data: {
platform: systemInfo.platform,
model: systemInfo.model,
version: systemInfo.version,
appVersion: this.config.appConfig.version,
appName: this.config.appConfig.appName,
screenWidth: systemInfo.screenWidth,
screenHeight: systemInfo.screenHeight,
statusBarHeight: systemInfo.statusBarHeight
}
};
this.sendMessageToIframe(deviceInfo);
},
// 处理导航
handleNavigation(data) {
if (data.url) {
formatAppLog("log", "at pages/index/index.vue:463", "导航到:", data.url);
}
},
// 处理分享
handleShare(data) {
formatAppLog("log", "at pages/index/index.vue:470", "UniApp: 处理分享请求", data);
uni.share({
provider: "weixin",
scene: "WXSceneSession",
type: 0,
href: data.url || this.currentUrl,
title: data.title || this.config.appConfig.appName,
summary: data.summary || "分享内容",
success: (res) => {
formatAppLog("log", "at pages/index/index.vue:479", "UniApp: 分享成功:", res);
this.sendToIframe("shareResult", { success: true });
},
fail: (err) => {
formatAppLog("error", "at pages/index/index.vue:483", "UniApp: 分享失败:", err);
this.sendToIframe("shareResult", { success: false, error: err });
}
});
},
// 处理支付
handlePayment(data) {
formatAppLog("log", "at pages/index/index.vue:491", "UniApp: 处理支付请求", data);
setTimeout(() => {
this.sendToIframe("paymentResult", {
success: true,
orderId: data.orderId || "order123"
});
}, 1e3);
},
// 处理Toast
handleToast(data) {
formatAppLog("log", "at pages/index/index.vue:504", "UniApp: 处理Toast请求", data);
uni.showToast({
title: data.message,
icon: "none",
duration: data.duration || 2e3
});
},
// 处理Alert
handleAlert(data) {
formatAppLog("log", "at pages/index/index.vue:514", "UniApp: 处理Alert请求", data);
uni.showModal({
title: data.title || "提示",
content: data.content,
showCancel: false
});
},
// 处理Confirm
handleConfirm(data) {
formatAppLog("log", "at pages/index/index.vue:524", "UniApp: 处理Confirm请求", data);
uni.showModal({
title: data.title || "确认",
content: data.content,
success: (res) => {
formatAppLog("log", "at pages/index/index.vue:529", "UniApp: Confirm结果:", res);
this.sendToIframe("confirmResult", {
confirmed: res.confirm
});
}
});
},
// 发送消息到iframe
sendMessageToIframe(message) {
this.messageQueue.push(message);
this.processMessageQueue();
},
// 处理消息队列
processMessageQueue() {
formatAppLog("log", "at pages/index/index.vue:545", "UniApp: 处理消息队列, 队列长度:", this.messageQueue.length, "加载状态:", this.loading);
if (this.messageQueue.length > 0 && !this.loading) {
const message = this.messageQueue.shift();
formatAppLog("log", "at pages/index/index.vue:548", "UniApp: 发送消息到iframe:", message);
this.evalJS(`
window.postMessage(${JSON.stringify(message)}, '*');
`);
}
},
// 恢复消息队列处理
resumeMessageQueue() {
this.processMessageQueue();
},
// 向iframe发送消息的通用方法
sendToIframe(type, data) {
const message = {
type,
data,
timestamp: Date.now()
};
this.sendMessageToIframe(message);
},
// 处理加载状态
handleLoading(event) {
formatAppLog("log", "at pages/index/index.vue:572", "WebView加载状态变化:", event.detail);
const newLoadingState = event.detail.loading;
formatAppLog("log", "at pages/index/index.vue:574", "加载状态从", this.loading, "变为", newLoadingState);
this.loading = newLoadingState;
if (!this.loading) {
formatAppLog("log", "at pages/index/index.vue:580", "页面加载完成,清除超时定时器");
if (this.loadingTimer) {
clearTimeout(this.loadingTimer);
this.loadingTimer = null;
}
this.injectBridgeCode();
this.processMessageQueue();
} else {
formatAppLog("log", "at pages/index/index.vue:592", "页面开始加载,设置超时检测");
this.setupLoadingTimeout();
}
},
// 处理错误
handleError(event) {
formatAppLog("error", "at pages/index/index.vue:599", "WebView错误:", event.detail);
this.error = "页面加载失败,请检查网络连接";
this.loading = false;
clearTimeout(this.loadingTimer);
},
// 重新加载页面
reloadPage() {
this.error = "";
this.loading = true;
this.setupLoadingTimeout();
const webview = this.$refs.webview;
if (webview) {
webview.reload();
}
},
// 切换到备用地址
switchToFallback() {
this.currentUrl = this.config.webConfig.fallbackUrl;
this.reloadPage();
},
// 清除超时
clearTimeout() {
formatAppLog("log", "at pages/index/index.vue:625", "手动清除超时");
if (this.loadingTimer) {
clearTimeout(this.loadingTimer);
this.loadingTimer = null;
}
this.error = "";
this.loading = false;
formatAppLog("log", "at pages/index/index.vue:632", "超时已清除");
},
// 获取安全区域高度
getSafeAreaHeight() {
try {
const systemInfo = uni.getSystemInfoSync();
formatAppLog("log", "at pages/index/index.vue:640", "UniApp: 系统信息:", systemInfo);
const safeArea = systemInfo.safeArea || {};
const safeAreaInsets = systemInfo.safeAreaInsets || {};
formatAppLog("log", "at pages/index/index.vue:646", "UniApp: 安全区域:", safeArea);
formatAppLog("log", "at pages/index/index.vue:647", "UniApp: 安全区域边距:", safeAreaInsets);
const statusBarHeight = systemInfo.statusBarHeight || 0;
formatAppLog("log", "at pages/index/index.vue:651", "UniApp: 状态栏高度:", statusBarHeight);
let topSafeAreaHeight = statusBarHeight;
if (safeAreaInsets.top !== void 0) {
topSafeAreaHeight = safeAreaInsets.top;
formatAppLog("log", "at pages/index/index.vue:659", "UniApp: 使用safeAreaInsets.top:", topSafeAreaHeight);
} else if (safeArea.top !== void 0) {
topSafeAreaHeight = safeArea.top;
formatAppLog("log", "at pages/index/index.vue:662", "UniApp: 使用safeArea.top:", topSafeAreaHeight);
} else {
topSafeAreaHeight = this.calculatePlatformSafeArea(statusBarHeight, systemInfo);
}
const safeAreaInfo = {
top: topSafeAreaHeight,
bottom: safeAreaInsets.bottom || safeArea.bottom || 0,
left: safeAreaInsets.left || safeArea.left || 0,
right: safeAreaInsets.right || safeArea.right || 0,
statusBarHeight,
navBarHeight: 44,
// 导航栏高度通常是44px
platform: systemInfo.platform,
model: systemInfo.model,
system: systemInfo.system,
screenWidth: systemInfo.screenWidth,
screenHeight: systemInfo.screenHeight
};
return safeAreaInfo;
} catch (error) {
formatAppLog("error", "at pages/index/index.vue:686", "UniApp: 获取安全区域信息失败:", error);
return {
top: 44,
bottom: 0,
left: 0,
right: 0,
statusBarHeight: 44,
navBarHeight: 44,
platform: "unknown",
model: "unknown",
system: "unknown",
screenWidth: 375,
screenHeight: 667
};
}
},
// 根据平台计算安全区域
calculatePlatformSafeArea(statusBarHeight, systemInfo) {
const platform = systemInfo.platform.toLowerCase();
const model = systemInfo.model || "";
const screenHeight = systemInfo.screenHeight;
const screenWidth = systemInfo.screenWidth;
formatAppLog("log", "at pages/index/index.vue:712", "UniApp: 平台信息:", { platform, model, screenHeight, screenWidth });
if (platform === "ios") {
if (screenHeight >= 812 || screenWidth >= 812) {
formatAppLog("log", "at pages/index/index.vue:718", "UniApp: 检测到iPhone X及以后设备");
return 44;
} else {
formatAppLog("log", "at pages/index/index.vue:723", "UniApp: 检测到传统iPhone设备");
return statusBarHeight || 20;
}
} else if (platform === "android") {
if (screenHeight >= 800 || screenWidth >= 800) {
formatAppLog("log", "at pages/index/index.vue:731", "UniApp: 检测到高分辨率Android设备");
return Math.max(statusBarHeight, 24);
} else {
formatAppLog("log", "at pages/index/index.vue:736", "UniApp: 检测到传统Android设备");
return statusBarHeight || 24;
}
} else {
formatAppLog("log", "at pages/index/index.vue:742", "UniApp: 其他平台设备");
return statusBarHeight || 20;
}
},
// 动态设置web-view高度
setWebViewHeight(height) {
formatAppLog("log", "at pages/index/index.vue:749", "设置web-view高度:", height);
if (this.$refs.webview) {
this.$refs.webview.$el.style.height = height + "px";
this.$refs.webview.$el.className = "webview custom-height";
this.$nextTick(() => {
this.$refs.webview.$el.style.setProperty("height", height + "px", "important");
});
}
},
// 设置web-view为全屏
setWebViewFullscreen() {
this.getSafeAreaHeight();
const fullHeight = uni.getSystemInfoSync().windowHeight;
formatAppLog("log", "at pages/index/index.vue:768", "设置web-view全屏高度:", fullHeight);
this.setWebViewHeight(fullHeight);
},
// 设置web-view为部分高度
setWebViewPartialHeight(percentage = 0.8) {
this.getSafeAreaHeight();
const windowHeight = uni.getSystemInfoSync().windowHeight;
const partialHeight = windowHeight * percentage;
formatAppLog("log", "at pages/index/index.vue:777", "设置web-view部分高度:", partialHeight, "百分比:", percentage);
this.setWebViewHeight(partialHeight);
},
// 清理资源
cleanup() {
if (this.loadingTimer) {
clearTimeout(this.loadingTimer);
}
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("view", { class: "container" }, [
vue.createCommentVNode(" 全屏web-view容器 "),
vue.createElementVNode("web-view", {
src: $data.currentUrl,
style: vue.normalizeStyle($options.webViewStyle),
ref: "webview",
onMessage: _cache[0] || (_cache[0] = (...args) => $options.handleMessage && $options.handleMessage(...args)),
onError: _cache[1] || (_cache[1] = (...args) => $options.handleError && $options.handleError(...args)),
onLoading: _cache[2] || (_cache[2] = (...args) => $options.handleLoading && $options.handleLoading(...args))
}, null, 44, ["src"]),
vue.createCommentVNode(" 加载状态 "),
$data.loading ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: "loading-container"
}, [
vue.createElementVNode("view", { class: "loading-spinner" }),
vue.createElementVNode("text", { class: "loading-text" }, "加载中...")
])) : vue.createCommentVNode("v-if", true),
vue.createCommentVNode(" 错误状态 "),
$data.error ? (vue.openBlock(), vue.createElementBlock("view", {
key: 1,
class: "error-container"
}, [
vue.createElementVNode(
"text",
{ class: "error-text" },
vue.toDisplayString($data.error),
1
/* TEXT */
),
vue.createElementVNode("button", {
onClick: _cache[3] || (_cache[3] = (...args) => $options.reloadPage && $options.reloadPage(...args)),
class: "reload-btn"
}, "重新加载"),
vue.createElementVNode("button", {
onClick: _cache[4] || (_cache[4] = (...args) => $options.switchToFallback && $options.switchToFallback(...args)),
class: "fallback-btn"
}, "使用备用地址"),
vue.createElementVNode("button", {
onClick: _cache[5] || (_cache[5] = (...args) => $options.clearTimeout && $options.clearTimeout(...args)),
class: "clear-btn"
}, "清除超时")
])) : vue.createCommentVNode("v-if", true),
vue.createCommentVNode(" 调试信息(仅在调试模式下显示) "),
$data.config.appConfig.debug ? (vue.openBlock(), vue.createElementBlock("view", {
key: 2,
class: "debug-info"
}, [
vue.createElementVNode(
"text",
null,
"当前URL: " + vue.toDisplayString($data.currentUrl),
1
/* TEXT */
),
vue.createElementVNode(
"text",
null,
"加载状态: " + vue.toDisplayString($data.loading ? "加载中" : "已加载"),
1
/* TEXT */
),
vue.createElementVNode(
"text",
null,
"navBarHeight: " + vue.toDisplayString($options.navBarHeight),
1
/* TEXT */
)
])) : vue.createCommentVNode("v-if", true)
]);
}
const PagesIndexIndex = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__file", "E:/Cunkebao/Cunkebao01/Appbuild/pages/index/index.vue"]]);
__definePage("pages/index/index", PagesIndexIndex);
const _sfc_main = {};
const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "E:/Cunkebao/Cunkebao01/Appbuild/App.vue"]]);
function createApp() {
const app = vue.createVueApp(App);
return {
app
};
}
const { app: __app__, Vuex: __Vuex__, Pinia: __Pinia__ } = createApp();
uni.Vuex = __Vuex__;
uni.Pinia = __Pinia__;
__app__.provide("__globalStyles", __uniConfig.styles);
__app__._component.mpType = "app";
__app__._component.render = () => {
};
__app__.mount("#app");
})(Vue);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,161 @@
{
"@platforms": [
"android",
"iPhone",
"iPad"
],
"id": "__UNI__96F2246",
"name": "存客宝",
"version": {
"name": "1.0.0",
"code": "100"
},
"description": "流量分发终端",
"developer": {
"name": "",
"email": "",
"url": ""
},
"permissions": {
"Barcode": {},
"Bluetooth": {},
"Camera": {},
"Contacts": {},
"FaceID": {},
"FacialRecognitionVerify": {},
"Fingerprint": {},
"Geolocation": {},
"UniNView": {
"description": "UniNView原生渲染"
}
},
"plus": {
"useragent": {
"value": "uni-app",
"concatenate": true
},
"splashscreen": {
"target": "id:1",
"autoclose": true,
"waiting": true,
"delay": 0
},
"popGesture": "close",
"launchwebview": {
"render": "always",
"id": "1",
"kernel": "WKWebview"
},
"usingComponents": true,
"nvueStyleCompiler": "uni-app",
"compilerVersion": 3,
"distribute": {
"icons": {
"android": {
"hdpi": "unpackage/res/icons/72x72.png",
"xhdpi": "unpackage/res/icons/96x96.png",
"xxhdpi": "unpackage/res/icons/144x144.png",
"xxxhdpi": "unpackage/res/icons/192x192.png"
},
"ios": {
"appstore": "unpackage/res/icons/1024x1024.png",
"ipad": {
"app": "unpackage/res/icons/76x76.png",
"app@2x": "unpackage/res/icons/152x152.png",
"notification": "unpackage/res/icons/20x20.png",
"notification@2x": "unpackage/res/icons/40x40.png",
"proapp@2x": "unpackage/res/icons/167x167.png",
"settings": "unpackage/res/icons/29x29.png",
"settings@2x": "unpackage/res/icons/58x58.png",
"spotlight": "unpackage/res/icons/40x40.png",
"spotlight@2x": "unpackage/res/icons/80x80.png"
},
"iphone": {
"app@2x": "unpackage/res/icons/120x120.png",
"app@3x": "unpackage/res/icons/180x180.png",
"notification@2x": "unpackage/res/icons/40x40.png",
"notification@3x": "unpackage/res/icons/60x60.png",
"settings@2x": "unpackage/res/icons/58x58.png",
"settings@3x": "unpackage/res/icons/87x87.png",
"spotlight@2x": "unpackage/res/icons/80x80.png",
"spotlight@3x": "unpackage/res/icons/120x120.png"
}
}
},
"google": {
"permissions": [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
"apple": {
"dSYMs": true
},
"plugins": {
"geolocation": {
"system": {
"__platform__": [
"ios",
"android"
]
}
},
"oauth": {
"apple": {}
},
"ad": {},
"audio": {
"mp3": {
"description": "Android平台录音支持MP3格式文件"
}
}
}
},
"statusbar": {
"immersed": "supportedDevice",
"style": "dark",
"background": "#F8F8F8"
},
"uniStatistics": {
"enable": false
},
"allowsInlineMediaPlayback": true,
"uni-app": {
"control": "uni-v3",
"vueVersion": "3",
"compilerVersion": "4.75",
"nvueCompiler": "uni-app",
"renderer": "auto",
"nvue": {
"flex-direction": "column"
},
"nvueLaunchMode": "normal",
"webView": {
"minUserAgentVersion": "49.0"
}
}
},
"app-harmony": {
"useragent": {
"value": "uni-app",
"concatenate": true
},
"uniStatistics": {
"enable": false
}
},
"launch_path": "__uniappview.html"
}

View File

@@ -0,0 +1,143 @@
.container {
width: 100%;
height: 100vh;
position: relative;
background-color: #000;
overflow: hidden;
}
/* 确保web-view在app基座中正确显示 */
.webview {
width: 100% !important;
height: 100% !important;
position: absolute !important;
top: 0 !important;
left: 0 !important;
right: 0 !important;
bottom: 0 !important;
z-index: 1;
}
/* 针对app基座的特殊处理 */
.container {
height: 100vh !important;
overflow: hidden !important;
}
.webview {
width: 100% !important;
height: 100% !important;
position: absolute !important;
top: 0 !important;
left: 0 !important;
right: 0 !important;
bottom: 0 !important;
z-index: 1 !important;
}
.loading-container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
display: flex;
flex-direction: column;
align-items: center;
background-color: rgba(255, 255, 255, 0.95);
padding: 30px;
border-radius: 15px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
.loading-spinner {
width: 50px;
height: 50px;
border: 4px solid #f3f3f3;
border-top: 4px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 15px;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.loading-text {
font-size: 16px;
color: #333;
font-weight: 500;
}
.error-container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
display: flex;
flex-direction: column;
align-items: center;
background-color: rgba(255, 255, 255, 0.95);
padding: 30px;
border-radius: 15px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
min-width: 280px;
}
.error-text {
font-size: 16px;
color: #e74c3c;
margin-bottom: 20px;
text-align: center;
line-height: 1.5;
}
.reload-btn,
.fallback-btn,
.clear-btn {
background-color: #3498db;
color: white;
border: none;
padding: 12px 24px;
border-radius: 8px;
font-size: 14px;
margin: 5px;
min-width: 120px;
}
.fallback-btn {
background-color: #95a5a6;
}
.clear-btn {
background-color: #e74c3c;
}
.debug-info {
position: absolute;
top: 300px;
right: 10px;
z-index: 3;
background-color: rgba(0, 0, 0, 0.7);
color: white;
padding: 10px;
border-radius: 5px;
font-size: 12px;
display: flex;
flex-direction: column;
}
/* 自定义高度样式 */
.webview.custom-height {
height: var(--custom-height, 100%) !important;
}
/* 针对不同高度的预设样式 */
.webview.height-50 {
height: 50vh !important;
}
.webview.height-75 {
height: 75vh !important;
}
.webview.height-90 {
height: 90vh !important;
}
.webview.height-full {
height: 100vh !important;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const common_vendor = require("./common/vendor.js");
if (!Math) {
"./pages/index/index.js";
}
const _sfc_main = {};
function createApp() {
const app = common_vendor.createSSRApp(_sfc_main);
return {
app
};
}
createApp().app.mount("#app");
exports.createApp = createApp;
//# sourceMappingURL=../.sourcemap/mp-weixin/app.js.map

View File

@@ -0,0 +1,13 @@
{
"pages": [
"pages/index/index"
],
"window": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "存客宝",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8",
"navigationStyle": "custom"
},
"usingComponents": {}
}

View File

@@ -0,0 +1,3 @@
/*每个页面公共css */
page{--status-bar-height:25px;--top-window-height:0px;--window-top:0px;--window-bottom:0px;--window-left:0px;--window-right:0px;--window-magin:0px}[data-c-h="true"]{display: none !important;}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,64 @@
"use strict";
const config = {
// 目标网站配置
webConfig: {
// 主要目标网站URL请替换为您的实际网站
mainUrl: "http://localhost:3000",
// // 备用网站URL如果主网站无法访问
fallbackUrl: "https://kr-op.quwanzhi.com",
// 测试页面URL用于开发测试
testUrl: "http://localhost:3000/test/postMessage",
// 是否启用HTTPS强制跳转
forceHttps: false,
// 是否允许跨域请求
allowCrossOrigin: true
},
// 应用配置
appConfig: {
// 应用名称
appName: "存客宝",
// 应用版本
version: "1.0.0",
// 是否启用超时检测
enableTimeout: false,
// 设为 false 禁用超时检测
// 加载超时时间(毫秒)- 设为0禁用超时检测
loadingTimeout: 3e4,
// 增加到30秒
// 是否启用调试模式
debug: true,
// 开发时设为 true生产时设为 false
// 是否使用测试页面
useTestPage: true
// 开发时设为 true生产时设为 false
},
// 通信配置
communication: {
// 消息类型定义
messageTypes: {
GET_USER_INFO: "getUserInfo",
GET_DEVICE_INFO: "getDeviceInfo",
NAVIGATE: "navigate",
SHARE: "share",
PAYMENT: "payment",
TOAST: "toast",
ALERT: "alert",
CONFIRM: "confirm"
},
// 允许的域名白名单
allowedDomains: ["kr-op.quwanzhi.com", "quwanzhi.com", "localhost"]
},
// 用户配置
userConfig: {
// 默认用户信息
defaultUser: {
id: "user123",
name: "测试用户",
avatar: "https://example.com/avatar.jpg",
phone: "13800138000",
email: "test@example.com"
}
}
};
exports.config = config;
//# sourceMappingURL=../.sourcemap/mp-weixin/config.js.map

View File

@@ -0,0 +1,529 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const config = require("../../config.js");
const _sfc_main = {
data() {
return {
config: config.config,
currentUrl: "",
// 初始化为空字符串
loading: false,
error: "",
loadingTimer: null,
messageQueue: []
};
},
onLoad() {
common_vendor.index.__f__("log", "at pages/index/index.vue:44", "WebView页面加载");
common_vendor.index.__f__("log", "at pages/index/index.vue:45", "UniApp: 当前平台信息:", common_vendor.index.getSystemInfoSync());
this.initApp();
},
onShow() {
common_vendor.index.__f__("log", "at pages/index/index.vue:49", "WebView页面显示");
this.resumeMessageQueue();
},
onHide() {
common_vendor.index.__f__("log", "at pages/index/index.vue:53", "WebView页面隐藏");
},
onUnload() {
this.cleanup();
},
methods: {
// 获取初始URL
getInitialUrl() {
common_vendor.index.__f__("log", "at pages/index/index.vue:61", "获取初始URLconfig:", this.config);
if (this.config && this.config.appConfig && this.config.appConfig.useTestPage) {
return this.config.webConfig.testUrl;
}
return this.config.webConfig.mainUrl;
},
// 初始化应用
initApp() {
common_vendor.index.__f__("log", "at pages/index/index.vue:70", "UniApp: 开始初始化应用");
this.currentUrl = this.getInitialUrl();
common_vendor.index.__f__("log", "at pages/index/index.vue:73", "UniApp: 设置URL:", this.currentUrl);
this.setupLoadingTimeout();
this.initMessageHandler();
common_vendor.index.__f__("log", "at pages/index/index.vue:79", "UniApp: 立即注入桥接代码");
this.injectBridgeCode();
},
// 设置加载超时
setupLoadingTimeout() {
if (this.loadingTimer) {
clearTimeout(this.loadingTimer);
}
if (!this.config.appConfig.enableTimeout) {
common_vendor.index.__f__("log", "at pages/index/index.vue:92", "超时检测已禁用");
return;
}
if (this.config.appConfig.loadingTimeout > 0) {
common_vendor.index.__f__("log", "at pages/index/index.vue:97", "设置加载超时:", this.config.appConfig.loadingTimeout + "ms");
this.loadingTimer = setTimeout(() => {
if (this.loading) {
common_vendor.index.__f__("warn", "at pages/index/index.vue:100", "页面加载超时,当前状态:", this.loading);
this.handleTimeout();
}
}, this.config.appConfig.loadingTimeout);
}
},
// 处理加载超时
handleTimeout() {
common_vendor.index.__f__("warn", "at pages/index/index.vue:109", "触发页面加载超时处理");
this.error = "页面加载超时,请检查网络连接";
this.loading = false;
if (this.loadingTimer) {
clearTimeout(this.loadingTimer);
this.loadingTimer = null;
}
},
// 初始化消息处理器
initMessageHandler() {
common_vendor.index.__f__("log", "at pages/index/index.vue:121", "UniApp: 初始化消息处理器");
window.addEventListener("message", (event) => {
common_vendor.index.__f__("log", "at pages/index/index.vue:124", "UniApp: 收到window.message事件:", event.data);
this.handleIframeMessage(event);
});
},
// 设置WebView桥接
setupWebViewBridge() {
this.injectBridgeCode();
},
// 注入桥接代码
injectBridgeCode() {
common_vendor.index.__f__("log", "at pages/index/index.vue:137", "UniApp: 开始注入桥接代码");
const bridgeCode = `
// UniApp WebView 桥接代码
uni.__f__('log','at pages/index/index.vue:141','开始注入UniApp桥接代码...');
// 检查是否已经存在桥接
if (window.uniAppBridge) {
uni.__f__('log','at pages/index/index.vue:145','UniApp桥接已存在跳过注入');
return;
}
window.uniAppBridge = {
// 发送消息到UniApp
postMessage: function(type, data) {
uni.__f__('log','at pages/index/index.vue:152','UniApp桥接发送消息:', type, data);
window.parent.postMessage({
type: type,
data: data,
timestamp: Date.now()
}, '*');
},
// 获取用户信息
getUserInfo: function() {
uni.__f__('log','at pages/index/index.vue:162','UniApp桥接: 请求用户信息');
this.postMessage('getUserInfo', {});
},
// 获取设备信息
getDeviceInfo: function() {
uni.__f__('log','at pages/index/index.vue:168','UniApp桥接: 请求设备信息');
this.postMessage('getDeviceInfo', {});
},
// 显示Toast
showToast: function(message, duration = 2000) {
uni.__f__('log','at pages/index/index.vue:174','UniApp桥接: 显示Toast', message, duration);
this.postMessage('toast', { message, duration });
},
// 显示Alert
showAlert: function(title, content) {
uni.__f__('log','at pages/index/index.vue:180','UniApp桥接: 显示Alert', title, content);
this.postMessage('alert', { title, content });
},
// 显示Confirm
showConfirm: function(title, content) {
uni.__f__('log','at pages/index/index.vue:186','UniApp桥接: 显示Confirm', title, content);
this.postMessage('confirm', { title, content });
},
// 分享
share: function(data) {
uni.__f__('log','at pages/index/index.vue:192','UniApp桥接: 分享', data);
this.postMessage('share', data);
},
// 支付
payment: function(data) {
uni.__f__('log','at pages/index/index.vue:198','UniApp桥接: 支付', data);
this.postMessage('payment', data);
},
// 页面导航
navigate: function(url) {
uni.__f__('log','at pages/index/index.vue:204','UniApp桥接: 导航', url);
this.postMessage('navigate', { url });
},
// 自定义消息
sendCustomMessage: function(type, data) {
uni.__f__('log','at pages/index/index.vue:210','UniApp桥接: 自定义消息', type, data);
this.postMessage(type, data);
},
// 页面准备就绪
notifyPageReady: function(data) {
uni.__f__('log','at pages/index/index.vue:216','UniApp桥接: 页面准备就绪', data);
this.postMessage('pageReady', data);
}
};
// 监听来自UniApp的消息
window.addEventListener('message', function(event) {
uni.__f__('log','at pages/index/index.vue:223','UniApp桥接收到消息:', event.data);
if (event.data && event.data.type) {
// 触发自定义事件
const customEvent = new CustomEvent('uniAppMessage', {
detail: event.data
});
window.dispatchEvent(customEvent);
}
});
uni.__f__('log','at pages/index/index.vue:233','UniApp桥接代码注入成功');
// 通知UniApp页面已加载完成
window.parent.postMessage({
type: 'pageLoaded',
data: { url: window.location.href },
timestamp: Date.now()
}, '*');
`;
common_vendor.index.__f__("log", "at pages/index/index.vue:244", "UniApp: 立即注入桥接代码");
this.evalJS(bridgeCode);
setTimeout(() => {
common_vendor.index.__f__("log", "at pages/index/index.vue:249", "UniApp: 延迟500ms后再次注入");
this.evalJS(bridgeCode);
}, 500);
setTimeout(() => {
common_vendor.index.__f__("log", "at pages/index/index.vue:255", "UniApp: 延迟1000ms后备用注入");
this.evalJS(bridgeCode);
}, 1e3);
},
// 执行JavaScript代码
evalJS(code) {
common_vendor.index.__f__("log", "at pages/index/index.vue:262", "UniApp: 执行JavaScript代码");
common_vendor.index.__f__("log", "at pages/index/index.vue:263", "UniApp: 当前平台:", common_vendor.index.getSystemInfoSync().platform);
const webview = this.$refs.webview;
common_vendor.index.__f__("log", "at pages/index/index.vue:266", "UniApp: webview引用:", webview);
common_vendor.index.__f__("log", "at pages/index/index.vue:285", "UniApp: 小程序环境,使用备用注入方案");
this.tryAlternativeInjection(code);
},
// 备用注入方案
tryAlternativeInjection(code) {
common_vendor.index.__f__("log", "at pages/index/index.vue:297", "UniApp: 尝试备用注入方案");
try {
window.postMessage({
type: "injectCode",
data: { code },
timestamp: Date.now()
}, "*");
common_vendor.index.__f__("log", "at pages/index/index.vue:305", "UniApp: 备用方案1执行成功");
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:307", "UniApp: 备用方案1失败:", error);
try {
const webview = this.$refs.webview;
if (webview && webview.postMessage) {
webview.postMessage({
type: "injectCode",
data: { code }
});
common_vendor.index.__f__("log", "at pages/index/index.vue:317", "UniApp: 备用方案2执行成功");
} else {
common_vendor.index.__f__("error", "at pages/index/index.vue:319", "UniApp: 备用方案2失败 - webview.postMessage不存在");
}
} catch (error2) {
common_vendor.index.__f__("error", "at pages/index/index.vue:322", "UniApp: 备用方案2失败:", error2);
}
}
},
// 处理web-view组件的消息
handleMessage(event) {
common_vendor.index.__f__("log", "at pages/index/index.vue:329", "收到web-view消息:", event.detail);
try {
const data = event.detail.data;
if (data && data.type) {
this.processMessage(data);
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:336", "处理消息失败:", error);
}
},
// 处理iframe消息
handleIframeMessage(event) {
common_vendor.index.__f__("log", "at pages/index/index.vue:342", "收到iframe消息:", event.data);
try {
if (event.data && event.data.type) {
if (event.data.type === "pageLoaded") {
common_vendor.index.__f__("log", "at pages/index/index.vue:347", "收到页面加载完成消息:", event.data.data);
if (this.loadingTimer) {
clearTimeout(this.loadingTimer);
this.loadingTimer = null;
}
this.loading = false;
this.processMessageQueue();
return;
}
this.processMessage(event.data);
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:362", "处理iframe消息失败:", error);
}
},
// 处理消息
processMessage(data) {
common_vendor.index.__f__("log", "at pages/index/index.vue:368", "UniApp处理消息:", data.type, data);
switch (data.type) {
case this.config.communication.messageTypes.GET_USER_INFO:
common_vendor.index.__f__("log", "at pages/index/index.vue:372", "UniApp: 处理获取用户信息请求");
this.sendUserInfo();
break;
case this.config.communication.messageTypes.GET_DEVICE_INFO:
common_vendor.index.__f__("log", "at pages/index/index.vue:376", "UniApp: 处理获取设备信息请求");
this.sendDeviceInfo();
break;
case this.config.communication.messageTypes.NAVIGATE:
common_vendor.index.__f__("log", "at pages/index/index.vue:380", "UniApp: 处理导航请求");
this.handleNavigation(data);
break;
case this.config.communication.messageTypes.SHARE:
common_vendor.index.__f__("log", "at pages/index/index.vue:384", "UniApp: 处理分享请求");
this.handleShare(data);
break;
case this.config.communication.messageTypes.PAYMENT:
common_vendor.index.__f__("log", "at pages/index/index.vue:388", "UniApp: 处理支付请求");
this.handlePayment(data);
break;
case this.config.communication.messageTypes.TOAST:
common_vendor.index.__f__("log", "at pages/index/index.vue:392", "UniApp: 处理Toast请求");
this.handleToast(data);
break;
case this.config.communication.messageTypes.ALERT:
common_vendor.index.__f__("log", "at pages/index/index.vue:396", "UniApp: 处理Alert请求");
this.handleAlert(data);
break;
case this.config.communication.messageTypes.CONFIRM:
common_vendor.index.__f__("log", "at pages/index/index.vue:400", "UniApp: 处理Confirm请求");
this.handleConfirm(data);
break;
case "pageReady":
common_vendor.index.__f__("log", "at pages/index/index.vue:404", "UniApp: 处理页面准备就绪消息");
break;
default:
common_vendor.index.__f__("log", "at pages/index/index.vue:408", "UniApp: 未知消息类型:", data.type);
}
},
// 发送用户信息到iframe
sendUserInfo() {
common_vendor.index.__f__("log", "at pages/index/index.vue:414", "UniApp: 发送用户信息");
const userInfo = {
type: "userInfo",
data: this.config.userConfig.defaultUser
};
this.sendMessageToIframe(userInfo);
},
// 发送设备信息到iframe
sendDeviceInfo() {
common_vendor.index.__f__("log", "at pages/index/index.vue:424", "UniApp: 发送设备信息");
const systemInfo = common_vendor.index.getSystemInfoSync();
const deviceInfo = {
type: "deviceInfo",
data: {
platform: systemInfo.platform,
model: systemInfo.model,
version: systemInfo.version,
appVersion: this.config.appConfig.version,
appName: this.config.appConfig.appName,
screenWidth: systemInfo.screenWidth,
screenHeight: systemInfo.screenHeight,
statusBarHeight: systemInfo.statusBarHeight
}
};
this.sendMessageToIframe(deviceInfo);
},
// 处理导航
handleNavigation(data) {
if (data.url) {
common_vendor.index.__f__("log", "at pages/index/index.vue:445", "导航到:", data.url);
}
},
// 处理分享
handleShare(data) {
common_vendor.index.__f__("log", "at pages/index/index.vue:452", "UniApp: 处理分享请求", data);
common_vendor.index.share({
provider: "weixin",
scene: "WXSceneSession",
type: 0,
href: data.url || this.currentUrl,
title: data.title || this.config.appConfig.appName,
summary: data.summary || "分享内容",
success: (res) => {
common_vendor.index.__f__("log", "at pages/index/index.vue:461", "UniApp: 分享成功:", res);
this.sendToIframe("shareResult", { success: true });
},
fail: (err) => {
common_vendor.index.__f__("error", "at pages/index/index.vue:465", "UniApp: 分享失败:", err);
this.sendToIframe("shareResult", { success: false, error: err });
}
});
},
// 处理支付
handlePayment(data) {
common_vendor.index.__f__("log", "at pages/index/index.vue:473", "UniApp: 处理支付请求", data);
setTimeout(() => {
this.sendToIframe("paymentResult", {
success: true,
orderId: data.orderId || "order123"
});
}, 1e3);
},
// 处理Toast
handleToast(data) {
common_vendor.index.__f__("log", "at pages/index/index.vue:486", "UniApp: 处理Toast请求", data);
common_vendor.index.showToast({
title: data.message,
icon: "none",
duration: data.duration || 2e3
});
},
// 处理Alert
handleAlert(data) {
common_vendor.index.__f__("log", "at pages/index/index.vue:496", "UniApp: 处理Alert请求", data);
common_vendor.index.showModal({
title: data.title || "提示",
content: data.content,
showCancel: false
});
},
// 处理Confirm
handleConfirm(data) {
common_vendor.index.__f__("log", "at pages/index/index.vue:506", "UniApp: 处理Confirm请求", data);
common_vendor.index.showModal({
title: data.title || "确认",
content: data.content,
success: (res) => {
common_vendor.index.__f__("log", "at pages/index/index.vue:511", "UniApp: Confirm结果:", res);
this.sendToIframe("confirmResult", {
confirmed: res.confirm
});
}
});
},
// 发送消息到iframe
sendMessageToIframe(message) {
this.messageQueue.push(message);
this.processMessageQueue();
},
// 处理消息队列
processMessageQueue() {
common_vendor.index.__f__("log", "at pages/index/index.vue:527", "UniApp: 处理消息队列, 队列长度:", this.messageQueue.length, "加载状态:", this.loading);
if (this.messageQueue.length > 0 && !this.loading) {
const message = this.messageQueue.shift();
common_vendor.index.__f__("log", "at pages/index/index.vue:530", "UniApp: 发送消息到iframe:", message);
this.evalJS(`
window.postMessage(${JSON.stringify(message)}, '*');
`);
}
},
// 恢复消息队列处理
resumeMessageQueue() {
this.processMessageQueue();
},
// 向iframe发送消息的通用方法
sendToIframe(type, data) {
const message = {
type,
data,
timestamp: Date.now()
};
this.sendMessageToIframe(message);
},
// 处理加载状态
handleLoading(event) {
common_vendor.index.__f__("log", "at pages/index/index.vue:554", "WebView加载状态变化:", event.detail);
const newLoadingState = event.detail.loading;
common_vendor.index.__f__("log", "at pages/index/index.vue:556", "加载状态从", this.loading, "变为", newLoadingState);
this.loading = newLoadingState;
if (!this.loading) {
common_vendor.index.__f__("log", "at pages/index/index.vue:562", "页面加载完成,清除超时定时器");
if (this.loadingTimer) {
clearTimeout(this.loadingTimer);
this.loadingTimer = null;
}
this.injectBridgeCode();
this.processMessageQueue();
} else {
common_vendor.index.__f__("log", "at pages/index/index.vue:574", "页面开始加载,设置超时检测");
this.setupLoadingTimeout();
}
},
// 处理错误
handleError(event) {
common_vendor.index.__f__("error", "at pages/index/index.vue:581", "WebView错误:", event.detail);
this.error = "页面加载失败,请检查网络连接";
this.loading = false;
clearTimeout(this.loadingTimer);
},
// 重新加载页面
reloadPage() {
this.error = "";
this.loading = true;
this.setupLoadingTimeout();
const webview = this.$refs.webview;
if (webview) {
webview.reload();
}
},
// 切换到备用地址
switchToFallback() {
this.currentUrl = this.config.webConfig.fallbackUrl;
this.reloadPage();
},
// 清除超时
clearTimeout() {
common_vendor.index.__f__("log", "at pages/index/index.vue:607", "手动清除超时");
if (this.loadingTimer) {
clearTimeout(this.loadingTimer);
this.loadingTimer = null;
}
this.error = "";
this.loading = false;
common_vendor.index.__f__("log", "at pages/index/index.vue:614", "超时已清除");
},
// 清理资源
cleanup() {
if (this.loadingTimer) {
clearTimeout(this.loadingTimer);
}
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: $data.currentUrl,
b: common_vendor.o((...args) => $options.handleMessage && $options.handleMessage(...args)),
c: common_vendor.o((...args) => $options.handleError && $options.handleError(...args)),
d: common_vendor.o((...args) => $options.handleLoading && $options.handleLoading(...args)),
e: $data.loading
}, $data.loading ? {} : {}, {
f: $data.error
}, $data.error ? {
g: common_vendor.t($data.error),
h: common_vendor.o((...args) => $options.reloadPage && $options.reloadPage(...args)),
i: common_vendor.o((...args) => $options.switchToFallback && $options.switchToFallback(...args)),
j: common_vendor.o((...args) => $options.clearTimeout && $options.clearTimeout(...args))
} : {}, {
k: $data.config.appConfig.debug
}, $data.config.appConfig.debug ? {
l: common_vendor.t($data.currentUrl),
m: common_vendor.t($data.loading ? "加载中" : "已加载")
} : {});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map

View File

@@ -0,0 +1,5 @@
{
"navigationBarTitleText": "存客宝",
"navigationStyle": "custom",
"usingComponents": {}
}

View File

@@ -0,0 +1 @@
<view class="container"><web-view src="{{a}}" class="webview" ref="webview" bindmessage="{{b}}" binderror="{{c}}" bindloading="{{d}}"></web-view><view wx:if="{{e}}" class="loading-container"><view class="loading-spinner"></view><text class="loading-text">加载中...</text></view><view wx:if="{{f}}" class="error-container"><text class="error-text">{{g}}</text><button bindtap="{{h}}" class="reload-btn">重新加载</button><button bindtap="{{i}}" class="fallback-btn">使用备用地址</button><button bindtap="{{j}}" class="clear-btn">清除超时</button></view><view wx:if="{{k}}" class="debug-info"><text>当前URL: {{l}}</text><text>加载状态: {{m}}</text></view></view>

View File

@@ -0,0 +1,105 @@
.container {
width: 100%;
height: 100vh;
position: relative;
background-color: #000;
overflow: hidden;
}
.webview {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 1;
}
.loading-container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
display: flex;
flex-direction: column;
align-items: center;
background-color: rgba(255, 255, 255, 0.95);
padding: 30px;
border-radius: 15px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
.loading-spinner {
width: 50px;
height: 50px;
border: 4px solid #f3f3f3;
border-top: 4px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 15px;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.loading-text {
font-size: 16px;
color: #333;
font-weight: 500;
}
.error-container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
display: flex;
flex-direction: column;
align-items: center;
background-color: rgba(255, 255, 255, 0.95);
padding: 30px;
border-radius: 15px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
min-width: 280px;
}
.error-text {
font-size: 16px;
color: #e74c3c;
margin-bottom: 20px;
text-align: center;
line-height: 1.5;
}
.reload-btn,
.fallback-btn,
.clear-btn {
background-color: #3498db;
color: white;
border: none;
padding: 12px 24px;
border-radius: 8px;
font-size: 14px;
margin: 5px;
min-width: 120px;
}
.fallback-btn {
background-color: #95a5a6;
}
.clear-btn {
background-color: #e74c3c;
}
.debug-info {
position: absolute;
top: 10px;
right: 10px;
z-index: 3;
background-color: rgba(0, 0, 0, 0.7);
color: white;
padding: 10px;
border-radius: 5px;
font-size: 12px;
display: flex;
flex-direction: column;
}

View File

@@ -0,0 +1,29 @@
{
"description": "项目配置文件。",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"urlCheck": false,
"es6": true,
"postcss": false,
"minified": false,
"newFeature": true,
"bigPackageSizeSupport": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
}
},
"compileType": "miniprogram",
"libVersion": "3.8.6",
"appid": "touristappid",
"projectname": "存客宝",
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}

View File

@@ -0,0 +1,7 @@
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "存客宝",
"setting": {
"compileHotReLoad": true
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB