后台
$jsticket = new WechatScript( $this->option );
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$url = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$jssign_info = $jsticket -> getJsSign( $url );
前台
<script src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
<script>
wx.config({
debug: false,
appId: '{$obj["appId"]}',
timestamp: '{$obj["timestamp"]}',
nonceStr: '{$obj["nonceStr"]}',
signature: '{$obj["signature"]}',
jsApiList: [
// 所有要调用的 API 都要加到这个列表中
'checkJsApi',
'openAddress',
'editAddress'
]
});
</script>
<script language="javascript">
function callpay()
{
wx.openAddress({
trigger: function (res) {
// alert('用户开始拉出地址');
},
success: function (res) {
var address_info = res.detailInfo + ' ' + res.userName + ' ' + res.telNumber;
$('#address').html( address_info );
$('#link_people').val( res.userName );
$('#link_phone').val( res.telNumber );
},
cancel: function (res) {
alert('地址拉取取消');
},
fail: function (res) {
alert('地址拉取失败');
}
});
}
</script>