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);
            }
        });
    })
相关推荐
hmywillstronger23 分钟前
【Excel】【VBA】根据内容调整打印区域
android·excel
coooliang1 小时前
【Android】ViewPager的使用
android
xvch3 小时前
Kotlin 2.1.0 入门教程(二十五)类型擦除
android·kotlin
simplepeng12 小时前
我的天,我真是和androidx的字体加载杠上了
android
小猫猫猫◍˃ᵕ˂◍13 小时前
备忘录模式:快速恢复原始数据
android·java·备忘录模式
CYRUS_STUDIO15 小时前
使用 AndroidNativeEmu 调用 JNI 函数
android·逆向·汇编语言
梦否15 小时前
【Android】类加载器&热修复-随记
android
徒步青云15 小时前
Java内存模型
android
今阳15 小时前
鸿蒙开发笔记-6-装饰器之@Require装饰器,@Reusable装饰器
android·app·harmonyos
careathers17 小时前
Vue3 + Spring WebMVC 验证码案例中的跨域问题与解决方法
okhttp