Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
335087fa
Commit
335087fa
authored
May 23, 2023
by
陈颖
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
~
parent
3abd9456
Pipeline
#47836
passed with stage
in 2 minutes 31 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
42 deletions
+32
-42
helper.js
app/extend/helper.js
+30
-41
config.default.js
config/config.default.js
+2
-1
No files found.
app/extend/helper.js
View file @
335087fa
...
@@ -185,34 +185,6 @@ module.exports = {
...
@@ -185,34 +185,6 @@ module.exports = {
return
gps
;
return
gps
;
},
},
async
parseGps
(
gps
)
{
if
(
!
gps
||
gps
.
indexOf
(
','
)
===
-
1
)
{
return
''
;
}
const
gps_arr
=
gps
.
split
(
','
);
if
(
Math
.
abs
(
gps_arr
[
0
])
>=
90
)
{
gps_arr
.
reverse
();
gps
=
gps_arr
.
join
(
','
);
}
const
data
=
{
ak
:
'kpqBbfkKx9HvdhfAAEybyy0ATwaZgimI'
,
pois
:
0
,
output
:
'json'
,
location
:
gps
,
};
const
{
ctx
}
=
this
;
const
resp
=
await
ctx
.
curl
(
'http://api.map.baidu.com/geocoder/v2/'
,
{
timeout
:
3000
,
dataType
:
'json'
,
method
:
'GET'
,
data
});
const
ret
=
resp
.
data
;
if
(
ret
.
status
!=
0
)
{
return
{};
}
return
ret
;
},
async
getGPS
(
address
,
city
)
{
async
getGPS
(
address
,
city
)
{
console
.
info
(
address
);
console
.
info
(
address
);
const
baidu_url
=
'https://api.map.baidu.com/geocoder/v2/'
;
const
baidu_url
=
'https://api.map.baidu.com/geocoder/v2/'
;
...
@@ -226,28 +198,45 @@ module.exports = {
...
@@ -226,28 +198,45 @@ module.exports = {
},
},
// 根据IP地址来处理业务的展示与否
// 根据IP地址来处理业务的展示与否
async
parseIp
()
{
async
parseIp
(
ip
=
''
)
{
const
ip
=
this
.
getClientIP
();
const
{
app
}
=
this
;
//
// ip = '122.224.130.226';
if
(
!
ip
)
{
if
(
!
ip
)
{
return
''
;
ip
=
this
.
getClientIP
()
;
}
}
const
ip_city_key
=
`ip_city_
${
ip
}
`
;
let
ret
=
{};
ret
=
await
app
.
memcache
.
get
(
ip_city_key
);
if
(
ret
&&
Object
.
keys
(
ret
).
length
!==
0
)
{
return
ret
;
}
const
txmap
=
await
this
.
getTaskIp
(
ip
);
if
(
Object
.
keys
(
txmap
).
length
!==
0
)
{
ret
=
txmap
.
info
;
}
await
app
.
memcache
.
set
(
ip_city_key
,
ret
,
5
);
return
ret
;
},
async
getTaskIp
(
ip
)
{
const
{
ctx
,
app
}
=
this
;
const
url
=
`
${
app
.
config
.
NODE_BASE_URL
}
/apply/task-ip`
;
const
data
=
{
const
data
=
{
ak
:
'kpqBbfkKx9HvdhfAAEybyy0ATwaZgimI'
,
output
:
'json'
,
ip
,
ip
,
source
:
'腾讯地图app-server'
,
key
:
app
.
config
.
TencentIpKey
,
};
};
const
{
ctx
}
=
this
;
const
ret
=
await
ctx
.
curl
(
url
,
{
const
resp
=
await
ctx
.
curl
(
'https://api.map.baidu.com/location/ip'
,
{
timeout
:
3000
,
dataType
:
'json'
,
method
:
'GET'
,
data
});
method
:
'POST'
,
data
,
dataType
:
'json'
,
contentType
:
'json'
,
});
const
ret
=
resp
.
data
;
app
.
logger
.
info
(
JSON
.
stringify
({
url
,
status
:
ret
.
status
,
res
:
ret
.
data
}))
;
if
(
ret
.
status
!=
0
)
{
if
(
ret
.
status
!=
=
20
0
)
{
return
{};
return
{};
}
}
return
ret
;
return
ret
.
data
;
},
},
async
check_submit_frequent
(
redis_key
,
expire
=
5
)
{
async
check_submit_frequent
(
redis_key
,
expire
=
5
)
{
...
...
config/config.default.js
View file @
335087fa
...
@@ -29,6 +29,7 @@ module.exports = appInfo => {
...
@@ -29,6 +29,7 @@ module.exports = appInfo => {
jsonLimit
:
'10mb'
,
jsonLimit
:
'10mb'
,
formLimit
:
'10mb'
,
formLimit
:
'10mb'
,
};
};
// 腾讯地图 key
config
.
TencentIpKey
=
'MSMBZ-LMTKZ-6STXT-ZUIE4-SOO7E-W4BO4'
;
return
config
;
return
config
;
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment