feat: add avatar payments and finance management
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
export function buildH5Url(base, session) {
|
||||
const url = new URL(base)
|
||||
if (session.token) url.searchParams.set('token', session.token)
|
||||
if (session.userId) url.searchParams.set('userId', session.userId)
|
||||
if (session.nickname) url.searchParams.set('nickname', session.nickname)
|
||||
if (session.avatarUrl) url.searchParams.set('avatar', session.avatarUrl)
|
||||
url.searchParams.set('ts', String(Date.now()))
|
||||
return url.toString()
|
||||
}
|
||||
|
||||
export function postToH5(webviewRef, message) {
|
||||
if (!webviewRef) return false
|
||||
const js = `window.__uniBridgeHandle__&&window.__uniBridgeHandle__(${JSON.stringify(message)})`
|
||||
try {
|
||||
if (typeof webviewRef.evalJS === 'function') {
|
||||
webviewRef.evalJS(js)
|
||||
return true
|
||||
}
|
||||
// #ifdef APP-PLUS
|
||||
const child = plus.webview.currentWebview().children()[0]
|
||||
if (child) { child.evalJS(js); return true }
|
||||
// #endif
|
||||
} catch (error) {
|
||||
console.error('[bridge] postToH5 failed', error)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export function parseH5Message(event) {
|
||||
const items = event?.detail?.data
|
||||
if (Array.isArray(items) && items.length) return items[items.length - 1]
|
||||
return event?.detail || null
|
||||
}
|
||||
Reference in New Issue
Block a user