zoukankan      html  css  js  c++  java
  • 微信接口测试

    <!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>
  • 相关阅读:
    【大话设计模式】——浅谈设计模式基础
    mongodb入门安装
    Unity3D研究之多语言用中文做KEY
    java7新特性之Try-with-resources (TWR)
    ORACLE取周、月、季、年的開始时间和结束时间
    topas命令详解
    topas解析(AIX)
    top(topas),vmstat,iostat在linux和AIX操作系统下显示情况
    怎么检查网站的死链接呢?
    网站死链接检测查询工具
  • 原文地址:https://www.cnblogs.com/amylis_chen/p/7528336.html
Copyright © 2011-2022 走看看