Skip to content

Commit

Permalink
增加打开扫描二维码
Browse files Browse the repository at this point in the history
  • Loading branch information
neelie committed Sep 17, 2014
1 parent 670ff4f commit 149c3b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
8、调起微信客户端的图片播放组件
9、关闭公众平台Web页面
10、判断当前网页是否在微信内置浏览器中打开
11、增加打开扫描二维码

你可以用微信的“扫一扫”来打开下面这个二维码体验一把:

Expand Down
10 changes: 9 additions & 1 deletion WeixinApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,13 @@ var WeixinApi = (function () {
return /MicroMessenger/i.test(navigator.userAgent);
}

/*
* 打开扫描二维码
*/
function scanQRCode () {
WeixinJSBridge.invoke("scanQRCode");
}

return {
version :"2.1",
ready :wxJsBridgeReady,
Expand All @@ -446,6 +453,7 @@ var WeixinApi = (function () {
getNetworkType :getNetworkType,
imagePreview :imagePreview,
closeWindow :closeWindow,
openInWeixin :openInWeixin
openInWeixin :openInWeixin,
scanQRCode :scanQRCode
};
})();
8 changes: 8 additions & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<p>
<button id="closeWindow">WeixinApi.closeWindow</button>
</p>
<p>
<button id="scanQRCode">WeixinApi.scanQRCode</button>
</p>

<p>
<a href="?">点击这里刷新!!!!</a>
Expand Down Expand Up @@ -99,6 +102,11 @@
WeixinApi.closeWindow();
});

// 打开扫码
addEvent('scanQRCode',function(el,e){
WeixinApi.scanQRCode();
});

// 需要分享的内容,请放到ready里
WeixinApi.ready(function(Api) {

Expand Down

0 comments on commit 149c3b2

Please sign in to comment.