1. Swipe left and right in the web page picture collection to view the pictures , as shown in the following example:
js effect
var pictures = [];
angular.forEach(pitctures,function(k,i){
pictures[i] = k.imgPath;
});
$scope.previewPics = function(currentUrl){
If (typeof window.WeixinJSBridge != 'undefined') {
//WeChat photo album view
WeixinJSBridge.invoke('imagePreview', {
'current':currentUrl, //Current address
'urls':pictures //Group
});
} else {
alert("Please check in WeChat", null, function () {});
}
}
Page elements:
2. WeChat window closing event , the example is as follows:
WeixinJSBridge.invoke('closeWindow',{},function(res){
//alert(res.err_msg);
});
3. Share web links to friends, Moments, and Weibo
var lineLink = 'http://../..',
imgUrl = 'http://../..',
shareTitle = 'Page title',
descContent='Content introduction',
appid = '';
//Determine whether WeChat js is supported
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);//Share friends
WeixinJsBridgeReady.on('menu:share:timeline',wx_shareTimeline);//Share to Moments
WeixinJsBridgeReady.on('menu:share:weibo',wx_shareWeibo);//Share friends
}
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. Hide the button in the upper right corner of the web page
WeixinJsBridge.call('hideOptionMenu');
5. Hide the navigation bar at the bottom of the web page
WeixinJsBridge.call('hideToolbar');
6. Get the current network connection type:
WeixinJsBridge.invoke('getNetworkType',{},function(e){
console.log(e.err_msg);
})
7. Users are prohibited from sharing
WeixinJsBridge.invoke('disabledShare',{},function(e){
})
8. Determine whether to open in WeChat built-in browser
// true or false
var flag = WeixinApi.openInWeixin();
The above 8 items are what this article will share with you. I hope it will be helpful to everyone’s WeChat development.