Newer
Older
Productization_H5_IOS / template / Module / webte.html
@zhangfeng zhangfeng on 8 Aug 2023 2 KB commit first
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>Document</title>
                <script>
                    function startLocation1() {
                        window.test1 = function(value) {
                            //这里是回调的数据,也就是出参
                        }
                        var obj = {
                            callId:"test1",
                            data: {
                                type: "task1",
                                time: 3,
                                needGeo:true
                            }
                        }
                        window.webkit.messageHandlers.getLocation.postMessage(obj);
                    }
                    
                    function startLocation2() {
                        window.test2 = function(value) {
                            window.webkit.messageHandlers.getIt.postMessage(value);
                        }
                        var obj = {
                            callId:"test2",
                            data: {
                                type: "task2",
                                time: 3,
                                needGeo:true}
                        }
                        window.webkit.messageHandlers.getLocation.postMessage(obj);
                    }
                    
                    function stopLocation1() {
                        window.test3 = function(value) {
                            window.webkit.messageHandlers.getIt.postMessage(value);
                        }
                        var obj = {
                            callId:"test3",
                            data: {
                                type: "task1",
                            }
                        }
                        window.webkit.messageHandlers.stopLocation.postMessage(obj);
                    }
                    
                    function stopLocation2() {
                        window.test4 = function(value) {
                            window.webkit.messageHandlers.getIt.postMessage(value);
                        }
                        var obj = {
                            callId:"test4",
                            data: {
                                type: "task2",
                            }
                        }
                        window.webkit.messageHandlers.stopLocation.postMessage(obj);
                    }
                </script>
            </head>
    <body>
        <button onclick="startLocation1()">开启定位1</button>
        <button onclick="startLocation2()">开启定位2</button>
        <button onclick="stopLocation1()">关闭定位1</button>
        <button onclick="stopLocation2()">关闭定位2</button>
    </body>
</html>