使用getphonenumber获取手机号问题?
发布于 6 年前 作者 xcheng 6468 次浏览 来自 问答
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”.

2 回复

怎么解决的

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

回到顶部