test4.html
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!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>