1.网页图片集左右滑动查看图片,如下样例:

js效果

复制代码代码如下:

var pictures = [];
 angular.forEach(pitctures,function(k,i){
     pictures[i] = k.imgPath;
 });
 $scope.previewPics = function(currentUrl){
    if (typeof window.WeixinJSBridge != 'undefined') {
      //微信图片集查看
      WeixinJSBridge.invoke('imagePreview', {
        'current':currentUrl, //当前地址
        'urls':pictures //组
      });
    } else {
      alert( "请在微信中查看", null, function () {});
    }
  }

页面元素:

复制代码代码如下:

  

          

               
         

    

2.微信窗口关闭事件,实例如下:

复制代码代码如下:

 WeixinJSBridge.invoke('closeWindow',{},function(res){
    //alert(res.err_msg);
 });

3.分享网页链接至朋友、朋友圈、微博

复制代码代码如下:

var lineLink = 'http://../..',
  imgUrl = 'http://../..',
  shareTitle = '页面标题',
  descContent='内容简介',
  appid = '';
//判断是否支持微信js
 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();
 }
function onBridgeReady (){
  WeixinJsBridgeReady.on('menu:share:appmessage',wx_shareFriend);//分享朋友
  WeixinJsBridgeReady.on('menu:share:timeline',wx_shareTimeline);//分享到朋友圈
  WeixinJsBridgeReady.on('menu:share:weibo',wx_shareWeibo);//分享朋友
}
function wx_shareFriend (){
  WeixinJsBridge.invoke('sendAppMessage',{
    "appid":appid,
    "img_url":imgurl,
    "img_width":'640',
    "img_height":'500',
    "link":lineLink,
    "desc":descContent,
    "title":shareTitle
    },function(res){
      console.log(res.err_msg);
    }
  });
}
function wx_shareTimeline (){
  WeixinJsBridge.invoke('sendTimeline',{
    "appid":appid,
    "img_url":imgurl,
    "img_width":'640',
    "img_height":'500',
    "link":lineLink,
    "desc":descContent,
    "title":shareTitle
    },function(res){
      console.log(res.err_msg);
    }
  })
}  
function wx_shareWeibo (){
  WeixinJsBridge.invoke('sendWeibo',{
    "appid":appid,
    "img_url":imgurl,
    "img_width":'640',
    "img_height":'500',
    "link":lineLink,
    "desc":descContent,
    "title":shareTitle
    },function(res){
      console.log(res.err_msg);
    }
  })
}

4.隐藏网页右上角按钮

复制代码代码如下:

 WeixinJsBridge.call('hideOptionMenu'); 

5.隐藏网页底部导航栏

复制代码代码如下:

 WeixinJsBridge.call('hideToolbar');

6.获取当前网络连接类型:

复制代码代码如下:

 WeixinJsBridge.invoke('getNetworkType',{},function(e){
    console.log(e.err_msg);
 })

7.禁止用户分享

复制代码代码如下:

  WeixinJsBridge.invoke('disabledShare',{},function(e){
  })

8.判断是否在微信内置浏览器中打开

复制代码代码如下:

  // true or false
  var flag = WeixinApi.openInWeixin();

发表评论

邮箱地址不会被公开。 必填项已用*标注