93 lines
3.0 KiB
JavaScript
93 lines
3.0 KiB
JavaScript
import { ref, openBlock, createElementBlock, createElementVNode, normalizeStyle, unref } from "vue";
|
|
function formatAppLog(type, filename, ...args) {
|
|
if (uni.__log__) {
|
|
uni.__log__(type, filename, ...args);
|
|
} else {
|
|
console[type].apply(console, [...args, filename]);
|
|
}
|
|
}
|
|
const sendWebWiew = (refValue, paramValue, callName = "onReceive") => {
|
|
if (!refValue) {
|
|
formatAppLog("error", "at utils/communicate/index.js:3", "evalJs: The reference to the webview is not provided or is null.");
|
|
return;
|
|
}
|
|
if (typeof refValue.evalJs !== "function") {
|
|
formatAppLog("error", "at utils/communicate/index.js:8", "evalJs: The evalJs method is not available on the provided reference.");
|
|
return;
|
|
}
|
|
try {
|
|
const jsonString = JSON.stringify(paramValue);
|
|
const jsCode = `window.${callName}(${jsonString})`;
|
|
refValue.evalJs(jsCode);
|
|
} catch (error) {
|
|
formatAppLog("error", "at utils/communicate/index.js:18", "evalJs: An error occurred while trying to stringify the parameter value or while invoking evalJs.", error);
|
|
}
|
|
};
|
|
const receiveWebView = (e) => {
|
|
return e.detail.data[0];
|
|
};
|
|
const _style_0 = { "content": { "": { "display": "flex", "flex": 1 } } };
|
|
const _export_sfc = (sfc, props) => {
|
|
const target = sfc.__vccOpts || sfc;
|
|
for (const [key, val] of props) {
|
|
target[key] = val;
|
|
}
|
|
return target;
|
|
};
|
|
const _sfc_main = {
|
|
__name: "index",
|
|
setup(__props) {
|
|
const webViewRef = ref(null);
|
|
const systemInfo = uni.getSystemInfoSync();
|
|
const webLoad = (e) => {
|
|
const m = receiveWebView(e);
|
|
switch (m.action) {
|
|
case "load-complete": {
|
|
const systemInfo2 = uni.getSystemInfoSync();
|
|
uni.getLocation({
|
|
type: "gcj02",
|
|
geocode: false,
|
|
isHighAccuracy: false,
|
|
success: async (res) => {
|
|
sendWebWiew(webViewRef.value, { ...res, systemInfo: systemInfo2 });
|
|
},
|
|
fail: (e2) => {
|
|
formatAppLog("log", "at pages/index/index.nvue:27", e2);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return openBlock(), createElementBlock("scroll-view", {
|
|
scrollY: true,
|
|
showScrollbar: true,
|
|
enableBackToTop: true,
|
|
bubble: "true",
|
|
style: { flexDirection: "column" }
|
|
}, [
|
|
createElementVNode("div", { class: "content" }, [
|
|
createElementVNode(
|
|
"u-web-view",
|
|
{
|
|
class: "webview",
|
|
"on:onPostMessage": webLoad,
|
|
style: normalizeStyle({ height: `${unref(systemInfo).windowHeight}px`, width: `${unref(systemInfo).windowWidth}` }),
|
|
ref_key: "webViewRef",
|
|
ref: webViewRef,
|
|
src: "http://192.168.88.35:8081/"
|
|
},
|
|
null,
|
|
36
|
|
/* STYLE, NEED_HYDRATION */
|
|
)
|
|
])
|
|
]);
|
|
};
|
|
}
|
|
};
|
|
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["styles", [_style_0]], ["__file", "D:/WebstormProjects/oa-base/pages/index/index.nvue"]]);
|
|
export {
|
|
index as default
|
|
};
|