When Mini Program got the mobile phone number, when this prompt appeared, did you want to receive the SMS interface?

clipboard.png

Mar.31,2021

if your mobile phone number is not authorized by any Mini Program (any Mini Program), it will send a text message for the first time, as long as it is authorized, it will not send a text message


check the login status of the user when you call. If you refresh the sessionKey without encryption, it will cause the call to fail. Have you determined that the third party's call will call back the parameters? the default is
reference:
get the mobile number

.

wxml

<button wx:if="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo"></button>
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber"> </button>

js

Page({

  /**
   * 
   */
  data: {
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },

  /**
   * --
   */
  onLoad: function (options) {
    var that = this;
    // 
    wx.getSetting({
      success: function (res) {
        if (res.authSetting['scope.userInfo']) {
          //  getUserInfo 
          wx.getUserInfo({
            success: function (res) {
              //
              if (res.userInfo) {
                //
                wx.request({
                  url: 'https:/xxxx',
                  data: {
                    userid: wx.getStorageSync('userid'),
                    avatarUrl: res.userInfo.avatarUrl,
                    city: res.userInfo.city,
                    country: res.userInfo.country,
                    gender: res.userInfo.gender,
                    nickName: res.userInfo.nickName,
                    province: res.userInfo.province
                  },
                  header: {
                    'content-type': 'application/x-www-form-urlencoded'
                  },
                  method: 'POST',
                  success: function (res) {
                    //console.log(res);
                    wx.showToast({
                      title: '',
                    })
                  }
                })
              }
            }
          })
        }
      }
    })
  },

  /**
   * --
   */
  onReady: function () {
  
  },

  getPhoneNumber: function (e) {
    console.log(e.detail.errMsg)
    console.log(e.detail.iv)
    console.log(e.detail.encryptedData)
  },
}

effect


I click to log in and harvest mobile phone in sequence

Menu