微信企业号JS SDK

微信企业号JS SDK

<?php
define('CorpID',        "wx82e2c31215d9a5a7");
define('CorpSecret',     ""); //设置->功能设置->权限管理->系统管理组->深圳管理(新建的管理组)->Secret
define('AgentID',        "24");     //应用ID

require_once('wxqiye.class.php');
$weixin = new class_wxqiye();
$signPackage = $weixin->GetSignPackage();

?>

<!DOCTYPE html>
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0, user-scalable=no" />
    <meta name="format-detection" content="telephone=no" />
  <title>微信企业JSSDK</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
  <link rel="stylesheet" href="http://demo.open.weixin.qq.com/jssdk/css/style.css">
</head>
<body ontouchstart="">
</body>
<script src="https://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
<script>

    wx.config({
        debug: false,
        appId: '<?php echo $signPackage["appId"];?>',
        timestamp: <?php echo $signPackage["timestamp"];?>,
        nonceStr: '<?php echo $signPackage["nonceStr"];?>',
        signature: '<?php echo $signPackage["signature"];?>',
        // url:'<?php echo $signPackage["url"];?>',
        jsApiList: [
            // 所有要调用的 API 都要加到这个列表中
            'checkJsApi',
            'openLocation',
            'getLocation',
          ]
    });
</script>

<script>
    wx.ready(function () {
        
        //自动执行的
        wx.checkJsApi({
            jsApiList: [
                'getLocation',
            ],
            success: function (res) {
                alert(JSON.stringify(res));
            }
        });
        
        wx.hideOptionMenu();
        
        //如果不支持则不会执行
        wx.getLocation({
            success: function (res) {
                alert(JSON.stringify(res));
                // alert('经度' + res.longitude);
                // alert('纬度' + res.latitude);
                // window.location.href = "location.php?longitude=" + res.longitude + "&latitude=" + res.latitude; 
          },
          cancel: function (res) {
            alert('用户拒绝授权获取地理位置');
          }
        });
  
      
    });

    wx.error(function (res) {
        alert(res.errMsg);
    });
 </script>
</html>

  

转载于:https://www.cnblogs.com/txw1958/p/11188962.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值