ios 分享需要写这个 html,默认分享出去的标题是该页面的 title,并且不可更改
id=”shortTitle” 是副标题
img 是分享出去的图片
<div style="display:none">
<p class="bbh_p">50</p>
<p id="shortTitle" style="display:none;">我参加了今今乐道共读训练营,快和我一起读书吧</p >
<img src="../images/share.jpg" style="display:none;" id="picture">
<span id="shareUrl"></span>
</div>
<script type="text/javascript">
var url = "";
$.ajax({
url:'/reading/index/getNetwork',
type:'post',
async:false,
success:function(res){
console.log(res);
if(res!=null){
url = res.network;
var thisURL = document.URL;
var getval = thisURL.split('?')[1];
var showval = getval.split("=")[1];
var ucid = showval;
url = "http://"+url+"/index/share?ucid="+ucid;
$('#shareUrl').html(url);
}
},
});
var u = navigator.userAgent, app = navigator.appVersion;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
var isiosapp = u.indexOf('Safari') == -1 && u.indexOf('Language') == -1 && u.indexOf('MicroMessenger') == -1;
var isanapp = u.indexOf('igetapp') > -1;
//判断该页面是否在微信上?
function is_weixn(){
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger") {//alert(1);
return true;
} else {//alert(2)
return false;
};
};
function toptodayandroid(top){
var bt = "共读训练营";
var fb = document.getElementById('shortTitle').innerText;
var pic = document.getElementById('picture').src;
var url = $('#shareUrl').html();
console.log(url);
//alert(top);
isinApp = true;
isinandroidapp = true;
var bb = top;
$(".bbh_p").text(bb);
if(bb>=43){
function chc(){
window.local_obj.getShareInfo(bt,fb,pic,url);
};
chc();
};
};
// 使用自带的右上角的分享不用写这些,若是自己手写的分享按钮需要写一个点击事件,然后触发window.location = "share://share_text";
// ios显示分享按钮
// if(isiOS&&isiosapp){
// window.location = "share://share_text";
// };
// //Android显示分享按钮
// if(isAndroid&&isanapp){
// window.local_obj.shouldStartLoadWithRequest("share://share_text");
// };
</script>