When the WeChat applet is authorized to log in, first judge whether to check the agreement and then pop up a pop-up window to obtain the mobile phone number

Idea: Set two identical buttons, one is the click event button, used to judge whether it is checked; the other is the authorized login button, used to obtain user information

<button class='bottom' wx:if="{
   
   {checked==false}}" bindtap="handleAgree">授权登录</button>
  <button class='bottom' wx:else open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">授权登录</button>
data:{
checked:false
},
handleAgree() {
    if (!this.data.checked) {
      wx.showToast({
        icon: "none",
        title: '请阅读并同意平台服务协议及隐私协议',
        duration: 2000
      })
      return false
    }
  },

Guess you like

Origin blog.csdn.net/yingw1/article/details/128654265