1. Slide left and right to view the pictures , as follows:
js effect
The code copy is as follows:
var pictures = [];
angular.forEach(pitctures,function(k,i){
pictures[i] = k.imgPath;
});
$scope.previewPics = function(currentUrl){
if (typeof window.WeixinJSBridge != 'undefined') {
//View WeChat picture collection
WeixinJSBridge.invoke('imagePreview', {
'current':currentUrl, //Current address
'urls':pictures //group
});
} else {
alert( "Please check it in WeChat", null, function () {});
}
}
Page elements:
The code copy is as follows:
<div>
<div ng-repeat="picture in info.infoContent.pitctures">
<img ng-src="{{picture.imgPath}}" ng-click="previewPics(picture.imgPath)">
</div>
</div>
2. The WeChat window close event , as shown below:
The code copy is as follows:
WeixinJSBridge.invoke('closeWindow',{},function(res){
//alert(res.err_msg);
});
3. Share the web page link to friends, circle of friends, Weibo
The code copy is as follows:
var lineLink = 'http://../..',
imgUrl = 'http://../..',
shareTitle = 'page title',
descContent='Introduction to content',
appid = '';
//Judge 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 friends circle
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
The code copy is as follows:
WeixinJsBridge.call('hideOptionMenu');
5. Hide the navigation bar at the bottom of the web page
The code copy is as follows:
WeixinJsBridge.call('hideToolbar');
6. Get the current network connection type:
The code copy is as follows:
WeixinJsBridge.invoke('getNetworkType',{},function(e){
console.log(e.err_msg);
})
7. Prohibit users' sharing
The code copy is as follows:
WeixinJsBridge.invoke('disabledShare',{},function(e){
})
8. Determine whether it is opened in the built-in browser of WeChat
The code copy is as follows:
// true or false
var flag = WeixinApi.openInWeixin();
The above 8 items are the content shared by this article. I hope it will be helpful to your WeChat development.