feat: 参数的拼接

This commit is contained in:
2026-04-06 13:58:06 +08:00
parent 1f75a7eab8
commit 8884529b91

View File

@@ -6,9 +6,10 @@
<script setup>
import { ref, onMounted, onUnmounted } from "vue";
import { navigateToNewPage, saveImageToAlbum, chooseAndUploadImage } from "./bridge.js";
import { navigateToNewPage, saveImageToAlbum } from "./bridge.js";
const webviewUrl = ref("");
const originalWebviewUrl = ref("");
onUnmounted(() => {
uni.$off('UPLOAD_RESULT')
@@ -25,6 +26,8 @@ onMounted(() => {
// 对URL进行解码因为传递时可能被编码了
const decoded = decodeURIComponent(options.url);
webviewUrl.value = decoded;
originalWebviewUrl.value = decoded;
console.log("WebView URL:", decoded);
}
chooseAndUpload();
@@ -33,18 +36,9 @@ onMounted(() => {
const chooseAndUpload = () => {
uni.$on('UPLOAD_RESULT', (imageUrl) => {
console.log('收到图片地址:', imageUrl)
const webview = getCurrentPages()
.slice(-1)[0]
.selectComponent('#webview')
if (webview) {
webview.evalJS(
`window.onUploadResult && window.onUploadResult("${imageUrl}")`
)
} else {
console.error('webview 未找到')
}
const resultUrl = originalWebviewUrl.value + '&imageUrl=' + encodeURIComponent(imageUrl);
console.log('新的URL:', resultUrl)
webviewUrl.value = resultUrl;
})
}