维信jspai thinkphp 类库及使用

1. 类库:下载

2. php 调用

$jssdk = new \Vendor\Jssdk\Jssdk("wx8b8eafc6427b1f84", "73705538fa7b0b0d5fae8452c666fc25");
            $signPackage = $jssdk->GetSignPackage();
            $this->assign('signPackage',$signPackage);

 3. js

<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script>
            wx.config({
                appId: '{$signPackage.appId}',
                timestamp: '{$signPackage.timestamp}',
                nonceStr: '{$signPackage.nonceStr}',
                signature: '{$signPackage.signature}',
                jsApiList: [
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage',
                ]
            });
            wx.ready(function () {
                wx.checkJsApi({
                    jsApiList: [
                        'onMenuShareTimeline',
                        'onMenuShareAppMessage'
                    ],
                });

                wx.onMenuShareTimeline({
                    title: '{$house.pname}',
                    link: '{$signPackage.url}',
                    imgUrl: '{$image[0][imgurl]}',
                    success: function (res) {
                        // 用户确认分享后执行的回调函数
                        shareSuccess(res);
                    },
                    cancel: function () {
                        // 用户取消分享后执行的回调函数

                        layer.msg('取消了分享到朋友圈');
                    }
                });

                wx.onMenuShareAppMessage({
                    title: '{$house.pname}',
                    desc: '{$house.description}',
                    link: '{$signPackage.url}',
                    imgUrl: '{$image[0][imgurl]}',
                    type: '',
                    dataUrl: '',
                    success: function (res) {
                        // 用户确认分享后执行的回调函数
                        shareSuccess(res);
                    },
                    cancel: function () {
                        // 用户取消分享后执行的回调函数
                        layer.msg('取消了分享给朋友');

                    }
                });
            });
        </script>
        <script>
        function shareSuccess(res){
            // r=eval("("+res+")");
            $.ajax({
                url: '/shareSuccess.php?checksign={$checksign}&id={$house.id}',
                type: 'get',
                dataType: 'json',
            })
            .done(function(r) {
                layer.msg(r.con);
            })
            console.log(res);
        }

        </script>


打赏

看恩吧
网站不承担任何有关评论的责任
  • 最新评论
  • 总共条评论
取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