test4.html 1.5 KB
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WebView Communication</title>
</head>
<body>
<h2>接口测试4</h2>

<div id="resp"></div>
<button onclick="clearResp()">清除响应数据</button>
<br>
<br>
<button onclick="compressImage()">测试图片压缩</button>
<br>
<br>
<button onclick="upload()">测试文件上传</button>
<br>
<br>
<a href="/test/test.html">跳转测试1</a>


</body>
<script>

    // 清空响应数据
    function clearResp() {
        document.getElementById('resp').innerHTML = '';
    }

    function xeJsBridgeCallback(message) {
        document.getElementById('resp').innerHTML = '<p><strong>响应:</strong> ' + message + '</p>';
    }

    function compressImage() {
        let params = {
            timestamp: 1,
            unique: '123',
            cmd: 'compressImage',
            params: {
                url: '/data/user/0/cn.banxe.bxe/cache/1757649757566_1000019639.jpg',
                quality: 50,
                compressedWidth: 800,
                compressedHeight: 600,
            }
        };
        xeJsBridge.postMessage(JSON.stringify(params));
    }

    function upload() {
        let params = {
            timestamp: 1,
            unique: '123',
            cmd: 'uploadFile',
            params: {
                tempFilePath: '/data/user/0/cn.banxe.bxe/cache/1758248263516_test.csv',
            }
        };
        xeJsBridge.postMessage(JSON.stringify(params));
    }


</script>
</html>