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);
            }
        });
    })
相关推荐
_阿南_25 分钟前
flutter 展示的字体突然奔放了
android·flutter·ios
文人sec3 小时前
MySQL事务与索引做了什么?
android·笔记·mysql
刘洋浪子4 小时前
AndroidStudio保存日志菜单
android
朱涛的自习室4 小时前
从 Prompt 到 Graph:AI 工程的进化史
android·前端·人工智能
157092511346 小时前
ViewBinding与DataBinding区别与选型
android
小乖写代码8 小时前
49款开源Android小游戏
android·游戏
三少爷的鞋8 小时前
小团队的最优解:单 Module + 包内 Clean 架构
android
爱和冰阔落9 小时前
【Linux】两个毫无关系的进程怎么通信?命名管道 FIFO 从原理到 Server/Client 实战
android·linux·数据库·c++·vim
Android-Flutter9 小时前
kotlin 协程 - 核心概念
android·kotlin
年小个大18 小时前
受 go-zero 启发,我给 Flutter 写了一套 CLI 脚手架
android·flutter·架构