123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>demo</title>
- <style type="text/css">
- </style>
- </head>
- <body>
- <div class="list">
- </div>
- <script src="https://cdn.bootcss.com/jquery/1.6.2/jquery.min.js"></script>
- <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
- <script type="text/javascript">
- $(function ()
- {
- var sign_url = window.location.href;
- sign_url = encodeURIComponent(sign_url);
- var host = window.location.protocol + '//' + window.location.host;
- $.ajax({
- type: "get",
- async: false,
- url: host +"/mobile/index.php?act=mshop&op=signurl&client_type=ajax&sign_url=" + sign_url,
- dataType: "jsonp",
- jsonp: "callback",//传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(一般默认为:callback)
- success: function (json) {
- console.log(json);
- var jsonx = json.datas;
- var timestamp = jsonx.timestamp,
- nonceStr = jsonx.noncestr,
- signature = jsonx.signature,
- appid = jsonx.appid;
- wx.config({
- debug: false,
- appId: appid,
- timestamp: timestamp,
- nonceStr: nonceStr,
- signature: signature,
- jsApiList: [
- 'checkJsApi',
- 'onMenuShareTimeline',
- 'onMenuShareAppMessage',
- 'onMenuShareQQ',
- 'onMenuShareWeibo',
- 'onMenuShareQZone',
- 'getNetworkType',
- 'hideOptionMenu',
- 'showOptionMenu',
- 'chooseWXPay'
- ]
- });
- ready();
- },
- error: function () {
- alert('fail');
- }
- });
- function ready()
- {
- wx.ready(function ()
- {
- //分享朋友圈 / 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
- wx.onMenuShareTimeline({
- title: "分享测试", // 分享标
- desc: "分享测试分享测试",
- link: "http://p.lrlz.com/mobile/index.php?act=mshop&op=test&client_type=wap", //cookie读取
- imgUrl: "http://p.lrlz.com/data/upload/shop/store/goods/6/6_05511819175096982_360.jpg",// 分享图标
- trigger: function (res) { // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
- },
- success: function (res) {
- },
- cancel: function (res) {
- //alert('已取消'+res);
- },
- fail: function (res) {
- //alert(JSON.stringify(res));
- }
- });
- //分享给好友
- wx.onMenuShareAppMessage({
- title: "分享测试", // 分享标
- desc: "分享测试分享测试",
- link: "http://p.lrlz.com/mobile/index.php?act=mshop&op=test&client_type=wap", //cookie读取
- imgUrl: "http://p.lrlz.com/data/upload/shop/store/goods/6/6_05511819175096982_360.jpg",// 分享图标
- trigger: function (res) {
- // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
- },
- success: function (res) {
- }
- });
- wx.error(function (res) {
- alert(res.errMsg);
- });
- })
- }
- })
- </script>
- </body>
- </html>
|