• 微信接口测试


    <!docType html>
    <html>
    <head>
    
     <meta http-equiv="content-type" content="text/html; charset=utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
    
    <title>微信接口测试</title>
    
    <script>
        function sendMessage(){
            WeixinJSBridge.on('menu:share:appmessage', function(argv){
                WeixinJSBridge.invoke('sendAppMessage',{
     
                "appid":"",                                     //appid 设置空就好了。
                "img_url":"",                                    //分享时所带的图片路径
                "img_width":"120",                                 //图片宽度
                "img_height":"120",                             //图片高度
                "link":"http://www.gbin1.com",                     //分享附带链接地址
                "desc":"极客标签--http://www.gbin1.com",             //分享内容介绍
                "title":"发现 极客标签 - 做最棒的极客知识分享平台"
                }, function(res){/*** 回调函数,最好设置为空 ***/
     
                });
            });
            
            WeixinJSBridge.on('menu:share:timeline', function(argv){
     
                WeixinJSBridge.invoke('shareTimeline',{
     
                "appid":"",                                     //appid 设置空就好了。
                "img_url":"",                                    //分享时所带的图片路径
                "img_width":"120",                                 //图片宽度
                "img_height":"120",                             //图片高度
                "link":"http://www.gbin1.com",                     //分享附带链接地址
                "desc":"极客标签--http://www.gbin1.com",             //分享内容介绍
                "title":"发现 极客标签 - 做最棒的极客知识分享平台"
                }, function(res){/*** 回调函数,最好设置为空 ***/
                });
     
            });
    
            
            alert("调用成功!现在可以通过右上角按钮分享给朋友或者朋友圈!");
            
        }
        
        function hideMenu(){
            WeixinJSBridge.call('hideOptionMenu');
        }
        
        function showMenu(){
            WeixinJSBridge.call('showOptionMenu');  
        }
        
        function hideTool(){
            WeixinJSBridge.call('hideToolbar');
        }
        
        function showTool(){
            WeixinJSBridge.call('showToolbar');
        }
        
    
        if(document.addEventListener){
            document.addEventListener('WeixinJSBridgeReady', sendMessage, false); 
        }else if(document.attachEvent){
            document.attachEvent('WeixinJSBridgeReady' , sendMessage);    
            document.attachEvent('onWeixinJSBridgeReady' , sendMessage); 
        }
        
        //判断网页是否在微信中被调用
        var ua = navigator.userAgent.toLowerCase();
        if(ua.match(/MicroMessenger/i)=="micromessenger") {
         } else {
            alert("调用失败,请用微信扫一扫,扫描下面二维码打开网页!");
        }
        
    
    </script>
    
    </head>
    
    <body>
        <center>
        <h2>分享请点击右上角</h2>
        <button onclick="hideMenu()" style="100px;height:100px;font-size:16px;">隐藏右上角三个点</button> <br /><br />
        <button onclick="showMenu()" style="100px;height:100px;font-size:16px;">显示右上角三个点</button> <br /><br />
        <button onclick="hideTool()" style="100px;height:100px;font-size:16px;">隐藏下面导条</button>      <br /><br />
        <button onclick="showTool()" style="100px;height:100px;font-size:16px;">显示下面导条</button>    <br /><br />
        </center>
    </body>
    
    </html>
  • 相关阅读:
    收集的java面试题
    重载和重写的区别
    java中封装的概念
    java中多态的概念
    vue中的$on,$emit,$once,$off源码实现
    js bind的实现
    对象的深拷贝
    v-for的简单实现
    v-for的显示过滤/排序结果
    ES6的数组方法之Array.from
  • 原文地址:https://www.cnblogs.com/amylis_chen/p/7528336.html
Copyright © 2020-2023  润新知