1***@qq.com
1***@qq.com
  • 发布:2020-08-13 15:11
  • 更新:2020-11-03 12:14
  • 阅读:1903

用button按钮获取支付宝小程序用户基础信息 对应的回调函数无效,不会触发

分类:uni-app
<button type="primary" open-type="getAuthorize" scope="userInfo" onGetAuthorize="onGetAuthorize" onError="onAuthError" >支付宝授权登录</button>  
onGetAuthorize(res) {  
        console.log(res)  
        my.getOpenUserInfo({  
    fail: (res) => {},  
    success: (res) => {  
        let userInfo = JSON.parse(res.response).response // 以下方的报文格式解析两层 response  
            }  
        });  
},  
onAuthError(res) {    
     console.log(res);    
},   

点击授权按钮,在弹出的授权弹框上点击允许,会在阿里的小程序编辑器控制台上会报‘can not find event handle method: onGetAuthorize’ 警告,而且也没有拿到用户的基础信息,然后继续点击会一直出这个警告


<button type="primary" open-type="getAuthorize" scope="userInfo" @GetAuthorize="onGetAuthorize" @Error="onAuthError" >支付宝授权登录</button>  
onGetAuthorize(res) {  
        console.log(res)  
        my.getOpenUserInfo({  
    fail: (res) => {},  
    success: (res) => {  
        let userInfo = JSON.parse(res.response).response // 以下方的报文格式解析两层 response  
            }  
        });  
},  
onAuthError(res) {    
     console.log(res);    
},   

点击授权按钮,在弹出的授权弹框上点击允许,然后就没有然后了,控制台警告也没了,授权回调函数也没调用,控制台啥都没打印出来

2020-08-13 15:11 负责人:无 分享
已邀请:
andersjava

andersjava

<button @getAuthorize="onGetAuthorize" scope="userInfo" open-type="getAuthorize" class="login">授权登录</button>

用这个来回调可以接收到数据
@getAuthorize="onGetAuthorize"

  • Vleejs

    还真是

    2022-03-07 15:41

liberty0

liberty0 - 一个学习uni-app的小白

你好,请问你这个有解决嘛

codan

codan

我也遇到这种问题,而且基本上搜不到答案,在官群也问了,没有回复

该问题目前已经被锁定, 无法添加新回复