频道栏目
首页 > 资讯 > 其他综合 > 正文

微信客户端自带的Js Api:WeixinJSBridge

16-01-15        来源:[db:作者]  
收藏   我要投稿

<script type="text/javascript"> (function(){ var a=document.getElementsByTagName("html")[0]; window.Session={appDomain:a.getAttribute("data-app-domain")||"",staticDomain:a.getAttribute("data-static-domain")||""} })(); window.registNS=function(fullNS,isIgnorSelf){ var reg=/^[_$a-z]+[_$a-z0-9]*/i;var nsArray=fullNS.split("."); var sEval=""; var sNS=""; var n=isIgnorSelf?nsArray.length-1:nsArray.length; for(var i=0;i
  1. <!DOCTYPE html>  
  2. <html>  
  3. <head><title>微信WeixinJSBridge API</title>  
  4. <meta charset=utf-8>  
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">  
  6. <script type="text/javascript">  
  7. (function(){  
  8. var a=document.getElementsByTagName("html")[0];  
  9. window.Session={appDomain:a.getAttribute("data-app-domain")||"",staticDomain:a.getAttribute("data-static-domain")||""}  
  10. })();  
  11.   
  12. window.registNS=function(fullNS,isIgnorSelf){  
  13. var reg=/^[_$a-z]+[_$a-z0-9]*/i;var nsArray=fullNS.split(".");  
  14. var sEval="";  
  15. var sNS="";  
  16. var n=isIgnorSelf?nsArray.length-1:nsArray.length;  
  17. for(var i=0;i<n;i++){  
  18.     if(!reg.test(nsArray[i])){throw new Error("Invalid namespace:"+nsArray[i]+"");  
  19.     return  
  20.     }  
  21.     if(i!=0){sNS+="."}  
  22.     sNS+=nsArray[i];  
  23.     sEval+="if(typeof("+sNS+")=='undefined') "+sNS+"=new Object();  
  24.     else "+sNS+";"  
  25. }  
  26. if(sEval!=""){  
  27. return eval(sEval)  
  28. }  
  29. return{}  
  30.   
  31. };  
  32. </script>  
  33.   
  34. </head>  
  35. <body><section class=mod-page-body>  
  36. <div class="mod-page-main wordwrap clearfix">  
  37.     <div class=mod-pageheader></div>  
  38.     <div class=mod-pagecontent>  
  39.     <div class=mod-weixinjsapi>  
  40.         <div class=x-desc>微信客户端自带的Js Api:WeixinJSBridge</div>  
  41.         <div id=WeixinJsApi>  
  42.                 <input type=button id=imagePreview value="图片预览"></input>  
  43.                 <input type=button id=profile value="查看profile"></input>  
  44.             <a href="weixin://profile/gh_412d74fbb474">企业微信小助手</a>  
  45.                 <input type=button id=shareWeibo value="分享微博"></input>  
  46.                 <input type=button id=shareFB value="分享facebook"></input>  
  47.                 <input type=button id=addContact value="添加联系人"></input>  
  48.                 <input type=button id=scanQRCode value="扫描二维码"></input>  
  49.                 <input type=button id=jumpToBizProfile value="跳转到指定公众账号页面"></input>  
  50.             <input type=button id=toggleMenuBtn value="隐藏右上角按钮"></input>  
  51.             <input type=button id=toggleToolbar value="隐藏底部导航栏"></input>  
  52.             <input type=button id=getNetType value="获取网络状态"></input>  
  53.                 <input type=button id=closeWindow value="关闭"></input>  
  54.                 <input type=button id=getBrandWCPayRequest value="发起公众号微信支付"></input>  
  55.                 <input type=button id=setPageState value="设置页面状态"></input>  
  56.                 <input type=button id=sendEmail value="发邮件"></input>  
  57.                 <input type=button id=openSpecificView value="微信团队打开webView,跳到指定页面"></input>  
  58.                 <input type=button id=getCanIAPPay value="getCanIAPPay"></input>  
  59.                 <input type=button id=getBrandIAPPayRequest value="发起公众号IAP支付"></input>  
  60.                 <input type=button id=openUrlByExtBrowser value="用safari打开指定链接"></input>  
  61.                 <input type=button id=openProductView value="跳转微信商品页"></input>  
  62.                 <input type=button id=openLocation value="查看地理位置"></input>  
  63.                 <input type=button id=timelineCheckIn value="朋友圈签到"></input>  
  64.                 <input type=button id=getBrandWCPayCreateCreditCardRequest value="开通微信信用卡"></input>  
  65.                 <input type=button id=geoLocation value="获取地理位置"></input>  
  66.                 <input type=button id=getInstallState value="获取某app是否安装"></input>  
  67.                 <input type=button id=editAddress value="公众号编辑收货地址"></input>  
  68.                 <input type=button id=getLatestAddress value="公众号获取最近的收货地址"></input>  
  69.                 <input type=button id=launch3rdApp value="启动第三方APP"></input>  
  70.                 <input type=button id=jumpWCMall value="跳转微信商品购买界面"></input>  
  71.                 <input type=button id=addEmoticon value="添加表情"></input>  
  72.                 <input type=button id=cancelAddEmoticon value="取消下载某表情"></input>  
  73.                 <input type=button id=hasEmoticon value="查询是否存在某表情"></input>  
  74.               
  75.         </div>  
  76.     </div>  
  77. </div>  
  78. </div>  
  79. </section>  
  80.   
  81. <script>  
  82. function onBridgeReady() {  
  83.     WeixinJSBridge.on('menu:share:appmessage', function(argv)   
  84.     {  
  85.         WeixinJSBridge.invoke('sendAppMessage',{  
  86.                     "link":"http://m.exmail.qq.com/",  
  87.                     "desc":"desc",  
  88.                     "title":"title for WeiXinJsBridge"  
  89.         }, function(res) {  
  90.             WeixinJSBridge.log(res.err_msg);  
  91.         });  
  92.     });  
  93.     WeixinJSBridge.on('menu:share:timeline', function(argv)   
  94.     {  
  95.     WeixinJSBridge.invoke("shareTimeline",{  
  96.         "link":"http://m.exmail.qq.com",  
  97.         "img_url":"../../bizmail/zh_CN/htmledition/images/bizmail/v3/logo1ca3fe.png",  
  98.         "img_width":"172",  
  99.         "img_height":"40",  
  100.         "desc":"i am description",  
  101.         "title":"just test from WeixinJsBridge"  
  102.         },  
  103.         function(e){  
  104.         alert(e.err_msg);  
  105.         })  
  106.     });  
  107. }  
  108.   
  109. if (typeof WeixinJSBridge === "undefined"){  
  110.     if (document.addEventListener){  
  111.         document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);  
  112.     }  
  113. }else{  
  114.     onBridgeReady();  
  115. }  
  116.   
  117.     var menuHidden=!1,toolbarHidden=!1,netType={"network_type:wifi":"wifi网络","network_type:edge":"非wifi,包含3G/2G","network_type:fail":"网络断开连接","network_type:wwan":"2g或者3g"};  
  118.     document.addEventListener("WeixinJSBridgeReady",function(){  
  119.             document.getElementById("imagePreview").addEventListener(  
  120.             "click",function(){  
  121.                                 WeixinJSBridge.invoke("imagePreview",{  
  122.                 "urls":[  
  123.                 "../../bizmail/zh_CN/htmledition/images/bizmail/v3/logo1ca3fe.png",  
  124.                 "../../bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png",  
  125.                 "../../bizmail/zh_CN/htmledition/images/bizmail/v3/icons_workStyle1ca3fe.png"  
  126.                 ],  
  127.                 "current":"../../bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png"  
  128.                 })  
  129.                         },!1),  
  130.         document.getElementById("profile").addEventListener(  
  131.             "click",function(){  
  132.                 alert("profile clicked");  
  133.                 WeixinJSBridge.invoke("profile",{  
  134.                     "username":"gh_412d74fbb474",  
  135.                     "nickname":"企业微信小助手"      
  136.                 })  
  137.             },!1),  
  138.         document.getElementById("shareWeibo").addEventListener(  
  139.             "click",function(){  
  140.                 WeixinJSBridge.invoke("shareWeibo",{  
  141.                     "type":"link",  
  142.                     "link":"http://m.exmail.qq.com"  
  143.                 },  
  144.                 function(e){  
  145.                     alert(e.err_msg);  
  146.                 })  
  147.             },!1),  
  148.         document.getElementById("shareFB").addEventListener(  
  149.             "click",function(){  
  150.                 WeixinJSBridge.invoke("shareFB",{  
  151.                     "link":"http://m.exmail.qq.com"  
  152.                 })  
  153.             },!1),  
  154.         document.getElementById("scanQRCode").addEventListener(  
  155.             "click",function(){  
  156.                 WeixinJSBridge.invoke("scanQRCode",{  
  157.                 })  
  158.             },!1),  
  159.         document.getElementById("addEmoticon").addEventListener(  
  160.             "click",function(){  
  161.                 WeixinJSBridge.invoke("addEmoticon",{  
  162.                     "url":"../../bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png",  
  163.                     "thumb_url":"../../bizmail/zh_CN/htmledition/images/bizmail/v3/logo1ca3fe.png"  
  164.   
  165.                 },  
  166.                 function(e){  
  167.                                         alert(e.err_msg);  
  168.                                 })  
  169.             },!1),  
  170.         document.getElementById("cancelAddEmoticon").addEventListener(  
  171.             "click",function(){  
  172.                 WeixinJSBridge.invoke("cancelAddEmoticon",{  
  173.                     "url":"../../bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png"  
  174.   
  175.                 },  
  176.                 function(e){  
  177.                                         alert(e.err_msg);  
  178.                                 })  
  179.             },!1),  
  180.         document.getElementById("hasEmoticon").addEventListener(  
  181.             "click",function(){  
  182.                 WeixinJSBridge.invoke("hasEmoticon",{  
  183.                     "url":"../../bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png"  
  184.   
  185.                 },  
  186.                 function(e){  
  187.                                         alert(e.err_msg);  
  188.                                 })  
  189.             },!1),  
  190.         document.getElementById("addContact").addEventListener(  
  191.             "click",function(){  
  192.                 WeixinJSBridge.invoke("addContact",{  
  193.                     "webtype":"1",  
  194.                     "username":"gh_412d74fbb474"  
  195.                 },  
  196.                 function(e){  
  197.                     alert(e.err_msg);  
  198.                 })  
  199.             },!1),  
  200.         document.getElementById("jumpToBizProfile").addEventListener(  
  201.             "click",function(){  
  202.                 WeixinJSBridge.invoke("jumpToBizProfile",{  
  203.                     "tousername":"syqnr0"  
  204.                 },  
  205.                 function(e){  
  206.                     alert(e.err_msg);  
  207.                 })  
  208.             },!1),  
  209.         document.getElementById("toggleMenuBtn").addEventListener(  
  210.             "click",function(){  
  211.                 menuHidden?  
  212.                 (WeixinJSBridge.call("showOptionMenu"),menuHidden=!1,this.value="隐藏右上角按钮")  
  213.                 :  
  214.                 (WeixinJSBridge.call("hideOptionMenu"),menuHidden=!0,this.value="显示右上角按钮")  
  215.             },!1),  
  216.         document.getElementById("toggleToolbar").addEventListener(  
  217.             "click",function(){  
  218.                 toolbarHidden?  
  219.                 (WeixinJSBridge.call("showToolbar"),toolbarHidden=!1,this.value="隐藏底部导航栏")  
  220.                 :  
  221.                 (WeixinJSBridge.call("hideToolbar"),toolbarHidden=!0,this.value="显示底部导航栏")  
  222.             },!1),  
  223.         document.getElementById("getNetType").addEventListener(  
  224.             "click",function(){  
  225.                 WeixinJSBridge.invoke("getNetworkType",{},  
  226.                     function(e){  
  227.                         alert(netType[e.err_msg])  
  228.                     })  
  229.             },!1),  
  230.          document.getElementById("closeWindow").addEventListener(  
  231.                         "click",function(){  
  232.                                 WeixinJSBridge.invoke("closeWindow",{},function(e){})  
  233.                         },!1),  
  234.         document.getElementById("getBrandWCPayRequest").addEventListener(  
  235.             "click",function(){  
  236.             WeixinJSBridge.invoke("getBrandWCPayRequest",{  
  237.                 "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传⼊入  
  238.                 "timeStamp" : "189026618", //时间戳 这⾥里随意使⽤用了⼀一个值  
  239.                 "nonceStr" : "adssdasssd13d", //随机串  
  240.                 "package" :  
  241.                 "body=xxx&fee_type=1&input_charset=GBK¬ify_url=http&out_trade_no=16642817866003386000&partner=1900000109&return_url=http&spbill_create_ip=127.0.0.1&total_fee=1&sign=273B7EEEE642A8E41F27213D8517E0E4", //扩展字段,由商户传⼊入  
  242.                 "signType" : "SHA1", //微信签名⽅方式:sha1  
  243.                 "paySign" : "b737015b5b1eabe5db580945a07eac08c7bb55f8" //微信签名  
  244.                 },  
  245.                 function(e){  
  246.                     alert(e.err_msg)  
  247.                 })  
  248.             },!1),  
  249.         document.getElementById("setPageState").addEventListener(  
  250.             "click",function(){  
  251.             WeixinJSBridge.invoke("setPageState",{  
  252.                 "state" : "1"  
  253.                 })  
  254.             },!1),  
  255.   
  256.         document.getElementById("sendEmail").addEventListener(  
  257.             "click",function(){  
  258.             WeixinJSBridge.invoke("sendEmail",{  
  259.                 "title" : "title!",  
  260.                 "content" : "i am an Email!", //时间戳 这⾥里随意使⽤用了⼀一个值  
  261.                 },  
  262.                 function(e){  
  263.         //          alert(e.err_msg)  
  264.                 })  
  265.             },!1),  
  266.         document.getElementById("openSpecificView").addEventListener(  
  267.             "click",function(){  
  268.             WeixinJSBridge.invoke("openSpecificView",{  
  269.                 "specificview" : "contacts"  
  270.                 },  
  271.                 function(e){  
  272.                     alert(e.err_msg)  
  273.                 })  
  274.             },!1),  
  275.         document.getElementById("getCanIAPPay").addEventListener(  
  276.             "click",function(){  
  277.             WeixinJSBridge.invoke("getCanIAPPay",{  },  
  278.                 function(e){  
  279.                     alert(e.err_msg)  
  280.                 })  
  281.             },!1),  
  282.         document.getElementById("getBrandIAPPayRequest").addEventListener(  
  283.             "click",function(){  
  284.             WeixinJSBridge.invoke("getBrandIAPPayRequest",{  
  285.                 "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传⼊入  
  286.                 "timeStamp" : "189026618", //时间戳 这⾥里随意使⽤用了⼀一个值  
  287.                 "nonceStr" : "adssdasssd13d", //随机串  
  288.                 "package" : "bankType=CITIC_CREDIT&bankName=%e4%b8%ad%e4%bf%a1%e9%93%b6%e8%a1%8c&sign=CF8922F49431FFE8A1834D0B32B25CE3",  
  289.                 //扩展字段,由商户传⼊入  
  290.                 "signType" : "SHA1", //微信签名⽅方式:sha1  
  291.                 "paySign" : "1e6f13f78ca0ec43fbb80899087f77568af66987" //微信签名  
  292.                 },  
  293.                 function(e){  
  294.                     alert(e.err_msg)  
  295.                 })  
  296.             },!1),  
  297.         document.getElementById("openLocation").addEventListener(  
  298.             "click",function(){  
  299.             WeixinJSBridge.invoke("openProductView",{     
  300.                 "latitude" : 23.113, //纬度  
  301.                 "longitude" : 113.23, //经度  
  302.                 "name" : "TIT创意园", //POI名称  
  303.                 "address" : "⼲⼴广州市海珠区新港中路397号", //地址  
  304.                 "scale" : 14, //地图缩放级别  
  305.                 "infoUrl" : "http://weixin.qq.com/", //查看位置界⾯面底部的超链接                  
  306.                 },  
  307.                 function(e){  
  308.                     alert(e.err_msg)  
  309.                 })  
  310.             },!1),  
  311.         document.getElementById("timelineCheckIn").addEventListener(  
  312.             "click",function(){  
  313.             WeixinJSBridge.invoke("timelineCheckIn",{     
  314.                 "img_url": "http://mmsns.qpic.cn/mmsns/RLllkTm3DUdV24xbZnKicx9jJWxXI0Bq84zzbtibGuRyk/0", // 分享到朋友圈的缩略图  
  315.                 "img_width": "640", // 图⽚片的⻓长度  
  316.                 "img_height": "640", // 图⽚片⾼高度  
  317.                 "link": "http://news.qq.com/zt2012/cxkyym/index.htm", // 连接地址  
  318.                 "desc": "这个是描述啊啊", // 描述  
  319.                 "title": "朝鲜称中国渔船越界捕捞", // 分享标题  
  320.                 "latitude" : 23.113, //纬度  
  321.                 "longitude" : 113.23, //经度  
  322.                 "poiId" : "dianping_2331037", //商户id  
  323.                 "poiName" : "TIT创意园", //POI名称  
  324.                 "poiAddress" : "⼲⼴广州市海珠区新港中路397号", //地址  
  325.                 "poiScale" : 14, //地图缩放级别  
  326.                 "poiInfoUrl" : "http://weixin.qq.com/" //查看位置界⾯面底部的超链接  
  327.                 },  
  328.                 function(e){  
  329.                     alert(e.err_msg)  
  330.                 })  
  331.             },!1),  
  332.         document.getElementById("geoLocation").addEventListener(  
  333.             "click",function(){  
  334.             WeixinJSBridge.invoke("geoLocation",{     
  335.                 },  
  336.                 function(e){  
  337.                     alert(e.err_msg)  
  338.                 })  
  339.             },!1),  
  340.         document.getElementById("getBrandWCPayCreateCreditCardRequest").addEventListener(  
  341.             "click",function(){  
  342.             WeixinJSBridge.invoke("getBrandWCPayCreateCreditCardRequest",{    
  343.                 "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传⼊入  
  344.                 "timeStamp" : "189026618", //时间戳 这⾥里随意使⽤用了⼀一个值  
  345.                 "nonceStr" : "adssdasssd13d", //随机串  
  346.                 "package" : "bankType=CITIC_CREDIT&bankName=%e4%b8%ad%e4%bf%a1%e9%93%b6%e8%a1%8c&signCF8922F49431FFE8A1834D0B32B25CE3",  
  347.                 //扩展字段,由商户传⼊入  
  348.                 "signType" : "SHA1", //微信签名⽅方式:sha1  
  349.                 "paySign" : "1e6f13f78ca0ec43fbb80899087f77568af66987" //微信签名  
  350.                 },  
  351.                 function(e){  
  352.                     alert(e.err_msg)  
  353.                 })  
  354.             },!1),  
  355.         document.getElementById("getInstallState").addEventListener(  
  356.             "click",function(){  
  357.             WeixinJSBridge.invoke("getInstallState",{     
  358.                     "packageUrl":"teamcircle://"  
  359.                 },  
  360.                 function(e){  
  361.                     alert(e.err_msg)  
  362.                 })  
  363.             },!1),  
  364.         document.getElementById("openProductView").addEventListener(  
  365.             "click",function(){  
  366.             WeixinJSBridge.invoke("openProductView",{     
  367.                     "productInfo":"json"  
  368.                 },  
  369.                 function(e){  
  370.                     alert(e.err_msg)  
  371.                 })  
  372.             },!1),  
  373.         document.getElementById("getLatestAddress").addEventListener(  
  374.                 "click",function(){  
  375.                 WeixinJSBridge.invoke("getLatestAddress",{    
  376.                     "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传⼊入  
  377.                     "timeStamp" : "189026618", //时间戳 这⾥里随意使⽤用了⼀一个值  
  378.                     "nonceStr" : "adssdasssd13d", //随机串  
  379.                     "signType" : "SHA1", //微信签名⽅方式:sha1  
  380.                     "addrSign" : "b737015b5b1eabe5db580945a07eac08c7bb55f8", //微信签名  
  381.                     "scope"    : "snsapi"  
  382.                 },  
  383.                 function(e){  
  384.                     alert(e.err_msg)  
  385.                 })  
  386.             },!1),  
  387.         document.getElementById("editAddress").addEventListener(  
  388.                 "click",function(){  
  389.                 WeixinJSBridge.invoke("editAddress",{     
  390.                     "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传⼊入  
  391.                     "timeStamp" : "189026618", //时间戳 这⾥里随意使⽤用了⼀一个值  
  392.                     "nonceStr" : "adssdasssd13d", //随机串  
  393.                     "signType" : "SHA1", //微信签名⽅方式:sha1  
  394.                     "addrSign" : "b737015b5b1eabe5db580945a07eac08c7bb55f8", //微信签名  
  395.                     "scope"    : "snsapi"  
  396.                 },  
  397.                 function(e){  
  398.                     alert(e.err_msg)  
  399.                 })  
  400.             },!1),  
  401.         document.getElementById("launch3rdApp").addEventListener(  
  402.                 "click",function(){  
  403.                 WeixinJSBridge.invoke("launch3rdApp",{    
  404.                     "appId" : "wx5823bf96d3bd56c7", //公众号名称,由商户传⼊入  
  405.                 },  
  406.                 function(e){  
  407.                     alert(e.err_msg)  
  408.                 })  
  409.             },!1),  
  410.         document.getElementById("jumpWCMall").addEventListener(  
  411.                 "click",function(){  
  412.                 WeixinJSBridge.invoke("jumpWCMall",{      
  413.                     "appId" : "wx5823bf96d3bd56c7", //公众号名称,由商户传⼊入  
  414.                     "funcId":"1000"  
  415.                 },  
  416.                 function(e){  
  417.                     alert(e.err_msg)  
  418.                 })  
  419.             },!1),  
  420.         document.getElementById("openUrlByExtBrowser").addEventListener(  
  421.             "click",function(){  
  422.             WeixinJSBridge.invoke("openUrlByExtBrowser",{  
  423.                 "url" : "http://m.exmail.qq.com"  
  424.                 },  
  425.                 function(e){  
  426.                     alert(e.err_msg)  
  427.                 })  
  428.             },!1)  
  429.         }  
  430.     );  
  431. <!DOCTYPE html>  
    <html>  
    <head><title>微信WeixinJSBridge API</title>  
    <meta charset=utf-8>  
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">  
    <script type="text/javascript">  
    (function(){  
    var a=document.getElementsByTagName("html")[0];  
    window.Session={appDomain:a.getAttribute("data-app-domain")||"",staticDomain:a.getAttribute("data-static-domain")||""}  
    })();  
      
    window.registNS=function(fullNS,isIgnorSelf){  
    var reg=/^[_$a-z]+[_$a-z0-9]*/i;var nsArray=fullNS.split(".");  
    var sEval="";  
    var sNS="";  
    var n=isIgnorSelf?nsArray.length-1:nsArray.length;  
    for(var i=0;i<n;i++){  
        if(!reg.test(nsArray[i])){throw new Error("Invalid namespace:"+nsArray[i]+"");  
        return  
        }  
        if(i!=0){sNS+="."}  
        sNS+=nsArray[i];  
        sEval+="if(typeof("+sNS+")=='undefined') "+sNS+"=new Object();  
        else "+sNS+";"  
    }  
    if(sEval!=""){  
    return eval(sEval)  
    }  
    return{}  
      
    };  
    </script>  
      
    </head>  
    <body><section class=mod-page-body>  
    <div class="mod-page-main wordwrap clearfix">  
        <div class=mod-pageheader></div>  
        <div class=mod-pagecontent>  
        <div class=mod-weixinjsapi>  
            <div class=x-desc>微信客户端自带的Js Api:WeixinJSBridge</div>  
            <div id=WeixinJsApi>  
                    <input type=button id=imagePreview value="图片预览"></input>  
                    <input type=button id=profile value="查看profile"></input>  
                <a href="weixin://profile/gh_412d74fbb474">企业微信小助手</a>  
                    <input type=button id=shareWeibo value="分享微博"></input>  
                    <input type=button id=shareFB value="分享facebook"></input>  
                    <input type=button id=addContact value="添加联系人"></input>  
                    <input type=button id=scanQRCode value="扫描二维码"></input>  
                    <input type=button id=jumpToBizProfile value="跳转到指定公众账号页面"></input>  
                <input type=button id=toggleMenuBtn value="隐藏右上角按钮"></input>  
                <input type=button id=toggleToolbar value="隐藏底部导航栏"></input>  
                <input type=button id=getNetType value="获取网络状态"></input>  
                    <input type=button id=closeWindow value="关闭"></input>  
                    <input type=button id=getBrandWCPayRequest value="发起公众号微信支付"></input>  
                    <input type=button id=setPageState value="设置页面状态"></input>  
                    <input type=button id=sendEmail value="发邮件"></input>  
                    <input type=button id=openSpecificView value="微信团队打开webView,跳到指定页面"></input>  
                    <input type=button id=getCanIAPPay value="getCanIAPPay"></input>  
                    <input type=button id=getBrandIAPPayRequest value="发起公众号IAP支付"></input>  
                    <input type=button id=openUrlByExtBrowser value="用safari打开指定链接"></input>  
                    <input type=button id=openProductView value="跳转微信商品页"></input>  
                    <input type=button id=openLocation value="查看地理位置"></input>  
                    <input type=button id=timelineCheckIn value="朋友圈签到"></input>  
                    <input type=button id=getBrandWCPayCreateCreditCardRequest value="开通微信信用卡"></input>  
                    <input type=button id=geoLocation value="获取地理位置"></input>  
                    <input type=button id=getInstallState value="获取某app是否安装"></input>  
                    <input type=button id=editAddress value="公众号编辑收货地址"></input>  
                    <input type=button id=getLatestAddress value="公众号获取最近的收货地址"></input>  
                    <input type=button id=launch3rdApp value="启动第三方APP"></input>  
                    <input type=button id=jumpWCMall value="跳转微信商品购买界面"></input>  
                    <input type=button id=addEmoticon value="添加表情"></input>  
                    <input type=button id=cancelAddEmoticon value="取消下载某表情"></input>  
                    <input type=button id=hasEmoticon value="查询是否存在某表情"></input>  
                  
            </div>  
        </div>  
    </div>  
    </div>  
    </section>  
      
    <script>  
    function onBridgeReady() {  
        WeixinJSBridge.on('menu:share:appmessage', function(argv)   
        {  
            WeixinJSBridge.invoke('sendAppMessage',{  
                        "link":"http://m.exmail.qq.com/",  
                        "desc":"desc",  
                        "title":"title for WeiXinJsBridge"  
            }, function(res) {  
                WeixinJSBridge.log(res.err_msg);  
            });  
        });  
        WeixinJSBridge.on('menu:share:timeline', function(argv)   
        {  
        WeixinJSBridge.invoke("shareTimeline",{  
            "link":"http://m.exmail.qq.com",  
            "img_url":"../../bizmail/zh_CN/htmledition/images/bizmail/v3/logo1ca3fe.png",  
            "img_width":"172",  
            "img_height":"40",  
            "desc":"i am description",  
            "title":"just test from WeixinJsBridge"  
            },  
            function(e){  
            alert(e.err_msg);  
            })  
        });  
    }  
      
    if (typeof WeixinJSBridge === "undefined"){  
        if (document.addEventListener){  
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);  
        }  
    }else{  
        onBridgeReady();  
    }  
      
        var menuHidden=!1,toolbarHidden=!1,netType={"network_type:wifi":"wifi网络","network_type:edge":"非wifi,包含3G/2G","network_type:fail":"网络断开连接","network_type:wwan":"2g或者3g"};  
        document.addEventListener("WeixinJSBridgeReady",function(){  
                document.getElementById("imagePreview").addEventListener(  
                "click",function(){  
                                    WeixinJSBridge.invoke("imagePreview",{  
                    "urls":[  
                    "../../bizmail/zh_CN/htmledition/images/bizmail/v3/logo1ca3fe.png",  
                    "../../bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png",  
                    "../../bizmail/zh_CN/htmledition/images/bizmail/v3/icons_workStyle1ca3fe.png"  
                    ],  
                    "current":"../../bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png"  
                    })  
                            },!1),  
            document.getElementById("profile").addEventListener(  
                "click",function(){  
                    alert("profile clicked");  
                    WeixinJSBridge.invoke("profile",{  
                        "username":"gh_412d74fbb474",  
                        "nickname":"企业微信小助手"      
                    })  
                },!1),  
            document.getElementById("shareWeibo").addEventListener(  
                "click",function(){  
                    WeixinJSBridge.invoke("shareWeibo",{  
                        "type":"link",  
                        "link":"http://m.exmail.qq.com"  
                    },  
                    function(e){  
                        alert(e.err_msg);  
                    })  
                },!1),  
            document.getElementById("shareFB").addEventListener(  
                "click",function(){  
                    WeixinJSBridge.invoke("shareFB",{  
                        "link":"http://m.exmail.qq.com"  
                    })  
                },!1),  
            document.getElementById("scanQRCode").addEventListener(  
                "click",function(){  
                    WeixinJSBridge.invoke("scanQRCode",{  
                    })  
                },!1),  
            document.getElementById("addEmoticon").addEventListener(  
                "click",function(){  
                    WeixinJSBridge.invoke("addEmoticon",{  
                        "url":"../../bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png",  
                        "thumb_url":"../../bizmail/zh_CN/htmledition/images/bizmail/v3/logo1ca3fe.png"  
      
                    },  
                    function(e){  
                                            alert(e.err_msg);  
                                    })  
                },!1),  
            document.getElementById("cancelAddEmoticon").addEventListener(  
                "click",function(){  
                    WeixinJSBridge.invoke("cancelAddEmoticon",{  
                        "url":"../../bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png"  
      
                    },  
                    function(e){  
                                            alert(e.err_msg);  
                                    })  
                },!1),  
            document.getElementById("hasEmoticon").addEventListener(  
                "click",function(){  
                    WeixinJSBridge.invoke("hasEmoticon",{  
                        "url":"../../bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png"  
      
                    },  
                    function(e){  
                                            alert(e.err_msg);  
                                    })  
                },!1),  
            document.getElementById("addContact").addEventListener(  
                "click",function(){  
                    WeixinJSBridge.invoke("addContact",{  
                        "webtype":"1",  
                        "username":"gh_412d74fbb474"  
                    },  
                    function(e){  
                        alert(e.err_msg);  
                    })  
                },!1),  
            document.getElementById("jumpToBizProfile").addEventListener(  
                "click",function(){  
                    WeixinJSBridge.invoke("jumpToBizProfile",{  
                        "tousername":"syqnr0"  
                    },  
                    function(e){  
                        alert(e.err_msg);  
                    })  
                },!1),  
            document.getElementById("toggleMenuBtn").addEventListener(  
                "click",function(){  
                    menuHidden?  
                    (WeixinJSBridge.call("showOptionMenu"),menuHidden=!1,this.value="隐藏右上角按钮")  
                    :  
                    (WeixinJSBridge.call("hideOptionMenu"),menuHidden=!0,this.value="显示右上角按钮")  
                },!1),  
            document.getElementById("toggleToolbar").addEventListener(  
                "click",function(){  
                    toolbarHidden?  
                    (WeixinJSBridge.call("showToolbar"),toolbarHidden=!1,this.value="隐藏底部导航栏")  
                    :  
                    (WeixinJSBridge.call("hideToolbar"),toolbarHidden=!0,this.value="显示底部导航栏")  
                },!1),  
            document.getElementById("getNetType").addEventListener(  
                "click",function(){  
                    WeixinJSBridge.invoke("getNetworkType",{},  
                        function(e){  
                            alert(netType[e.err_msg])  
                        })  
                },!1),  
             document.getElementById("closeWindow").addEventListener(  
                            "click",function(){  
                                    WeixinJSBridge.invoke("closeWindow",{},function(e){})  
                            },!1),  
            document.getElementById("getBrandWCPayRequest").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("getBrandWCPayRequest",{  
                    "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传⼊入  
                    "timeStamp" : "189026618", //时间戳 这⾥里随意使⽤用了⼀一个值  
                    "nonceStr" : "adssdasssd13d", //随机串  
                    "package" :  
                    "body=xxx&fee_type=1&input_charset=GBK¬ify_url=http&out_trade_no=16642817866003386000&partner=1900000109&return_url=http&spbill_create_ip=127.0.0.1&total_fee=1&sign=273B7EEEE642A8E41F27213D8517E0E4", //扩展字段,由商户传⼊入  
                    "signType" : "SHA1", //微信签名⽅方式:sha1  
                    "paySign" : "b737015b5b1eabe5db580945a07eac08c7bb55f8" //微信签名  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("setPageState").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("setPageState",{  
                    "state" : "1"  
                    })  
                },!1),  
      
            document.getElementById("sendEmail").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("sendEmail",{  
                    "title" : "title!",  
                    "content" : "i am an Email!", //时间戳 这⾥里随意使⽤用了⼀一个值  
                    },  
                    function(e){  
            //          alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("openSpecificView").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("openSpecificView",{  
                    "specificview" : "contacts"  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("getCanIAPPay").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("getCanIAPPay",{  },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("getBrandIAPPayRequest").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("getBrandIAPPayRequest",{  
                    "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传⼊入  
                    "timeStamp" : "189026618", //时间戳 这⾥里随意使⽤用了⼀一个值  
                    "nonceStr" : "adssdasssd13d", //随机串  
                    "package" : "bankType=CITIC_CREDIT&bankName=%e4%b8%ad%e4%bf%a1%e9%93%b6%e8%a1%8c&sign=CF8922F49431FFE8A1834D0B32B25CE3",  
                    //扩展字段,由商户传⼊入  
                    "signType" : "SHA1", //微信签名⽅方式:sha1  
                    "paySign" : "1e6f13f78ca0ec43fbb80899087f77568af66987" //微信签名  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("openLocation").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("openProductView",{     
                    "latitude" : 23.113, //纬度  
                    "longitude" : 113.23, //经度  
                    "name" : "TIT创意园", //POI名称  
                    "address" : "⼲⼴广州市海珠区新港中路397号", //地址  
                    "scale" : 14, //地图缩放级别  
                    "infoUrl" : "http://weixin.qq.com/", //查看位置界⾯面底部的超链接                  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("timelineCheckIn").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("timelineCheckIn",{     
                    "img_url": "http://mmsns.qpic.cn/mmsns/RLllkTm3DUdV24xbZnKicx9jJWxXI0Bq84zzbtibGuRyk/0", // 分享到朋友圈的缩略图  
                    "img_width": "640", // 图⽚片的⻓长度  
                    "img_height": "640", // 图⽚片⾼高度  
                    "link": "http://news.qq.com/zt2012/cxkyym/index.htm", // 连接地址  
                    "desc": "这个是描述啊啊", // 描述  
                    "title": "朝鲜称中国渔船越界捕捞", // 分享标题  
                    "latitude" : 23.113, //纬度  
                    "longitude" : 113.23, //经度  
                    "poiId" : "dianping_2331037", //商户id  
                    "poiName" : "TIT创意园", //POI名称  
                    "poiAddress" : "⼲⼴广州市海珠区新港中路397号", //地址  
                    "poiScale" : 14, //地图缩放级别  
                    "poiInfoUrl" : "http://weixin.qq.com/" //查看位置界⾯面底部的超链接  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("geoLocation").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("geoLocation",{     
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("getBrandWCPayCreateCreditCardRequest").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("getBrandWCPayCreateCreditCardRequest",{    
                    "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传⼊入  
                    "timeStamp" : "189026618", //时间戳 这⾥里随意使⽤用了⼀一个值  
                    "nonceStr" : "adssdasssd13d", //随机串  
                    "package" : "bankType=CITIC_CREDIT&bankName=%e4%b8%ad%e4%bf%a1%e9%93%b6%e8%a1%8c&sign= CF8922F49431FFE8A1834D0B32B25CE3",  
                    //扩展字段,由商户传⼊入  
                    "signType" : "SHA1", //微信签名⽅方式:sha1  
                    "paySign" : "1e6f13f78ca0ec43fbb80899087f77568af66987" //微信签名  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("getInstallState").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("getInstallState",{     
                        "packageUrl":"teamcircle://"  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("openProductView").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("openProductView",{     
                        "productInfo":"json"  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("getLatestAddress").addEventListener(  
                    "click",function(){  
                    WeixinJSBridge.invoke("getLatestAddress",{    
                        "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传⼊入  
                        "timeStamp" : "189026618", //时间戳 这⾥里随意使⽤用了⼀一个值  
                        "nonceStr" : "adssdasssd13d", //随机串  
                        "signType" : "SHA1", //微信签名⽅方式:sha1  
                        "addrSign" : "b737015b5b1eabe5db580945a07eac08c7bb55f8", //微信签名  
                        "scope"    : "snsapi"  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("editAddress").addEventListener(  
                    "click",function(){  
                    WeixinJSBridge.invoke("editAddress",{     
                        "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传⼊入  
                        "timeStamp" : "189026618", //时间戳 这⾥里随意使⽤用了⼀一个值  
                        "nonceStr" : "adssdasssd13d", //随机串  
                        "signType" : "SHA1", //微信签名⽅方式:sha1  
                        "addrSign" : "b737015b5b1eabe5db580945a07eac08c7bb55f8", //微信签名  
                        "scope"    : "snsapi"  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("launch3rdApp").addEventListener(  
                    "click",function(){  
                    WeixinJSBridge.invoke("launch3rdApp",{    
                        "appId" : "wx5823bf96d3bd56c7", //公众号名称,由商户传⼊入  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("jumpWCMall").addEventListener(  
                    "click",function(){  
                    WeixinJSBridge.invoke("jumpWCMall",{      
                        "appId" : "wx5823bf96d3bd56c7", //公众号名称,由商户传⼊入  
                        "funcId":"1000"  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1),  
            document.getElementById("openUrlByExtBrowser").addEventListener(  
                "click",function(){  
                WeixinJSBridge.invoke("openUrlByExtBrowser",{  
                    "url" : "http://m.exmail.qq.com"  
                    },  
                    function(e){  
                        alert(e.err_msg)  
                    })  
                },!1)  
            }  
        );  
    </script>  
    </script>  
相关TAG标签
上一篇:微信第三方登录接口
下一篇:微信JS接口汇总及使用详解
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站