mo-h5-bridge 0.0.39 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mo-h5-bridge.js +98 -107
- package/dist/mo-h5-bridge.js.map +1 -1
- package/dist-doc/assets/{index-XzCQKQlN.js → index--sndaAMN.js} +1 -1
- package/dist-doc/assets/{index-lNSi5YYg.js → index-B6KGmQXg.js} +1 -1
- package/dist-doc/assets/{index-ExIo_WmK.js → index-B87tz7kB.js} +1 -1
- package/dist-doc/assets/{index-Ao_QNIqd.js → index-B9p8N7EV.js} +1 -1
- package/dist-doc/assets/{index-D4fDFaRw.js → index-BIuKgWQ5.js} +1 -1
- package/dist-doc/assets/{index-DJmN5ZjH.js → index-BOO9dqVY.js} +1 -1
- package/dist-doc/assets/{index-CahgnCeI.js → index-BOzsxVGZ.js} +1 -1
- package/dist-doc/assets/{index-D7Nzvbcr.js → index-CD1hsI54.js} +3 -3
- package/dist-doc/assets/{index-Dy2rzoCt.js → index-DDKjIpyS.js} +1 -1
- package/dist-doc/assets/{index-Lve4tkqR.js → index-DljxjBlk.js} +1 -1
- package/dist-doc/assets/{index-Bj05_9gR.js → index-LeRjrSgb.js} +1 -1
- package/dist-doc/assets/{index-B45wvUvd.js → index-VzYTPSBI.js} +1 -1
- package/dist-doc/assets/{index-Bs890x46.js → index-YCVSxOd9.js} +1 -1
- package/dist-doc/assets/{index-D0etwguE.js → index-uP88-_4j.js} +1 -1
- package/dist-doc/assets/{index-CmepzL9v.js → index-x6M37aYS.js} +1 -1
- package/dist-doc/assets/main-z7OjBsw6.js +1 -0
- package/package.json +1 -1
- package/dist-doc/assets/main-BVsgWIXK.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as h,B as r,C as d}from"./main-
|
|
1
|
+
import{i as h,B as r,C as d}from"./main-z7OjBsw6.js";import{d as m,r as j,o as l,c,b as s,e as n,w as t,u as _,a}from"./index-CD1hsI54.js";/* empty css */const g=m({__name:"index.md.Virtual6b39553a",setup(o){h();async function e(){r.postMessage({type:"changeCommonData",data:{aa:111}})}return(p,E)=>{const i=j("m-button");return l(),c("div",null,[s(" 在console中查看 "),n(i,{onClick:e},{default:t(()=>[s("检验")]),_:1})])}}}),u={class:"marked-body"},C=a("h2",{id:"postmessage"},"postMessage",-1),A=a("p",null,"向小程序发送消息",-1),B=a("h3",{id:"使用说明"},"使用说明",-1),f=a("ul",null,[a("li",null,"以微信小程序的api为准")],-1),k=a("pre",{class:"language-xml"},[a("code",{class:"hljs"},[a("span",{class:"hljs-tag"},[s("<"),a("span",{class:"hljs-name"},"template"),s(">")]),s(`
|
|
2
2
|
`),a("span",{class:"hljs-tag"},[s("<"),a("span",{class:"hljs-name"},"div"),s(">")]),s(`
|
|
3
3
|
在console中查看
|
|
4
4
|
`),a("span",{class:"hljs-tag"},[s("<"),a("span",{class:"hljs-name"},"m-button"),s(" @"),a("span",{class:"hljs-attr"},"click"),s("="),a("span",{class:"hljs-string"},'"handleCheck"'),s(">")]),s("检验"),a("span",{class:"hljs-tag"},[s("</"),a("span",{class:"hljs-name"},"m-button"),s(">")]),s(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as p,B as h,C as d}from"./main-
|
|
1
|
+
import{i as p,B as h,C as d}from"./main-z7OjBsw6.js";import{d as m,r as j,o as c,c as o,b as s,e,w as l,u as _,a}from"./index-CD1hsI54.js";/* empty css */const g=m({__name:"index.md.Virtual341275b0",setup(i){p();async function t(){let n=await h.getArea();console.log(n)}return(n,k)=>{const r=j("m-button");return c(),o("div",null,[s(" 在console中查看 "),e(r,{onClick:t},{default:l(()=>[s("检验")]),_:1})])}}}),u={class:"marked-body"},A=a("h2",{id:"getarea"},"getArea",-1),C=a("p",null,"获取区域",-1),B=a("h3",{id:"使用说明"},"使用说明",-1),f=a("pre",{class:"language-xml"},[a("code",{class:"hljs"},[a("span",{class:"hljs-tag"},[s("<"),a("span",{class:"hljs-name"},"template"),s(">")]),s(`
|
|
2
2
|
`),a("span",{class:"hljs-tag"},[s("<"),a("span",{class:"hljs-name"},"div"),s(">")]),s(`
|
|
3
3
|
在console中查看
|
|
4
4
|
`),a("span",{class:"hljs-tag"},[s("<"),a("span",{class:"hljs-name"},"m-button"),s(" @"),a("span",{class:"hljs-attr"},"click"),s("="),a("span",{class:"hljs-string"},'"handleCheck"'),s(">")]),s("检验"),a("span",{class:"hljs-tag"},[s("</"),a("span",{class:"hljs-name"},"m-button"),s(">")]),s(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as o,B as r,C as h}from"./main-
|
|
1
|
+
import{i as o,B as r,C as h}from"./main-z7OjBsw6.js";import{d as A,r as m,o as e,c,b as s,e as n,w as t,u as d,a}from"./index-CD1hsI54.js";/* empty css */const B=A({__name:"index.md.Virtual9e90aa7a",setup(i){o();async function l(){r.updateTimelineShareData({title:"大学生领券享8折专属特惠",link:"大学生领券享8折专属特惠",imgUrl:"https://mobje-pro-04-1309183960.cos.ap-beijing.myqcloud.com/share.jpg"})}return(p,F)=>{const E=m("m-button");return e(),c("div",null,[s(" 在console中查看 "),n(E,{onClick:l},{default:t(()=>[s("检验")]),_:1})])}}}),j={class:"marked-body"},g=a("h2",{id:"updatetimelinesharedata"},"updateTimelineShareData",-1),u=a("p",null,"自定义“分享到朋友圈”及“分享到QQ空间”按钮的分享内容",-1),_=a("h3",{id:"使用说明"},"使用说明",-1),C=a("pre",{class:"language-xml"},[a("code",{class:"hljs"},[a("span",{class:"hljs-tag"},[s("<"),a("span",{class:"hljs-name"},"template"),s(">")]),s(`
|
|
2
2
|
`),a("span",{class:"hljs-tag"},[s("<"),a("span",{class:"hljs-name"},"div"),s(">")]),s(`
|
|
3
3
|
在console中查看
|
|
4
4
|
`),a("span",{class:"hljs-tag"},[s("<"),a("span",{class:"hljs-name"},"m-button"),s(" @"),a("span",{class:"hljs-attr"},"click"),s("="),a("span",{class:"hljs-string"},'"handleCheck"'),s(">")]),s("检验"),a("span",{class:"hljs-tag"},[s("</"),a("span",{class:"hljs-name"},"m-button"),s(">")]),s(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as p,B as h,C as d}from"./main-
|
|
1
|
+
import{i as p,B as h,C as d}from"./main-z7OjBsw6.js";import{d as m,r as j,o as c,c as o,b as s,e,w as l,u as _,a}from"./index-CD1hsI54.js";/* empty css */const g=m({__name:"index.md.Virtual831be197",setup(i){p();async function t(){let n=await h.getAreas();console.log(n)}return(n,k)=>{const r=j("m-button");return c(),o("div",null,[s(" 在console中查看 "),e(r,{onClick:t},{default:l(()=>[s("检验")]),_:1})])}}}),u={class:"marked-body"},A=a("h2",{id:"getareas"},"getAreas",-1),C=a("p",null,"获取库存页面的区域",-1),B=a("h3",{id:"使用说明"},"使用说明",-1),f=a("pre",{class:"language-xml"},[a("code",{class:"hljs"},[a("span",{class:"hljs-tag"},[s("<"),a("span",{class:"hljs-name"},"template"),s(">")]),s(`
|
|
2
2
|
`),a("span",{class:"hljs-tag"},[s("<"),a("span",{class:"hljs-name"},"div"),s(">")]),s(`
|
|
3
3
|
在console中查看
|
|
4
4
|
`),a("span",{class:"hljs-tag"},[s("<"),a("span",{class:"hljs-name"},"m-button"),s(" @"),a("span",{class:"hljs-attr"},"click"),s("="),a("span",{class:"hljs-string"},'"handleCheck"'),s(">")]),s("检验"),a("span",{class:"hljs-tag"},[s("</"),a("span",{class:"hljs-name"},"m-button"),s(">")]),s(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as M,f as P,o as k,c as S,a as o,g as f,h,v as m,t as T,p as b,i as C}from"./index-CD1hsI54.js";/* empty css */const p=n=>(b("data-v-43edb7f1"),n=n(),C(),n),x={class:"doc-preview"},L={class:"component"},A={class:"fixed-tools"},I=p(()=>o("svg",{fill:"none",height:"20",stroke:"currentColor","stroke-width":"2",viewBox:"0 0 24 24",width:"20",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2m-6 9 2 2 4-4","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),D=[I],W=p(()=>o("svg",{height:"20",viewBox:"0 0 512 512",width:"20",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M160 368L32 256l128-112M352 368l128-112-128-112M304 96l-96 320",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"46"})],-1)),E=[W],O={class:"code"},V={class:"control-tools"},$=p(()=>o("svg",{fill:"none",height:"20",stroke:"currentColor","stroke-width":"2",viewBox:"0 0 24 24",width:"20",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2m-6 9 2 2 4-4","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),J=[$],j=p(()=>o("svg",{height:"20",viewBox:"0 0 512 512",width:"20",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M160 368L32 256l128-112M352 368l128-112-128-112M304 96l-96 320",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"46"})],-1)),N=[j],R=M({__name:"vue",props:{code:{}},setup(n){const e=n,i=P(!1),t=()=>{try{navigator.clipboard.writeText(decodeURIComponent(e.code))}catch(c){console.log(c)}},a=()=>{i.value=!i.value};return(c,u)=>(k(),S("div",x,[o("div",L,[f(c.$slots,"default",{},void 0,!0)]),h(o("div",A,[o("div",{class:"tools"},[o("div",{class:"item",onClick:t},D),o("div",{class:"item",onClick:a},E)])],512),[[m,i.value]]),h(o("div",O,[f(c.$slots,"code",{},void 0,!0)],512),[[m,i.value]]),o("div",V,[o("div",{class:"text",onClick:a},T(i.value?"隐藏代码":"展开代码"),1),o("div",{class:"tools"},[o("div",{class:"item",onClick:t},J),o("div",{class:"item",onClick:a},N)])])]))}}),U=(n,e)=>{const i=n.__vccOpts||n;for(const[t,a]of e)i[t]=a;return i},_e=U(R,[["__scopeId","data-v-43edb7f1"]]);function y(n){return new Promise(e=>{const i=document.createElement("script");i.type="text/javascript",i.src=n,i.onload=function(){e()},document.head.appendChild(i)})}const d=navigator.userAgent,B=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(d),q=/Windows|Macintosh|Linux/i.test(d)&&!B,l={WeChatMini:"WeChatMini",AlipayMini:"AlipayMini",Android:"Android",Ios:"Ios",Mobile:"Mobile",Pc:"Pc"},w={["is"+l.WeChatMini]:/miniProgram/i.test(d),["is"+l.AlipayMini]:/AlipayClient.*miniProgram/i.test(d),["is"+l.Android]:/Android/i.test(d),["is"+l.Ios]:/iPhone|iPad|iPod/i.test(d),["is"+l.Mobile]:B,["is"+l.Pc]:q},H="https://appx/web-view.min.js",F={refreshCar:void 0};class G{constructor(){this.map=new Map,Object.keys(F).forEach(e=>{this.map.set(e,new Set)})}add(e,i){return this.map.has(e)||this.map.set(e,new Set),this.map.get(e).add(i),this}delete(e,i){if(!this.map.has(e))return!1;const t=this.map.get(e),a=t.delete(i);return t.size===0&&this.map.delete(e),a}has(e,i){return this.map.has(e)&&this.map.get(e).has(i)}get(e){return this.map.get(e)||new Set}deleteKey(e){return this.map.delete(e)}hasKey(e){return this.map.has(e)}keys(){return this.map.keys()}values(){return this.map.values()}entries(){return this.map.entries()}clear(){this.map.clear()}forEach(e){this.map.forEach((i,t)=>{e(i,t,this.map)})}}const K=new G;function r(n){return(...e)=>{console.warn(`[Bridge] ${n} called before init`,new Date().toISOString(),"args:",e),console.warn(`[Bridge] ${n} call stack:`,new Error().stack)}}const s={navigateTo:r("navigateTo"),navigateBack:r("navigateBack"),switchTab:r("switchTab"),getLocation:r("getLocation"),openLocation:r("openLocation"),postMessage:r("postMessage"),onMessage:r("onMessage"),getToken:r("getToken"),gotoOrderDetail:r("gotoOrderDetail"),getAreas:r("getAreas"),updateAppMessageShareData:r("updateAppMessageShareData"),updateTimelineShareData:r("updateTimelineShareData"),getArea:r("getArea")};async function z(n){return new Promise(e=>{my.postMessage({...n}),e()})}async function Q(n){return new Promise(e=>{my.onMessage=n,e()})}async function X(n){return new Promise((e,i)=>{my.getLocation({...n,success:function(t){e(t)},fail:function(t){i(t)}})})}async function Y(n){return new Promise((e,i)=>{my.openLocation({...n,success:function(t){e(t)},fail:function(t){i(t)}})})}async function Z(n){return new Promise((e,i)=>{my.navigateTo({...n,success:function(t){e(t)},fail:function(t){i(t)}})})}async function ee(n){return new Promise((e,i)=>{my.navigateBack({...n,success:function(t){e(t)},fail:function(t){i(t)}})})}async function te(n){return new Promise((e,i)=>{my.redirectTo({...n,success:function(t){e(t)},fail:function(t){i(t)}})})}function ne(n){return new Promise((e,i)=>{my.switchTab({...n,success:function(t){e(t)},fail:function(t){i(t)}})})}function ie(){s.postMessage=z,s.onMessage=Q,s.getLocation=X,s.openLocation=Y,s.navigateTo=Z,s.navigateBack=ee,s.redirectTo=te,s.switchTab=ne}async function oe(){await y(H),ie()}const se="https://res.wx.qq.com/open/js/jweixin-1.6.0.js";async function ae(n={}){return new Promise((e,i)=>{wx.getLocation({...n,success:function(t){console.log("success",t),e(t)},fail:function(t){console.log("fail",t),i(t)}})})}async function re(n){return new Promise((e,i)=>{wx.openLocation({...n,success:function(t){e(t)},fail:function(t){i(t)}})})}async function ce(n){return new Promise((e,i)=>{wx.miniProgram.postMessage({...n,success:function(t){e(t)},fail:function(t){i(t)}})})}async function le(n){return new Promise((e,i)=>{wx.miniProgram.navigateTo({...n,success:function(t){e(t)},fail:function(t){i(t)}})})}async function de(n){return new Promise((e,i)=>{wx.miniProgram.navigateBack({...n,success:function(t){e(t)},fail:function(t){i(t)}})})}async function ue(n){return new Promise((e,i)=>{wx.miniProgram.switchTab({...n,success:function(t){e(t)},fail:function(t){i(t)}})})}async function ge(n){return new Promise((e,i)=>{wx.miniProgram.redirectTo({...n,success:function(t){e(t)},fail:function(t){i(t)}})})}function v(){console.log("[Bridge] we-chat register start",new Date().toISOString()),s.navigateTo=le,s.navigateBack=de,s.redirectTo=ge,s.switchTab=ue,s.postMessage=ce,s.getLocation=ae,s.openLocation=re,console.log("[Bridge] we-chat register done",new Date().toISOString())}async function we(n){const e=location.href.split("#")[0];return await fetch(`${n.requestUrl}?url=${e}`,{method:"GET"}).then(i=>i.json())}async function pe(n){try{const e=await we(n);console.log("[Bridge] wx.config with:",{appId:e.data.appId,timestamp:e.data.timestamp,nonceStr:e.data.nonceStr,signature:e.data.signature}),wx.config({debug:!1,appId:e.data.appId,timestamp:e.data.timestamp,nonceStr:e.data.nonceStr,signature:e.data.signature,jsApiList:["getLocation","openLocation","startRecord","chooseImage","scanQRCode"]})}catch(e){console.error("[Bridge] setConfig failed:",e)}}async function fe(n){console.log("[Bridge] we-chat init start",new Date().toISOString(),"hasRequestUrl:",!!n.requestUrl),await y(se),console.log("[Bridge] we-chat CDN downloaded",new Date().toISOString()),n.requestUrl?(await pe(n),await new Promise(e=>{let i=!1;const t=()=>{i||(i=!0,clearTimeout(a),v(),e())},a=setTimeout(()=>{console.warn("[Bridge] wx.ready timeout (5s), registering anyway"),t()},5e3);wx.ready(function(){console.log("[Bridge] we-chat wx.ready fired",new Date().toISOString()),t()}),wx.error(function(c){console.error("[Bridge] wx.error:",c),t()})})):(console.log("[Bridge] we-chat register (no config)",new Date().toISOString()),v())}const _=w.isAndroid,he=n=>{window.WebViewJavascriptBridge?n(window.WebViewJavascriptBridge):document.addEventListener("WebViewJavascriptBridgeReady",function(){n(window.WebViewJavascriptBridge)},!1)},me=n=>{if(window.WebViewJavascriptBridge)return n(window.WebViewJavascriptBridge);if(window.WVJBCallbacks)return window.WVJBCallbacks.push(n);window.WVJBCallbacks=[n];const e=document.createElement("iframe");e.style.display="none",e.src="wvjbscheme://__BRIDGE_LOADED__",document.documentElement.appendChild(e),setTimeout(function(){document.documentElement.removeChild(e)},0)};window.setupWebViewJavascriptBridge=_?he:me;_&&window.setupWebViewJavascriptBridge(function(n){n.init(function(e,i){i("JS 返回给原生的消息内容")})});async function ve(){return new Promise(n=>{window.setupWebViewJavascriptBridge(e=>{Object.keys(s).forEach(i=>{s[i]=function(t){return new Promise((a,c)=>{e.callHandler("sendToNative",{type:i,value:t},u=>{console.log("fromNativeParams 1",u);const g=typeof u=="string"?JSON.parse(u):u;console.log("fromNativeParams 2",g),g.type==="success"?(console.log("fromNativeParams 3",g.value),a(g.value)):c(g.value)})})}}),e.registerHandler("receiveFromNative",(i,t)=>{console.log(1111,i);const a=typeof i=="string"?JSON.parse(i):i;console.log(2222,a),K.get(a.type).forEach(c=>{console.log(3333,a.value),c(a.value)}),t()}),n()})})}async function Me(n){try{w.isAlipayMini?await oe():w.isWeChatMini?await fe(n):w.isMobile?await ve():console.warn("[Bridge] unknown env, RUN_ENV:",w)}catch(e){console.error("[Bridge] initBridge failed:",e)}}export{s as B,_e as C,Me as i};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as k,f as C,o as b,c as T,a as o,g as m,h as v,v as y,t as L,p as x,i as A}from"./index-D7Nzvbcr.js";/* empty css */const f=i=>(x("data-v-43edb7f1"),i=i(),A(),i),S={class:"doc-preview"},W={class:"component"},I={class:"fixed-tools"},E=f(()=>o("svg",{fill:"none",height:"20",stroke:"currentColor","stroke-width":"2",viewBox:"0 0 24 24",width:"20",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2m-6 9 2 2 4-4","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),J=[E],V=f(()=>o("svg",{height:"20",viewBox:"0 0 512 512",width:"20",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M160 368L32 256l128-112M352 368l128-112-128-112M304 96l-96 320",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"46"})],-1)),$=[V],j={class:"code"},D={class:"control-tools"},R=f(()=>o("svg",{fill:"none",height:"20",stroke:"currentColor","stroke-width":"2",viewBox:"0 0 24 24",width:"20",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2m-6 9 2 2 4-4","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),O=[R],N=f(()=>o("svg",{height:"20",viewBox:"0 0 512 512",width:"20",xmlns:"http://www.w3.org/2000/svg"},[o("path",{d:"M160 368L32 256l128-112M352 368l128-112-128-112M304 96l-96 320",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"46"})],-1)),H=[N],U=k({__name:"vue",props:{code:{}},setup(i){const e=i,t=C(!1),n=()=>{try{navigator.clipboard.writeText(decodeURIComponent(e.code))}catch(r){console.log(r)}},a=()=>{t.value=!t.value};return(r,d)=>(b(),T("div",S,[o("div",W,[m(r.$slots,"default",{},void 0,!0)]),v(o("div",I,[o("div",{class:"tools"},[o("div",{class:"item",onClick:n},J),o("div",{class:"item",onClick:a},$)])],512),[[y,t.value]]),v(o("div",j,[m(r.$slots,"code",{},void 0,!0)],512),[[y,t.value]]),o("div",D,[o("div",{class:"text",onClick:a},L(t.value?"隐藏代码":"展开代码"),1),o("div",{class:"tools"},[o("div",{class:"item",onClick:n},O),o("div",{class:"item",onClick:a},H)])])]))}}),q=(i,e)=>{const t=i.__vccOpts||i;for(const[n,a]of e)t[n]=a;return t},Be=q(U,[["__scopeId","data-v-43edb7f1"]]);function _(i){return new Promise(e=>{const t=document.createElement("script");t.type="text/javascript",t.src=i,t.onload=function(){e()},document.head.appendChild(t)})}const u=navigator.userAgent,M=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(u),F=/Windows|Macintosh|Linux/i.test(u)&&!M,l={WeChatMini:"WeChatMini",AlipayMini:"AlipayMini",Android:"Android",Ios:"Ios",Mobile:"Mobile",Pc:"Pc"},g={["is"+l.WeChatMini]:/miniProgram/i.test(u),["is"+l.AlipayMini]:/AlipayClient.*miniProgram/i.test(u),["is"+l.Android]:/Android/i.test(u),["is"+l.Ios]:/iPhone|iPad|iPod/i.test(u),["is"+l.Mobile]:M,["is"+l.Pc]:F},G="https://appx/web-view.min.js",K={refreshCar:void 0};class Q{constructor(){this.map=new Map,Object.keys(K).forEach(e=>{this.map.set(e,new Set)})}add(e,t){return this.map.has(e)||this.map.set(e,new Set),this.map.get(e).add(t),this}delete(e,t){if(!this.map.has(e))return!1;const n=this.map.get(e),a=n.delete(t);return n.size===0&&this.map.delete(e),a}has(e,t){return this.map.has(e)&&this.map.get(e).has(t)}get(e){return this.map.get(e)||new Set}deleteKey(e){return this.map.delete(e)}hasKey(e){return this.map.has(e)}keys(){return this.map.keys()}values(){return this.map.values()}entries(){return this.map.entries()}clear(){this.map.clear()}forEach(e){this.map.forEach((t,n)=>{e(t,n,this.map)})}}const z=new Q,h=[];function c(i){return(...e)=>(console.warn(`Bridge:${i} not init`),new Promise((t,n)=>{h.push({name:i,args:e,resolve:t,reject:n})}))}function w(){if(h.length===0)return;h.splice(0).forEach(({name:e,args:t,resolve:n,reject:a})=>{s[e](...t).then(n).catch(a)})}const s={navigateTo:c("navigateTo"),navigateBack:c("navigateBack"),switchTab:c("switchTab"),getLocation:c("getLocation"),openLocation:c("openLocation"),postMessage:c("postMessage"),onMessage:c("onMessage"),getToken:c("getToken"),gotoOrderDetail:c("gotoOrderDetail"),getAreas:c("getAreas"),updateAppMessageShareData:c("updateAppMessageShareData"),updateTimelineShareData:c("updateTimelineShareData"),getArea:c("getArea")};async function X(i){return new Promise(e=>{my.postMessage({...i}),e()})}async function Y(i){return new Promise(e=>{my.onMessage=i,e()})}async function Z(i){return new Promise((e,t)=>{my.getLocation({...i,success:function(n){e(n)},fail:function(n){t(n)}})})}async function ee(i){return new Promise((e,t)=>{my.openLocation({...i,success:function(n){e(n)},fail:function(n){t(n)}})})}async function te(i){return new Promise((e,t)=>{my.navigateTo({...i,success:function(n){e(n)},fail:function(n){t(n)}})})}async function ne(i){return new Promise((e,t)=>{my.navigateBack({...i,success:function(n){e(n)},fail:function(n){t(n)}})})}async function ie(i){return new Promise((e,t)=>{my.redirectTo({...i,success:function(n){e(n)},fail:function(n){t(n)}})})}function oe(i){return new Promise((e,t)=>{my.switchTab({...i,success:function(n){e(n)},fail:function(n){t(n)}})})}function se(){s.postMessage=X,s.onMessage=Y,s.getLocation=Z,s.openLocation=ee,s.navigateTo=te,s.navigateBack=ne,s.redirectTo=ie,s.switchTab=oe,w()}async function ae(){await _(G),se()}const ce="https://res.wx.qq.com/open/js/jweixin-1.6.0.js";async function re(i={}){return new Promise((e,t)=>{wx.getLocation({...i,success:function(n){console.log("success",n),e(n)},fail:function(n){console.log("fail",n),t(n)}})})}async function le(i){return new Promise((e,t)=>{wx.openLocation({...i,success:function(n){e(n)},fail:function(n){t(n)}})})}async function ue(i){return new Promise((e,t)=>{wx.miniProgram.postMessage({...i,success:function(n){e(n)},fail:function(n){t(n)}})})}async function de(i){return new Promise((e,t)=>{wx.miniProgram.navigateTo({...i,success:function(n){e(n)},fail:function(n){t(n)}})})}async function pe(i){return new Promise((e,t)=>{wx.miniProgram.navigateBack({...i,success:function(n){e(n)},fail:function(n){t(n)}})})}async function ge(i){return new Promise((e,t)=>{wx.miniProgram.switchTab({...i,success:function(n){e(n)},fail:function(n){t(n)}})})}async function fe(i){return new Promise((e,t)=>{wx.miniProgram.redirectTo({...i,success:function(n){e(n)},fail:function(n){t(n)}})})}function P(){s.navigateTo=de,s.navigateBack=pe,s.redirectTo=fe,s.switchTab=ge,s.postMessage=ue,s.getLocation=re,s.openLocation=le,w()}async function he(i){const e=location.href.split("#")[0];return await fetch(`${i.requestUrl}?url=${e}`,{method:"GET"}).then(t=>t.json())}function we(i){async function e(){const t=await he(i);console.log({debug:!1,appId:t.data.appId,timestamp:t.data.timestamp,nonceStr:t.data.nonceStr,signature:t.data.signature,jsApiList:["getLocation","openLocation","startRecord","chooseImage","scanQRCode"]}),wx.config({debug:!1,appId:t.data.appId,timestamp:t.data.timestamp,nonceStr:t.data.nonceStr,signature:t.data.signature,jsApiList:["getLocation","openLocation","startRecord","chooseImage","scanQRCode"]})}return e(),Promise.resolve()}async function me(i){await _(ce),i.requestUrl?(await we(i),wx.ready(function(){P()})):P()}const B=g.isAndroid,ve=i=>{window.WebViewJavascriptBridge?i(window.WebViewJavascriptBridge):document.addEventListener("WebViewJavascriptBridgeReady",function(){i(window.WebViewJavascriptBridge)},!1)},ye=i=>{if(window.WebViewJavascriptBridge)return i(window.WebViewJavascriptBridge);if(window.WVJBCallbacks)return window.WVJBCallbacks.push(i);window.WVJBCallbacks=[i];const e=document.createElement("iframe");e.style.display="none",e.src="wvjbscheme://__BRIDGE_LOADED__",document.documentElement.appendChild(e),setTimeout(function(){document.documentElement.removeChild(e)},0)};window.setupWebViewJavascriptBridge=B?ve:ye;B&&window.setupWebViewJavascriptBridge(function(i){i.init(function(e,t){t("JS 返回给原生的消息内容")})});async function Pe(){return new Promise(i=>{window.setupWebViewJavascriptBridge(e=>{Object.keys(s).forEach(t=>{s[t]=function(n){return new Promise((a,r)=>{e.callHandler("sendToNative",{type:t,value:n},d=>{console.log("fromNativeParams 1",d);const p=typeof d=="string"?JSON.parse(d):d;console.log("fromNativeParams 2",p),p.type==="success"?(console.log("fromNativeParams 3",p.value),a(p.value)):r(p.value)})})}}),e.registerHandler("receiveFromNative",(t,n)=>{console.log(1111,t);const a=typeof t=="string"?JSON.parse(t):t;console.log(2222,a),z.get(a.type).forEach(r=>{console.log(3333,a.value),r(a.value)}),n()}),w(),i()})})}async function ke(i){g.isAlipayMini?await ae():g.isWeChatMini?await me(i):g.isMobile&&await Pe()}export{s as B,Be as C,ke as i};
|