app微信分享功能

看了大部分的帖子,还是发现有用的帖子。本帖子是抄袭的,具体是那位位前辈的,我也不太清楚。

第一 、我是用mui+vue+jQuery+bootstrap开发的app应用

第二、开始我们在我们需要分享的页面加上下面的代码


function openShare() {

shareWebview();

}

mui.plusReady(function() {

ws = plus.webview.currentWebview();

//关闭splash页面;

plus.navigator.closeSplashscreen();

})

var sharew;

var ws = null;

/**

*分享窗口

*/

function shareWebview() {

ws = plus.webview.currentWebview();

if (sharew) { // 避免快速多次点击创建多个窗口

return;

}

var top = plus.display.resolutionHeight - 134;

var href = "share.html";

sharew = plus.webview.create(href, "share.html", {

width: '100%',

height: '134',

top: top,

scrollIndicator: 'none',

scalable: false,

popGesture: 'none'

}, {

shareInfo: {

"href": "http://m.suyanwen.cn/bussiness-detail-enquiry.html?id="+ws.extId+"&userId="+vm.loginUser.id,

"title": vm.detail.name,

"content": vm.detail.name,

"pageSourceId": ws.id,

"thumbs":'https://image.baidu.com/search/detail?ct=503316480&z=undefined&tn=baiduimagedetail&ipn=d&word=%E7%95%A5%E7%BC%A9%E5%9B%BE&step_word=&ie=utf-8&in=&cl=2&lm=-1&st=undefined&hd=undefined&latest=undefined©right=undefined&cs=59017913,365141432&os=4138957081,3547576863&simid=3524715438,349312346&pn=278&rn=1&di=28600&ln=1125&fr=&fmq=1601366345000_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&is=0,0&istype=0&ist=&jit=&bdtype=0&spn=0&pi=0&gsm=f0&objurl=http%3A%2F%2Fimg1m.pconline.com.cn%2Fpconline%2F0708%2F22%2F1086006_0703_qhtfv616_20.jpg&rpstart=0&rpnum=0&adpicid=0&force=undefined'

}

});

sharew.addEventListener("loaded", function() {

sharew.show('slide-in-bottom', 300);

}, false);

// 显示遮罩层 

ws.setStyle({

mask: "rgba(0,0,0,0.5)"

});

// 点击关闭遮罩层

ws.addEventListener("maskClick", closeMask, false);

}

function closeMask() {

ws.setStyle({

mask: "none"

});

//避免出现特殊情况,确保分享页面在初始化时关闭

if (!sharew) {

sharew = plus.webview.getWebviewById("share.html");

}

if (sharew) {

sharew.close();

sharew = null;

}

}

第三、分享下面的小图标






















  • 微信
  • 朋友圈

******大家要注意 分享页面必须有配套的移动端页面

你可能感兴趣的:(app微信分享功能)