编程语言
首页 > 编程语言> > uniapp/微信小程序 获取手机号码

uniapp/微信小程序 获取手机号码

作者:互联网

<button
	type="primary"
	open-type="getPhoneNumber"
	@getphonenumber="getPhoneNumber"
>获取本机号码</button>
getPhoneNumber(e) {
	this.$request({
		url: 'user/get_phonenumber'
		, method: 'POST'
		, data: {
			encrypteddata: e.detail.encryptedData
			, iv: e.detail.iv
			, sessionkey: gracejs.getStorage('user_sessionkey')
		}
	}).then(res => {
		if (res) {
			this.run_mobile = res.phoneNumber
		}
	})
}
function get_phonenumber(){
	$encrypteddata=I('encrypteddata');
	$aes_encrypteddata=base64_decode($encrypteddata);
	$iv=I('iv');
	$aes_iv=base64_decode($iv);
	$sessionkey=I('sessionkey');
	$aes_sessionkey=base64_decode($sessionkey);
	$result=openssl_decrypt($aes_encrypteddata,"AES-128-CBC",$aes_sessionkey,1,$aes_iv);
	\ajax_success(\jsondecode($result));
}

标签:uniapp,aes,res,微信,base64,iv,sessionkey,encrypteddata,手机号码
来源: https://www.cnblogs.com/sunr/p/16672038.html