• md笔记——微信JS接口


    微信js接口

    隐藏微信中网页右上角按钮

    document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
    	WeixinJSBridge.call('hideOptionMenu'); //showOptionMenu
    });
    

    隐藏底部导航栏按钮

    document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
    	WeixinJSBridge.call('hideToolbar');   //showToolbar
    });
    

    网页获取用户网络状态

    WeixinJSBridge.invoke('getNetworkType',{},
    	function(e){
        	WeixinJSBridge.log(e.err_msg);
    });
    
    返回值	;
    	network_type:wifi wifi网络
    	network_type:edge 非wifi,包含3G/2G
    	network_type:fail 网络断开连接
    	network_type:wwan(2g或者3g)
    

    分享

    document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
            window.shareData = {
                "imgUrl": "",
                "timeLineLink": '',
                "sendFriendLink": '',
                "weiboLink": '',
                "tTitle": '',
                "tContent": "",
                "fTitle": "",
                "fContent": "",
                "wContent": ""
            };
    
            // 发送给好友
            WeixinJSBridge.on('menu:share:appmessage', function (argv) {
                WeixinJSBridge.invoke('sendAppMessage', {
                    "img_url": window.shareData.imgUrl,
                    "img_width": "640",
                    "img_height": "640",
                    "link": window.shareData.sendFriendLink,
                    "desc": window.shareData.fContent,
                    "title": window.shareData.fTitle
                }, function (res) {
                    _report('send_msg', res.err_msg);
                })
            });
    
            // 分享到朋友圈
            WeixinJSBridge.on('menu:share:timeline', function (argv) {
                WeixinJSBridge.invoke('shareTimeline', {
                    "img_url": window.shareData.imgUrl,
                    "img_width": "640",
                    "img_height": "640",
                    "link": window.shareData.timeLineLink,
                    "desc": window.shareData.tContent,
                    "title": window.shareData.tTitle
                }, function (res) {
                    _report('timeline', res.err_msg);
                });
            });
    
            // 分享到微博
            WeixinJSBridge.on('menu:share:weibo', function (argv) {
                WeixinJSBridge.invoke('shareWeibo', {
    				"img_url": window.shareData.imgUrl,
                    "img_width": "640",
                    "img_height": "640",
                    "content": window.shareData.wContent+window.shareData.weiboLink,
                    "url": window.shareData.weiboLink
                }, function (res) {
                    _report('weibo', res.err_msg);
                });
            });
            WeixinJSBridge.call('hideToolbar');
        }, false)
    Now or nerver .
  • 相关阅读:
    thinkPHP 无法加载控制器:Hello
    在html中引用分享的链接
    div中iframe高度自适应问题
    php编写tcp服务器和客户端程序
    Maximum Subsequence Sum (25)——改进版
    水仙花数——升级版
    数据结构实验八——队列打印杨辉三角
    数据结构实验七——循环队列
    数据结构实验六——链队列
    水仙花数(20)
  • 原文地址:https://www.cnblogs.com/iyueyao/p/3892764.html
Copyright © 2020-2023  润新知