前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >微信开发扫一扫功能并且屏蔽分享菜单

微信开发扫一扫功能并且屏蔽分享菜单

作者头像
用户1055830
发布2018-01-18 15:57:53
3.6K0
发布2018-01-18 15:57:53
举报
文章被收录于专栏:飞扬的花生飞扬的花生

1.引入JS

  <script language="javascript" type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

2.代码

用到微信的这3个接口'translateVoice', 'scanQRCode', 'hideMenuItems'

屏蔽  分享到朋友圈 分享给朋友 发送给QQ好友 发送给QQ空间:"menuItem:share:timeline", "menuItem:share:appMessage", "menuItem:share:qq", "menuItem:share:QZone"

完整代码如下:

代码语言:javascript
复制
<script>
                if (wx) {
                    var jurl = location.href;
                    if (jurl.indexOf('#'))
                        jurl = jurl.split('#')[0];
                    var timestamp = Math.round(new Date().getTime() / 1000), nonceStr = Math.random().toString(36).substr(2, 15);
                    $.getJSON("http://取票据接口?noncestr=" + nonceStr + "&timestamp=" + timestamp + "&url=" + encodeURIComponent(location.href) + "&callback=?",
                            function (a) {
                                if (a.success) {
                                    wx.config({
                                        debug: false,
                                        appId: 'wxd6cccc001e84efdb',
                                        timestamp: timestamp,
                                        nonceStr: nonceStr,
                                        signature: a.msg,
                                        jsApiList: ['translateVoice', 'scanQRCode', 'hideMenuItems']
                                    });
                                    wx.error(function (res) {
                                        alert("出错了:" + res.errMsg);
                                    });
                                    wx.ready(function () {
                                        wx.checkJsApi({
                                            jsApiList: ['translateVoice', 'scanQRCode', 'hideMenuItems'],
                                            success: function (res) {
                                            }
                                        })
                                        wx.hideMenuItems({ menuList: ["menuItem:share:timeline", "menuItem:share:appMessage", "menuItem:share:qq", "menuItem:share:QZone"] });
                                    });
                                }
                                else {
                                    alert(a.msg);
                                }
                            });
                }
                function Sao() {
                    $.ajax({
                        url: '/WxMeeting/GetBoDrawState?r=' + Math.random(),
                        type: 'post',
                        async: false,
                        dataType: 'jsonp',
                        data: { phone: "", id: "@Model.HDManageID" },
                        success: function (r) {
                            if (r.success) {
                                if (wx) {
                                    wx.scanQRCode({
                                        needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
                                        scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
                                        success: function (res) {
                                            location.href = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
                                        }
                                    });
                                }
                            }
                            else {
                                alert(r.msg);
                            }
                        }
                    });
                }
            </script>

3.参考JSSDK地址:

微信JS-SDK说明文档

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-07-10 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 微信JS-SDK说明文档
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档