Today, the Share button in the upper right corner to hide doing micro letter

Today, the Share button in the upper right corner to hide doing micro letter

Now is the wording used

1

2

3

wx.hideMenuItems({

                menuList: ["menuItem:share:timeline""menuItem:copyUrl""menuItem:share:appMessage""menuItem:share:qq""menuItem:share:weiboApp""menuItem:favorite""menuItem:share:facebook""menuItem:share:QZone""menuItem:editTag""menuItem:delete""menuItem:copyUrl""menuItem:originPage""menuItem:readMode""menuItem:openWithQQBrowser""menuItem:openWithSafari""menuItem:share:email""menuItem:share:brand"// 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮

            });

 Appendix three micro-channel in the API

Copy the code

附录3-所有菜单项列表

基本类

举报: "menuItem:exposeArticle"

调整字体: "menuItem:setFont"

日间模式: "menuItem:dayMode"

夜间模式: "menuItem:nightMode"

刷新: "menuItem:refresh"

查看公众号(已添加): "menuItem:profile"

查看公众号(未添加): "menuItem:addContact"

传播类

发送给朋友: "menuItem:share:appMessage"

分享到朋友圈: "menuItem:share:timeline"

分享到QQ: "menuItem:share:qq"

分享到Weibo: "menuItem:share:weiboApp"

收藏: "menuItem:favorite"

分享到FB: "menuItem:share:facebook"

分享到 QQ 空间/menuItem:share:QZone

保护类

编辑标签: "menuItem:editTag"

删除: "menuItem:delete"

复制链接: "menuItem:copyUrl"

原网页: "menuItem:originPage"

阅读模式: "menuItem:readMode"

在QQ浏览器中打开: "menuItem:openWithQQBrowser"

在Safari中打开: "menuItem:openWithSafari"

邮件: "menuItem:share:email"

一些特殊公众号: "menuItem:share:brand"

Copy the code

 

Baidu found a string of code, very good use

Copy the code

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

        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        } else {
            onBridgeReady();
        }
    </script>

Copy the code


Also looked at the other

Found an article: http://www.2cto.com/weixin/201511/451592.html

Author: Man in Money

To prevent not find a copy of it altogether.

The following is the content of the article:

 

Before writing an article about this WeixinJSBridge API, the article addresses, so there are many users are in consultation over the use of the API, where necessary with you to tell you: This API is out of harmony long before the official announcement of the interface section up, such as a key concern, share with friends, circle of friends to share and so on. Of course, you might find some articles micro-channel official push can also use these features, a rough estimate, the official is on this API adds the white list control, judgment Referer, if a micro-channel official address, or there is a business address of cooperation, is allowed to call, otherwise, it returns "access denied"!

Up to now, I have not found that there is any way to use can continue to use it! However, the official harmony out of this API actually makes sense, because in the upper right corner of the entire WebView, the official made a Navtive button to open later point, including share with friends, to share such a function circle of friends has, therefore, official also doing some guidance.

Of course, WeixinJSBridge this API, not all functions are out of harmony, on the contrary, there are several very useful function is working properly, for example:

1, micro-channel to hide the upper right corner of the page button (... button): Developers can use this function to disable the current page to be shared

2, hide the bottom of the micro-letter web page navigation bar (such as forward and back and refresh): The navigation bar will occupy a certain area, developers can believe users will not use it, hide it away

3, the micro-letter page acquired user's network status: Developers can use this API to obtain the user's network status and provides various services, such as video category, provide high-definition video stream at wifi, providing general definition video at 2g network flow, etc.

The following are a few simple lines of code illustrate the use of these API's:

1. Hide button the top right corner of the micro-letter web page

1

2

3

4

5

6

7

8

9

document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {

    // 通过下面这个API隐藏右上角按钮

    WeixinJSBridge.call('hideOptionMenu');

});

             

document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {

    // 通过下面这个API显示右上角按钮

    WeixinJSBridge.call('showOptionMenu');

});

2, hide the bottom of the micro-letter web page navigation bar

1

2

3

4

5

6

7

8

9

document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {

    // 通过下面这个API隐藏底部导航栏

    WeixinJSBridge.call('hideToolbar');

});

            

document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {

    // 通过下面这个API显示底部导航栏

    WeixinJSBridge.call('showToolbar');

});

3, the user's network status obtaining micro-letter page

1

2

3

4

WeixinJSBridge.invoke('getNetworkType',{},function(e){

    // 在这里拿到e.err_msg,这里面就包含了所有的网络类型

    alert(e.err_msg);

 });

e.err_msg的取值如下所示:

network_type:wifi wifi网络 2 network_type:edge 非wifi,包含3G/2G 3 network_type:fail 网络断开连接 4 network_type:wwan 2g或者3g

 

********************************************************************************此处分割线 *******************************************************************************

 

在微信JSSDK说明文档中有关于按钮屏蔽使用等的说明:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html

左边菜单点击【微信网页开发】,点击下面的二级菜单【微信JS-SDK说明文档】,然后就能看到一系列关于JS-SDK的说明。目录10.界面操作就是需要的地方,只不过火狐大概点击不了或者根本没做页面点击,所以直接页面CTRL+F搜【菜单】两个字,往下找就是了

 

第十条界面操作则是对于按钮的处理

1

 

在附录三中有所有涉及的菜单项列表

wx.hideMenuItems({
    menuList: [] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
});

使用方式,直接将项隐藏的菜单项
  • 发送给朋友: "menuItem:share:appMessage"
  • 分享到朋友圈: "menuItem:share:timeline"
  • 分享到QQ: "menuItem:share:qq"
  • 分享到Weibo: "menuItem:share:weiboApp"
  • 收藏: "menuItem:favorite"
  • 分享到FB: "menuItem:share:facebook"
  • 分享到 QQ 空间/menuItem:share:QZone

Put to menuList: [] brackets, specific splicing, probably, ""

fighting

Published 79 original articles · won praise 48 · views 90000 +

Guess you like

Origin blog.csdn.net/bianyamei/article/details/95175653