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


    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"

    完整代码如下:

    <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说明文档

  • 相关阅读:
    C/C++的64为长整型数的表示
    二分图带权匹配 KM算法与费用流模型建立
    常见的排序算法比较及总结
    个人联系方式
    (1) linux 3.x
    (4) linux 3.x
    (3) linux 3.x
    (2) linux 3.x
    (1) linux 3.x
    (3) linux 3.x
  • 原文地址:https://www.cnblogs.com/CallmeYhz/p/7145076.html
Copyright © 2020-2023  润新知