zoukankan      html  css  js  c++  java
  • 微信小程序 getUserProfile直接进入fail函数,getUserProfile调用失败:fail can only be invoked by user TAP gesture.

    两点改动:
    问题1. fail can only be invoked by user TAP gesture.
    需要用户手动确认才能通过验证:

    uni.showModal({
    	title: '温馨提示',
    	content: '亲,授权微信登录后才能正常使用小程序功能',
    	success(res) {
      }
    }
    

    问题2. fail desc length does not meet the requirements
    接口字段有调整:desc

    uni.getUserProfile({
    	desc: '获取你的昵称、头像、地区及性别',
    	success: res => {
    		console.log(res);
    		console.log(1);
    	}
    }
    

    完整的代码:

    uni.showModal({
    	title: '温馨提示',
    	content: '亲,授权微信登录后才能正常使用小程序功能',
    	success(res) {
    		console.log(0)
    		console.log(res)
    		//如果用户点击了确定按钮
    		if (res.confirm) {
    			uni.getUserProfile({
    				desc: '获取你的昵称、头像、地区及性别',
    				success: res => {
    					console.log(res);
    					console.log(1);
    				},
    				fail: res => {
    					console.log(2);
    					console.log(res)
    					//拒绝授权
    					uni.showToast({
    						title: '您拒绝了请求,不能正常使用小程序',
    						icon: 'error',
    						duration: 2000
    					});
    					return;
    				}
    			});
    		} else if (res.cancel) {
    			//如果用户点击了取消按钮
    			console.log(3);
    			uni.showToast({
    				title: '您拒绝了请求,不能正常使用小程序',
    				icon: 'error',
    				duration: 2000
    			});
    			return;
    		}
    	}
    });
    

    ————————————————
    原文链接:https://blog.csdn.net/Gabriel_wei/article/details/115607347

  • 相关阅读:
    在Linux终端命令行下播放音乐的命令
    危险,几条可致命的Linux命令!
    Linux 之 shell 比较运算符
    Linux-dd命令详解
    vi总结的几个技巧
    用iptables实现代理上网
    CentOS7.5 开启Samba服务
    CentOS7.5常用命令
    CentOS7.5 安装部署Apache+Mysql+Php
    C++入门基础笔记
  • 原文地址:https://www.cnblogs.com/wanthune/p/14757992.html
Copyright © 2011-2022 走看看