0

Template.rendered:

var wxparams = {debug: false, jsApiList: ['chooseImage', 'uploadImage'], url: location.href};
    Meteor.call('GetJsConfig', wxparams, function (err, result) {
        if (!err && result) {
            alert(err);
            alert(result);
            wx.config(result);
            wx.ready(function () {
                alert('ready!~');
            });
            wx.error(function (res) {
                // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
                alert('err!~:' + res.errMsg);
            });
        }
   });

Template.events:

'click .routeheadimg': function () {
        //alert('点击图片');
        wx.chooseImage({
            success: function (res) {
                Session.set('headimgId', res.localIds[0]); // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
            },
            fail: function (res) {
                alert('choosefail:' + res.errMsg);
            }
        });
    }

The result of wx.config is OK.

wx.ready run success.

wx.error do not run.

wx.chooseImage result:{"errMsg":"system:permission denied"}

1 Answer 1

0

it seems like you have disabled phote/camera access for Wechat app, enable it in your system settings and it should work fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.