Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bms
Overview
Overview
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
iambtr
bms
Commits
2ce1960b
Commit
2ce1960b
authored
May 10, 2020
by
王榕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
电池接口接入
parent
a416261c
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
540 additions
and
945 deletions
+540
-945
common.wxml
components/title/common.wxml
+20
-19
index.js
config/index.js
+5
-5
util.js
lib/util.js
+12
-0
batteryHeath.js
pages/batteryHeath/batteryHeath.js
+114
-129
batteryHeath.wxml
pages/batteryHeath/batteryHeath.wxml
+11
-11
batteryHeath.wxss
pages/batteryHeath/batteryHeath.wxss
+12
-0
index.js
pages/car_action/index.js
+142
-412
index.wxml
pages/car_action/index.wxml
+11
-13
pay.js
pages/pay/pay.js
+6
-1
pay.wxml
pages/pay/pay.wxml
+2
-2
register2.js
pages/register2/register2.js
+1
-18
user_device_list.js
pages/user_device_list/user_device_list.js
+4
-3
defaultAvator.png
pages/user_index/defaultAvator.png
+0
-0
user_index.js
pages/user_index/user_index.js
+153
-303
user_index.wxml
pages/user_index/user_index.wxml
+46
-28
user_index.wxss
pages/user_index/user_index.wxss
+1
-1
No files found.
components/title/common.wxml
View file @
2ce1960b
<view>
<view class="custom_nav" style="height:{{navbarHeight}}px;">
<
cover-
view class="custom_nav" style="height:{{navbarHeight}}px;">
<view class="custom_nav_box" style="height:{{navbarHeight}}px;">
<view class="custom_nav_bar" style="top:{{statusBarHeight}}px; height:{{cusnavH}}px;">
<
cover-
view class="custom_nav_box" style="height:{{navbarHeight}}px;">
<
cover-
view class="custom_nav_bar" style="top:{{statusBarHeight}}px; height:{{cusnavH}}px;">
<block wx:if="{{isSearch}}">
<input class="navSearch" style="height:{{navbarBtn.height-2}}px;line-height:{{navbarBtn.height-4}}px; top:{{navbarBtn.top+1}}px; left:{{navbarBtn.right}}px; border-radius:{{navbarBtn.height/2}}px;" maxlength="10" bindinput="bindKeyInput" placeholder="输入文字搜索"
/>
</block>
<block wx:else>
<view class="custom_nav_icon {{!haveBack||'borderLine'}}" style="height:{{navbarBtn.height}}px;line-height:{{navbarBtn.height-2}}px; top:{{navbarBtn.top}}px; left:{{navbarBtn.right}}px; border-radius:{{navbarBtn.height/2}}px;">
<view wx:if="{{haveBack}}" class="icon-back" bindtap='_goBack'>
<
image src='./back.png' mode='aspectFill' class='back-pre'></
image>
</view>
<
view wx:if="{{haveBack}}" class='navbar-v-line'></
view>
<view class="icon-home">
<view class="home_a" catchtap="_clickLeftIcon">
<
image src='{{more?moreIcon:homeIcon}}' mode='aspectFill' class='back-home'></
image>
</view>
</view>
</view>
<view class="nav_title" style="height:{{cusnavH}}px; line-height:{{cusnavH}}px;">
<
cover-
view class="custom_nav_icon {{!haveBack||'borderLine'}}" style="height:{{navbarBtn.height}}px;line-height:{{navbarBtn.height-2}}px; top:{{navbarBtn.top}}px; left:{{navbarBtn.right}}px; border-radius:{{navbarBtn.height/2}}px;">
<
cover-
view wx:if="{{haveBack}}" class="icon-back" bindtap='_goBack'>
<
cover-image src='./back.png' mode='aspectFill' class='back-pre'></cover-
image>
</
cover-
view>
<
cover-view wx:if="{{haveBack}}" class='navbar-v-line'></cover-
view>
<
cover-
view class="icon-home">
<
cover-
view class="home_a" catchtap="_clickLeftIcon">
<
cover-image src='{{more?moreIcon:homeIcon}}' mode='aspectFill' class='back-home'></cover-
image>
</
cover-
view>
</
cover-
view>
</
cover-
view>
<
cover-
view class="nav_title" style="height:{{cusnavH}}px; line-height:{{cusnavH}}px;">
{{vTitle}}
</view>
</
cover-
view>
</block>
</view>
</view>
</view>
</
cover-
view>
</
cover-
view>
</
cover-
view>
<!-- <view style="height:{{navbarHeight}}rpx;"></view> -->
<slot />
</view>
\ No newline at end of file
config/index.js
View file @
2ce1960b
//
const type = 'dev'
const
type
=
'pro'
const
type
=
'dev'
//
const type = 'pro'
var
config
=
{
dev
:
{
appid
:
'wxb517dae1188a1900'
,
api
:
'http://
192.168.0.102:9995
/app/'
,
api
:
'http://
47.92.207.93:8084
/app/'
,
wss
:
'wss://app.doomore.cn/websocket/app/api/'
,
payapi
:
'http://
192.168.0.102:9995
/pay/'
,
rapi
:
'http
s://app.doomore.cn/repair
/app/'
,
//repair
payapi
:
'http://
47.92.207.93:8084
/pay/'
,
rapi
:
'http
://47.92.207.93:8084
/app/'
,
//repair
version
:
'v1.0.00'
,
imgPath
:
'/static/image/'
},
...
...
lib/util.js
View file @
2ce1960b
...
...
@@ -773,9 +773,21 @@ function getPx(rpx) {
function
getRpx
(
px
)
{
return
px
*
750
/
windowWidth
}
function
arrTarrs
(
num
,
arr
)
{
// 一维数组转换为二维数组
const
iconsArr
=
[];
// 声明数组
arr
.
forEach
((
item
,
index
)
=>
{
const
page
=
Math
.
floor
(
index
/
num
);
// 计算该元素为第几个素组内
if
(
!
iconsArr
[
page
])
{
// 判断是否存在
iconsArr
[
page
]
=
[];
}
iconsArr
[
page
].
push
(
item
);
});
return
iconsArr
;
}
module
.
exports
=
{
formatTime
,
imgName
,
arrTarrs
,
api
,
getUserInfo
,
wxLogin
,
...
...
pages/batteryHeath/batteryHeath.js
View file @
2ce1960b
...
...
@@ -13,134 +13,56 @@ const {
userLocation
,
getRgbColor
,
getPx
,
arrTarrs
,
wxscan
}
=
require
(
'../../lib/util.js'
)
const
moment
=
require
(
'../../lib/moment.js'
)
let
cmd
=
null
let
app
=
getApp
()
let
timer
Page
({
/**
* 页面的初始数据
*/
data
:
{
vos
:
[
[{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
}],
[{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
}],
[{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
}],
[{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
msg
:
true
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
}]
gprsImei
:
''
,
bmsVer
:
''
,
bmsVolt
:
''
,
bmsCurrent
:
''
,
bmsState
:
''
,
bmsCycles
:
''
,
bmsSoc
:
''
,
gpsSnr
:
''
,
gpsLocate
:
''
,
updateTime
:
''
,
cellVolt
:
[
[
// {
// index: '01',
// vo: '3.544'
// }
],
],
bmsTempetrue
:
[
[
// {
// index: '01',
// vo: '3.544'
// }
],
],
tms
:
[
[{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
}],
[{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
}],
[{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
}],
[{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
msg
:
true
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
},
{
index
:
'01'
,
vo
:
'3.544'
}]
]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad
:
function
(
options
)
{
this
.
getCarDetail
()
clearInterval
(
timer
)
setInterval
(()
=>
{
this
.
getCarDetail
()
},
4000
)
},
drawProgressbg
:
function
()
{
...
...
@@ -201,27 +123,91 @@ Page({
* 生命周期函数--监听页面卸载
*/
onUnload
:
function
()
{
clearInterval
(
timer
)
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh
:
function
()
{
getCarDetail
()
{
api
.
get
(
'device/base/deviceDetailNew'
,
{},
true
)
.
then
(
res
=>
{
let
{
data
,
model
:
{
deviceBmsInfo
}
}
=
res
let
carData
=
{
...
data
,
...
deviceBmsInfo
}
this
.
setUI2
(
carData
)
})
.
catch
(
err
=>
{
console
.
error
(
1
,
err
)
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom
:
function
()
{
// 轮询设置
setUI2
(
data
)
{
console
.
log
(
data
)
let
{
gprsImei
,
bmsVer
,
bmsVolt
,
bmsCurrent
,
bmsState
,
bmsCycles
,
bmsSoc
,
gpsSnr
,
gpsLocate
,
cellVolt
,
bmsTempetrue
,
updateTime
}
=
data
if
(
bmsState
==
1
)
{
bmsState
=
'开锁'
}
else
{
bmsState
=
'关锁'
}
cellVolt
=
JSON
.
parse
(
cellVolt
)
bmsTempetrue
=
JSON
.
parse
(
bmsTempetrue
)
if
(
cellVolt
&&
cellVolt
.
length
)
{
cellVolt
=
arrTarrs
(
4
,
cellVolt
.
map
((
elt
,
i
)
=>
{
return
{
index
:
i
,
vo
:
elt
}
}))
}
else
{
cellVolt
=
[
[]
]
}
if
(
bmsTempetrue
&&
bmsTempetrue
.
length
)
{
bmsTempetrue
=
arrTarrs
(
4
,
bmsTempetrue
.
map
((
elt
,
i
)
=>
{
return
{
index
:
i
,
vo
:
elt
}
}))
}
else
{
cellVolt
=
[
[]
]
}
this
.
setData
({
gprsImei
,
bmsVer
,
bmsVolt
,
bmsCurrent
,
bmsState
,
bmsCycles
,
bmsSoc
,
updateTime
,
gpsSnr
,
cellVolt
,
bmsTempetrue
,
batteryDeatil
:
data
})
this
.
drawCircle
(
bmsSoc
);
},
/**
* 用户点击右上角分享
*/
onShareAppMessage
:
function
()
{
}
})
\ No newline at end of file
pages/batteryHeath/batteryHeath.wxml
View file @
2ce1960b
...
...
@@ -5,7 +5,7 @@
<canvas class="cvs progress_bg" canvas-id="canvasProgressbg"> </canvas>
<canvas class="cvs progress_canvas" canvas-id="canvasProgress"> </canvas>
<view class="content">
<view class="power">
65
<view class="power">
{{bmsSoc}}
<text>%</text>
</view>
<view class="bar"></view>
...
...
@@ -13,36 +13,36 @@
</view>
<view class="b-right">
<view class="b-right-top">
<view>
ABCDEF1234567890
</view>
<view class="error"
>警告!电池异常 3345
</view>
<view>
{{batteryDeatil.bmsSn}}
</view>
<view class="error"
wx:if="{{batteryDeatil.bmsErrCode}}">警告!电池异常 {{batteryDeatil.bmsErrCode}}
</view>
</view>
<view class="b-right-bottom">
<view class="b-right-line1">
<view class="col-item">
<text>电压</text>
<text>
5.0
V</text>
<text>
{{bmsVolt}}
V</text>
</view>
<view class="col-item">
<text>电流</text>
<text>
1.0
A</text>
<text>
{{bmsCurrent}}
A</text>
</view>
<view class="col-item">
<text>状态</text>
<text>
充电中
</text>
<text>
{{bmsState}}
</text>
</view>
<view class="col-item">
<text>电池循环</text>
<text>
1
次</text>
<text>
{{bmsCycles}}
次</text>
</view>
</view>
<view class="b-right-line2">
<view class="col-item">
<text>电池版本</text>
<text>
ver33333
</text>
<text>
{{bmsVer}}
</text>
</view>
<view class="col-item">
<text>IMEI</text>
<text>
232321312312313221
</text>
<text>
{{gprsImei}}
</text>
</view>
</view>
</view>
...
...
@@ -54,7 +54,7 @@
<text>(单位:V)</text>
</view>
<view class="info-content">
<view wx:for="{{
vos
}}" wx:key="{{index}}" class="vos-row">
<view wx:for="{{
cellVolt
}}" wx:key="{{index}}" class="vos-row">
<view wx:for="{{item}}" wx:key="{{vItem.index}}" wx:for-item="vItem" class="vos-item">
<text>{{vItem.index}}</text>
<text class="num {{vItem.msg?'error':''}}">{{vItem.vo}}</text>
...
...
@@ -67,7 +67,7 @@
<text>(单位:℃)</text>
</view>
<view class="info-content">
<view wx:for="{{
vos
}}" wx:key="{{index}}" class="vos-row">
<view wx:for="{{
bmsTempetrue
}}" wx:key="{{index}}" class="vos-row">
<view wx:for="{{item}}" wx:key="{{vItem.index}}" wx:for-item="vItem" class="vos-item">
<text>{{vItem.index}}</text>
<text class="num {{vItem.msg?'error':''}}">{{vItem.vo}}</text>
...
...
pages/batteryHeath/batteryHeath.wxss
View file @
2ce1960b
...
...
@@ -82,6 +82,12 @@
justify-content: space-between;
margin-top: 16rpx;
}
.b-right-line1 .col-item{
flex: 0 0 25%;
}
.b-right-line2 .col-item{
flex: 1;
}
.col-item text:nth-of-type(1){
color: #587699;
margin-right: 10rpx;
...
...
@@ -109,11 +115,17 @@
font-size: 20rpx;
margin-bottom: 30rpx;
}
.info-body .vos-item{
flex: 1;
display: flex;
}
.vos-item text:nth-of-type(1){
padding: 3px 6px;
background-color: #587699;
border-radius: 3px;
margin-right: 14rpx;
text-align: center;
min-width: 24rpx;
}
.vos-item text:nth-of-type(2){
color: #587699;
...
...
pages/car_action/index.js
View file @
2ce1960b
...
...
@@ -18,59 +18,13 @@ const moment = require('../../lib/moment.js')
import
Cmd
from
'../../lib/cmd.js'
let
cmd
=
null
let
app
=
getApp
()
let
medicalTimer
,
actionTimer
,
deviceTimer
=
null
//体检 延时器
let
medicalTimer
,
actionTimer
=
null
//体检 延时器
Page
({
/**
* 页面的初始数据
*/
data
:
{
imgLogo2
:
imgName
(
'logo2.png'
),
imgFind
:
imgName
(
'find.png'
),
imgLoc
:
imgName
(
'loc.png'
),
imgToloc
:
imgName
(
'toloc.png'
),
imgcarloc
:
imgName
(
'timeline_location.png'
),
imgMore
:
imgName
(
'more.png'
),
imgCarLoc
:
imgName
(
'carLoc.png'
),
imgWeatherbg
:
imgName
(
'weatherbg.jpg'
),
user
:
null
,
//用户
person
:
1
,
//个租
deviceLocError
:
false
,
device
:
null
,
//设备
timerDevice
:
null
,
message
:
''
,
baseMsg
:
true
,
//基础数据获取是否正常
weather
:
{
city
:
'常州市'
,
area
:
'武进区'
,
type
:
'多云'
,
maxt
:
'13'
,
mint
:
'0'
},
//天气
ui
:
{
message
:
'22'
,
//消息内容
froNo
:
'--'
,
//车架号
vcuNo
:
'--'
,
//中控号
licensePlate
:
'--'
,
//号牌
vehicleTypeName
:
'--'
,
//车型名称
rentStartTime
:
'--'
,
//起租时间
fee
:
'1.5'
,
deviceAdress
:
'--'
,
//位置
last_communication_time
:
'--'
,
//更新时间
lockState
:
0
,
//锁
speed
:
'0'
,
estimatedMileage
:
'--'
,
//预估里程
dumpEnergy
:
'--'
,
//剩余电量
bluetoothAddress
:
null
,
showMoreInfo
:
true
,
//显示速度信息
canLock
:
true
,
//能否锁车
gps_time
:
'--'
,
hasSetHelp
:
false
,
//设置求救电话
disable
:
true
,
//禁车
powerColor
:
'67, 207, 124'
,
//电池颜色
kmColor
:
'121,72,234)'
,
//里程颜色
GPS
:
"*"
,
GSM
:
"*"
,
locMap
:
{
latitude
:
30.334546
,
longitude
:
120.121121
,
...
...
@@ -81,22 +35,108 @@ Page({
iconPath
:
imgName
(
'location_sucess.png'
),
}]
},
multiIndex
:
[
0
,
0
,
23
],
multiArray
:
[
[
'2018-06-01'
,
'2018-06-02'
,
'2018-06-03'
],
[
'00:00起'
,
'01:00起'
,
'02:00起'
,
'03:00起'
,
'04:00起'
,
'05:00起'
,
'06:00起'
,
'07:00起'
,
'08:00起'
,
'09:00起'
,
'10:00起'
,
'11:00起'
,
'12:00起'
,
'13:00起'
,
'14:00起'
,
'15:00起'
,
'16:00起'
,
'17:00起'
,
'18:00起'
,
'19:00起'
,
'20:00起'
,
'21:00起'
,
'22:00起'
,
'23:00起'
],
[
'01:00止'
,
'02:00止'
,
'03:00止'
,
'04:00止'
,
'05:00止'
,
'06:00止'
,
'07:00止'
,
'08:00止'
,
'09:00止'
,
'10:00止'
,
'11:00止'
,
'12:00止'
,
'13:00止'
,
'14:00止'
,
'15:00止'
,
'16:00止'
,
'17:00止'
,
'18:00止'
,
'19:00止'
,
'20:00止'
,
'21:00止'
,
'22:00止'
,
'23:00止'
,
'24:00止'
]
],
batteryDeatil
:{},
polyline
:[],
},
location
:
null
,
latitude
:
null
,
//维度
longitude
:
null
,
//经度
rent
:
'false'
,
//物联网到期
carDetail
:
false
,
//车辆详情
hasMedical
:
false
,
//是否体检
medicalNum
:
0
,
//体检百分比
medicalScore
:
80
,
//体检百分比
initDate
()
{
let
now
=
moment
().
format
(
'YYYY-MM-DD'
)
let
lastMonthDay
=
moment
().
subtract
(
1
,
'months'
).
format
(
'YYYY-MM-DD'
)
let
daysArr
=
[
now
]
for
(
let
i
=
1
;
i
<
31
;
i
++
)
{
let
day
=
moment
().
subtract
(
i
,
'days'
).
format
(
'YYYY-MM-DD'
)
daysArr
.
unshift
(
day
)
if
(
day
===
lastMonthDay
)
{
break
;
}
}
this
.
setData
({
'multiArray[0]'
:
daysArr
,
'multiIndex[0]'
:
daysArr
.
length
-
1
})
},
markerTap
()
{
// 时间变化
bindTimeColumnChange
(
e
)
{
// console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
let
{
column
,
value
}
=
e
.
detail
let
{
multiIndex
:
[
x
,
y
,
z
]
}
=
this
.
data
if
(
column
===
0
)
{
this
.
setData
({
'multiIndex[0]'
:
value
,
})
}
if
(
column
===
1
)
{
this
.
setData
({
'multiIndex[1]'
:
value
,
})
if
(
value
>
z
)
{
this
.
setData
({
'multiIndex[1]'
:
value
,
'multiIndex[2]'
:
value
})
}
}
if
(
column
===
2
)
{
this
.
setData
({
'multiIndex[2]'
:
value
,
})
if
(
value
<
y
)
{
this
.
setData
({
'multiIndex[1]'
:
value
,
'multiIndex[2]'
:
value
})
}
}
},
chooseTime
(){
},
// 时间选择
bindTimeChange
(
e
)
{
// console.log('picker发送选择改变,携带值为', e.detail.value)
this
.
setData
({
multiIndex
:
e
.
detail
.
value
})
let
[
x
,
y
,
z
]
=
e
.
detail
.
value
let
data
=
{
start
:
moment
(
this
.
data
.
multiArray
[
0
][
x
]
+
' '
+
this
.
data
.
multiArray
[
1
][
y
].
slice
(
0
,
-
1
)
+
':00'
).
valueOf
(),
end
:
moment
(
this
.
data
.
multiArray
[
0
][
x
]
+
' '
+
(
z
==
23
?
'23:59:59'
:
(
this
.
data
.
multiArray
[
2
][
z
].
slice
(
0
,
-
1
)
+
':00'
))).
valueOf
(),
}
api
.
get
(
'gps/query'
,
data
)
.
then
(
res
=>
{
console
.
log
(
'轨迹:'
,
res
)
if
(
res
.
items
){
let
polyline
=
[{
points
:
[],
color
:
'#b80303FF'
,
arrowLine
:
true
,
width
:
3
}]
items
.
map
(
item
=>
{
item
=
{
latitude
:
item
.
lat
,
longitude
:
item
.
lng
}
polyline
[
0
].
points
.
push
(
item
)
return
item
})
this
.
mapCtx
.
includePoints
({
points
:
polyline
.
points
})
this
.
setData
({
polyline
,
})
}
else
{
toastTip
(
'无行驶记录'
)
}
})
.
catch
(
err
=>
{
alertTip
(
err
)
})
// start: 2019-03-03 00: 00: 00
// end: 2019-03-03 23: 59: 59
// imei: -559038737
},
disableCar
()
{
if
(
this
.
data
.
ui
.
disable
)
{
// 解禁
...
...
@@ -149,328 +189,61 @@ Page({
})
},
onLoad
:
function
()
{
this
.
initDate
()
return
const
user
=
wx
.
getStorageSync
(
'user'
)
if
(
!
user
)
{
wx
.
redirectTo
({
url
:
'/pages/register2/register2'
,
})
return
}
this
.
mapCtx
=
wx
.
createMapContext
(
'carMap'
)
let
batteryDeatil
=
wx
.
getStorageSync
(
'batteryDeatil'
)
this
.
setData
({
user
batteryDeatil
})
this
.
setUI2
(
batteryDeatil
)
// 查询时间
},
socketLink
()
{
const
{
user
}
=
this
.
data
app
.
socketLink
(
user
.
userMapp
.
id
)
cmd
=
new
Cmd
(
user
.
userMapp
.
nowVcuNo
,
user
.
token
)
},
socketClose
()
{
app
.
socketClose
()
},
socketSend
(
msg
)
{
// wx.onSocketMessage((res) => {
// let data = cmd.parse(res.data)
// console.log('收到服务器内容2:', data)
// if (data.type == msg) {
// app.onSocketMessage()
// }
// })
const
stringifyMsg
=
cmd
.
stringify
(
msg
)
if
(
stringifyMsg
)
{
if
(
msg
!=
'findcar'
&&
msg
!=
'firstDevice'
)
{
clearTimeout
(
actionTimer
)
actionTimer
=
setTimeout
(()
=>
{
$Message
({
content
:
'操作超时可能失败'
,
type
:
'warning'
});
},
8000
)
}
return
app
.
sendSocketMessage
(
stringifyMsg
)
}
else
{
return
Promise
.
reject
(
'不存在的指令'
)
}
},
setSocketUI
(
ui
)
{
const
msg
=
cmd
.
parse
(
ui
)
const
dataUi
=
this
.
data
.
ui
switch
(
msg
.
type
)
{
case
'carinfo'
:
this
.
setUI
(
msg
.
val
)
break
;
case
'lock'
:
wx
.
hideLoading
()
dataUi
.
lockState
=
0
this
.
setData
({
ui
:
dataUi
,
})
clearTimeout
(
actionTimer
)
$Message
({
content
:
'锁车成功'
,
type
:
'success'
});
break
;
case
'alarm'
:
app
.
socket
.
alarmMsg
=
msg
.
val
this
.
setData
({
message
:
msg
.
val
,
})
wx
.
vibrateLong
()
alertTip
(
`您的车辆发生
${
msg
.
val
}
报警!`
)
break
;
case
'unlock'
:
wx
.
hideLoading
()
dataUi
.
lockState
=
1
this
.
setData
({
ui
:
dataUi
,
})
clearTimeout
(
actionTimer
)
$Message
({
content
:
'开锁成功'
,
type
:
'success'
});
break
;
case
'findcar'
:
wx
.
hideLoading
()
clearTimeout
(
actionTimer
)
$Message
({
content
:
'寻车成功'
,
type
:
'success'
});
break
;
case
'gps'
:
console
.
log
(
'gps'
)
break
;
}
},
onHide
:
function
()
{
clearInterval
(
deviceTimer
)
},
onUnload
()
{
clearInterval
(
deviceTimer
)
},
onShow
:
function
()
{
return
let
that
=
this
// sokect
// if (!app.socket.open) {
// app.socket.repeat = 0
// this.socketLink()
// }else{
// this.socketSend('firstDevice')
// }
let
user
=
wx
.
getStorageSync
(
'user'
).
userMapp
if
(
!
user
)
{
wx
.
redirectTo
({
url
:
'/pages/register2/register2'
,
})
return
}
// 获取车辆信息或者用户列表
clearInterval
(
deviceTimer
)
that
.
getCarDetail
()
deviceTimer
=
setInterval
(()
=>
{
that
.
getCarDetail
()
},
5000
)
// 重置消息
this
.
setData
({
message
:
app
.
socket
.
alarmMsg
,
})
},
//获取硬件信息
/*
新增 type
type 2 是小定位器
无操作 无数据
大于等于3定位有效
*/
getCarDetail
()
{
api
.
get
(
'device/base/deviceDetail'
,
{},
true
)
.
then
(
res
=>
{
let
{
data
,
model
:
{
deviceInfo
}
}
=
res
let
carData
=
{
...
data
,
...
deviceInfo
}
this
.
setUI2
(
carData
)
})
.
catch
(
err
=>
{
console
.
error
(
1
,
err
)
})
this
.
initDate
()
},
// 轮询设置
setUI2
(
data
)
{
const
{
ui
}
=
this
.
data
let
last_communication_time
=
null
let
gps_time
=
null
if
(
data
.
message
)
{
ui
.
message
=
data
.
message
//消息
}
if
(
data
.
address
)
{
ui
.
deviceAdress
=
data
.
address
//位置
}
if
(
data
.
type
==
2
)
{
ui
.
showMoreInfo
=
false
//小定位器
ui
.
canLock
=
false
}
if
(
data
.
dbDate
)
{
last_communication_time
=
moment
(
data
.
dbDate
).
format
(
'YYYY-MM-DD HH:mm'
)
ui
.
last_communication_time
=
last_communication_time
//更新时间
}
if
(
data
.
gps_cn
)
{
ui
.
GPS
=
data
.
gps_cn
}
if
(
data
.
gprs_signal
)
{
ui
.
GSM
=
data
.
gprs_signal
}
if
(
data
.
isSetSosyes
)
{
ui
.
hasSetHelp
=
data
.
isSetSosyes
==
'no'
?
false
:
true
}
if
(
data
.
isSetSosyes
)
{
ui
.
hasSetHelp
=
data
.
isSetSosyes
==
'no'
?
false
:
true
}
if
(
data
.
disable
)
{
ui
.
disable
=
data
.
disable
===
'yes'
?
true
:
false
}
if
(
data
.
gps_datetime
&&
data
.
gps_datetime
!=
'null'
)
{
// gps_time = moment(data.gps_datetime).format('YYYY-MM-DD HH:mm')
gps_time
=
data
.
gps_datetime
.
split
(
'.'
)[
0
]
ui
.
gps_time
=
moment
(
gps_time
).
format
(
'HH:mm/YYYY.MM.DD'
)
}
ui
.
vcuNo
=
data
.
vcuNo
ui
.
dumpEnergy
=
data
.
power
//剩余电量
ui
.
powerColor
=
getRgbColor
(
'227,60,100'
,
'67,207,124'
,
ui
.
dumpEnergy
)
if
(
data
.
remainingMileage
)
{
ui
.
estimatedMileage
=
data
.
remainingMileage
if
(
data
.
maxMileage
)
{
ui
.
estimatedMileage
=
data
.
remainingMileage
ui
.
kmColor
=
getRgbColor
(
'0,168,173'
,
'121,72,234'
,
Number
(
ui
.
estimatedMileage
)
/
Number
(
data
.
maxMileage
))
}
}
else
{
ui
.
estimatedMileage
=
0
;
ui
.
kmColor
=
getRgbColor
(
'0,168,173'
,
'121,72,234'
,
0
)
}
ui
.
lockState
=
data
.
lock_state
==
'1'
?
0
:
1
//锁 1开锁状态
ui
.
speed
=
data
.
speed
||
'--'
//行驶速度
//地图内容
let
deviceLocError
=
true
if
(
data
.
lng
&&
data
.
lat
)
{
ui
.
locMap
.
latitude
=
data
.
lat
ui
.
locMap
.
longitude
=
data
.
lng
ui
.
locMap
.
markers
[
0
].
latitude
=
data
.
lat
ui
.
locMap
.
markers
[
0
].
longitude
=
data
.
lng
deviceLocError
=
false
let
{
gprsImei
,
bmsSn
,
bmsVolt
,
bmsCurrent
,
bmsState
,
bmsCycles
,
bmsSoc
,
gpsSnr
,
gpsLocate
,
restDay
,
updateTime
}
=
data
gpsLocate
=
JSON
.
parse
(
gpsLocate
)
if
(
gpsLocate
&&
gpsLocate
.
length
)
{
this
.
setMap
(
gpsLocate
[
0
],
gpsLocate
[
1
])
}
if
(
bmsState
==
1
)
{
bmsState
=
'开锁'
}
else
{
deviceLocError
=
true
bmsState
=
'关锁'
}
//详情内容
// this.setCarDetail(data)
this
.
setData
({
ui
:
{
...
ui
},
deviceLocError
})
},
setUI
(
data
)
{
const
{
ui
,
details
}
=
this
.
data
let
last_communication_time
=
null
let
gps_time
=
null
if
(
data
.
message
)
{
ui
.
message
=
data
.
message
//消息
}
if
(
data
.
address
)
{
ui
.
deviceAdress
=
data
.
address
//位置
}
if
(
data
.
type
==
2
)
{
ui
.
showMoreInfo
=
false
//小定位器
ui
.
canLock
=
false
}
if
(
data
.
dbDate
)
{
last_communication_time
=
moment
(
data
.
dbDate
).
format
(
'YYYY-MM-DD HH:mm'
)
ui
.
last_communication_time
=
last_communication_time
//更新时间
}
if
(
data
.
gpsDate
)
{
gps_time
=
moment
(
data
.
gpsDate
*
1000
).
format
(
'YYYY-MM-DD HH:mm'
)
ui
.
gps_time
=
gps_time
}
ui
.
vcuNo
=
data
.
vcuNo
ui
.
estimatedMileage
=
(
data
.
mile
/
1000
||
'0'
)
//预估里程
ui
.
lockState
=
data
.
lock_state
==
'1'
?
0
:
1
//锁 1开锁状态
ui
.
dumpEnergy
=
data
.
power
//剩余电量
ui
.
speed
=
data
.
speed
||
'--'
//行驶速度
gprsImei
,
bmsVolt
,
bmsCurrent
,
bmsSn
,
bmsState
,
bmsCycles
,
bmsSoc
,
updateTime
,
gpsSnr
,
batteryDeatil
:
data
})
},
setMap
(
lat
,
lng
)
{
let
{
locMap
}
=
this
.
data
locMap
.
latitude
=
lat
locMap
.
longitude
=
lng
locMap
.
markers
[
0
].
latitude
=
lng
locMap
.
markers
[
0
].
longitude
=
lng
details
[
0
].
des1
=
`信号强度:
${
data
.
accuracy
}
`
details
[
0
].
des2
=
`最后通信时间:
${
last_communication_time
}
`
details
[
1
].
des1
=
`经度:
${
data
.
lng
}
`
details
[
1
].
des2
=
`纬度:
${
data
.
lat
}
`
details
[
1
].
des3
=
`gps:
${
data
.
accuracy
>=
3
?
'有效'
:
'无效'
}
`
details
[
1
].
des4
=
`位置:
${
data
.
address
||
'--'
}
`
details
[
1
].
des5
=
`定位时间:
${
gps_time
||
'--'
}
`
details
[
1
].
tip
=
`
${
data
.
accuracy
>=
3
?
''
:
'当前定位不精确,将车辆移至信号良好处, 可增强通讯和定位。'
}
`
// details[2].des1 = `可用卫星:${d.number_satellite}`
//地图内容
let
deviceLocError
=
true
if
(
data
.
lng
&&
data
.
lat
)
{
ui
.
locMap
.
latitude
=
data
.
lat
ui
.
locMap
.
longitude
=
data
.
lng
ui
.
locMap
.
markers
[
0
].
latitude
=
data
.
lat
ui
.
locMap
.
markers
[
0
].
longitude
=
data
.
lng
deviceLocError
=
false
}
else
{
deviceLocError
=
true
}
//详情内容
// this.setCarDetail(data)
this
.
setData
({
ui
:
{
...
ui
},
details
:
[...
details
],
deviceLocError
})
},
getUserLoc
()
{
let
This
=
this
userLocation
()
.
then
(
location
=>
{
This
.
setData
({
location
})
})
.
catch
(
err
=>
{
wx
.
showModal
({
title
:
'提示'
,
showCancel
:
false
,
content
:
'需要授权地理定位才能正常使用,点击确定去授权'
,
success
(
res
)
{
if
(
res
.
confirm
)
{
wx
.
openSetting
({
complete
()
{
This
.
getUserLoc
()
}
})
}
}
})
locMap
:
{
...
locMap
}
})
},
//关锁
...
...
@@ -576,9 +349,6 @@ Page({
})
},
showMyLoc
()
{
if
(
!
this
.
mapCtx
)
{
this
.
mapCtx
=
wx
.
createMapContext
(
'carMap'
)
}
this
.
mapCtx
.
moveToLocation
()
},
progressChange
(
e
)
{
...
...
@@ -610,25 +380,6 @@ Page({
medicalTimer
=
null
},
3000
)
},
//统一设置ui
// setUi() {
// let {
// user,
// device,
// ui
// } = this.data
// //基础信息
// if (user && device) {
// ui.froNo = device.frameNo || '未录入' //车架号
// ui.vcuNo = device.vcuNo || '未录入' //中控号
// ui.licensePlate = device.licensePlate || '未录入' //号牌
// ui.rentStartTime = moment(device.createDate).format('YYYY-MM-DD HH:mm') //租车起始时间
// }
// //车辆信息
// this.setData({
// ui
// })
// },
//查看二维码
seeQrCode
(
e
)
{
let
code
=
e
.
currentTarget
.
id
...
...
@@ -648,27 +399,6 @@ Page({
url
:
'/pages/server_point/server_point'
,
})
},
// 时间选择
bindTimeChange
(
e
)
{
// console.log('picker发送选择改变,携带值为', e.detail.value)
this
.
setData
({
multiIndex
:
e
.
detail
.
value
})
let
[
x
,
y
,
z
]
=
e
.
detail
.
value
let
data
=
{
start
:
this
.
data
.
multiArray
[
0
][
x
]
+
' '
+
this
.
data
.
multiArray
[
1
][
y
].
slice
(
0
,
-
1
)
+
':00'
,
end
:
this
.
data
.
multiArray
[
0
][
x
]
+
' '
+
(
z
==
23
?
'23:59:59'
:
(
this
.
data
.
multiArray
[
2
][
z
].
slice
(
0
,
-
1
)
+
':00'
)),
vcuNo
:
this
.
data
.
ui
.
vcuNo
}
console
.
log
(
data
)
wx
.
setStorageSync
(
'trailQuery'
,
data
)
wx
.
navigateTo
({
url
:
"/pages/user_travel_query/index"
,
})
// start: 2019 - 03 - 03 00: 00: 00
// end: 2019 - 03 - 03 23: 59: 59
// imei: -559038737
},
// 时间变化
bindTimeColumnChange
(
e
)
{
// console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
...
...
pages/car_action/index.wxml
View file @
2ce1960b
<view class='map'>
<!-- <view class='map-top'>
<view class='top'>{{ui.deviceAdress}}</view>
<view class='bottom'>
<text decode='{{true}}'>GPS:{{ui.GPS}} GSM:{{ui.GSM}}</text>
<text>定位时间:{{ui.gps_time}}</text>
</view>
</view> -->
<map id='carMap' scale='13' markers='{{ui.locMap.markers}}' show-location bindmarkertap='markersTap' longitude='{{ui.locMap.longitude}}' latitude='{{ui.locMap.latitude}}'>
<map class="map" id='carMap' scale='13' markers='{{locMap.markers}}' polyline='{{polyline}}' show-location longitude='{{locMap.longitude}}' latitude='{{locMap.latitude}}'>
<cover-view wx:if='{{deviceLocError}}' class='out-line'>当前设备定位异常</cover-view>
<!-- </cover-view> -->
...
...
@@ -14,14 +7,19 @@
<view>
<view class="map-bottom">
<view class="map-bottom-right">
<view>当前位置:{{ui.deviceAdress}}</view>
<view>最后上报:{{ui.gps_time}}</view>
<view>信号强度:GPS <text class="error">{{ui.GPS}}</text> GSM {{ui.GSM}}</view>
<view>当前位置:{{batteryDeatil.address}}</view>
<view>最后上报:{{batteryDeatil.time}}</view>
<view>信号强度:GPS
<text class="{{batteryDeatil.gpsSnr?'':'error'}}">{{batteryDeatil.gpsSnr}}</text> GSM
<text class="{{batteryDeatil.gsmSnr?'':'error'}}">{{batteryDeatil.gsmSnr}}</text>
</view>
<view class="abtn detail-btn" bindtap="chooseTime">查看轨迹</view>
</view>
<picker mode="multiSelector" bindchange="bindTimeChange" bindcolumnchange="bindTimeColumnChange" value="{{multiIndex}}" range="{{multiArray}}">
<view class="abtn detail-btn" bindtap="chooseTime">查看轨迹</view>
</picker>
</view>
<!-- <view class='map-bottom'>
</view>
<!-- <view class='map-bottom'>
<view catchtap='showMyLoc'>
<image src='{{imgToloc}}'></image>
<text>我的位置</text>
...
...
pages/pay/pay.js
View file @
2ce1960b
...
...
@@ -3,6 +3,7 @@ const { api, formatTime, imgName, wxLogin, payApi, alertTip, useTime, changeTime
Page
({
data
:
{
price
:
'30.0'
,
restDay
:
''
,
payType
:
'rent'
,
//deposit rent
success
:
true
,
//
orderNumber
:
''
,
...
...
@@ -15,7 +16,11 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad
:
function
(
options
)
{
console
.
log
(
options
)
this
.
setData
({
endRentTime
:
options
.
serverEndDate
,
restDay
:
options
.
day
,
})
},
//判断是否未支付定单或者押金 个租
getRentRecord
()
{
...
...
pages/pay/pay.wxml
View file @
2ce1960b
<view class="con">
<view class="battery-tip">
<text>该电池的物联网服务剩余</text>
<text>
33
</text>
<text>
{{restDay}}
</text>
<text>天</text>
</view>
<view class="time-body">
<view class="bar"></view>
<view class="time">截止到
2020-12-12
</view>
<view class="time">截止到
{{endRentTime}}
</view>
<view class="bar"></view>
</view>
<text class="tip">
...
...
pages/register2/register2.js
View file @
2ce1960b
...
...
@@ -242,24 +242,7 @@ Page({
logAfter
(
res
)
{
wx
.
setStorageSync
(
'user'
,
res
.
data
)
//有车
this
.
getCarList
()
.
then
(
hasCar
=>
{
if
(
hasCar
)
{
//有使用的车辆 跳到用车
wx
.
switchTab
({
url
:
'/pages/user_index/user_index'
,
})
return
}
else
{
//没车绑定车辆
wx
.
redirectTo
({
url
:
'/pages/device_bind/device_bind'
,
})
}
})
.
catch
(
err
=>
{
alertTip
(
err
.
toString
())
})
wx
.
navigateBack
()
},
loginBycode
()
{
let
body
=
{
...
...
pages/user_device_list/user_device_list.js
View file @
2ce1960b
...
...
@@ -176,9 +176,6 @@ Page({
})
},
onPullDownRefresh
()
{
this
.
getCarList
()
},
changeCar
(
vcuNo
)
{
confirmTip
(
`确定切换设备为
${
vcuNo
}
`
,
()
=>
{
api
.
post
(
'device/changeDevice'
,
{
...
...
@@ -201,6 +198,10 @@ Page({
})
})
},
onPullDownRefresh
()
{
this
.
getCarList
()
},
unbindCar
(
vcuNo
)
{
let
that
=
this
wx
.
showModal
({
...
...
pages/user_index/defaultAvator.png
0 → 100644
View file @
2ce1960b
8.13 KB
pages/user_index/user_index.js
View file @
2ce1960b
...
...
@@ -16,7 +16,7 @@ const {
getRgbColor
,
getPx
,
wxscan
}
=
require
(
'../../lib/util.js'
)
}
=
require
(
'../../lib/util.js'
)
const
moment
=
require
(
'../../lib/moment.js'
)
import
Cmd
from
'../../lib/cmd.js'
let
cmd
=
null
...
...
@@ -30,58 +30,6 @@ Page({
data
:
{
progress_txt
:
'正在匹配中...'
,
imgLoc
:
imgName
(
'homoeLoc.png'
),
imgToloc
:
imgName
(
'toloc.png'
),
dangerStatus
:
false
,
person
:
1
,
//个租
deviceLocError
:
false
,
device
:
null
,
//设备
timerDevice
:
null
,
message
:
''
,
baseMsg
:
true
,
//基础数据获取是否正常
hasaAuthorization
:
false
,
animation2
:
''
,
lockAction
:
false
,
percent
:
0
,
targetStatus
:
null
,
online
:
false
,
//在线
weather
:
{
city
:
'获取中'
,
area
:
''
,
type
:
'。。。'
,
maxt
:
''
,
mint
:
''
},
//天气
assistActions
:
[{
name
:
'禁车'
,
width
:
60
,
color
:
'#fff'
,
fontsize
:
'14'
,
background
:
'#d43030'
}],
ui
:
{
message
:
'22'
,
//消息内容
froNo
:
'--'
,
//车架号
vcuNo
:
'--'
,
//中控号
licensePlate
:
'--'
,
//号牌
vehicleTypeName
:
'--'
,
//车型名称
rentStartTime
:
'--'
,
//起租时间
fee
:
'1.5'
,
deviceAdress
:
'--'
,
//位置
last_communication_time
:
'--'
,
//更新时间
lockState
:
0
,
//锁
speed
:
'0'
,
estimatedMileage
:
'--'
,
//预估里程
dumpEnergy
:
'--'
,
//剩余电量
bluetoothAddress
:
null
,
showMoreInfo
:
true
,
//显示速度信息
canLock
:
true
,
//能否锁车
gps_time
:
'--'
,
hasSetHelp
:
false
,
//设置求救电话
disable
:
true
,
//禁车
powerColor
:
'67, 207, 124'
,
//电池颜色
kmColor
:
'121,72,234)'
,
//里程颜色
GPS
:
"*"
,
GSM
:
"*"
,
locMap
:
{
latitude
:
30.334546
,
longitude
:
120.121121
,
...
...
@@ -92,43 +40,50 @@ Page({
iconPath
:
imgName
(
'location_sucess.png'
),
}]
},
bmsVolt
:
''
,
//电压 v
bmsCurrent
:
''
,
//电流 a
bmsTempetrue
:
''
,
//温度 ℃
bmsState
:
''
,
//电池状态
bmsSoc
:
''
,
//电量
bmsSn
:
''
,
//电池编号
bmsVer
:
''
,
//电池版本
},
user
:
{
nickname
:
'王榕'
,
avatarUrl
:
'http://ruiju.oss-cn-hangzhou.aliyuncs.com/ruijub8c4cbd4-4a1b-45fa-a288-ac430d5fc03d.jpg'
,
},
location
:
null
,
latitude
:
null
,
//维度
longitude
:
null
,
//经度
rent
:
'false'
,
//物联网到期
carDetail
:
false
,
//车辆详情
hasMedical
:
false
,
//是否体检
medicalNum
:
0
,
//体检百分比
medicalScore
:
80
,
//体检百分比
user
:
{},
gprsImei
:
''
,
bmsSn
:
''
,
bmsVolt
:
0
,
bmsCurrent
:
0
,
bmsState
:
''
,
bmsCycles
:
0
,
bmsSoc
:
0
,
updateTime
:
'--'
,
gpsSnr
:
'--'
,
actionVisible
:
false
,
//
navHeight
:
0
,
myModel
:
false
,
hasBattery
:
true
,
},
nullfunc
(){},
navHeight
:
0
,
myModel
:
false
,
hasBattery
:
true
,
auth
:
false
,
batteryList
:
[],
batteryDeatil
:
{},
serverEndDate
:
''
,
},
nullfunc
()
{},
// 绑定电池
bindBattery
(){
bindBattery
()
{
wxscan
()
.
then
(
code
=>
{
console
.
log
(
'电池编号:'
,
code
)
.
then
(
code
=>
{
console
.
log
(
'电池编号:'
,
code
)
this
.
apiUseCar
(
code
)
})
},
getCarList
()
{
let
that
=
this
api
.
post
(
'device/userBindingDeviceList'
)
.
then
(
res
=>
{
console
.
log
(
'设备列表:'
,
res
)
if
(
res
.
items
.
length
>
0
)
{
this
.
setData
({
batteryList
:
res
.
items
})
}
})
},
showBuying
(){
showBuying
()
{
let
{
serverEndDate
,
batteryDeatil
:
{
restDay
}}
=
this
.
data
wx
.
navigateTo
({
url
:
'/pages/pay/pay'
,
url
:
`/pages/pay/pay?day=
${
restDay
}
&serverEndDate=
${
serverEndDate
}
`
,
})
},
commonNavAttr
(
e
)
{
...
...
@@ -139,7 +94,7 @@ Page({
})
}
},
drawProgressbg
:
function
()
{
drawProgressbg
:
function
()
{
// 使用 wx.createContext 获取绘图上下文 context
var
ctx
=
wx
.
createCanvasContext
(
'canvasProgressbg'
,
this
)
// 划线
...
...
@@ -165,17 +120,17 @@ Page({
ctx
.
lineTo
(
getPx
(
640
),
getPx
(
276
))
ctx
.
stroke
()
ctx
.
draw
(
true
)
ctx
.
setLineWidth
(
getPx
(
20
));
// 设置圆环的宽度
ctx
.
setLineWidth
(
getPx
(
20
));
// 设置圆环的宽度
ctx
.
setStrokeStyle
(
'#333333'
);
// 设置圆环的颜色
ctx
.
setLineCap
(
'round'
)
// 设置圆环端点的形状
ctx
.
beginPath
();
//开始一个新的路径
ctx
.
arc
(
getPx
(
350
),
getPx
(
180
),
getPx
(
170
),
0.75
*
Math
.
PI
,
2.25
*
Math
.
PI
,
false
);
ctx
.
beginPath
();
//开始一个新的路径
ctx
.
arc
(
getPx
(
350
),
getPx
(
180
),
getPx
(
170
),
0.75
*
Math
.
PI
,
2.25
*
Math
.
PI
,
false
);
//设置一个原点(110,110),半径为100的圆的路径到当前路径
ctx
.
stroke
();
//对当前路径进行描边
ctx
.
stroke
();
//对当前路径进行描边
ctx
.
draw
(
true
);
// Fill with gradient
ctx
.
beginPath
()
ctx
.
arc
(
getPx
(
10
),
getPx
(
166
),
getPx
(
8
),
0
,
2
*
Math
.
PI
)
ctx
.
arc
(
getPx
(
10
),
getPx
(
166
),
getPx
(
8
),
0
,
2
*
Math
.
PI
)
ctx
.
setFillStyle
(
this
.
getCircularGradient
(
10
,
166
,
ctx
))
ctx
.
fill
()
ctx
.
beginPath
()
...
...
@@ -192,14 +147,14 @@ Page({
ctx
.
fill
()
ctx
.
draw
(
true
)
},
getCircularGradient
(
x
,
y
,
ctx
)
{
getCircularGradient
(
x
,
y
,
ctx
)
{
const
grd
=
ctx
.
createCircularGradient
(
getPx
(
x
),
getPx
(
y
),
getPx
(
10
))
grd
.
addColorStop
(
0
,
'#ffffff'
)
grd
.
addColorStop
(
0.5
,
'#0089f8'
)
grd
.
addColorStop
(
1
,
'#171b1f'
)
return
grd
},
drawCircle
:
function
(
step
=
100
)
{
drawCircle
:
function
(
step
=
100
)
{
var
context
=
wx
.
createCanvasContext
(
'canvasProgress'
,
this
);
// 设置渐变
var
gradient
=
context
.
createLinearGradient
(
getPx
(
150
),
0
,
getPx
(
550
),
0
);
...
...
@@ -211,22 +166,21 @@ Page({
context
.
setLineCap
(
'round'
)
context
.
beginPath
();
// 参数step 为绘制的圆环周长,从0到2为一周 。 -Math.PI / 2 将起始角设在12点钟位置 ,结束角 通过改变 step 的值确定
context
.
arc
(
getPx
(
350
),
getPx
(
180
),
getPx
(
170
),
0.75
*
Math
.
PI
,
(
0.75
+
(
step
/
100
)
*
1.5
)
*
Math
.
PI
,
false
);
context
.
arc
(
getPx
(
350
),
getPx
(
180
),
getPx
(
170
),
0.75
*
Math
.
PI
,
(
0.75
+
(
step
/
100
)
*
1.5
)
*
Math
.
PI
,
false
);
context
.
stroke
();
context
.
draw
()
},
onReady
:
function
()
{
onReady
:
function
()
{
this
.
drawProgressbg
();
this
.
drawCircle
(
40
);
},
toHeath
(){
toHeath
()
{
wx
.
navigateTo
({
url
:
'/pages/batteryHeath/batteryHeath'
,
})
},
showMy
(){
showMy
()
{
this
.
setData
({
myModel
:
!
this
.
data
.
myModel
})
...
...
@@ -278,6 +232,8 @@ Page({
})
},
seeMap
()
{
let
{
batteryDeatil
}
=
this
.
data
wx
.
setStorageSync
(
'batteryDeatil'
,
batteryDeatil
)
wx
.
navigateTo
({
url
:
'/pages/car_action/index'
,
})
...
...
@@ -338,6 +294,48 @@ Page({
}
},
apiUseCar
(
vcuNo
)
{
let
that
=
this
api
.
post
(
'device/userBindingDevice'
,
{
vcuNo
})
.
then
(
res
=>
{
//有使用的车辆 跳到用车
console
.
log
(
'bind:'
,
res
)
let
user
=
wx
.
getStorageSync
(
'user'
)
user
.
userMapp
.
nowVcuNo
=
vcuNo
wx
.
setStorageSync
(
'user'
,
user
)
// app.socket.open = false
// wx.switchTab({
// url: '/pages/user_index/user_index',
// })
that
.
getCarList
()
toastTip
(
'绑定成功'
)
return
})
.
catch
(
err
=>
{
alertTip
(
err
)
console
.
error
(
err
)
})
},
changeCar
(
e
)
{
let
vcuNo
=
e
.
currentTarget
.
dataset
.
deviceno
confirmTip
(
`确定切换设备为
${
vcuNo
}
`
,
()
=>
{
api
.
post
(
'device/changeDevice'
,
{
vcuNo
})
.
then
(
res
=>
{
const
user
=
wx
.
getStorageSync
(
'user'
)
user
.
userMapp
.
nowVcuNo
=
vcuNo
wx
.
setStorageSync
(
'user'
,
user
)
toastTip
(
res
.
message
)
})
.
catch
(
err
=>
{
alertTip
(
err
)
})
})
},
// 去设置求救电话
toSetHelp
()
{
if
(
this
.
data
.
ui
.
hasSetHelp
)
{
...
...
@@ -368,22 +366,6 @@ Page({
url
:
'/pages/user_message/user_message'
,
})
},
onLoad
:
function
()
{
return
const
user
=
wx
.
getStorageSync
(
'user'
)
if
(
!
user
)
{
wx
.
redirectTo
({
url
:
'/pages/register2/register2'
,
})
return
}
this
.
setData
({
user
})
// 查询时间
// this.initDate()
},
socketLink
()
{
const
{
user
...
...
@@ -478,7 +460,6 @@ Page({
},
onShow
:
function
()
{
let
that
=
this
return
// sokect
// if (!app.socket.open) {
// app.socket.repeat = 0
...
...
@@ -488,22 +469,27 @@ Page({
// }
let
user
=
wx
.
getStorageSync
(
'user'
).
userMapp
if
(
!
user
)
{
wx
.
redirectTo
({
url
:
'/pages/register2/register2'
,
this
.
setData
({
auth
:
false
})
return
}
else
{
this
.
setData
({
user
,
auth
:
true
})
}
// 获取车辆信息或者用户列表
clearInterval
(
deviceTimer
)
that
.
getCarList
()
that
.
getCarDetail
()
deviceTimer
=
setInterval
(()
=>
{
that
.
getCarDetail
()
},
3000
)
// 重置消息
this
.
setData
({
message
:
app
.
socket
.
alarmMsg
,
})
// this.getWeather()
// this.setData({
// message: app.socket.alarmMsg,
// })
},
//获取硬件信息
/*
...
...
@@ -518,12 +504,10 @@ Page({
let
{
data
,
model
:
{
deviceInfo
,
deviceBmsInfo
}
}
=
res
let
carData
=
{
...
data
,
...
deviceInfo
,
...
deviceBmsInfo
}
this
.
setUI2
(
carData
)
...
...
@@ -535,190 +519,54 @@ Page({
},
// 轮询设置
setUI2
(
data
)
{
const
{
ui
,
targetStatus
}
=
this
.
data
let
last_communication_time
=
null
let
gps_time
=
null
if
(
data
.
message
)
{
ui
.
message
=
data
.
message
//消息
}
if
(
data
.
address
)
{
ui
.
deviceAdress
=
data
.
address
//位置
}
if
(
data
.
type
==
2
)
{
ui
.
showMoreInfo
=
false
//小定位器
ui
.
canLock
=
false
}
if
(
data
.
dbDate
)
{
last_communication_time
=
moment
(
data
.
dbDate
).
format
(
'YYYY-MM-DD HH:mm'
)
ui
.
last_communication_time
=
last_communication_time
//更新时间
}
if
(
data
.
gps_cn
)
{
ui
.
GPS
=
data
.
gps_cn
}
if
(
data
.
gprs_signal
)
{
ui
.
GSM
=
data
.
gprs_signal
}
if
(
data
.
isSetSos
)
{
ui
.
hasSetHelp
=
data
.
isSetSos
==
'no'
?
false
:
true
}
// 电池内容
ui
.
bmsVolt
=
data
.
bmsVolt
||
'--'
//电压 v
ui
.
bmsCurrent
=
data
.
bmsCurrent
||
'--'
//电流 a
ui
.
bmsTempetrue
=
data
.
bmsTempetrue
||
'--'
//温度 ℃
ui
.
bmsState
=
(
data
.
bmsState
&&
[
''
,
'静止'
,
'放电'
,
'充电'
][
data
.
bmsState
])
||
'--'
//电池状态
ui
.
bmsSoc
=
data
.
bmsSoc
||
'--'
//电量
ui
.
bmsSn
=
data
.
bmsSn
||
'--'
//电池编号
ui
.
bmsVer
=
data
.
bmsVer
||
'--'
//电池版本
if
(
data
.
disable
)
{
ui
.
disable
=
data
.
disable
===
'yes'
?
true
:
false
if
(
ui
.
disable
)
{
this
.
setData
({
'assistActions[0].name'
:
'解禁'
,
'assistActions[0].background'
:
'#00baad'
,
})
}
else
{
let
{
gprsImei
,
bmsSn
,
bmsVolt
,
bmsCurrent
,
bmsState
,
bmsCycles
,
bmsSoc
,
gpsSnr
,
gpsLocate
,
restDay
,
updateTime
}
=
data
gpsLocate
=
JSON
.
parse
(
gpsLocate
)
if
(
gpsLocate
&&
gpsLocate
.
length
){
this
.
setMap
(
gpsLocate
[
0
],
gpsLocate
[
1
])
}
if
(
bmsState
==
1
){
bmsState
=
'开锁'
}
else
{
bmsState
=
'关锁'
}
let
serverEndDate
=
moment
().
add
(
restDay
,
'days'
).
format
(
'YYYY-MM-DD'
);
this
.
setData
({
'assistActions[0].name'
:
'禁车'
,
'assistActions[0].background'
:
'#d43030'
,
})
}
}
if
(
data
.
gps_datetime
&&
data
.
gps_datetime
!=
'null'
)
{
// gps_time = moment(data.gps_datetime).format('YYYY-MM-DD HH:mm')
gps_time
=
data
.
gps_datetime
.
split
(
'.'
)[
0
]
ui
.
gps_time
=
moment
(
gps_time
).
format
(
'HH:mm/YYYY.MM.DD'
)
}
ui
.
vcuNo
=
data
.
vcuNo
ui
.
dumpEnergy
=
data
.
power
//剩余电量
ui
.
powerColor
=
getRgbColor
(
'227,60,100'
,
'67,207,124'
,
ui
.
dumpEnergy
)
if
(
data
.
batteryAPower
==
'null'
||
data
.
batteryAPower
>
100
||
data
.
batteryAPower
==
-
1
)
{
ui
.
batteryAPower
=
-
1
}
else
{
ui
.
batteryAPower
=
data
.
batteryAPower
}
if
(
data
.
batteryBPower
==
'null'
||
data
.
batteryBPower
>
100
||
data
.
batteryBPower
==
-
1
)
{
ui
.
batteryBPower
=
-
1
}
else
{
ui
.
batteryBPower
=
data
.
batteryBPower
}
if
(
data
.
remainingMileage
)
{
ui
.
estimatedMileage
=
data
.
remainingMileage
if
(
data
.
maxMileage
)
{
ui
.
estimatedMileage
=
data
.
remainingMileage
ui
.
kmColor
=
getRgbColor
(
'0,168,173'
,
'121,72,234'
,
Number
(
ui
.
estimatedMileage
)
/
Number
(
data
.
maxMileage
))
}
}
else
{
ui
.
estimatedMileage
=
0
;
ui
.
kmColor
=
getRgbColor
(
'0,168,173'
,
'121,72,234'
,
0
)
}
ui
.
lockState
=
data
.
lock_state
==
'2'
?
0
:
1
//锁 2是关锁状态 1开锁状态
if
(
targetStatus
!==
null
)
{
if
(
ui
.
lockState
===
targetStatus
)
{
if
(
targetStatus
===
0
)
{
toastTip
({
title
:
'关锁成功'
,
icon
:
'none'
})
}
else
{
toastTip
({
title
:
'开锁成功'
,
icon
:
'none'
})
}
gprsImei
,
bmsVolt
,
bmsCurrent
,
bmsSn
,
bmsState
,
bmsCycles
,
bmsSoc
,
updateTime
,
gpsSnr
,
serverEndDate
,
batteryDeatil
:
data
})
this
.
drawCircle
(
bmsSoc
);
this
.
closeTimer
()
}
}
ui
.
speed
=
data
.
speed
||
'--'
//行驶速度
//地图内容
let
deviceLocError
=
true
let
[
longitude
,
latitude
,
online
=
0
,
utcTime
=
0
]
=
data
.
gpsLocate
.
split
(
','
)
longitude
=
Number
(
longitude
)
latitude
=
Number
(
latitude
)
online
=
Number
(
online
)
utcTime
=
Number
(
utcTime
)
if
(
longitude
&&
latitude
)
{
ui
.
locMap
.
latitude
=
latitude
ui
.
locMap
.
longitude
=
longitude
ui
.
locMap
.
markers
[
0
].
latitude
=
latitude
ui
.
locMap
.
markers
[
0
].
longitude
=
longitude
deviceLocError
=
false
// if (!weather.maxt || this.data.mint == 'person') {
// this.getWeather(data.lat, data.lng)
// }
}
else
{
deviceLocError
=
true
}
//详情内容
// this.setCarDetail(data)
this
.
setData
({
ui
:
{
...
ui
},
deviceLocError
})
},
setUI
(
data
)
{
const
{
ui
,
details
}
=
this
.
data
let
last_communication_time
=
null
let
gps_time
=
null
if
(
data
.
message
)
{
ui
.
message
=
data
.
message
//消息
}
if
(
data
.
address
)
{
ui
.
deviceAdress
=
data
.
address
//位置
}
if
(
data
.
type
==
2
)
{
ui
.
showMoreInfo
=
false
//小定位器
ui
.
canLock
=
false
}
if
(
data
.
dbDate
)
{
last_communication_time
=
moment
(
data
.
dbDate
).
format
(
'YYYY-MM-DD HH:mm'
)
ui
.
last_communication_time
=
last_communication_time
//更新时间
}
if
(
data
.
gpsDate
)
{
gps_time
=
moment
(
data
.
gpsDate
*
1000
).
format
(
'YYYY-MM-DD HH:mm'
)
ui
.
gps_time
=
gps_time
}
ui
.
vcuNo
=
data
.
vcuNo
ui
.
estimatedMileage
=
(
data
.
mile
/
1000
||
'0'
)
//预估里程
ui
.
lockState
=
data
.
lock_state
==
'2'
?
0
:
1
//锁 返回1开锁状态
ui
.
dumpEnergy
=
data
.
power
//剩余电量
ui
.
speed
=
data
.
speed
||
'--'
//行驶速度
setMap
(
lat
,
lng
){
let
{
locMap
}
=
this
.
data
locMap
.
latitude
=
lat
locMap
.
longitude
=
lng
locMap
.
markers
[
0
].
latitude
=
lng
locMap
.
markers
[
0
].
longitude
=
lng
details
[
0
].
des1
=
`信号强度:
${
data
.
accuracy
}
`
details
[
0
].
des2
=
`最后通信时间:
${
last_communication_time
}
`
details
[
1
].
des1
=
`经度:
${
data
.
lng
}
`
details
[
1
].
des2
=
`纬度:
${
data
.
lat
}
`
details
[
1
].
des3
=
`gps:
${
data
.
accuracy
>=
3
?
'有效'
:
'无效'
}
`
details
[
1
].
des4
=
`位置:
${
data
.
address
||
'--'
}
`
details
[
1
].
des5
=
`定位时间:
${
gps_time
||
'--'
}
`
details
[
1
].
tip
=
`
${
data
.
accuracy
>=
3
?
''
:
'当前定位不精确,将车辆移至信号良好处, 可增强通讯和定位。'
}
`
// details[2].des1 = `可用卫星:${d.number_satellite}`
//地图内容
let
deviceLocError
=
true
if
(
data
.
lng
&&
data
.
lat
)
{
ui
.
locMap
.
latitude
=
data
.
lat
ui
.
locMap
.
longitude
=
data
.
lng
ui
.
locMap
.
markers
[
0
].
latitude
=
data
.
lat
ui
.
locMap
.
markers
[
0
].
longitude
=
data
.
lng
deviceLocError
=
false
}
else
{
deviceLocError
=
true
}
//详情内容
// this.setCarDetail(data)
this
.
setData
({
ui
:
{
...
ui
},
details
:
[...
details
],
deviceLocError
locMap
:{...
locMap
}
})
},
getUserLoc
()
{
...
...
@@ -865,7 +713,9 @@ Page({
if
(
!
this
.
data
.
ui
.
canLock
)
{
return
}
let
{
item
}
=
e
.
currentTarget
.
dataset
let
{
item
}
=
e
.
currentTarget
.
dataset
if
(
item
==
2
)
{
//开
this
.
setData
({
lockAction
:
true
,
...
...
@@ -908,7 +758,7 @@ Page({
},
//无数据返回登录
reLogin
()
{
wx
.
redirect
To
({
wx
.
navigate
To
({
url
:
'/pages/register2/register2'
,
})
},
...
...
pages/user_index/user_index.wxml
View file @
2ce1960b
...
...
@@ -5,77 +5,83 @@
<canvas class="cvs progress_canvas" canvas-id="canvasProgress"> </canvas>
<view class="progress_text">
<view class="iv ab it">
<text wx:if="{{
hasBattery}}">5.0
V</text>
<text wx:if="{{
auth&&hasBattery}}">{{bmsVolt}}
V</text>
<text>电压</text>
</view>
<view class="ia ab it">
<text wx:if="{{
hasBattery}}">1.0
A</text>
<text wx:if="{{
auth&&hasBattery}}">{{bmsCurrent}}
A</text>
<text>电流</text>
</view>
<view class="is ab it">
<text wx:if="{{
hasBattery}}">充电中
</text>
<text wx:if="{{
auth&&hasBattery}}">{{bmsState}}
</text>
<text>状态</text>
</view>
<view class="ix ab it">
<text wx:if="{{
hasBattery}}">1
次</text>
<text wx:if="{{
auth&&hasBattery}}">{{bmsCycles}}
次</text>
<text>电池循环</text>
</view>
<view class="ic ab">
<view class="power-content">
<block wx:if="{{!auth}}">
<view class="no-battery">您还未登录哦</view>
</block>
<block wx:else>
<text wx:if="{{hasBattery}}">剩余电量</text>
<view wx:if="{{!hasBattery}}" class="no-battery">您还未绑定电池</view>
<view wx:if="{{hasBattery}}">
65
{{bmsSoc}}
<text>%</text>
</view>
</block>
</view>
<view class="sep-bar"></view>
<view class="bms-no" wx:if="{{
hasBattery}}">ABCDEF1234567890
</view>
<view class="bms-no" wx:if="{{
auth&&hasBattery}}">{{gprsImei}}
</view>
</view>
</view>
</view>
<view class="pg" wx:if="{{hasBattery}}">
<view class="pg" wx:if="{{
auth&&
hasBattery}}">
<view class="vip-box abtn" catchtap="showBuying">
<view>物联网卡服务截止到
2020-12-12
</view>
<view>物联网卡服务截止到
{{serverEndDate}}
</view>
<view class="v-t2">
<view>
<text>剩余</text>
<text class="day">
33
</text>
<text class="day">
{{batteryDeatil.restDay}}
</text>
<text>天</text>
</view>
<text>VIP续费</text>
</view>
</view>
</view>
<view class="pg"
wx:if="{{
hasBattery}}">
<map class="map" id='carMap' scale='13' markers='{{
ui.locMap.markers}}' show-location longitude='{{ui.locMap.longitude}}' latitude='{{ui.
locMap.latitude}}'>
<view class="pg"
wx:if="{{auth&&
hasBattery}}">
<map class="map" id='carMap' scale='13' markers='{{
locMap.markers}}' show-location longitude='{{locMap.longitude}}' latitude='{{
locMap.latitude}}'>
<cover-view class="cover" bindtap="seeMap">
<cover-view class="c-top">
<cover-view>GPS
|||||
</cover-view>
<cover-view>GSM
|||||
</cover-view>
<cover-view>GPS
{{gpsSnr}}
</cover-view>
<cover-view>GSM
{{batteryDeatil.gsmSnr}}
</cover-view>
</cover-view>
<cover-view class="c-bottom">
<cover-view>
浙江省杭州市余杭区
</cover-view>
<cover-view>
2020-10-22 12:22:33
</cover-view>
<cover-view>
{{batteryDeatil.address}}
</cover-view>
<cover-view>
{{updateTime}}
</cover-view>
</cover-view>
</cover-view>
</map>
</view>
<view class="pg" wx:if="{{hasBattery}}">
<view class="pg" wx:if="{{
auth&&
hasBattery}}">
<view class="battery-box abtn" bindtap="toHeath">
<view class="b-left">
<text>电池健康度</text>
<text>良好的电池使用习惯可以延长电池寿命</text>
</view>
<view class="b-right">
<text>
80
</text>
<text>
{{batteryDeatil.health}}
</text>
<text>分</text>
</view>
</view>
</view>
<view wx:if="{{!hasBattery}}" class="bind-btn">
<view class="btn" catchtap="bindBattery">立即扫码绑定</view>
<view wx:if="{{!auth&&hasBattery}}" class="bind-btn">
<view wx:if="{{!auth}}" catchtap="reLogin">立即登录</view>
<view class="btn" catchtap="bindBattery" wx:else>立即扫码绑定</view>
</view>
<i-modal visible="{{ lockAction }}" title="{{targetStatus===0?'关锁中。。':'开锁中。。'}}" show-ok="{{false}}" show-cancel="{{false}}">
<view style='padding:0 10rpx;'>
...
...
@@ -86,10 +92,26 @@
<cover-view class="my-cover {{myModel?'my-model':''}}" style="top:{{navHeight}}px" bindtap="showMy">
<cover-view class="my-body" catchtap="nullfunc">
<cover-view class="my-avator">
<cover-image class="avator" src="{{user.avatarUrl}}"></cover-image>
<block wx:if="{{user.avatarUrl}}">
<cover-image class="avator" src="{{user.avatarUrl||'./defaultAvator.png'}}"></cover-image>
</block>
<block wx:else>
<open-data class="avator" type="userAvatarUrl"></open-data>
</block>
<cover-view class="my-right">
<block wx:if="{{auth}}">
<block wx:if="{{user.nickname}}">
<cover-view class="nickname">{{user.nickname}}</cover-view>
</block>
<block wx:else>
<open-data class="nickname" type="userNickName"></open-data>
</block>
<cover-view catchtap="bindBattery" class="bind-btn abtn">绑定电池</cover-view>
</block>
<block wx:else>
<cover-view class="nickname" bindtap="reLogin">点击登录</cover-view>
</block>
</cover-view>
</cover-view>
<!-- <cover-view catchtap="bindBattery" class="bind-btn2"></cover-view> -->
...
...
@@ -99,14 +121,10 @@
</cover-view>
<cover-view>绑定电池</cover-view>
</cover-view> -->
<cover-view class="battery-list">
<cover-view class="battery-item">
<cover-view class="battery-no">ABCDEF1234567890</cover-view>
<cover-view>33%</cover-view>
</cover-view>
<cover-view class="battery-item">
<cover-view class="battery-no">ABCDEF1234567890</cover-view>
<cover-view>33%</cover-view>
<cover-view class="battery-list" wx:if="{{batteryList.length}}">
<cover-view class="battery-item" wx:for="{{batteryList}}" wx:key="{{item.id}}" bindtap="changeCar" data-id="{{item.id}}" data-deviceNo="{{item.deviceNo}}">
<cover-view class="battery-no">{{item.gprsImei}}</cover-view>
<cover-view>{{item.bmsSoc||'0'}}%</cover-view>
</cover-view>
</cover-view>
...
...
pages/user_index/user_index.wxss
View file @
2ce1960b
...
...
@@ -41,7 +41,7 @@ page {
justify-content: center;
align-items: center;
color: #fff;
padding-top: 200rpx;
/* padding-top: 200rpx; */
}
.bind-btn >view{
padding: 4px 20px;
...
...
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