收藏
回答

wx.getUserProfile回调只fail?

wx.login({

          

            success: function (res) {

                var vcode = res.code;

                

                console.log('login code:' + vcode);

                console.log(that.data.canIUseGetUserProfile)

                if (vcode{

                  console.log(11)

                    wx.getUserProfile({

                        desc:'用于获取头像昵称',

                        success: function (resp) {

                            console.log('getUserInfo successd........');

                            var encryptedData = encodeURIComponent(resp.encryptedData);


                            me.ajaxPost('/user/login', {

                                tuiuid: me.appQuery.shareuid,

                                code: vcode,

                                encryptData: resp.encryptedData,

                                iv: resp.iv,

                            }, function (ret) {

                                wx.hideLoading();

                                console.log(ret.sdata);

                                console.log(ret);

                                if (ret.errcode == 0{

                                    try {

                                        me.gUser = ret.sdata

                                        me.cache().set('loginUser', ret.sdata)

                                        cb && cb(true)

                                    } catch (e{

                                        cb && cb(false)

                                        console.log(e)

                                    }

                                } else {

                                    console.log(ret.msg)

                                }

                            })

                        },

                        fail: function (res) {

                            wx.hideLoading()

                            console.log('getUserInfo fail:未授权');

                            console.log(res);

                        }

                    })

                }


回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容