doctype html
html(lang="en")
    head
        title= title
        link(href='/public/css/main.css')
    body
        h1 ajax 调用demo
        div(class="panel m-v-10")
            pre(class="p20", id="ajax-config")
        script(type='text/javascript', src="/public/js/jquery.min.js")
        script(type='text/javascript', src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js")
        script(type='text/javascript').
            $.ajax({
                url: '/api/wechat/config',
                type: "get",
                data: {},
                dataType: "json",
                success: function (data) {
                    console.info(data);
                    var seen=[];
                    $('#ajax-config').html(JSON.stringify(data, null, 4));

                    wx.config({
                        appId: data.appId,
                        debug: true,
                        timestamp: data.timestamp,
                        nonceStr: data.nonceStr,
                        signature: data.signature,
                        jsApiList: [
                            'checkJsApi',
                            'onMenuShareTimeline',
                            'onMenuShareAppMessage',
                            'onMenuShareQQ',
                            'onMenuShareWeibo',
                            'hideMenuItems',
                            'showMenuItems',
                            'hideAllNonBaseMenuItem',
                            'showAllNonBaseMenuItem',
                            'translateVoice',
                            'startRecord',
                            'stopRecord',
                            'onRecordEnd',
                            'playVoice',
                            'pauseVoice',
                            'stopVoice',
                            'uploadVoice',
                            'downloadVoice',
                            'chooseImage',
                            'previewImage',
                            'uploadImage',
                            'downloadImage',
                            'getNetworkType',
                            'openLocation',
                            'getLocation',
                            'hideOptionMenu',
                            'showOptionMenu',
                            'closeWindow',
                            'scanQRCode',
                            'chooseWXPay',
                            'openProductSpecificView',
                            'addCard',
                            'chooseCard',
                            'openCard'
                        ]
                    });

                    wx.ready(function () {
                        // 判断当前版本是否支持指定 JS 接口，支持批量判断
                        wx.checkJsApi({
                            jsApiList: [
                                'onMenuShareTimeline',
                                'onMenuShareQQ'
                            ],
                            success: function (res) {
                                alert(JSON.stringify(res));
                            }
                        });

                        wx.error(function (res) {
                            alert(res.errMsg);
                        });
                    });
                }
            });

