1、这里重中之重是分享到微信:web端网页通常是没有权限分享过去的 所以用: weixin://dl/business/?ticket=ta428dhj739hg3efe6e 但是这个ticket真的是很蛋疼,查了许多资料说还得花钱在第三方对接巴拉巴拉的,2、所以:window.open(‘http://api.liufuweb.com/api/p5.php?p=d&url=你要分享的链接‘); 但是这个缺点是:打开微信的时候要识别二维码才能访问到你要分享的页面3、就是内嵌入到app端,写个方法让其监听,他们自己调取好了 参考:https://blog.csdn.net/weiqinhua1/article/details/80514113http://vip.wxticket.com/api.php function shareTo (stype){ var ftit = ‘‘; var flink = ‘‘; var lk = ‘‘; //获取文章标题 ftit = ‘测试标题‘; //获取网页中内容的第一张图片 flink = ‘/mobile/img/local/invitation.png‘; if(typeof flink == ‘undefined‘){ flink=‘‘; } //当内容中没有图片时,设置分享图片为网站logo if(flink == ‘‘){ lk = ‘http://g.search2.alicdn.com/img/i2/126351555/TB25JDIACtYBeNjSspaXXaOOFXa_!!0-saturn_solar.jpg_220x220.jpg‘; } //qq空间接口的传参 if(stype==‘qzone‘){ window.open(‘https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=‘+document.location.href+‘?sharesource=qzone&title=‘+ftit+‘&pics=‘+lk+‘&summary=‘+document.querySelector(‘meta[name="description"]‘).getAttribute(‘content‘)); } //新浪微博接口的传参 if(stype==‘WB‘){ window.open(‘http://service.weibo.com/share/share.php?url=‘+document.location.href+‘?sharesource=weibo&title=‘+ftit+‘&pic=‘+lk+‘&appkey=2706825840‘); } //分享到微信 if(stype == ‘WX‘){ //window.open(‘weixin://dl/business/?ticket=t2f8d6bf4879b4be12c30ddeea2e265f9‘); window.open(‘http://api.liufuweb.com/api/p5.php?p=d&url=http://192.168.50.13/mobile/finance/be_invited‘); //weixin://dl/business/?ticket=ta428dhj739hg3efe6e -->这个ticket不好实现 } //qq好友接口的传参 if(stype == ‘QQ‘){ window.open(‘http://connect.qq.com/widget/shareqq/index.html?url=‘+document.location.href+‘?sharesource=qzone&title=‘+ftit+‘&pics=‘+lk+‘&summary="hgjshdhjsdhsgd"‘); } //生成二维码给微信扫描分享 if(stype == ‘wechat‘){ window.open(‘inc/qrcode_img.php?url=http://zixuephp.net/article-1.html‘); } }
生成二维码:需要的的js自己动手官网下载好了
<script src="/mobile/js/finance/jquery.min.js" type="text/javascript"></script> <script src="/mobile/js/finance/qrcode.js" type="text/javascript"></script> <div id="qrcode" class="img"></div> var qrcode = new QRCode(document.getElementById("qrcode"), { /* width : 100, height : 100*/ }); var elText = ‘http://192.168.50.13/mobile/finance/be_invited‘; qrcode.makeCode(elText);
原文地址:https://www.cnblogs.com/lmxxlm-123/p/9262662.html
时间: 2024-10-08 00:07:33