H5 使用微信地址

效果图

复制代码
1.先引入sdk 文件
$.ajax({
        type: "get",
        url: baseUrl + "api/wechat/Pubaccount/jssdk?url=" + linkurl,//请求接口,获取授权
        success:function(data){
            let res = data;
            jWeixin.config({
                debug: false,
                appId: res.appId,
                timestamp: res.timestamp,
                nonceStr: res.nonceStr,
                signature: res.signature,
                jsApiList: ['openAddress']
            });
        },
        error: function(data) {
            alert("连接失败!");
        }
    })

获取微信地址信息

复制代码
    $(document).on("click",".wechat_address",function(){
         jWeixin.openAddress({
            success: function (res) {
             //把返回的信息填入到页面
                $('#c-name').val(res.userName);
                $('#c-mobiles').val(res.telNumber);
                $('#location').val(res.provinceName+res.cityName+res.countryName);
                $('#detail').val(res.detailInfo);
            },
            cancel: function (errMsg) {
                console.log(errMsg);
            }
        });
    })
相关推荐
Dxy12393102169 分钟前
MySQL如何加唯一索引
android·数据库·mysql
奋进的芋圆32 分钟前
Spring Boot 实现三模安全登录:微信扫码 + 手机号验证码 + 邮箱验证码
spring boot·redis·微信
冠希陈、2 小时前
PHP 判断是否是移动端,更新鸿蒙系统
android·开发语言·php
晚霞的不甘4 小时前
Flutter for OpenHarmony从零到一:构建《冰火人》双人合作闯关游戏
android·flutter·游戏·前端框架·全文检索·交互
2601_949833394 小时前
flutter_for_openharmony口腔护理app实战+饮食记录实现
android·javascript·flutter
独自破碎E5 小时前
【滑动窗口+字符计数数组】LCR_014_字符串的排列
android·java·开发语言
stevenzqzq5 小时前
compose 中 align和Arrangement的区别
android·compose
VincentWei955 小时前
Compose:MutableState 和 mutableStateOf
android
jian110585 小时前
Android studio配置flutter,mac Android studio 发现苹果手机设备
android·flutter·android studio
2501_940007896 小时前
Flutter for OpenHarmony三国杀攻略App实战 - 性能优化与最佳实践
android·flutter·性能优化