uni-app开发支付宝小程序获取手机号码

<button  open-type="getAuthorize" @getAuthorize="getAlPhoneNumber" @error="onAuthError" scope="phoneNumber"></button>
onAuthError(err) {
	console.log('err',err)
	uni.showToast({
		title: "需要您授权手机号码后领取哦~",
		icon: 'none',
		duration: 2000
	})
},
getAlPhoneNumber() {
	my.getPhoneNumber({
		scopes: "auth_user",
		success: res => {
			var resData = JSON.parse(res.response);
			console.log('res',resData)
			
		},
		fail: res => {
			uni.showToast({
				title: "需要您授权手机号码后领取哦~",
				icon: 'none',
				duration: 2000
			})
		}
	});
},

你可能感兴趣的:(uni-app开发支付宝小程序获取手机号码)