wanglizhong
2025-05-05 2876dd05c0528ec665791a0844f643f566f7c31b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?php include "./inc/odbc.php"; ?>
<?php include "./inc/function.php"; ?>
<?php 
$OrdID=empty($_REQUEST['OrdID'])!=false ? "" : $_REQUEST['OrdID'];
$time=empty($_REQUEST['time'])!=false ? "" : $_REQUEST['time'];
$sign=empty($_REQUEST['sign'])!=false ? "" : $_REQUEST['sign'];
include "./inc/OAuth2.php";
if ($OrdID=="" or $time=="" or $sign==""){header("Location: /OrdEvaluateError.asp");exit;}
if ($sign!=MD5($OrdID.$time.$GPSKey)){header("Location: /OrdEvaluateError.asp");exit;}
 
//微信JS
require_once "./inc/jssdk.php";
$jssdk = new JSSDK($APPID, $APPSECRET);
$signPackage = $jssdk->GetSignPackage();
$ShareURL="https://wx.966120.com.cn/CarGPS.php?OrdID=$OrdID&time=$time&sign=$sign";
 
//调度单数据
$sql="select DispatchOrdCarID from DispatchOrd where DispatchOrdState>=6 and DispatchOrdState<7 and DispatchOrdID=".$OrdID;
$data = sqlsrv_query($conn,$sql);
if($data == true){
    if (sqlsrv_rows_affected($data)!=0) {
        while($rs = sqlsrv_fetch_array($data) ) {
            $CarID        = $rs['DispatchOrdCarID'];        //派遣车辆ID
        }
    }else{
        header("Location: /OrdEvaluateError.asp?ErrorID=3");exit;
    }
}
//车辆数据
$sql="select CarLicense,GPS_IMEI from CarData where CarID=".$CarID;
//echo $sql;
$data = sqlsrv_query($conn,$sql);
if($data == true){
    if (sqlsrv_rows_affected($data)!=0) {
        while($rs = sqlsrv_fetch_array($data) ) {
            $CarLicense    = $rs['CarLicense'];
            $imeis        = $rs['GPS_IMEI'];
        }
    }else{
        header("Location: /");exit;
    }
}
 
//GPS接口信息
$account="966120";
$accountpass="966120888";
$access_token=GetAccess_token();
 
//获取GPS access_token
Function GetAccess_token() {
    $access_tokenID=4039;    //对应数据库ID 
    global $conn;
    global $account;
    global $accountpass;
    $sql = "select vtext,vMono from dictionary where id=".$access_tokenID;
    //echo $sql;exit;
    $dataDt = sqlsrv_query($conn,$sql);
    if($dataDt == true){
        while($rs = sqlsrv_fetch_array( $dataDt, SQLSRV_FETCH_ASSOC) ) {
            $access_token=$rs['vtext'];
            $access_token_time=$rs['vMono'];
            if(strtotime($access_token_time)<strtotime(date("y-m-d h:i:s"))){
                $data_url="http://api.gpsoo.net/1/auth/access_token?account=".$account."&time=".time()."&signature=".MD5(MD5($accountpass).time());
                $datainfo=file_get_contents($data_url);
                $datainfo=json_decode($datainfo,true);
                if ($datainfo['ret']==0){
                    $access_token=$datainfo['access_token'];
                    $sql="update dictionary set vtext='".$access_token."',vMono='".date("Y-m-d H:i:s",time()+7200)."' where id=".$access_tokenID;
                    $UPsql = sqlsrv_query($conn,$sql);
                }else{
                    header("Location: /");exit;
                }
            }
        }
    }
    return $access_token;
}
 
