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 _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) { target[key] = val; } return target; }; var wv; const _sfc_main$1 = { data() { return { title: "sanfan", // url: 'http://139.9.102.170:10012/#/', url: "http://121.37.194.75:20011/#/", src: "", wv: null, canBack: false, top: 0, //webview 头部高度 height: 0, //webview 高度 kbHeight: 0 //键盘高度 }; }, onBackPress() { if (wv && this.canBack) { wv.back(); return true; } return false; }, onReady() { var self = this; var currentWebview = this.$scope.$getAppWebview(); setTimeout(function() { wv = currentWebview.children()[0]; wv.addEventListener( "progressChanged", function(e) { wv.canBack(function(e2) { self.canBack = e2.canBack; }); }, false ); }, 500); }, onLoad() { uni.getSystemInfo({ //成功获取的回调函数,返回值为系统信息 success: (sysinfo) => { this.height = sysinfo.windowHeight; }, complete: () => { } }); let info = uni.getSystemInfoSync(); this.top = info.statusBarHeight; var currentWebview = this.$scope.$getAppWebview(); setTimeout(() => { this.wv = currentWebview.children()[0]; this.wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px top: this.top, //此处是距离顶部的高度,应该是你页面的头部 // bottom: 0, //防止输入框被软键盘遮挡 height: this.height - this.top, //webview的高度 scalable: false //webview的页面是否可以缩放,双指放大缩小 }); }, 1e3); uni.onKeyboardHeightChange((obj) => { let _sysInfo = uni.getSystemInfoSync(); let _heightDiff = _sysInfo.screenHeight - _sysInfo.windowHeight; let _diff = obj.height - _heightDiff; this.kbHeight = (_diff > 0 ? _diff : 0) - 2; this.wv.setStyle({ top: this.top, // webview的高度动态修改为减去键盘高度后的 height: this.height - this.kbHeight, // bottom: 0, scalable: false }); }); uni.onWindowResize((res) => { if (res.size.windowHeight < this.height) { setTimeout(() => { this.wv.setStyle({ top: this.top, // webview的高度动态修改为减去键盘高度后的 height: this.height - this.kbHeight, // bottom: 0, scalable: false }); }, 50); } else { setTimeout(() => { this.wv.setStyle({ top: this.top, // 这里可以根据自己情况微调 height: this.height - this.top, bottom: 0 }); }, 50); } }); uni.$on("connectStatusChange", (connectStatus) => { if (connectStatus) { jpushModule.getRegistrationID((result) => { formatAppLog("log", "at pages/index/index.vue:138", result, "注册ID....."); this.wv.evalJS(`getVueMessage(${JSON.stringify(result.registerID)})`); }); } }); }, onUnload() { uni.$off("connectStatusChange"); }, methods: { messageData(e) { const data = e.detail.data; if (data[0].type == "file") { let url = data[0].url; uni.downloadFile({ url, // 文件的下载链接 success: function(res) { if (res.statusCode === 200) { uni.openDocument({ filePath: res.tempFilePath, success: function(res2) { }, fail: function(error) { } }); } }, fail: function(error) { } }); } else if (data[0].type == "scanCode") { uni.scanCode({ success: (res) => { this.wv.evalJS(`getVueMessage(${JSON.stringify(res.result)} , ${data[0].scanType})`); } }); } } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return vue.openBlock(), vue.createElementBlock("view", { class: "content" }, [ vue.createElementVNode("view", { class: "status_bar" }, [ vue.createCommentVNode(" 这里是状态栏 ") ]), vue.createElementVNode("web-view", { src: $data.url, fullscreen: false, onMessage: _cache[0] || (_cache[0] = (...args) => $options.messageData && $options.messageData(...args)) }, null, 40, ["src"]) ]); } const PagesIndexIndex = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__file", "D:/uni-fans-mobile/pages/index/index.vue"]]); __definePage("pages/index/index", PagesIndexIndex); const _sfc_main = { onLaunch: function() { formatAppLog("log", "at App.vue:4", "onLaunch"); }, onShow: function() { formatAppLog("log", "at App.vue:7", "App Show"); }, onHide: function() { formatAppLog("log", "at App.vue:10", "App Hide"); } }; const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "D:/uni-fans-mobile/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);