javascript - 微信jssdk调用的问题,明明已经已经注入成功了,为何这样

WBOY
Libérer: 2016-07-06 13:51:41
original
1149 Les gens l'ont consulté

javascript - 微信jssdk调用的问题,明明已经已经注入成功了,为何这样

<code>public constructor (options?: BodyConfig, page?: JQuery) {

        var _self = this;

        if (options == null) { return; }

        if (options.jsApiList != null) {

            options.jsApiList.unshift.apply(wecaht_opt.jsApiList, options.jsApiList);

        }

        wecaht_opt = $.extend(true, wecaht_opt, options || {});

        if (wecaht_opt.appId == null || wecaht_opt.timestamp == null || wecaht_opt.nonceStr == null || wecaht_opt.signature == null) {

            console.log('wx.options is null');
            return;

        }

        wx.config(wecaht_opt);

        console.log(wecaht_opt);

        wx.ready(function (res) {

            console.log('wx is ready');

            wx.showOptionMenu();

            wx.hideMenuItems({

                menuList: [
                    'menuItem:copyUrl',
                    'menuItem:readMode',
                    'menuItem:openWithQQBrowser',
                    'menuItem:openWithSafari',
                    'menuItem:share:QZone',
                    'menuItem:share:qq',
                    'menuItem:share:weiboApp',
                    'menuItem:share:facebook',
                    'menuItem:favorite'
                ] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3

            });

            var _title = page.data('share-title');
            var _desc  = page.data('share-desc');
            var _link  = page.data('share-link');
            var _img   = page.data('share-img');

            var timeline: MyBodyMenuShareTimeline = {
                title: _title,
                link: _link,
                imgUrl: _img,
                success: function () {
                    console.log('已分享');
                },
                cancel: function (res) {
                    console.log('已取消');
                },
                fail: function (res) {
                    console.log(JSON.stringify(res));
                }
            }

            var appmessage: MyBodyMenuShareAppMessage = {
                title: _title,
                desc: _desc,
                link: _link,
                imgUrl: _img,
                success: function () {
                    console.log('已分享');
                },
                cancel: function (res) {
                    console.log('已取消');
                },
                fail: function (res) {
                    console.log(JSON.stringify(res));
                }
            }

               wx.onMenuShareTimeline(timeline);
            wx.onMenuShareAppMessage(appmessage);

            page.trigger('MrWechatReady');

        });

        wx.error(function (error) {

            console.log('wx is error');

            page.trigger('MrWechatError');

        });

    }</code>
Copier après la connexion
Copier après la connexion

javascript - 微信jssdk调用的问题,明明已经已经注入成功了,为何这样

回复内容:

javascript - 微信jssdk调用的问题,明明已经已经注入成功了,为何这样

<code>public constructor (options?: BodyConfig, page?: JQuery) {

        var _self = this;

        if (options == null) { return; }

        if (options.jsApiList != null) {

            options.jsApiList.unshift.apply(wecaht_opt.jsApiList, options.jsApiList);

        }

        wecaht_opt = $.extend(true, wecaht_opt, options || {});

        if (wecaht_opt.appId == null || wecaht_opt.timestamp == null || wecaht_opt.nonceStr == null || wecaht_opt.signature == null) {

            console.log('wx.options is null');
            return;

        }

        wx.config(wecaht_opt);

        console.log(wecaht_opt);

        wx.ready(function (res) {

            console.log('wx is ready');

            wx.showOptionMenu();

            wx.hideMenuItems({

                menuList: [
                    'menuItem:copyUrl',
                    'menuItem:readMode',
                    'menuItem:openWithQQBrowser',
                    'menuItem:openWithSafari',
                    'menuItem:share:QZone',
                    'menuItem:share:qq',
                    'menuItem:share:weiboApp',
                    'menuItem:share:facebook',
                    'menuItem:favorite'
                ] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3

            });

            var _title = page.data('share-title');
            var _desc  = page.data('share-desc');
            var _link  = page.data('share-link');
            var _img   = page.data('share-img');

            var timeline: MyBodyMenuShareTimeline = {
                title: _title,
                link: _link,
                imgUrl: _img,
                success: function () {
                    console.log('已分享');
                },
                cancel: function (res) {
                    console.log('已取消');
                },
                fail: function (res) {
                    console.log(JSON.stringify(res));
                }
            }

            var appmessage: MyBodyMenuShareAppMessage = {
                title: _title,
                desc: _desc,
                link: _link,
                imgUrl: _img,
                success: function () {
                    console.log('已分享');
                },
                cancel: function (res) {
                    console.log('已取消');
                },
                fail: function (res) {
                    console.log(JSON.stringify(res));
                }
            }

               wx.onMenuShareTimeline(timeline);
            wx.onMenuShareAppMessage(appmessage);

            page.trigger('MrWechatReady');

        });

        wx.error(function (error) {

            console.log('wx is error');

            page.trigger('MrWechatError');

        });

    }</code>
Copier après la connexion
Copier après la connexion

javascript - 微信jssdk调用的问题,明明已经已经注入成功了,为何这样

permission denied
该公众号没有权限使用这个JSAPI,
或者是调用的JSAPI没有传入config的jsApiList参数中(部分接口需要认证之后才能使用)

多看文档……

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal