小程序获取用户授权加载时间过长怎么办,至少3到6秒时间才能授权成功,然后跳转
发布于 6 年前 作者 qhao 13139 次浏览 来自 问答

小程序获取用户授权加载时间过长怎么办,至少3到6秒时间才能授权成功,然后跳转

getUserInfo: function(e) {

   wx.showLoading({

     title: ‘加载中’,

   })

   console.log(e)

   var that = this;

   // 获取用户信息

   wx.login({

     success(res) {

       console.log(res)

       if (res.code) {

         // 获取用户openid

             // 获取用户信息

             app.getRequest("/api/api/reg", {

               “code”: res.code,

               headimgurl: e.detail.userInfo.avatarUrl,

               name: e.detail.userInfo.nickName,

               sex: e.detail.userInfo.gender

             }, function(result_userinfo) {

               console.log(result_userinfo);

               console.log(“result_userinfo”);

               if (result_userinfo.status == “success”) {

                 // 保存用户信息到缓存

                 wx.setStorageSync(“userInfoid”, result_userinfo.info)

                 wx.reLaunch({ //关闭所有页面,跳转到应用内的某个页面

                   url: “/pages/Easy/Easy?id=142”

                 })

               }

             }, false);

       } else {

         wx.showToast({

           title: “授权失败,重新获取”,

           icon: ‘none’,

           duration: 1000

         });

       }

     }

   })

 },

})

1 回复

reg接口的问题,请求删除掉你看快不快


回到顶部