<!DOCTYPE html>
<html>
<head><title>微信WeixinJSBridge API</title>
<meta charset=utf-8>
<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":"http://rescdn.qqmail.com/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":[
"http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/logo1ca3fe.png",
"http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png",
"http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/icons_workStyle1ca3fe.png"
],
"current":"http://rescdn.qqmail.com/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":"http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png",
"thumb_url":"http://rescdn.qqmail.com/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":"http://rescdn.qqmail.com/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":"http://rescdn.qqmail.com/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":"gh_2248a2ade13e"
},
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&notify_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>

WeixinJSBridge 微信的更多相关文章

  1. -_-#微信内置JavaScript API WeixinJSBridge

    微信相关的 js 操作:分享.网络.菜单 微信内置JsAPI之WeixinJSBridge微信WeixinJSBridge API续

  2. 微信禁用右上角的分享按钮,WeixinJSBridge API以及隐藏分享的子按钮等菜单项

    <!--禁用微信分享按钮--> <script> function onBridgeReady() { WeixinJSBridge.call('hideOptionMenu' ...

  3. 微信WeixinJSBridge API(屏蔽右上角按钮等)

    [声明]:我这份纯属于备份,为了自己将来用起来方便: [相关链接]:http://www.2cto.com/weixin/201511/451592.html(好不好用完全看这个文档的作者了) [感谢 ...

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

    <!DOCTYPE html> <html> <head> <title>微信WeixinJSBridge API</title> < ...

  5. 微信WeixinJSBridge API

    <!DOCTYPE html><html> <head> <title>微信WeixinJSBridge API</title> <m ...

  6. 微信内置浏览器的JsAPI(WeixinJSBridge续)[转载]

    原文地址:  http://www.baidufe.com/item/f07a3be0b23b4c9606bb.html 之前有写过几篇关于微信内置浏览器(WebView)中特有的Javascript ...

  7. 传说中的WeixinJSBridge和微信rest接口

    直接上图,金山的APP“微信导航”,从界面上看有粉丝数等关键数据,实现了直接关注功能,莫不是rest接口?这江湖是大佬们的江湖,小喽啰只有眼馋的份咯. 很早就听说过WeixinJSBridge,不过官 ...

  8. 微信浏览器内置JavaScript 对象:WeixinJSBridge

    微信公众平台开发 微信公众平台开发模式 企业微信公众平台 微信浏览器 分享到朋友圈 发送给好友 分享到腾讯微博 作者:方倍工作室 原文: http://www.cnblogs.com/txw1958/ ...

  9. 微信内置浏览器的JsAPI(WeixinJSBridge续)_Alien的笔记

    微信内置浏览器的JsAPI(WeixinJSBridge续)_Alien的笔记 微信内置浏览器的JsAPI(WeixinJSBridge续)进入全屏 之前有写过几篇关于微信内置浏览器(WebView) ...

随机推荐

  1. Listview多种布局的使用

    ListView中有两个可以用来让ListView可以在视图中显示多种布局的方法,分别是getItemType和getViewTypeCount 其中 getItemViewType返回的是有参数po ...

  2. FTP初始化文件.netrc使用技巧[转发]

    FTP初始化文件.netrc使用技巧 FTP(文件传输)和E-mail(电子邮件).Telnet(远程登录)一样,是 Internet的三大主要功能之一.因为使用频繁,用户往往会遇到各种 各样的问题, ...

  3. phpcms标签第三弹

    {CHARSET}  -------------------------------------字符集 (gbk或者utf-8) {if isset($SEO['title']) && ...

  4. Assembly之instruction之JC

    JC Jump if carry setJHS  Jump if higher or same Syntax JC label JHS label Operation If C = 1: PC + 2 ...

  5. Java多线程学习笔记(四)——Thread类中方法介绍

    currentThread():返回代码正在被哪个线程调用. public class CurrentThreadWay { public static void main(String[] args ...

  6. Java基础(六)--枚举Enum

    枚举: 刚开始项目中没怎么用过,只知道能够实现作为项目中类似定义Constant的功能,然后知道枚举实现的单例模式几乎是最优雅的,所以, 想要深入完整的了解一下 1.基本特性: Enum.values ...

  7. 每日命令:(5)rm

    昨天学习了创建文件和目录的命令mkdir ,今天学习一下linux中删除文件和目录的命令: rm命令.rm是常用的命令,该命令的功能为删除一个目录中的一个或多个文件或目录,它也可以将某个目录及其下的所 ...

  8. 爬楼梯,N级楼梯有多少种走法?

    https://blog.csdn.net/tcpipstack/article/details/45173685 一个人爬楼梯,一步可以迈一级,二级,三级台阶,如果楼梯有N级,要求编写程序,求总共有 ...

  9. [bzoj1042][HAOI2008][硬币购物] (容斥原理+递推)

    Description 硬币购物一共有4种硬币.面值分别为c1,c2,c3,c4.某人去商店买东西,去了tot次.每次带di枚ci硬币,买si的价值的东西.请问每次有多少种付款方法. Input 第一 ...

  10. 3.8.5 多重选择:switch语句

        在处理多个选项时,使用if/else结构显得有些笨拙.               Scanner in = new Scanner(System.in);             Syste ...