y***@jqsoft.net
y***@jqsoft.net
  • 发布:2019-07-11 09:29
  • 更新:2019-12-31 10:14
  • 阅读:2068

button组件的事件回调问题

分类:uni-app

uni-app的button组件open-type 有效值包含一些微信的特有的属性,并有对应的回调事件写法,比如说
当open-type=“getPhoneNumber”时,它对应的回调写法是 @getphonenumber=“getPhoneNumber”

		methods: {  
			getPhoneNumber: function(e) {  
				console.log(11111);  
				console.log('authinfo======' + JSON.stringify(e));  
			}  
		}

当open-type=“getUserInfo”时,它对应的回调写法是 @getUserInfo=“getUserInfo”

		methods: {  
			getUserInfo: function(e) {  
				console.log(11111);  
				console.log('authinfo======' + JSON.stringify(e));  
			}  
		}

微信还有一个高级接口,一般不对外开放,只有指定行业才能申请,官方文档如下
https://developers.weixin.qq.com/community/business/doc/0008eae0f4c82843cb88ab7de5600d

按照官方说明,这个button的写法是

<button open-type=“getRealnameAuthInfo” bindgetRealnameAuthInfo=“authinfo” category-id="{{[99, 904]}}">实名授权</button>

uni-app对open-type=“getRealnameAuthInfo”是支持的,虽然在uni-app官方的button组件介绍页面中没有提到这个属性值,在实际效果中是可以正常弹出实名认证界面的,但是对于bindgetRealnameAuthInfo=“authinfo” 这个回调事件就不支持了,一直进不到这个方法里面,我也尝试着参照getPhoneNumber换成下面的写法:

<button open-type=“getRealnameAuthInfo” @getRealnameAuthInfo=“authinfo” category-id="{{[99, 904]}}">实名授权</button>

结果也是没有进入到@getRealnameAuthInfo=“authinfo”这个回调方法里面,
请问是我的写法有问题,还是uni-app的button组件不支持bindgetRealnameAuthInfo=“authinfo” 这样 或者 @getRealnameAuthInfo=“authinfo”这样的写法?
请指教

2019-07-11 09:29 负责人:无 分享
已邀请:
y***@jqsoft.net

y***@jqsoft.net (作者)

有人知道吗

y***@jqsoft.net

y***@jqsoft.net (作者)

已解决
<button open-type=“getRealnameAuthInfo” @getRealnameAuthInfo=“authinfo” category-id="{{[99, 904]}}">实名授权</button>
将@getRealnameAuthInfo=“authinfo”换成
@getrealnameauthinfo="getrealname"
这样就可以进回调了

hello9527

hello9527

你好,我想问下 为什么我这里没有授权窗弹出呢? <button open-type="getRealnameAuthInfo" bindgetrealnameauthinfo="authinfo" category-id="{{[231, 235]}}}">实名授权</button>
authinfo: function (e) {
console.log("1111")
console.log(e)
}

出来这个:
{type: "getrealnameauthinfo", timeStamp: 3544, target: {…}, currentTarget: {…}, mark: {…}, …}
currentTarget:
dataset: {}
id: ""
offsetLeft: 16
offsetTop: 529
proto: Object
detail: {errMsg: "openRealnameAuth:fail not support"}
mark: {}
mut: false
target: {id: "", offsetLeft: 16, offsetTop: 529, dataset: {…}}
timeStamp: 3544
type: "getrealnameauthinfo"
proto: Object

hello9527

hello9527

“<button open-type="getRealnameAuthInfo" bindgetrealnameauthinfo="authinfo" category-id="{{[231, 235]}}}">实名授权</button> ” 还有别的操作吗?
文档中说 需要将 <button> 组件 open-type 的值设置为 getRealnameAuthInfo,当用户点击并同意之后,可以通过 bindgetRealnameAuthInfo事件回调获取到微信服务器返回的auth_token,再用auth_token调用API来获取用户加密过后的实名信息,,但我没看到 返回auth_token ,

hello9527

hello9527

我这是小程序 button也是一样的 open-type="getRealnameAuthInfo" bindgetrealnameauthinfo="authinfo" category-id="{{[231, 235]}}}

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