Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
micro-customization-system
/
e-shield-miniprogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 48fc6a15
authored
Apr 27, 2022
by
zhangxw
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
找车页面修改
1 parent
648a9ae2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
88 deletions
pages/newFindCar/findCar.js
pages/newFindCar/findCar.js
View file @
48fc6a1
...
...
@@ -74,92 +74,74 @@ Page({
getData
()
{
this
.
getVehicleData
()
},
getVehicleData
(){
async
getVehicleData
(){
if
(
this
.
data
.
sns
){
this
.
setData
({
isLoading
:
true
})
WXRequest
.
get
(
'trialdrive/api/vehicle/location'
,
{
sns
:
decodeURIComponent
(
this
.
data
.
sns
)
},
true
).
then
(
res
=>
{
this
.
setData
({
isLoading
:
false
})
if
(
res
.
code
==
200
)
{
let
[
markers
,
includePoints
]
=
[[],
[]]
if
(
res
.
data
.
length
>
0
)
{
res
.
data
.
forEach
(
item
=>
{
markers
.
push
({
id
:
Number
(
item
.
sn
),
// 设备号唯一 可作为markerid
width
:
28
,
height
:
36
,
latitude
:
Number
(
item
[
'gpsLocation'
].
elat
),
// 默认显示GPS定位位置
longitude
:
Number
(
item
[
'gpsLocation'
].
elng
),
iconPath
:
item
.
source
===
1
?
'../../images/oncar.png'
:
'../../images/offcar.png'
})
includePoints
.
push
({
latitude
:
item
[
'gpsLocation'
].
elat
,
longitude
:
item
[
'gpsLocation'
].
elng
,
padding
:
[
80
,
80
,
80
,
80
]
})
item
.
type
=
'gpsLocation'
// 默认显示GPS的定位类型
let
res
=
await
WXRequest
.
get
(
'trialdrive/api/vehicle/location'
,
{
sns
:
decodeURIComponent
(
this
.
data
.
sns
)},
true
)
if
(
res
)
this
.
setData
({
isLoading
:
false
})
if
(
res
.
code
==
200
)
{
let
[
markers
,
includePoints
]
=
[[],
[]]
if
(
res
.
data
.
length
>
0
)
{
for
(
var
i
=
0
;
i
<
res
.
data
.
length
;
i
++
)
{
markers
.
push
({
id
:
Number
(
res
.
data
[
i
].
sn
),
// 设备号唯一 可作为markerid
width
:
28
,
height
:
36
,
latitude
:
Number
(
res
.
data
[
i
][
'gpsLocation'
].
elat
),
// 默认显示GPS定位位置
longitude
:
Number
(
res
.
data
[
i
][
'gpsLocation'
].
elng
),
iconPath
:
res
.
data
[
i
].
source
===
1
?
'../../images/oncar.png'
:
'../../images/offcar.png'
})
this
.
myMap
.
setData
({
// 防止页面跳转回退页面未保留用户的操作 用mapContext 会有问题
inPoints
:
includePoints
includePoints
.
push
({
latitude
:
res
.
data
[
i
][
'gpsLocation'
].
elat
,
longitude
:
res
.
data
[
i
][
'gpsLocation'
].
elng
,
padding
:
[
80
,
80
,
80
,
80
]
})
wx
.
getSystemInfo
({
success
:
(
res
)
=>
{
if
(
res
.
platform
==
'devtools'
)
{
// 开发工具上include-points 失效
res
.
data
[
i
].
type
=
'gpsLocation'
// 默认显示GPS的定位类型
let
typeArr
=
[
'gpsLocation'
,
'bsLocation'
]
for
(
var
j
=
0
;
j
<
typeArr
.
length
;
j
++
)
{
await
this
.
getTransferAddress
(
res
.
data
[
i
],
typeArr
[
j
])
}
}
this
.
setData
({
carInfoArr
:
res
.
data
,
includePoints
:
includePoints
,
markers
:
markers
})
wx
.
getSystemInfo
({
success
:
(
res
)
=>
{
console
.
log
(
res
)
if
(
res
.
platform
==
'devtools'
)
{
// 开发工具上include-points 失效
console
.
log
(
'123'
)
this
.
myMap
.
getMapCtx
().
includePoints
({
points
:
includePoints
,
padding
:
[
80
,
80
,
80
,
80
]
points
:
includePoints
,
padding
:
[
80
,
80
,
80
,
80
]
})
}
else
{
}
else
{
this
.
myMap
.
setData
({
// 防止页面跳转回退页面未保留用户的操作 用mapContext 会有问题
inPoints
:
includePoints
inPoints
:
includePoints
})
}
}
})
this
.
setData
({
carInfoArr
:
res
.
data
,
includePoints
:
includePoints
,
markers
:
markers
})
}
else
{
wx
.
showModal
({
content
:
'暂无数据'
,
showCancel
:
false
})
}
}
})
}
else
{
wx
.
showModal
({
content
:
'暂无数据'
,
showCancel
:
false
})
}
}
)
}
}
}
},
// 显示对应marker详情
getCarInfoWindowObj
(
e
)
{
let
data
=
this
.
data
.
carInfoArr
.
find
(
item
=>
Number
(
item
.
sn
)
===
e
.
detail
.
markerId
)
// 根据坐标返回详细地址
let
_this
=
this
_this
.
moveToLocation
(
Number
(
data
[
data
[
'type'
]].
elat
),
Number
(
data
[
data
[
'type'
]].
elng
))
if
(
data
[
data
[
'type'
]].
transferAddress
)
{
_this
.
setData
({
isShowCarInfoWindow
:
true
,
carInfoWindowObj
:
data
,
})
return
}
wx
.
request
({
url
:
`https://apis.map.qq.com/ws/geocoder/v1/?key=46XBZ-RVUCD-FI34X-H66JJ-HZ5FS-3YFID&location=`
+
data
[
data
[
'type'
]].
elat
+
','
+
data
[
data
[
'type'
]].
elng
,
success
:
res
=>
{
if
(
res
.
statusCode
===
200
)
{
data
[
data
[
'type'
]].
transferAddress
=
res
.
data
&&
res
.
data
.
result
.
address_component
.
province
===
res
.
data
.
result
.
address_component
.
city
?
(
res
.
data
.
result
.
address_component
.
city
+
''
+
res
.
data
.
result
.
formatted_addresses
.
rough
)
:
(
res
.
data
.
result
.
address_component
.
province
+
''
+
res
.
data
.
result
.
address_component
.
city
+
''
+
res
.
data
.
result
.
formatted_addresses
.
rough
)
_this
.
setData
({
carInfoWindowObj
:
data
,
isShowCarInfoWindow
:
true
})
}
}
_this
.
setData
({
isShowCarInfoWindow
:
true
,
carInfoWindowObj
:
data
,
})
},
findCarClick
()
{
...
...
@@ -242,29 +224,22 @@ Page({
markers
:
markers
})
this
.
moveToLocation
(
Number
(
this
.
data
.
carInfoWindowObj
[
'bsLocation'
].
elat
),
Number
(
this
.
data
.
carInfoWindowObj
[
'bsLocation'
].
elng
))
if
(
this
.
data
.
carInfoWindowObj
[
'bsLocation'
].
transferAddress
)
return
wx
.
request
({
url
:
`https://apis.map.qq.com/ws/geocoder/v1/?key=46XBZ-RVUCD-FI34X-H66JJ-HZ5FS-3YFID&location=`
+
this
.
data
.
carInfoWindowObj
[
'bsLocation'
].
elat
+
','
+
this
.
data
.
carInfoWindowObj
[
'bsLocation'
].
elng
,
success
:
res
=>
{
if
(
res
.
statusCode
===
200
)
{
let
transferAddress
=
res
.
data
&&
res
.
data
.
result
.
address_component
.
province
===
res
.
data
.
result
.
address_component
.
city
?
(
res
.
data
.
result
.
address_component
.
city
+
''
+
res
.
data
.
result
.
formatted_addresses
.
rough
)
:
(
res
.
data
.
result
.
address_component
.
province
+
''
+
res
.
data
.
result
.
address_component
.
city
+
''
+
res
.
data
.
result
.
formatted_addresses
.
rough
)
data
[
'bsLocation'
].
transferAddress
=
transferAddress
carInfoArr
.
forEach
(
val
=>
{
if
(
val
.
sn
===
this
.
data
.
carInfoWindowObj
.
sn
)
{
val
.
type
=
'bsLocation'
val
[
'bsLocation'
].
transferAddress
=
transferAddress
}
})
this
.
setData
({
carInfoWindowObj
:
data
,
carInfoArr
:
carInfoArr
})
}
}
})
break
}
},
async
getTransferAddress
(
data
,
typeItem
)
{
new
Promise
(
async
reslove
=>
{
wx
.
request
({
url
:
`https://apis.map.qq.com/ws/geocoder/v1/?key=46XBZ-RVUCD-FI34X-H66JJ-HZ5FS-3YFID&location=`
+
data
[
typeItem
].
elat
+
','
+
data
[
typeItem
].
elng
,
success
:
res
=>
{
if
(
res
.
statusCode
===
200
)
{
data
[
typeItem
].
transferAddress
=
res
.
data
&&
res
.
data
.
result
.
address_component
.
province
===
res
.
data
.
result
.
address_component
.
city
?
(
res
.
data
.
result
.
address_component
.
city
+
''
+
res
.
data
.
result
.
formatted_addresses
.
rough
)
:
(
res
.
data
.
result
.
address_component
.
province
+
''
+
res
.
data
.
result
.
address_component
.
city
+
''
+
res
.
data
.
result
.
formatted_addresses
.
rough
)
reslove
()
}
}
})
})
},
moveToLocation
:
function
(
latitude
,
longitude
)
{
this
.
myMap
.
getMapCtx
().
moveToLocation
({
longitude
:
Number
(
longitude
),
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment