|
- <?php
- require_once '../Common/Config.php';
- require_once '../Common/driver_config.php';
- require_once __DIR__.'/../Common/Function.php';
- $openid=isset($_COOKIE['user_openid'])?$_COOKIE['user_openid']:'';
- $code=isset($_GET['code'])?$_GET['code']:'';
-
- if ($openid==''){
- if ($code ==''){
- $selfUrl=urlencode("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
- $getCodeUrl="https://open.weixin.qq.com/connect/oauth2/authorize?appid=".APPID."&redirect_uri=".$selfUrl."&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
- Header("Location: $getCodeUrl");
- exit();
- }else{
- $getOpenidUrl="https://api.weixin.qq.com/sns/oauth2/access_token?appid=".APPID."&secret=".APPSECRET."&code=".$code."&grant_type=authorization_code";
- $response=http_request($getOpenidUrl);
- $openIdObj=json_decode($response);
- $openid=$openIdObj->openid;
- setcookie('user_openid', $openid, 0, '/');
- }
- }
- require_once "jssdk.php";
- $jssdk = new JSSDK(APPID, APPSECRET);
- $signPackage = $jssdk->GetSignPackage();
- $pdo=conn();
- $sql="select a.pos_x,a.pos_y
- from run_bus_pos as a
- inner join (
- select RUN_ID,RUN_BUS_ORDER_ID
- from order_main
- where PARENT_ORDER_ID=(
- select order_id
- from order_weixin_bond
- where weixin_open_id='".$openid."'
- order by id desc
- limit 1)
- and CANCEL_FLAG=0 and ORDER_VALID_STATUS=1 and IF_LAST_PROD=1 limit 1
- ) as b on a.run_id=b.RUN_ID and a.bus_no=b.RUN_BUS_ORDER_ID ORDER BY a.log_time DESC LIMIT 1";
-
- write_log($sql);
-
- $result=$pdo->query($sql);
- $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- write_log($rowset[0]['pos_x'].",".$rowset[0]['pos_y']);
- $latitude=isset($rowset[0]['pos_x']) && !empty($rowset[0]['pos_x']) ?$rowset[0]['pos_x']:31.2031650000;
- $longitude=isset($rowset[0]['pos_y']) && !empty($rowset[0]['pos_y']) ?$rowset[0]['pos_y']:121.3214510000;
- convert_baidumap_to_tencentmap($latitude,$longitude);
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- </head>
- <body>
- </body>
- <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
- <script>
- /*
- * 注意:
- * 1. 所有的JS接口只能在公众号绑定的域名下调用,公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。
- * 2. 如果发现在 Android 不能分享自定义内容,请到官网下载最新的包覆盖安装,Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
- * 3. 常见问题及完整 JS-SDK 文档地址:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
- *
- * 开发中遇到问题详见文档“附录5-常见错误及解决办法”解决,如仍未能解决可通过以下渠道反馈:
- * 邮箱地址:weixin-open@qq.com
- * 邮件主题:【微信JS-SDK反馈】具体问题
- * 邮件内容说明:用简明的语言描述问题所在,并交代清楚遇到该问题的场景,可附上截屏图片,微信团队会尽快处理你的反馈。
- */
-
- wx.config({
- debug: false,
- appId: '<?php echo $signPackage["appId"];?>',
- timestamp: <?php echo $signPackage["timestamp"];?>,
- nonceStr: '<?php echo $signPackage["nonceStr"];?>',
- signature: '<?php echo $signPackage["signature"];?>',
- jsApiList: [
- // 所有要调用的 API 都要加到这个列表中
- 'hideOptionMenu',
- 'openLocation',
- //'closeWindow'
- ]
- });
- wx.ready(function () {
- // 在这里调用 API
- wx.hideOptionMenu();
- wx.openLocation({
- latitude: <?php echo $latitude; ?>, // 纬度,浮点数,范围为90 ~ -90
- longitude:<?php echo $longitude; ?> , // 经度,浮点数,范围为180 ~ -180。
- name: ' ', // 位置名
- address: ' ', // 地址详情说明
- // name: '这是测试名称', // 位置名
- // address: 'asf', // 地址详情说明
- scale: 14, // 地图缩放级别,整形值,范围从1~28。默认为最大
- infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
- });
- wx.closeWindow();
- });
- </script>
-
- </html>
|