2024-04-11 06:31:44 +00:00
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 ] ) ;
}
}
2024-04-12 08:30:22 +00:00
const env = "dev" ;
const configs = {
dev : {
apiBaseUrl : "https://warehouse.szjixun.cn/oa_backend" ,
h5Url : "http://192.168.88.35:8080/"
} ,
test : {
apiBaseUrl : "https://warehouse.szjixun.cn/oa_backend" ,
h5Url : "http://172.16.100.93:8041/#/"
} ,
prod : {
apiBaseUrl : "https://oa.szjixun.cn/api" ,
h5Url : "https://oa.szjixun.cn/#/"
}
} ;
const config = configs [ env ] ;
2024-04-11 06:31:44 +00:00
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 ) => {
2024-04-12 08:30:22 +00:00
formatAppLog ( "log" , "at pages/index/index.nvue:38" , e2 ) ;
2024-04-11 06:31:44 +00:00
}
} ) ;
}
}
} ;
return ( _ctx , _cache ) => {
return openBlock ( ) , createElementBlock ( "scroll-view" , {
scrollY : true ,
showScrollbar : true ,
enableBackToTop : true ,
bubble : "true" ,
style : { flexDirection : "column" }
} , [
createElementVNode ( "div" , { class : "content" } , [
2024-04-12 08:30:22 +00:00
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 : unref ( config ) . h5Url
} , null , 44 , [ "src" ] )
2024-04-11 06:31:44 +00:00
] )
] ) ;
} ;
}
} ;
const index = /* @__PURE__ */ _export _sfc ( _sfc _main , [ [ "styles" , [ _style _0 ] ] , [ "__file" , "D:/WebstormProjects/oa-base/pages/index/index.nvue" ] ] ) ;
export {
index as default
} ;