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