ios 分享需要写这个 html,默认分享出去的标题是该页面的 title,并且不可更改
    id=”shortTitle” 是副标题
    img 是分享出去的图片

    1. <div style="display:none">
    2. <p class="bbh_p">50</p>
    3. <p id="shortTitle" style="display:none;">我参加了今今乐道共读训练营,快和我一起读书吧</p >
    4. <img src="../images/share.jpg" style="display:none;" id="picture">
    5. <span id="shareUrl"></span>
    6. </div>
    1. <script type="text/javascript">
    2. var url = "";
    3. $.ajax({
    4. url:'/reading/index/getNetwork',
    5. type:'post',
    6. async:false,
    7. success:function(res){
    8. console.log(res);
    9. if(res!=null){
    10. url = res.network;
    11. var thisURL = document.URL;
    12. var getval = thisURL.split('?')[1];
    13. var showval = getval.split("=")[1];
    14. var ucid = showval;
    15. url = "http://"+url+"/index/share?ucid="+ucid;
    16. $('#shareUrl').html(url);
    17. }
    18. },
    19. });
    20. var u = navigator.userAgent, app = navigator.appVersion;
    21. var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
    22. var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    23. var isiosapp = u.indexOf('Safari') == -1 && u.indexOf('Language') == -1 && u.indexOf('MicroMessenger') == -1;
    24. var isanapp = u.indexOf('igetapp') > -1;
    25. //判断该页面是否在微信上?
    26. function is_weixn(){
    27. var ua = navigator.userAgent.toLowerCase();
    28. if(ua.match(/MicroMessenger/i)=="micromessenger") {//alert(1);
    29. return true;
    30. } else {//alert(2)
    31. return false;
    32. };
    33. };
    34. function toptodayandroid(top){
    35. var bt = "共读训练营";
    36. var fb = document.getElementById('shortTitle').innerText;
    37. var pic = document.getElementById('picture').src;
    38. var url = $('#shareUrl').html();
    39. console.log(url);
    40. //alert(top);
    41. isinApp = true;
    42. isinandroidapp = true;
    43. var bb = top;
    44. $(".bbh_p").text(bb);
    45. if(bb>=43){
    46. function chc(){
    47. window.local_obj.getShareInfo(bt,fb,pic,url);
    48. };
    49. chc();
    50. };
    51. };
    52. // 使用自带的右上角的分享不用写这些,若是自己手写的分享按钮需要写一个点击事件,然后触发window.location = "share://share_text";
    53. // ios显示分享按钮
    54. // if(isiOS&&isiosapp){
    55. // window.location = "share://share_text";
    56. // };
    57. // //Android显示分享按钮
    58. // if(isAndroid&&isanapp){
    59. // window.local_obj.shouldStartLoadWithRequest("share://share_text");
    60. // };
    61. </script>