$data_url='http://api.gpsoo.net/1/devices/tracking?access_token='.$access_token."&imeis=".$imeis."&map_type=BAIDU&time=".time();
$datainfo=file_get_contents($data_url);
$datainfo=json_decode($datainfo,true);
//var_dump($datainfo);exit;
if ($datainfo['ret']==0){
    foreach ($datainfo['data'] as $ArrayValue) {
        $data_imei        = $ArrayValue['imei'];            //设备IMEI
        $device_info    = $ArrayValue['device_info'];    //0:正常数据 1:设备未上线 2:设备已过期 3:设备离线
        $data_lng        = $ArrayValue['lng'];            //经度
        $data_lat        = $ArrayValue['lat'];            //纬度
        $data_course    = $ArrayValue['course'];        //航向
        $data_speed        = $ArrayValue['speed'];            //速度
    }
}else{
    header("Location: /");exit;
}
?>
 
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="refresh" content="10">
    <style type="text/css">
        body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;}
        #golist {display: none;}
        @media (max-device-width: 780px){#golist{display: block !important;}}
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?ak=vZk06XkStGGYT4ZGreQb0a6TsOLym4hR&v=2.0"></script>
    <title>实时位置</title>
<style>
*{margin:0px;padding: 0px;}
#shareit {-webkit-user-select: none;display: none;position: absolute;width: 100%;height: 100%;
  background: rgba(0,0,0,0.85);text-align: center;top: 0;left: 0;z-index: 105;
}
#shareit img { max-width: 100%;}
.arrow {position: absolute; right: 10%;top: 5%;}
#follow{width: 100%;height: 50px;line-height: 50px;text-align: center; text-decoration: none;font-size: 18px;color: white;float: left;margin-top: 400px;}
ul{width: 100%;list-style: none;text-align: center;margin-bottom: 10px;}
ul li{height: 30px;width: 70%;line-height: 30px;margin-left: 15%; background: #d9534f; margin-top: 10px;border-radius: 5px;}
ul li a{text-decoration: none;color: white;display: block;}
 
</style>
</head>
<body>
<div  style="text-align:center;margin-top:20px"><img src="img/top.png" width="90%" height="" border="0" alt=""></div>
<ul><li><a id="share_btn" href="javascript:;">分享给朋友<?php echo http_build_query($_GET);?></a></li></ul>
<hr style="text-align:center;width:100%"></hr>
<div id="shareit">
  <img class="arrow" src="/img/guide1.png">
  <a href="#" id="follow">点击右上角按钮,分享给朋友</a>
</div>
<script src="/js/jquery-1.10.2.min.js"></script>
<script>
  //为TA拉票
  $("#share_btn").on("click", function() {
      $("#shareit").show();
  });
  $("#shareit").on("click", function(){
    $("#shareit").hide();
  })
</script>
 
    <div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
// 百度地图API功能
var map = new BMap.Map("allmap");
map.centerAndZoom(new BMap.Point(<?php echo $data_lng?>, <?php echo $data_lat?>), 15);
 
//map.addControl(new BMap.ZoomControl());  //添加地图缩放控件
var marker1 = new BMap.Marker(new BMap.Point(<?php echo $data_lng?>, <?php echo $data_lat?>));  //创建标注
map.addOverlay(marker1);                 // 将标注添加到地图中
//创建信息窗口
var infoWindow1 = new BMap.InfoWindow("<?php echo $CarLicense?><br/>速度:<?php echo $data_speed?>km/h");
marker1.addEventListener("click", function(){this.openInfoWindow(infoWindow1);});
</script>
 
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script>
  wx.config({
    appId: '<?php echo $signPackage["appId"];?>',
    timestamp: <?php echo $signPackage["timestamp"];?>,
    nonceStr: '<?php echo $signPackage["nonceStr"];?>',
    signature: '<?php echo $signPackage["signature"];?>',
    jsApiList: [
      // 所有要调用的 API 都要加到这个列表中
        'checkJsApi',
        'updateAppMessageShareData',
        'updateTimelineShareData'
    ]
  });
  wx.ready(function () {
    // 在这里调用 API
    //自定义“分享给朋友”及“分享到QQ”按钮的分享内容(1.4.0)
    wx.updateAppMessageShareData({ 
        title: '共享在【966120医疗快线】转运中的车辆信息', // 分享标题
        desc: '查看正在为您服务中的966120车辆信息,包括车牌号、实时位置和车速。', // 分享描述
        link: '<?php echo $ShareURL?>', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
        imgUrl: 'https://wx.966120.com.cn/img/20181102151700.png', // 分享图标
        success: function () {
          // 设置成功
        }
    });
    //自定义“分享到朋友圈”及“分享到QQ空间”按钮的分享内容(1.4.0)
    wx.updateTimelineShareData({ 
        title: '共享在【966120医疗快线】转运中的车辆信息', // 分享标题
        link: '<?php echo $ShareURL?>', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
        imgUrl: 'https://wx.966120.com.cn/img/20181102151700.png', // 分享图标
        success: function () {
          // 设置成功
        }
    });
  });
</script>