Skip to content

Commit 93951e0

Browse files
committed
add parameter
1 parent 549273e commit 93951e0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

_posts/2019-02-02-car-location.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@
6868
function $(id){
6969
return document.getElementById(id);
7070
}
71+
function getParameter(key){
72+
var searchArr = location.search.slice(1).split('&');
73+
for(let i = 0; i < searchArr.length; i++){
74+
let searchItem = searchArr[i].split('=');
75+
if(searchItem[0] == key){
76+
return decodeURIComponent(searchItem[1]);
77+
}
78+
}
79+
}
7180
/* function getNormalizedDateTimeString(date){//date是标准的Date对象
7281
var iosString = date.toISOString();
7382
return iosString.replace(/\..+/, '');
@@ -286,10 +295,14 @@
286295
this.baiduMap.init(this.baiduMapCtn);
287296
var _this = this;
288297
this.initTimeRound(new Date());
289-
if(localStorage.getItem('apiKey')){//0XlwMJm8U42KEZ394N4p8hm2p=s=
298+
if(getParameter('apikey')){
299+
$apiKey.value = getParameter('apikey');
300+
}else if(localStorage.getItem('apiKey')){//0XlwMJm8U42KEZ394N4p8hm2p=s=
290301
$apiKey.value = localStorage.getItem('apiKey');
291302
}
292-
if(localStorage.getItem('deviceId')){//517162506
303+
if(getParameter('deviceid')){
304+
$deviceId.value = getParameter('deviceid');
305+
}else if(localStorage.getItem('deviceId')){//517162506
293306
$deviceId.value = localStorage.getItem('deviceId');
294307
}
295308
if(localStorage.getItem('pointCount')){//500

0 commit comments

Comments
 (0)