You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

103 lines
4.0 KiB

  1. <?php
  2. require_once '../Common/Config.php';
  3. require_once '../Common/driver_config.php';
  4. require_once __DIR__.'/../Common/Function.php';
  5. $openid=isset($_COOKIE['user_openid'])?$_COOKIE['user_openid']:'';
  6. $code=isset($_GET['code'])?$_GET['code']:'';
  7. if ($openid==''){
  8. if ($code ==''){
  9. $selfUrl=urlencode("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
  10. $getCodeUrl="https://open.weixin.qq.com/connect/oauth2/authorize?appid=".APPID."&redirect_uri=".$selfUrl."&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
  11. Header("Location: $getCodeUrl");
  12. exit();
  13. }else{
  14. $getOpenidUrl="https://api.weixin.qq.com/sns/oauth2/access_token?appid=".APPID."&secret=".APPSECRET."&code=".$code."&grant_type=authorization_code";
  15. $response=http_request($getOpenidUrl);
  16. $openIdObj=json_decode($response);
  17. $openid=$openIdObj->openid;
  18. setcookie('user_openid', $openid, 0, '/');
  19. }
  20. }
  21. require_once "jssdk.php";
  22. $jssdk = new JSSDK(APPID, APPSECRET);
  23. $signPackage = $jssdk->GetSignPackage();
  24. $pdo=conn();
  25. $sql="select a.pos_x,a.pos_y
  26. from run_bus_pos as a
  27. inner join (
  28. select RUN_ID,RUN_BUS_ORDER_ID
  29. from order_main
  30. where PARENT_ORDER_ID=(
  31. select order_id
  32. from order_weixin_bond
  33. where weixin_open_id='".$openid."'
  34. order by id desc
  35. limit 1)
  36. and CANCEL_FLAG=0 and ORDER_VALID_STATUS=1 and IF_LAST_PROD=1 limit 1
  37. ) 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";
  38. write_log($sql);
  39. $result=$pdo->query($sql);
  40. $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
  41. $result->closeCursor();
  42. write_log($rowset[0]['pos_x'].",".$rowset[0]['pos_y']);
  43. $latitude=isset($rowset[0]['pos_x']) && !empty($rowset[0]['pos_x']) ?$rowset[0]['pos_x']:31.2031650000;
  44. $longitude=isset($rowset[0]['pos_y']) && !empty($rowset[0]['pos_y']) ?$rowset[0]['pos_y']:121.3214510000;
  45. convert_baidumap_to_tencentmap($latitude,$longitude);
  46. ?>
  47. <!DOCTYPE html>
  48. <html lang="en">
  49. <head>
  50. <meta charset="UTF-8">
  51. <meta name="viewport" content="width=device-width, initial-scale=1" />
  52. </head>
  53. <body>
  54. </body>
  55. <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
  56. <script>
  57. /*
  58. * 注意:
  59. * 1. 所有的JS接口只能在公众号绑定的域名下调用,公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。
  60. * 2. 如果发现在 Android 不能分享自定义内容,请到官网下载最新的包覆盖安装,Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
  61. * 3. 常见问题及完整 JS-SDK 文档地址:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
  62. *
  63. * 开发中遇到问题详见文档“附录5-常见错误及解决办法”解决,如仍未能解决可通过以下渠道反馈:
  64. * 邮箱地址:weixin-open@qq.com
  65. * 邮件主题:【微信JS-SDK反馈】具体问题
  66. * 邮件内容说明:用简明的语言描述问题所在,并交代清楚遇到该问题的场景,可附上截屏图片,微信团队会尽快处理你的反馈。
  67. */
  68. wx.config({
  69. debug: false,
  70. appId: '<?php echo $signPackage["appId"];?>',
  71. timestamp: <?php echo $signPackage["timestamp"];?>,
  72. nonceStr: '<?php echo $signPackage["nonceStr"];?>',
  73. signature: '<?php echo $signPackage["signature"];?>',
  74. jsApiList: [
  75. // 所有要调用的 API 都要加到这个列表中
  76. 'hideOptionMenu',
  77. 'openLocation',
  78. //'closeWindow'
  79. ]
  80. });
  81. wx.ready(function () {
  82. // 在这里调用 API
  83. wx.hideOptionMenu();
  84. wx.openLocation({
  85. latitude: <?php echo $latitude; ?>, // 纬度,浮点数,范围为90 ~ -90
  86. longitude:<?php echo $longitude; ?> , // 经度,浮点数,范围为180 ~ -180。
  87. name: ' ', // 位置名
  88. address: ' ', // 地址详情说明
  89. // name: '这是测试名称', // 位置名
  90. // address: 'asf', // 地址详情说明
  91. scale: 14, // 地图缩放级别,整形值,范围从1~28。默认为最大
  92. infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
  93. });
  94. wx.closeWindow();
  95. });
  96. </script>
  97. </html>