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

  • 相关阅读:
    Oracle 删除某个用户下的对象
    解决11g导出时,空表不能导出问题
    Oracle常用sql
    Oracle 创建表空间和用户
    chapter4.1、函数,参数
    chapter3.6、标准库datetime
    chapter3.5内建函数
    简单选择排序和二元选择排序
    chapter3.4解析式、生成器
    列表解析练习
  • 原文地址:https://www.cnblogs.com/wanthune/p/14757992.html
Copyright © 2011-2022 走看看