收藏
回答

使用getphonenumber获取手机号问题?

getPhoneNumber(e) {
      console.log("1111")
      if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
        wx.showModal({
          title: "提示",
          showCancel: false,
          content: "未授权",
          success: function(res) {}
        });
      } else {
        wx.showModal({
          title: "提示",
          showCancel: false,
          content: "同意授权",
          success: function(res) {
            // 用户登录
            wx.login({
              success: res => {
                console.log("code转换", res.code); //用code传给服务器调换session_key
                wx.request({
                  url: "http://127.0.0.1:3030/wechat/login", //接口地址
                  data: {
                    code: res.code
                  },
                  success: res => {
                    wx.setStorageSync("openid", res.data.openid);
                    wx.setStorageSync("session_key", res.data.session_key);
                    console.log(res);
                    wx.request({
                      url: "http://127.0.0.1:3030/wechat/wxbizdatacrypt",
                      data: {
                        encryptedData: e.detail.encryptedData,
                        iv: e.detail.iv,
                        session_key: wx.getStorageSync("session_key")
                      },
                      success: res => {
                        console.log(res);
                      }
                    });
                  }
                });
              }
            });
          }
        });
      }
    },


一直报:Component "pages/sign/sign" does not have a method "getPhoneNumber" to handle event "getphonenumber".

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

3 个回答

  • 刘蓉
    刘蓉
    03-28

    跟楼主一样的问题,按照处理方法确实不会报错了,但是那个回调接收不到数据

    很奇怪,有人遇到吗

    03-28
    有用
    回复
  • 陈青文越邦科技
    陈青文越邦科技
    2019-11-19

    怎么解决的

    2019-11-19
    有用
    回复
  • จุ๊บ
    จุ๊บ
    2019-02-26

    应该是函数大小写问题吧。你在wxml写的事件和在js里面的大小写不一致,导致找不到这个函数

    2019-02-26
    有用
    回复 6
    查看更多(1)
登录 后发表内容