zoukankan      html  css  js  c++  java
  • 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 .
  • 相关阅读:
    算法14-----位运算操作(1)
    算法13------集合所有的子集或者字符串所有子串
    21、缓存设计
    20、内存溢出(Out of Memory)
    19、内容共享
    14、数据传输更省电
    15、自定义Content Provider
    16、编写适应多个API Level的APK
    17、屏幕适配,多语言支持,手机类型适配
    18、不同平台版本
  • 原文地址:https://www.cnblogs.com/iyueyao/p/3892764.html
Copyright © 2011-2022 走看看