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

  • 相关阅读:
    css基础属性
    选择器的类型
    css的三种表现形式
    表单和表格
    如何比较两个xml 的异同
    xslt 简单的语法
    xslt 和一个demo
    event based xml parser (SAX) demo
    SAX vs. DOM (Event vs. Tree)
    xmlns 实例分析
  • 原文地址:https://www.cnblogs.com/wanthune/p/14757992.html
Copyright © 2011-2022 走看看