deviceLocal - 副本.nvue 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050
  1. <template>
  2. <view class="container-view">
  3. <map
  4. id="myMap"
  5. :longitude="longitude"
  6. :latitude="latitude"
  7. :scale="scale"
  8. :markers="marker"
  9. :polyline="polylines"
  10. :circles="circles"
  11. @markertap="bindMarkertap"
  12. show-location
  13. enable-3D
  14. show-compass
  15. enable-overlooking
  16. :enable-satellite="mapParams.enableSatellite"
  17. :enable-traffic="mapParams.enableTraffic"
  18. :style="'height:'+ screenHeight*2 +'rpx;width:100%'"
  19. @tap="bindTapMap">
  20. </map>
  21. <map-control :mapParams="mapParams" @changeParams="mapChange"></map-control>
  22. <view v-if="showInfo" class="battery-group">
  23. <view class="battery-item">
  24. <view class="map-top">
  25. <view class="map-cross">
  26. <view class="map-top-box">
  27. <text class="map-top-text">GPS</text>
  28. <view :class="gps > 0 ? 'map-top-i' : 'map-top-n'" />
  29. <view :class="gps > 1 ? 'map-top-i' : 'map-top-n'" />
  30. <view :class="gps > 2 ? 'map-top-i' : 'map-top-n'" />
  31. <view :class="gps > 3 ? 'map-top-i' : 'map-top-n'" />
  32. <view :class="gps > 4 ? 'map-top-i' : 'map-top-n'" />
  33. </view>
  34. <view class="map-top-box gsm-view">
  35. <text class="map-top-text">GSM</text>
  36. <view :class="gsm > 0 ? 'map-top-i' : 'map-top-n'" />
  37. <view :class="gsm > 1 ? 'map-top-i' : 'map-top-n'" />
  38. <view :class="gsm > 2 ? 'map-top-i' : 'map-top-n'" />
  39. <view :class="gsm > 3 ? 'map-top-i' : 'map-top-n'" />
  40. <view :class="gsm > 4 ? 'map-top-i' : 'map-top-n'" />
  41. </view>
  42. </view>
  43. <view class="map-top-box-1">
  44. <text class="map-top-text-1">{{ deviceInfo.quantity }}%</text>
  45. <image src="https://qiniu.bms16.com/FikqU8xHYKBjolOPZ7uc9ZNJXfHU" class="bottom-img"></image>
  46. </view>
  47. <view v-if="deviceInfo.quantity >= 20"
  48. :style="'width: ' + batteryWidth + 'rpx;right:' + (31 + (37 - batteryWidth)) + 'rpx'"
  49. class="battery_num_view"></view>
  50. <view v-if="deviceInfo.quantity < 20"
  51. :style="'width: ' + batteryWidth + 'rpx;right:' + (31 + (37 - batteryWidth)) + 'rpx'"
  52. class="battery_num_view_red"></view>
  53. </view>
  54. <view class="batter-info-group">
  55. <view class="flex-row flex-between">
  56. <text class="battery-desc">{{ i18n['名称'] + ':' + deviceInfo.name }}</text>
  57. <text class="battery-desc">{{ i18n['状态'] + ':' + status }}</text>
  58. </view>
  59. <view class="flex-row flex-between">
  60. <text class="battery-desc">{{ i18n['编号'] + ':' + macid }}</text>
  61. <text class="battery-desc">{{ i18n['设防状态'] + ':' + deviceInfo.protectState ? (deviceInfo.protectState == 1 ? i18n['设防'] : i18n['撤防']) : i18n['未知'] }}
  62. </text>
  63. </view>
  64. <view class="flex-row flex-between">
  65. <text class="battery-desc">{{ i18n['控制'] + ':' + deviceInfo.oilState == 1 ? i18n['已通电'] : i18n['已断电'] }}</text>
  66. <text class="battery-desc">
  67. {{ i18n['定位类型'] + ':' + deviceInfo.signalType == 0 ? i18n['北斗GPS'] : deviceInfo.signalType == 1 ? 'WIFI' : deviceInfo.signalType == 16 ? 'LBS' : i18n['未知'] }}
  68. </text>
  69. </view>
  70. <view class="flex-row flex-between">
  71. <text class="battery-desc">{{ i18n['当日里程'] + ':' + deviceInfo.day_mil }}</text>
  72. <text class="battery-desc">{{ i18n['总里程'] + ':' + deviceInfo.mil }}</text>
  73. </view>
  74. <view class="flex-row flex-between">
  75. <text class="battery-desc">
  76. {{i18n['电压'] + ':' +(deviceInfo.voltage ? deviceInfo.voltage + 'V' : i18n['未知']) +(deviceInfo.elecState ? (deviceInfo.elecState == 1 ? '('+i18n['主电接通']+')' : '('+i18n['主电断开'] + ')') : '')}}
  77. </text>
  78. <text class="battery-desc" v-if="deviceInfo && deviceInfo.temp && deviceInfo.temp != ''">{{ i18n['温度'] + ':'+deviceInfo.temp + '℃' }}</text>
  79. </view>
  80. <text class="battery-desc">{{ i18n['通信'] + ':' + deviceInfo.heart_time ? formatTime(deviceInfo.heart_time) : i18n['未知'] }}</text>
  81. <text class="battery-desc">{{ i18n['定位'] + ':' + deviceInfo.gps_time ? formatTime(deviceInfo.gps_time) : i18n['未知'] }}</text>
  82. <text v-if="address != ''" class="battery-desc">{{ i18n['地址'] + ':' + address }}</text>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="bottom-view" >
  87. <view class="bottom-center">
  88. <image :src="trace ? 'https://qiniu.bms16.com/FtYkQp4Nc2JD2SZ-_BjCI--DJWyi' : 'https://qiniu.bms16.com/FlRUmvzPd-BzkMAj04LwmX7UBrEP'"
  89. class="bottom-img"></image>
  90. </view>
  91. <view class="bottom-centent" style="width:750rpx;">
  92. <view class="bottom-item" @tap="bindTrackDialogOpen">
  93. <image
  94. :src="trackPoints.length == 0 ? 'https://qiniu.bms16.com/FqYJ3dMKvis19y8-onbNdRBEO5mT' : 'https://qiniu.bms16.com/FlH-IsasGFDH2QsRZixIFh7q7Tjv'"
  95. class="bottom-img"></image>
  96. <text class="bottom-text">{{i18n['轨迹']}}</text>
  97. </view>
  98. <view class="bottom-item" @tap="bindAlarmPopupOpen">
  99. <image
  100. :src="alarmList.length == 0 ? 'https://qiniu.bms16.com/FkVJmibJNj0CvoIrQmtz_wKotWpO' : 'https://qiniu.bms16.com/Fu4mutL6ECkBLManyT_cvZ6C8iAT'"
  101. class="bottom-img"></image>
  102. <text class="bottom-text">{{i18n['报警']}}</text>
  103. </view>
  104. <view class="bottom-item" @tap="bindNavigate">
  105. <image class="bottom-img"></image>
  106. <text class="bottom-text">{{i18n['导航']}}</text>
  107. </view>
  108. <view class="bottom-item" @tap="bindSendCommand" data-cmd="CLOSERELAY">
  109. <image src="https://qiniu.bms16.com/Fr-g3_g0T5aZ_sLQB7Xs1qRpxGAS" class="bottom-img"></image>
  110. <text class="bottom-text">{{i18n['断电']}}</text>
  111. </view>
  112. <view class="bottom-item" @tap="bindSendCommand" data-cmd="OPENRELAY">
  113. <image src="https://qiniu.bms16.com/Fv1eQozcTejKVdXbqkcea9syHOU3" class="bottom-img"></image>
  114. <text class="bottom-text">{{i18n['通电']}}</text>
  115. </view>
  116. </view>
  117. <image v-if="trackPoints.length != 0"
  118. :src="inPlay ? 'https://qiniu.bms16.com/FrTpj-jPSkQIsRjPOFE25lzJ4H7Z' : 'https://qiniu.bms16.com/Fl6EjlB1RufKn7QeKdBJC7dXxC9M'"
  119. class="play-img" @tap="bindPlay"></image>
  120. <image v-if="trackStopList.length != 0" src="https://qiniu.bms16.com/FoMwbUuD37w4Ja13-NXtm3hhkUgZ" class="stop-img"
  121. @tap="bindStopPopupOpen"></image>
  122. <view v-if="trackStopList.length != 0" class="stop-img" @tap="bindStopPopupOpen">
  123. <view class="tip-top">{{ trackStopList.length }}</view>
  124. </view>
  125. <image v-if="trackPoints.length != 0" src="https://qiniu.bms16.com/FqZcllaWWt2WJ3QGDt3wfKJM3wgP" class="close-img"
  126. @tap="bindCloseTrack"></image>
  127. <view @tap="loadLastGpsInfo" class="gps_last">
  128. <text class="text_view">{{i18n['最新']}}</text>
  129. <text class="text_view">GPS</text>
  130. </view>
  131. <image src="https://qiniu.bms16.com/Fg4wwTFjltC-0avrON1I0WLrIa82" class="fence-img" @tap="bindFencePopupOpen"></image>
  132. <view v-if="trace" class="trace-box">{{ i18n['追踪时间'] + ':' + tools.formatHourSeconds(traceTime) }}</view>
  133. </view>
  134. <view class="left-group">
  135. <view class="left-group-i">
  136. <image class="btn-ctr" src="https://qiniu.bms16.com/Fm-AhAqRdu14DZcE52vl85nw_vuD" @tap="moveToLocation"></image>
  137. </view>
  138. </view>
  139. <view v-if="trackPoints.length != 0" class="track_bottom">
  140. <text class="track_total_time">
  141. {{ i18n['时间'] + ':' + formatTimeNoSecond(trackDialogFrom.startTime / 1000) + i18n['至'] + formatTimeNoSecond(trackDialogFrom.endTime / 1000) + i18n['共'] + mileage_total + i18n['公里'] }}
  142. </text>
  143. <view class="track_slide flex-row flex-between">
  144. <slider @change="trackPlayChangeAdress" @changing="trackPlayChange" :value="nowPlayIndex" min="1"
  145. :max="totalTrackValue" style="width:600rpx;" />
  146. <view @tap="bindFastForward" class="flex-row fastForward">
  147. <image class="fastForward_img" src="https://qiniu.bms16.com/Fp6Kaid1eEQYqdGgwQD5TGZ1ir_7"></image>
  148. <text v-if="adjustSpeed == 0" class="fastForward_text">{{i18n['慢']}}</text>
  149. <text v-if="adjustSpeed == 1" class="fastForward_text">{{i18n['中']}}</text>
  150. <text v-if="adjustSpeed == 2" class="fastForward_text">{{i18n['快']}}</text>
  151. </view>
  152. </view>
  153. </view>
  154. <!-- 下方点击轨迹弹窗 -->
  155. <view v-if="trackDialogShow" class="popup-black" :style="'height:'+ screenHeight*2 +'rpx;width: 750rpx;'">
  156. <view class="popup-view">
  157. <view class="popup-top"><text style="font-size: 30rpx;">{{i18n['轨迹']}}</text></view>
  158. <view style="padding-left: 30rpx;padding-right: 30rpx;">
  159. <view class="flex-row" style="margin-bottom: 40rpx;">
  160. <text class="location_mark">{{i18n['定位类型'] + ':'}}</text>
  161. <text @tap="bindLocationType" data-index="1"
  162. :class="isLocationType == 1 ? 'sel_location_view' : 'un_location_view'">GPS</text>
  163. <text @tap="bindLocationType" data-index="2"
  164. :class="isLocationType == 2 ? 'sel_location_view' : 'un_location_view'">LBS</text>
  165. <text @tap="bindLocationType" data-index="3"
  166. :class="isLocationType == 3 ? 'sel_location_view' : 'un_location_view'">GPS+LBS</text>
  167. </view>
  168. <view class="flex-row" style="margin-bottom: 50rpx;align-items: center;">
  169. <view class="flex-row" style="margin-right: 60rpx;">
  170. <img class="time-img" src="https://qiniu.bms16.com/Ful5wl2uV3-Ys8PdeFDGZRgBm6DX" />
  171. <text style="font-size: 28rpx;">{{i18n['起始日期']}}</text>
  172. </view>
  173. <view style="height: 40rpx;">
  174. <time-picker :time="trackDialogFrom.formatStartTime" @confirmPickDate="confirmPickDate" />
  175. </view>
  176. </view>
  177. <view class="flex-row" style="margin-bottom: 70rpx;align-items: center;">
  178. <view class="flex-row" style="margin-right: 60rpx;">
  179. <img class="time-img" src="https://qiniu.bms16.com/Ful5wl2uV3-Ys8PdeFDGZRgBm6DX" />
  180. <text style="font-size: 28rpx;">{{i18n['结束日期']}}</text>
  181. </view>
  182. <view style="height: 40rpx;">
  183. <time-picker :time="trackDialogFrom.formatEndTime" @confirmPickDate="confirmPickDate" />
  184. </view>
  185. </view>
  186. <view class="day-btn flex-row">
  187. <view @tap="bindTrackTimeSelectToday"><text style="font-size: 28rpx;">{{i18n['今天']}}</text></view>
  188. <view @tap="bindTrackTimeSelectYesterday"><text style="font-size: 28rpx;">{{i18n['昨天']}}</text></view>
  189. <view @tap="bindTrackTimeSelectLastday"><text style="font-size: 28rpx;">{{i18n['前天']}}</text></view>
  190. </view>
  191. </view>
  192. <view class="bottom-btn flex-row">
  193. <view class="btn first-btn" @tap="bindTrackDialogClose"><text style="text-align: center;font-size: 28rpx;">{{i18n['取消']}}</text></view>
  194. <view class="btn second-btn" @tap="bindTrackDialogConfirm"><text style="text-align: center;font-size: 28rpx;color: #1989fa;">{{i18n['查询']}}</text></view>
  195. </view>
  196. </view>
  197. </view>
  198. <!-- 下方点击报警弹窗 -->
  199. <view v-if="alarmPopupShow" class="popup-black" :style="'height:'+ screenHeight*2 +'rpx;width:750rpx;'">
  200. <scroll-view class="alarm-view" style="width:750rpx;" :scroll-y="true">
  201. <view class="alarm-top flex-row">
  202. <view><text style="font-size: 30rpx;">{{i18n['报警']}}</text></view>
  203. <view @tap="bindAlarmPopupClose"><img style="width: 50rpx;height: 50rpx;" src="https://qiniu.bms16.com/FjhcWGFGsI56rLZRu7_OnhGtpoUs" />
  204. </view>
  205. </view>
  206. <view class="alarm-content flex-row flex-between" @tap="MoveToAlarm($event, { p: item })" :data-p="item"
  207. v-for="(item, index) in alarmList" :key="index">
  208. <view>
  209. <view class="flex-row" style="margin-bottom: 10rpx;">
  210. <text class="danger-view">{{ item.alarm_desc }}</text>
  211. <text class="primary-view">{{ item.speed +i18n['公里']+'/'+i18n['小时'] }}/</text>
  212. </view>
  213. <text style="font-size: 30rpx;">{{ item.formatTime }}</text>
  214. </view>
  215. <view class="alarm-right"><text style="font-size: 32rpx;">{{item.address}}</text></view>
  216. </view>
  217. </scroll-view>
  218. </view>
  219. <!-- 停留点 -->
  220. <view v-if="trackStopPopupShow" class="popup-black" :style="'height:'+ screenHeight*2 +'rpx;width:750rpx;'">
  221. <scroll-view class="stop-view" style="width:750rpx;">
  222. <view class="stop-top flex-row flex-between">
  223. <view><text style="font-size: 30rpx;">{{i18n['停留点']}}</text></view>
  224. <view @tap="bindStopPopupClose">
  225. <img style="width: 50rpx;height: 50rpx;" src="https://qiniu.bms16.com/FjhcWGFGsI56rLZRu7_OnhGtpoUs" />
  226. </view>
  227. </view>
  228. <view class="stop-content flex-row flex-between" @tap="MoveToStop($event, { p: item })" :data-p="item"
  229. v-for="(item, index) in trackStopList" :key="index">
  230. <view style="width: 350rpx;">
  231. <view class="flex-row" style="margin-bottom: 10rpx;">
  232. <text style="font-size: 30rpx;">{{ item.name }}</text>
  233. <view class="o-text"><text style="font-size: 30rpx;">{{ item.format_stop_time }}</text></view>
  234. </view>
  235. <view style="white-space: break-spaces;"><text style="font-size: 30rpx;">{{ item.time }} - {{ item.end_time }}</text></view>
  236. </view>
  237. <view class="stop-right"><text style="font-size: 30rpx;">{{item.address}}</text></view>
  238. </view>
  239. </scroll-view>
  240. </view>
  241. <!-- 右下角围栏 -->
  242. <view v-if="fencePopupShow" class="popup-black" :style="'height:'+ screenHeight*2 +'rpx;width:750rpx;'">
  243. <scroll-view class="fence-view" style="width:750rpx;" :scroll-y="true">
  244. <view class="fence-top flex-row flex-between">
  245. <view class="flex-row">
  246. <view style="margin-right: 20rpx;"><text style="font-size: 30rpx;">{{i18n['围栏']}}</text></view>
  247. <view class="fence-btn flex-row" @tap="addFence"><img
  248. style="width: 30rpx;height: 30rpx;margin-right: 15rpx;"
  249. src="https://qiniu.bms16.com/FkjjRjSiRHnbPJk_2PhaiAcfwY1f" /><text style="font-size: 30rpx;color: #ffffff;">{{i18n['添加']}}</text></view>
  250. </view>
  251. <view @tap="bindFencePopupClose"><img style="width: 50rpx;height: 50rpx;" src="https://qiniu.bms16.com/FjhcWGFGsI56rLZRu7_OnhGtpoUs" />
  252. </view>
  253. </view>
  254. <view class="fence-content flex-row flex-between" @click="MoveToFence($event, { p: item })"
  255. :data-p="item" v-for="(item, index) in fenceList" :key="index">
  256. <view>
  257. <text class="van-cell-text">
  258. {{ item.name }}
  259. </text>
  260. <view class="flex-row">
  261. <text class="van-cell-text">{{ i18n['报警类型'] + ':' }}</text>
  262. <text v-if="item.type == 2" class="van-cell-text">{{i18n['出']}}</text>
  263. <text v-if="item.type == 3" class="van-cell-text">{{i18n['双向']}}</text>
  264. <text v-if="item.type == 4" class="van-cell-text">{{i18n['关闭']}}</text>
  265. <text v-if="item.type == 1" class="van-cell-text">{{i18n['进']}}</text>
  266. <!-- <text class="van-cell-text">{{ i18n['报警类型'] + ':' + item.type == 1 ? i18n['进'] : item.type == 2 ? i18n['出'] : item.type == 3 ? i18n['双向'] : i18n['关闭'] }}</text> -->
  267. </view>
  268. </view>
  269. <view class="fence-right"><text style="font-size: 32rpx;">{{item.radius + i18n['米']}}</text></view>
  270. </view>
  271. </scroll-view>
  272. </view>
  273. <!-- 围栏设置 -->
  274. <view v-if="selectFence != null" class="popup-black" :style="'height:'+ screenHeight*2 +'rpx;width:750rpx;'">
  275. <scroll-view class="fence-view" style="width:750rpx;" :scroll-y="true">
  276. <view class="fence-top flex-row flex-between">
  277. <view style="margin-right: 20rpx;"><text style="font-size: 30rpx;">{{i18n['围栏设置']}}</text></view>
  278. <view @tap="bindFenceClose"><img style="width: 50rpx;height: 50rpx;" src="https://qiniu.bms16.com/FjhcWGFGsI56rLZRu7_OnhGtpoUs" /></view>
  279. </view>
  280. <view>
  281. <view class="fence-config flex-row flex-between" style="align-items: center;">
  282. <text style="font-size: 30rpx;">{{i18n['围栏名称']}}</text>
  283. <input type="text" :placeholder="i18n['请输入围栏名称']" @blur="onFenceNameChange" :value="selectFence.name"
  284. style="color: rgba(0, 0, 0, 1);font-size: 30rpx;width: 300rpx;text-align: right;" />
  285. </view>
  286. <view class="fence-config flex-row flex-between">
  287. <text style="font-size: 30rpx;">{{i18n['报警类型']}}</text>
  288. <view class="flex-row">
  289. <radio-group class="radio-group flex-row" @change="onFenceTypeChange">
  290. <radio value="1" /><text style="font-size: 30rpx;">{{i18n['进']}}</text>
  291. <radio value="2" /><text style="font-size: 30rpx;">{{i18n['出']}}</text>
  292. <radio value="3" /><text style="font-size: 30rpx;">{{i18n['双向']}}</text>
  293. <radio value="0" /><text style="font-size: 30rpx;">{{i18n['关闭']}}</text>
  294. </radio-group>
  295. </view>
  296. </view>
  297. <view class="fence-config flex-row flex-between">
  298. <text style="font-size: 30rpx;">{{i18n['围栏半径']}}</text>
  299. <view style="width: 500rpx;" class="flex-row flex-around">
  300. <image src="https://qiniu.bms16.com/Fgthw9jHOk5KP9wfiOEv_6iwCpt5" style="width: 40rpx; height: 40rpx"
  301. @tap="onFenceRadiusMinus"></image>
  302. <slider :value="selectFence.radius" @change="onFenceRadiusChange"
  303. @changing="onFenceRadiusChange" min="1" max="10000" show-value block-size="21" />
  304. <image src="https://qiniu.bms16.com/FnL1ghroP_oJRk1_0PpUXONI533U" style="width: 40rpx; height: 40rpx"
  305. @tap="onFenceRadiusPlus"></image>
  306. </view>
  307. </view>
  308. <view class="fence-config">
  309. <button class="save-btn" style="width:700rpx;" @tap="bindFenceSave">{{i18n['保存']}}</button>
  310. </view>
  311. </view>
  312. </scroll-view>
  313. </view>
  314. </view>
  315. </template>
  316. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  317. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  318. <script>
  319. import zh from '@/locale/zh-Hans.json'; //简体中文
  320. import en from '@/locale/en.json'; //英文
  321. import mapControl from '@/component/mapControl/mapControl';
  322. import timePicker from '@/component/time-pickers/time-pickers';
  323. // pages/deviceLocal/deviceLocal.js
  324. const config = require('../../common/config.js');
  325. const common = require('../../common/common.js');
  326. var http = require('../../common/http.js');
  327. var storage = require('../../common/storage.js');
  328. var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
  329. var qqmapsdk;
  330. export default {
  331. components: {
  332. mapControl,
  333. timePicker
  334. },
  335. data() {
  336. return {
  337. id: '',
  338. deviceInfo: {
  339. quantity: '',
  340. name: '',
  341. protectState: false,
  342. oilState: 0,
  343. signalType: 0,
  344. day_mil: '',
  345. mil: '',
  346. voltage: false,
  347. elecState: false,
  348. temp: '',
  349. heart_time: false,
  350. gps_time: false
  351. },
  352. marker: [],
  353. mileage_total: 0,
  354. deviceMarker: [],
  355. trackMarker: [],
  356. alarmMarker: [],
  357. playMarker: [],
  358. endSlide: 0,
  359. polylines: [],
  360. trackPoints: [],
  361. trackStopList: [],
  362. batteryWidth: 37,
  363. alarmList: [],
  364. adjustSpeed: 1,
  365. scale: 8,
  366. speedTime: 200,
  367. trackDialogFrom: {
  368. startTime: new Date().getTime(),
  369. endTime: new Date().getTime() + 3600,
  370. // startTime: new Date(new Date().getTime() - 3600000).getTime(),
  371. // endTime: new Date().getTime(),
  372. // formatStartTime: common.formatDateTime(new Date(new Date().getTime() - 3600000).getTime()),
  373. // formatEndTime: common.formatDateTime(new Date().getTime()),
  374. formatStartTime: common.formatDateTime(new Date().getTime()),
  375. formatEndTime: common.formatDateTime(new Date(new Date().getTime() + 3600000).getTime())
  376. },
  377. latitude_my: null,
  378. longitude_my: null,
  379. trackDialogShow: false,
  380. selectTime: new Date().getTime(),
  381. selectTimeType: '',
  382. alarmPopupShow: false,
  383. trackStopPopupShow: false,
  384. timeSelectShow: false,
  385. inPlay: false,
  386. playTimer: null,
  387. nowPlayIndex: 0,
  388. totalTrackValue: 0,
  389. currentTrackValue: 0,
  390. macid: '',
  391. gps: 0,
  392. gsm: 0,
  393. status: '',
  394. address: '',
  395. showInfo: true,
  396. iconList: [],
  397. locationTimer: null,
  398. longitude: null,
  399. latitude: null,
  400. trace: false,
  401. tracePoints: [],
  402. traceTime: 0,
  403. traceTimer: null,
  404. fencePopupShow: false,
  405. fenceList: [],
  406. isLocationType: 1,
  407. circles: [],
  408. selectFence: null,
  409. mapParams: {
  410. enableSatellite: false,
  411. // 是否开启卫星图
  412. enableTraffic: false // 是否开启实时路况
  413. },
  414. isShowGPS: false,
  415. // locationInfo:{}
  416. locationType: '',
  417. locationAdress: '',
  418. locationGpsType: '',
  419. locationGpsAdress: '',
  420. gpsMarker: [],
  421. flase: '',
  422. screenHeight: 0,
  423. screenWidth: 0,
  424. i18n: {},
  425. };
  426. },
  427. /**
  428. * 生命周期函数--监听页面加载
  429. */
  430. onLoad: function(options) {
  431. // this.i18n = en
  432. this.i18n = zh
  433. this.screenHeight = uni.getSystemInfoSync().windowHeight + 40
  434. this.screenWidth = uni.getSystemInfoSync().windowWidth
  435. this.loadIconList();
  436. this.readyDeviceInfo();
  437. this.loadAlarmList();
  438. this.loadFenceList();
  439. this.locationLoop(true);
  440. //this.loadLastGpsInfo()
  441. this.locationTimer = setInterval(this.locationLoop, 10000);
  442. //获取当前位置
  443. uni.getLocation({
  444. type: 'gcj02',
  445. success: (res) => {
  446. this.latitude_my = res.latitude
  447. this.longitude_my = res.longitude
  448. }
  449. });
  450. setTimeout(function() {
  451. this.mapCtx = uni.createMapContext('myMap');
  452. }, 500);
  453. // this.mapCtx = uni.createMapContext('myMap');
  454. },
  455. onHide: function() {},
  456. onShow: function() {},
  457. onUnload: function() {
  458. clearInterval(this.locationTimer);
  459. clearInterval(this.traceTimer);
  460. clearInterval(this.playTimer);
  461. },
  462. methods: {
  463. formatTime (datetime) {
  464. if (!datetime) return '';
  465. var date = new Date(datetime * 1000);
  466. var year = date.getFullYear()
  467. var month = date.getMonth() + 1
  468. var day = date.getDate()
  469. var hour = date.getHours()
  470. var minute = date.getMinutes()
  471. var second = date.getSeconds()
  472. return year + '-' + this.formatNumber(month) + '-' + this.formatNumber(day) + ' ' + this.formatNumber(hour) + ':' + this.formatNumber(minute) + ':' + this.formatNumber(second);
  473. },
  474. formatNumber(n) {
  475. n = n.toString()
  476. return n[1] ? n : '0' + n
  477. },
  478. formatTimeNoSecond(datetime) {
  479. if (!datetime) return '';
  480. var date = new Date(datetime * 1000);
  481. var year = date.getFullYear()
  482. var month = date.getMonth() + 1
  483. var day = date.getDate()
  484. var hour = date.getHours()
  485. var minute = date.getMinutes()
  486. var second = date.getSeconds()
  487. return year + '-' + this.formatNumber(month) + '-' + this.formatNumber(day) + ' ' + this.formatNumber(hour) + ':' + this.formatNumber(minute);
  488. },
  489. loadIconList: function() {
  490. this.iconList = storage.getIconList();
  491. if (!this.iconList) {
  492. http.postApi(config.API_BATTERY_ICON_LIST, {}, (resp) => {
  493. if (resp.data.code === 200) {
  494. this.iconList = resp.data.data.list;
  495. storage.setIconList(resp.data.data.list);
  496. } else {
  497. common.simpleToast(this,resp.data.msg);
  498. }
  499. });
  500. }
  501. },
  502. onStartTimeChange(e) {
  503. this.trackDialogFrom.startTime = e.detail.value;
  504. // 更新结束时间的最小值,确保结束时间不早于开始时间
  505. this.trackDialogFrom.endTime = Math.max(this.trackDialogFrom.endTime, this.trackDialogFrom.startTime);
  506. // trackDialogFrom.formatStartTime
  507. // trackDialogFrom.formatEndTime
  508. },
  509. onEndTimeChange(e) {
  510. this.trackDialogFrom.endTime = e.detail.value;
  511. },
  512. confirmPickDate(dataStr) {
  513. this.trackDialogFrom.formatStartTime = dataStr
  514. this.$emit("time", dateStr);
  515. },
  516. trackPlayChange(e) {
  517. var index = e.detail.value;
  518. this.nowPlayIndex = index
  519. this.playLoop();
  520. },
  521. bindLocationType(e) {
  522. const index = e.currentTarget.dataset.index;
  523. this.isLocationType = index
  524. },
  525. trackPlayChangeAdress(e) {
  526. var index = e.detail.value;
  527. this.nowPlayIndex = index
  528. const me = this;
  529. this.playLoop();
  530. if (me.playMarker.length > 0) {
  531. // qqmapsdk.reverseGeocoder({
  532. // location: {
  533. // latitude: me.data.playMarker[0].latitude,
  534. // longitude: me.data.playMarker[0].longitude
  535. // },
  536. // success: function (res) {
  537. // const formatted_addresses = res.result.formatted_addresses
  538. // const address = res.result.address
  539. // let ps = '';
  540. // let tmp_addr = '地址: ' + address
  541. // while (tmp_addr.length > 15) {
  542. // ps += tmp_addr.substring(0, 15) + "\n";
  543. // tmp_addr = tmp_addr.substring(15);
  544. // }
  545. // ps += tmp_addr
  546. // var playMark = me.data.playMarker
  547. // playMark[0].callout.content += ps
  548. // me.setData({
  549. // playMarker: playMark
  550. // })
  551. // me.setMarkers()
  552. // }
  553. // })
  554. const me = this;
  555. const pData = {
  556. lng: me.playMarker[0].longitude,
  557. lat: me.playMarker[0].latitude,
  558. pi: 'wx_deviceLocal'
  559. };
  560. http.postApi(config.API_MAP_REGEO, pData, function(resp) {
  561. if (resp.data.code === 200) {
  562. var jsonData = resp.data.data.data;
  563. if (jsonData.code === 0) {
  564. const address = jsonData.address;
  565. let ps = '';
  566. let tmp_addr = me.i18n['地址']+':'+ address;
  567. while (tmp_addr.length > 15) {
  568. ps += tmp_addr.substring(0, 15) + '\n';
  569. tmp_addr = tmp_addr.substring(15);
  570. }
  571. ps += tmp_addr;
  572. var playMark = me.playMarker;
  573. playMark[0].callout.content += ps;
  574. me.playMarker = playMark
  575. }
  576. }
  577. });
  578. }
  579. },
  580. bindFastForward() {
  581. if (this.adjustSpeed === 0) {
  582. this.adjustSpeed = 1
  583. this.speedTime = 400
  584. clearInterval(this.playTimer);
  585. this.playTimer = setInterval(this.playLoop, this.speedTime);
  586. } else if (this.adjustSpeed === 1) {
  587. this.adjustSpeed = 2
  588. this.speedTime = 200
  589. clearInterval(this.playTimer);
  590. this.playTimer = setInterval(this.playLoop, this.speedTime);
  591. } else if (this.adjustSpeed === 2) {
  592. this.adjustSpeed = 0
  593. this.speedTime = 600
  594. clearInterval(this.playTimer);
  595. this.playTimer = setInterval(this.playLoop, this.speedTime);
  596. }
  597. },
  598. loadAlarmList() {
  599. common.loading(this);
  600. const me = this
  601. const deviceInfo = storage.getSelectedDeviceInfo();
  602. http.postApi(
  603. config.API_GPS_ALARM, {
  604. macid: deviceInfo.mac_id
  605. },
  606. (resp) => {
  607. uni.hideLoading();
  608. if (resp.data.code === 200) {
  609. var alarmList = resp.data.data.list;
  610. alarmList.forEach((p, i) => {
  611. alarmList[i].formatTime = common.formatDateTime(p.send_time * 1000);
  612. qqmapsdk.reverseGeocoder({
  613. location: {
  614. latitude: p.latitude,
  615. longitude: p.longitude
  616. },
  617. success: (res) => {
  618. const formatted_addresses = res.result.formatted_addresses;
  619. const address = res.result
  620. .address; //+ formatted_addresses.recommend
  621. let ps = '';
  622. let tmp_addr = me.i18n['地址']+':'+ address;
  623. while (tmp_addr.length > 15) {
  624. ps += tmp_addr.substring(0, 15) + '\n';
  625. tmp_addr = tmp_addr.substring(15);
  626. }
  627. ps += tmp_addr;
  628. alarmList[i].address = address;
  629. alarmList[i].ps = ps;
  630. this.alarmList = alarmList
  631. }
  632. });
  633. });
  634. this.alarmList = alarmList
  635. } else {
  636. common.simpleToast(this,resp.data.msg);
  637. }
  638. }
  639. );
  640. },
  641. readyDeviceInfo() {
  642. const me = this;
  643. // 实例化API核心类
  644. qqmapsdk = new QQMapWX({
  645. key: config.QQ_MAP_KEY
  646. });
  647. const deviceInfo = storage.getSelectedDeviceInfo();
  648. if (deviceInfo) {
  649. // this.batteryWidth = deviceInfo.quantity/100*37
  650. uni.setNavigationBarTitle({
  651. title: deviceInfo.mac_id
  652. });
  653. if (parseInt(deviceInfo.expire) === 1) {
  654. common.simpleToast(me,me.i18n['设备到期']);
  655. setTimeout(function() {
  656. uni.navigateBack({
  657. delta: 1
  658. });
  659. }, 1500);
  660. }
  661. } else {
  662. clearInterval(this.locationTimer);
  663. setTimeout(function() {
  664. uni.navigateBack({
  665. delta: 1
  666. });
  667. }, 1500);
  668. }
  669. },
  670. setMarkers() {
  671. this.marker = this.deviceMarker.concat(this.trackMarker, this.alarmMarker, this.playMarker, this.gpsMarker)
  672. },
  673. setPolylines() {
  674. var polylines = [{
  675. points: this.trackPoints,
  676. color: '#1989FADD',
  677. width: 5,
  678. arrowLine: true
  679. }];
  680. /*, {
  681. points: this.data.trackPoints.slice(0,this.data.nowPlayIndex+1),
  682. color: '#F56C6CDD',
  683. width: 3,
  684. }]*/
  685. if (this.trace) {
  686. polylines.push({
  687. points: this.tracePoints,
  688. color: '#DD4C4CDD',
  689. width: 3,
  690. arrowLine: true
  691. });
  692. }
  693. this.polylines = polylines
  694. },
  695. bindTrackDialogOpen() {
  696. this.trackDialogShow = true
  697. },
  698. // 计算里程数
  699. calculateMileage(history) {
  700. let mileage = 0;
  701. for (let i = 0; i < history.length - 1; i++) {
  702. mileage += parseInt(common.getFlatternDistance(history[i].longitude, history[i].latitude, history[i +
  703. 1].longitude, history[i + 1].latitude));
  704. }
  705. var mileage_total = mileage == 0 ? 0 : (mileage / 1000).toFixed(2);
  706. this.mileage_total = mileage_total
  707. },
  708. getCurrentMil(mileage, i, history) {
  709. //var mileage = mileage_current
  710. mileage += parseInt(common.getFlatternDistance(history[i].longitude, history[i].latitude, history[i + 1]
  711. .longitude, history[i + 1].latitude));
  712. return mileage;
  713. },
  714. loadTotalMil() {
  715. const deviceInfo = storage.getSelectedDeviceInfo();
  716. http.postApi(
  717. config.API_SHOW_MIL, {
  718. macid: deviceInfo.mac_id,
  719. location_type: this.isLocationType,
  720. from: parseInt(this.trackDialogFrom.startTime / 1000),
  721. to: parseInt(this.trackDialogFrom.endTime / 1000)
  722. },
  723. (resp) => {
  724. if (resp.data.code === 200) {
  725. this.mileage_total = resp.data.data.distance
  726. } else {
  727. common.simpleToast(this,resp.data.msg);
  728. }
  729. }
  730. );
  731. },
  732. bindTrackDialogConfirm() {
  733. var me = this;
  734. this.bindTrackDialogClose();
  735. this.inPlay = false
  736. clearInterval(this.playTimer);
  737. common.loading(this);
  738. const deviceInfo = storage.getSelectedDeviceInfo();
  739. http.postApi(
  740. config.API_GPS_TRACK, {
  741. macid: deviceInfo.mac_id,
  742. location_type: this.isLocationType,
  743. from: parseInt(this.trackDialogFrom.startTime / 1000),
  744. to: parseInt(this.trackDialogFrom.endTime / 1000)
  745. },
  746. (resp) => {
  747. this.loadTotalMil();
  748. uni.hideLoading();
  749. if (resp.data.code === 200) {
  750. if (!resp.data.data.points || resp.data.data.points.length === 0) {
  751. common.simpleToast(me,me.i18n['当前未有轨迹']);
  752. return;
  753. }
  754. // this.calculateMileage(resp.data.data.points)
  755. var points = [];
  756. var trackMarker = [];
  757. var trackStopList = [];
  758. var n = 1;
  759. this.totalTrackValue = resp.data.data.points.length
  760. var mileage = 0;
  761. resp.data.data.points.forEach((p, i) => {
  762. //移动坐标点
  763. if (resp.data.data.points.length - 1 > i) {
  764. mileage = this.getCurrentMil(mileage, i, resp.data.data.points);
  765. }
  766. points.push({
  767. latitude: parseFloat(p.latitude),
  768. longitude: parseFloat(p.longitude),
  769. time: p.time,
  770. speed: p.speed,
  771. voltage: p.voltage,
  772. time: p.time,
  773. mileage: (mileage / 1000).toFixed(2),
  774. stop_time: p.stop_time
  775. });
  776. //起点
  777. if (i === 0) {
  778. trackStopList.push({
  779. name: me.i18n['起点'],
  780. latitude: parseFloat(p.latitude),
  781. longitude: parseFloat(p.longitude),
  782. time: p.time,
  783. end_time: common.formatDateTime(new Date(p.time).getTime() + p
  784. .stop_time * 1000),
  785. stop_time: p.stop_time,
  786. // format_stop_time: common.formatSeconds(me,p.stop_time),
  787. format_stop_time: me.formatSeconds(p.stop_time),
  788. address: ''
  789. });
  790. //mark弹出框坐标
  791. trackMarker.push({
  792. id: 0,
  793. latitude: p.latitude,
  794. longitude: p.longitude,
  795. name: '',
  796. iconPath: 'https://qiniu.bms16.com/FudnX-2lAHteUZHxpH6cAXFESNVs',
  797. width: 28,
  798. height: 35,
  799. zIndex: 2,
  800. callout: {
  801. content: '\u8D77\u70B9\n\u505C\u7559: ' +
  802. // common.formatSeconds(me,p.stop_time) +
  803. me.formatSeconds(p.stop_time) +
  804. '\n' +
  805. me.i18n['开始'] + ':' +
  806. p.time +
  807. '\n' +
  808. me.i18n['结束'] + ':' +
  809. common.formatDateTime(new Date(p.time).getTime() + p
  810. .stop_time * 1000) +
  811. '\n',
  812. padding: 10,
  813. borderRadius: 4,
  814. boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
  815. display: 'BYCLICK'
  816. }
  817. });
  818. const pData = {
  819. lng: parseFloat(p.longitude),
  820. lat: parseFloat(p.latitude),
  821. pi: 'wx_deviceLocal'
  822. };
  823. http.postApi(config.API_MAP_REGEO, pData, function(resp) {
  824. if (resp.data.code === 200) {
  825. var jsonData = resp.data.data.data;
  826. if (jsonData.code === 0) {
  827. const address = jsonData.address;
  828. let ps = '';
  829. let tmp_addr = me.i18n['地址'] + ':' + address;
  830. while (tmp_addr.length > 15) {
  831. ps += tmp_addr.substring(0, 15) + '\n';
  832. tmp_addr = tmp_addr.substring(15);
  833. }
  834. ps += tmp_addr;
  835. trackMarker[0].callout.content += ps;
  836. trackStopList[0].address = address;
  837. me.trackMarker = trackMarker
  838. me.trackStopList = trackStopList
  839. me.setMarkers();
  840. }
  841. }
  842. });
  843. // qqmapsdk.reverseGeocoder({
  844. // location: {
  845. // latitude: parseFloat(p.latitude),
  846. // longitude: parseFloat(p.longitude)
  847. // },
  848. // success: (res) => {
  849. // const formatted_addresses = res.result.formatted_addresses
  850. // const address = res.result.address + formatted_addresses.recommend
  851. // let ps = '';
  852. // let tmp_addr = '地址: ' + address
  853. // while (tmp_addr.length > 15) {
  854. // ps += tmp_addr.substring(0, 15) + "\n";
  855. // tmp_addr = tmp_addr.substring(15);
  856. // }
  857. // ps += tmp_addr
  858. // trackMarker[0].callout.content += ps
  859. // trackStopList[0].address = address
  860. // this.setData({
  861. // trackMarker: trackMarker,
  862. // trackStopList: trackStopList,
  863. // })
  864. // this.setMarkers()
  865. // }
  866. // })
  867. } else if (p.stop_time > 300 && i !== resp.data.data.points.length - 1) {
  868. //地图设置mark停留点
  869. trackStopList.push({
  870. name: 'P' + n,
  871. latitude: parseFloat(p.latitude),
  872. longitude: parseFloat(p.longitude),
  873. time: p.time,
  874. end_time: common.formatDateTime(new Date(p.time).getTime() + p
  875. .stop_time * 1000),
  876. stop_time: p.stop_time,
  877. // format_stop_time: common.formatSeconds(me,p.stop_time),
  878. format_stop_time: me.formatSeconds(p.stop_time),
  879. address: ''
  880. });
  881. //mark弹出框
  882. trackMarker.push({
  883. id: i,
  884. latitude: parseFloat(p.latitude),
  885. longitude: parseFloat(p.longitude),
  886. name: '',
  887. iconPath: 'https://qiniu.bms16.com/FtYXEurXCr7Ul2A1J8Kgn4BqF8Z7',
  888. width: 28,
  889. height: 35,
  890. zIndex: 1,
  891. callout: {
  892. content: 'P' +
  893. n +
  894. '\n' +
  895. me.i18n['停留'] + ':' +
  896. // common.formatSeconds(me,p.stop_time) +
  897. me.formatSeconds(p.stop_time) +
  898. '\n' +
  899. me.i18n['开始'] + ':' +
  900. p.time +
  901. '\n' +
  902. me.i18n['结束'] + ':' +
  903. common.formatDateTime(new Date(p.time).getTime() + p
  904. .stop_time * 1000) +
  905. '\n',
  906. padding: 10,
  907. borderRadius: 4,
  908. boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
  909. display: 'BYCLICK'
  910. }
  911. });
  912. var i = n;
  913. qqmapsdk.reverseGeocoder({
  914. location: {
  915. latitude: parseFloat(p.latitude),
  916. longitude: parseFloat(p.longitude)
  917. },
  918. success: (res) => {
  919. console.log(res);
  920. const formatted_addresses = res.result
  921. .formatted_addresses;
  922. const address = res.result.address +
  923. formatted_addresses.recommend;
  924. let ps = '';
  925. let tmp_addr = me.i18n['地址'] + ':' + address;
  926. while (tmp_addr.length > 15) {
  927. ps += tmp_addr.substring(0, 15) + '\n';
  928. tmp_addr = tmp_addr.substring(15);
  929. }
  930. ps += tmp_addr;
  931. trackMarker[i].callout.content += ps;
  932. trackStopList[i].address = address;
  933. this.trackMarker = trackMarker
  934. this.trackStopList =trackStopList
  935. this.setMarkers();
  936. }
  937. });
  938. n++;
  939. }
  940. });
  941. //设置终点
  942. trackStopList.push({
  943. name: me.i18n['终点'],
  944. latitude: parseFloat(points[points.length - 1].latitude),
  945. longitude: parseFloat(points[points.length - 1].longitude),
  946. time: points[points.length - 1].time,
  947. end_time: common.formatDateTime(new Date(points[points.length - 1].time)
  948. .getTime() + points[points.length - 1].stop_time * 1000),
  949. stop_time: points[points.length - 1].stop_time,
  950. // format_stop_time: common.formatSeconds(me,points[points.length - 1].stop_time),
  951. format_stop_time: me.formatSeconds(points[points.length - 1].stop_time),
  952. address: ''
  953. });
  954. trackMarker.push({
  955. id: points.length - 1,
  956. latitude: points[points.length - 1].latitude,
  957. longitude: points[points.length - 1].longitude,
  958. name: '',
  959. iconPath: '/static/resource/images/end_point.png',
  960. width: 28,
  961. height: 35,
  962. zIndex: 2,
  963. callout: {
  964. content: '\u7EC8\u70B9\n\u505C\u7559: ' +
  965. // common.formatSeconds(me,points[points.length - 1].stop_time) +
  966. me.formatSeconds(points[points.length - 1].stop_time) +
  967. '\n' +
  968. me.i18n['开始'] + ':' +
  969. points[points.length - 1].time +
  970. '\n' +
  971. me.i18n['结束'] + ':' +
  972. common.formatDateTime(new Date(points[points.length - 1].time)
  973. .getTime() + points[points.length - 1].stop_time * 1000) +
  974. '\n',
  975. padding: 10,
  976. borderRadius: 4,
  977. boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
  978. display: 'BYCLICK'
  979. }
  980. });
  981. qqmapsdk.reverseGeocoder({
  982. location: {
  983. latitude: parseFloat(points[points.length - 1].latitude),
  984. longitude: parseFloat(points[points.length - 1].longitude)
  985. },
  986. success: (res) => {
  987. console.log(res);
  988. const formatted_addresses = res.result.formatted_addresses;
  989. const address = res.result.address + formatted_addresses.recommend;
  990. let ps = '';
  991. let tmp_addr = me.i18n['地址'] + ':' + address;
  992. while (tmp_addr.length > 15) {
  993. ps += tmp_addr.substring(0, 15) + '\n';
  994. tmp_addr = tmp_addr.substring(15);
  995. }
  996. ps += tmp_addr;
  997. trackMarker[n].callout.content += ps;
  998. trackStopList[n].address = address;
  999. this.trackMarker = trackMarker
  1000. this.trackStopList = trackStopList
  1001. this.setMarkers();
  1002. }
  1003. });
  1004. var deviceMarker = this.deviceMarker;
  1005. //deviceMarker[0].callout.display = 'BYCLICK'=
  1006. this.trackPoints= points
  1007. this.trackMarker= trackMarker
  1008. this.deviceMarker= deviceMarker
  1009. this.trackStopList= trackStopList
  1010. this.nowPlayIndex= 0
  1011. this.playMarker= []
  1012. this.setMarkers();
  1013. this.setPolylines();
  1014. // this.mapCtx.scale = 8
  1015. var map = uni.createMapContext('myMap');
  1016. map.includePoints({
  1017. points: points,
  1018. padding: [10, 10, 10, 10]
  1019. });
  1020. this.scale = 13
  1021. } else {
  1022. common.simpleToast(this,resp.data.msg);
  1023. }
  1024. }
  1025. );
  1026. },
  1027. bindTrackDialogClose() {
  1028. this.trackDialogShow = false
  1029. },
  1030. bindTrackStartTimeSelect(e) {
  1031. this.selectTime = this.trackDialogFrom.formatStartTime
  1032. this.selectTimeType = 'track_start'
  1033. // this.bindTimeSelectOpen();
  1034. },
  1035. bindTrackEndTimeSelect() {
  1036. this.selectTime = this.trackDialogFrom.formatEndTime
  1037. this.selectTimeType = 'track_end'
  1038. // this.bindTimeSelectOpen();
  1039. },
  1040. bindTrackTimeSelectToday() {
  1041. this.trackDialogFrom = Object.assign(this.trackDialogFrom, {
  1042. startTime: new Date(new Date().toLocaleDateString()).getTime(),
  1043. formatStartTime: common.formatDateTime(new Date(new Date().toLocaleDateString())
  1044. .getTime()),
  1045. endTime: new Date().getTime(),
  1046. formatEndTime: common.formatDateTime(new Date().getTime())
  1047. })
  1048. this.bindTrackDialogConfirm();
  1049. },
  1050. bindTrackTimeSelectYesterday() {
  1051. this.trackDialogFrom = Object.assign(this.trackDialogFrom, {
  1052. startTime: new Date(new Date().toLocaleDateString()).getTime() - 86400 * 1000,
  1053. formatStartTime: common.formatDateTime(new Date(new Date().toLocaleDateString())
  1054. .getTime() - 86400 * 1000),
  1055. endTime: new Date(new Date().toLocaleDateString()).getTime() - 1,
  1056. formatEndTime: common.formatDateTime(new Date(new Date().toLocaleDateString())
  1057. .getTime() - 1)
  1058. })
  1059. this.bindTrackDialogConfirm();
  1060. },
  1061. bindTrackTimeSelectLastday() {
  1062. this.trackDialogFrom = Object.assign(this.trackDialogFrom, {
  1063. startTime: new Date(new Date().toLocaleDateString()).getTime() - 2880 * 60 * 1000,
  1064. formatStartTime: common.formatDateTime(new Date(new Date().toLocaleDateString())
  1065. .getTime() - 2880 * 60 * 1000),
  1066. endTime: new Date(new Date().toLocaleDateString()).getTime() - 86400 * 1000 - 1,
  1067. formatEndTime: common.formatDateTime(new Date(new Date().toLocaleDateString())
  1068. .getTime() - 86400 * 1000 - 1)
  1069. });
  1070. this.bindTrackDialogConfirm();
  1071. },
  1072. bindTimeSelectConfirm(event) {
  1073. switch (this.selectTimeType) {
  1074. case 'track_start':
  1075. this.trackDialogFrom = Object.assign(this.trackDialogFrom, {
  1076. startTime: event.detail,
  1077. formatStartTime: common.formatDateTime(event.detail)
  1078. }),
  1079. this.selectTimeType = ''
  1080. break;
  1081. case 'track_end':
  1082. this.trackDialogFrom = Object.assign(this.trackDialogFrom, {
  1083. endTime: event.detail,
  1084. formatEndTime: common.formatDateTime(event.detail)
  1085. }),
  1086. selectTimeType = ''
  1087. break;
  1088. }
  1089. this.bindTimeSelectClose();
  1090. },
  1091. bindTimeSelectOpen() {
  1092. this.timeSelectShow = true
  1093. },
  1094. bindTimeSelectClose() {
  1095. this.timeSelectShow = false
  1096. },
  1097. bindStopPopupOpen() {
  1098. this.trackStopPopupShow = true
  1099. },
  1100. bindStopPopupClose() {
  1101. this.trackStopPopupShow = false
  1102. },
  1103. MoveToStop(event, _dataset) {
  1104. /* ---处理dataset begin--- */
  1105. this.handleDataset(event, _dataset);
  1106. /* ---处理dataset end--- */
  1107. var map = uni.createMapContext('myMap');
  1108. this.latitude = event.currentTarget.dataset.p.latitude,
  1109. this.longitude = event.currentTarget.dataset.p.longitude
  1110. /*map.moveToLocation({
  1111. latitude: event.currentTarget.dataset.p.latitude,
  1112. longitude: event.currentTarget.dataset.p.longitude
  1113. })*/
  1114. },
  1115. bindAlarmPopupOpen() {
  1116. this.alarmPopupShow = true
  1117. },
  1118. bindAlarmPopupClose() {
  1119. this.alarmPopupShow = false
  1120. this.alarmMarker = []
  1121. this.setMarkers();
  1122. },
  1123. MoveToAlarm(event, _dataset) {
  1124. /* ---处理dataset begin--- */
  1125. this.handleDataset(event, _dataset);
  1126. /* ---处理dataset end--- */
  1127. var map = uni.createMapContext('myMap');
  1128. var me = this
  1129. var alarmMarker = [{
  1130. id: 0,
  1131. latitude: event.currentTarget.dataset.p.latitude,
  1132. longitude: event.currentTarget.dataset.p.longitude,
  1133. name: '',
  1134. iconPath: '/static/resource/images/alarm.png',
  1135. width: 28,
  1136. height: 35,
  1137. zIndex: 10,
  1138. callout: {
  1139. content: event.currentTarget.dataset.p.alarm_desc +
  1140. '\n' +
  1141. me.i18n['时间'] + ':' +
  1142. event.currentTarget.dataset.p.formatTime +
  1143. '\n' +
  1144. me.i18n['速度'] + ':' +
  1145. event.currentTarget.dataset.p.speed +
  1146. me.i18n['公里'] + '/' + me.i18n['小时'] +
  1147. event.currentTarget.dataset.p.ps +
  1148. '\n',
  1149. padding: 10,
  1150. borderRadius: 4,
  1151. boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
  1152. display: 'ALWAYS'
  1153. }
  1154. }];
  1155. this.alarmMarker = alarmMarker
  1156. this.latitude = event.currentTarget.dataset.p.latitude
  1157. this.longitude = event.currentTarget.dataset.p.longitude
  1158. this.setMarkers();
  1159. },
  1160. playLoop() {
  1161. if (this.nowPlayIndex >= this.trackPoints.length - 1) {
  1162. this.inPlay = false
  1163. clearInterval(this.playTimer);
  1164. return;
  1165. }
  1166. this.showInfo = false
  1167. var map = uni.createMapContext('myMap');
  1168. var leng = Math.sqrt(
  1169. Math.pow(Math.abs(this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this
  1170. .nowPlayIndex].longitude) * 111, 2) +
  1171. Math.pow(
  1172. Math.abs(this.trackPoints[this.nowPlayIndex + 1].latitude - this.trackPoints[this.nowPlayIndex]
  1173. .latitude) *
  1174. 111 *
  1175. Math.cos(((2 * Math.PI) / 360) * this.trackPoints[this.nowPlayIndex].latitude),
  1176. 2
  1177. )
  1178. );
  1179. while (leng < 0.1 && this.nowPlayIndex < this.trackPoints.length - 1) {
  1180. leng += Math.sqrt(
  1181. Math.pow(Math.abs(this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this
  1182. .nowPlayIndex].longitude) * 111, 2) +
  1183. Math.pow(
  1184. Math.abs(this.trackPoints[this.nowPlayIndex + 1].latitude - this.trackPoints[this
  1185. .nowPlayIndex].latitude) *
  1186. 111 *
  1187. Math.cos(((2 * Math.PI) / 360) * this.trackPoints[this.nowPlayIndex].latitude),
  1188. 2
  1189. )
  1190. );
  1191. this.nowPlayIndex = this.nowPlayIndex + 1;
  1192. }
  1193. var rotate =
  1194. (Math.atan(
  1195. (this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this.nowPlayIndex]
  1196. .longitude) /
  1197. (this.trackPoints[this.nowPlayIndex + 1].latitude - this.trackPoints[this.nowPlayIndex]
  1198. .latitude) /
  1199. Math.cos(((2 * Math.PI) / 360) * this.trackPoints[this.nowPlayIndex].latitude)
  1200. ) *
  1201. 180) /
  1202. Math.PI;
  1203. if (rotate === NaN) {
  1204. if (this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this.nowPlayIndex].longitude >
  1205. 0) {
  1206. rotate = 90;
  1207. } else {
  1208. rotate = 270;
  1209. }
  1210. } else if (this.trackPoints[this.nowPlayIndex + 1].latitude - this.trackPoints[this.nowPlayIndex]
  1211. .latitude < 0) {
  1212. rotate = 180 + rotate;
  1213. } else if (this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this.nowPlayIndex]
  1214. .longitude < 0) {
  1215. rotate = 360 + rotate;
  1216. }
  1217. var playMarker = [{
  1218. id: -1,
  1219. latitude: this.trackPoints[this.nowPlayIndex].latitude,
  1220. longitude: this.trackPoints[this.nowPlayIndex].longitude,
  1221. name: '',
  1222. iconPath: '/static/resource/images/1.gif',
  1223. width: 35,
  1224. height: 35,
  1225. zIndex: 20,
  1226. callout: {
  1227. content: this.i18n['电压'] + ':' +
  1228. this.trackPoints[this.nowPlayIndex].voltage +
  1229. '\n' +
  1230. this.i18n['速度'] + ':' +
  1231. this.trackPoints[this.nowPlayIndex].speed +
  1232. 'km/' + this.i18n['小时'] + '\n' +
  1233. this.i18n['时间'] + ':' +
  1234. this.trackPoints[this.nowPlayIndex].time +
  1235. '\n' +
  1236. this.i18n['里程'] + ':' +
  1237. this.trackPoints[this.nowPlayIndex].mileage +
  1238. this.i18n['公里'] + '\n',
  1239. padding: 10,
  1240. borderRadius: 4,
  1241. boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
  1242. display: 'ALWAYS'
  1243. }
  1244. }];
  1245. this.playMarker = playMarker;
  1246. this.setMarkers();
  1247. this.latitude = this.trackPoints[this.nowPlayIndex].latitude
  1248. this.longitude = this.trackPoints[this.nowPlayIndex].longitude
  1249. this.nowPlayIndex = this.nowPlayIndex + 1
  1250. },
  1251. bindPlay() {
  1252. if (this.inPlay) {
  1253. this.inPlay = false
  1254. const me = this;
  1255. clearInterval(this.playTimer);
  1256. if (me.playMarker.length > 0) {
  1257. const pData = {
  1258. lng: me.playMarker[0].longitude,
  1259. lat: me.playMarker[0].latitude,
  1260. pi: 'wx_deviceLocal'
  1261. };
  1262. const me = this;
  1263. http.postApi(config.API_MAP_REGEO, pData, function(resp) {
  1264. if (resp.data.code === 200) {
  1265. var jsonData = resp.data.data.data;
  1266. if (jsonData.code === 0) {
  1267. const address = jsonData.address;
  1268. var ps = '';
  1269. let tmp_addr = me.i18n['地址'] + ':' + address;
  1270. while (tmp_addr.length > 15) {
  1271. ps += tmp_addr.substring(0, 15) + '\n';
  1272. tmp_addr = tmp_addr.substring(15);
  1273. }
  1274. ps += tmp_addr;
  1275. var playMark = me.playMarker;
  1276. playMark[0].callout.content += ps;
  1277. me.playMarker = playMark
  1278. me.setMarkers();
  1279. }
  1280. }
  1281. });
  1282. // qqmapsdk.reverseGeocoder({
  1283. // location: {
  1284. // latitude: me.data.playMarker[0].latitude,
  1285. // longitude: me.data.playMarker[0].longitude
  1286. // },
  1287. // success: function (res) {
  1288. // const formatted_addresses = res.result.formatted_addresses
  1289. // const address = res.result.address
  1290. // let ps = '';
  1291. // let tmp_addr = '地址: ' + address
  1292. // while (tmp_addr.length > 15) {
  1293. // ps += tmp_addr.substring(0, 15) + "\n";
  1294. // tmp_addr = tmp_addr.substring(15);
  1295. // }
  1296. // ps += tmp_addr
  1297. // var playMark = me.data.playMarker
  1298. // playMark[0].callout.content += ps
  1299. // me.setData({
  1300. // playMarker: playMark
  1301. // })
  1302. // me.setMarkers()
  1303. // }
  1304. // })
  1305. }
  1306. } else {
  1307. if (this.nowPlayIndex >= this.trackPoints.length - 1) {
  1308. this.nowPlayIndex = 0
  1309. }
  1310. this.inPlay = true
  1311. this.playTimer = setInterval(this.playLoop, this.speedTime);
  1312. }
  1313. },
  1314. // bindGPSLocation(){
  1315. // this.setData({
  1316. // isShowGPS:true
  1317. // })
  1318. // this.locationLoop(true)
  1319. // },
  1320. locationLoop(init = false) {
  1321. const deviceInfo = storage.getSelectedDeviceInfo();
  1322. if (deviceInfo) {
  1323. //common.loading()
  1324. http.postApi(
  1325. config.API_GPS_INFO, {
  1326. macid: deviceInfo.mac_id
  1327. },
  1328. (resp) => {
  1329. //wx.hideLoading()
  1330. if (resp.data.code === 200) {
  1331. let status;
  1332. let stat = '';
  1333. if (parseInt(resp.data.data.info.online) === 1) {
  1334. if (parseInt(resp.data.data.info.speed) === 0) {
  1335. // status = this.i18n['静止'] + '(' + common.formatSeconds(this,resp.data.data.info.heart_time - resp.data.data.info.gps_time, false) + ')';
  1336. status = this.i18n['静止'] + '(' + this.formatSeconds(resp.data.data.info.heart_time - resp.data.data.info.gps_time, false) + ')';
  1337. stat = 'static';
  1338. } else {
  1339. status = this.i18n['行驶']+'(' + resp.data.data.info.speed + 'Km/h)';
  1340. stat = 'running';
  1341. }
  1342. } else {
  1343. status =
  1344. this.i18n['离线']+'(' +
  1345. // common.formatSeconds(this,
  1346. this.formatSeconds(
  1347. new Date().getTime() / 1000 -
  1348. (resp.data.data.info.heart_time === undefined ? resp.data.data.info.gps_time : resp.data.data.info.heart_time),
  1349. false
  1350. ) +
  1351. ')';
  1352. stat = 'offline';
  1353. }
  1354. if (init) {
  1355. this.longitude = resp.data.data.info.longitude
  1356. this.latitude = resp.data.data.info.latitude
  1357. }
  1358. var device_info = resp.data.data.info;
  1359. this.locationType = device_info.signalType
  1360. this.macid= deviceInfo.mac_id
  1361. this.deviceInfo= resp.data.data.info
  1362. this.gps= resp.data.data.info.gpscount
  1363. this.gsm= parseInt(resp.data.data.info.online) === 0 ? 0 : resp.data.data.info.gsmlevel <= 15 ? 3 : resp.data.data.info.gsmlevel > 18 ? 5 : 4
  1364. this.status= status
  1365. this.deviceMarker= [{
  1366. id: 1,
  1367. latitude: resp.data.data.info.latitude,
  1368. longitude: resp.data.data.info.longitude,
  1369. name: '',
  1370. iconPath: this.iconList[resp.data.data.info.icon] ? this.iconList[resp.data.data.info.icon][stat] :'/static/resource/images/weizhi2.png',
  1371. width: 35,
  1372. height: 35,
  1373. zIndex: 10
  1374. }]
  1375. this.circles= [{
  1376. latitude: resp.data.data.info.latitude,
  1377. longitude: resp.data.data.info.longitude,
  1378. color: '#6495ED1F',
  1379. fillColor: '#6495ED1F',
  1380. radius: 1000,
  1381. strokeWidth: 1
  1382. }]
  1383. this.setMarkers();
  1384. if (
  1385. this.trace &&
  1386. (this.tracePoints.length == 0 ||
  1387. this.tracePoints[this.tracePoints.length - 1].latitude != resp.data.data.info.latitude ||
  1388. this.tracePoints[this.tracePoints.length - 1].longitude != resp.data.data.info.longitude)
  1389. ) {
  1390. this.tracePoints.push({
  1391. latitude: resp.data.data.info.latitude,
  1392. longitude: resp.data.data.info.longitude
  1393. });
  1394. this.setPolylines();
  1395. this.latitude = resp.data.data.info.latitude
  1396. this.longitude = resp.data.data.info.longitude
  1397. }
  1398. const pData = {
  1399. lng: resp.data.data.info.longitude,
  1400. lat: resp.data.data.info.latitude,
  1401. pi: 'wx_deviceLocal'
  1402. };
  1403. const me = this;
  1404. http.postApi(config.API_MAP_REGEO, pData, function(resp) {
  1405. if (resp.data.code === 200) {
  1406. var jsonData = resp.data.data.data;
  1407. if (jsonData.code === 0) {
  1408. me.address = jsonData.address
  1409. me.locationAdress = jsonData.address
  1410. }
  1411. }
  1412. });
  1413. // qqmapsdk.reverseGeocoder({
  1414. // location: {
  1415. // latitude: resp.data.data.info.latitude,
  1416. // longitude: resp.data.data.info.longitude
  1417. // },
  1418. // success: function (res) {
  1419. // console.log(res)
  1420. // const formatted_addresses = res.result.formatted_addresses
  1421. // const address = res.result.address //+ formatted_addresses.recommend
  1422. // me.setData({
  1423. // address: address,
  1424. // locationAdress: address
  1425. // })
  1426. // }
  1427. // })
  1428. } else {
  1429. common.simpleToast(me,resp.data.msg);
  1430. clearInterval(this.locationTimer);
  1431. setTimeout(function() {
  1432. uni.navigateBack({
  1433. delta: 1
  1434. });
  1435. }, 1500);
  1436. }
  1437. }
  1438. );
  1439. }
  1440. },
  1441. formatSeconds(value, tail = true) {
  1442. var that = this
  1443. var theTime = parseInt(value); // 需要转换的时间秒
  1444. var theTime1 = 0; // 分
  1445. var theTime2 = 0; // 小时
  1446. var theTime3 = 0; // 天
  1447. if (theTime === 0) {
  1448. return parseInt(theTime) + that.i18n['秒'];
  1449. }
  1450. if (theTime > 60) {
  1451. theTime1 = parseInt(theTime / 60);
  1452. theTime = parseInt(theTime % 60);
  1453. if (theTime1 > 60) {
  1454. theTime2 = parseInt(theTime1 / 60);
  1455. theTime1 = parseInt(theTime1 % 60);
  1456. if (theTime2 > 24) {
  1457. //大于24小时
  1458. theTime3 = parseInt(theTime2 / 24);
  1459. theTime2 = parseInt(theTime2 % 24);
  1460. }
  1461. }
  1462. }
  1463. var result = '';
  1464. if (theTime > 0) {
  1465. result = '' + parseInt(theTime) + that.i18n['秒'];
  1466. }
  1467. if (theTime1 > 0) {
  1468. result = '' + parseInt(theTime1) + that.i18n['分'] + (tail ? result : '');
  1469. }
  1470. if (theTime2 > 0) {
  1471. result = '' + parseInt(theTime2) + that.i18n['小时'] + (tail ? result : '');
  1472. }
  1473. if (theTime3 > 0) {
  1474. result = '' + parseInt(theTime3) + that.i18n['天'] + (tail ? result : '');
  1475. }
  1476. return result;
  1477. },
  1478. isEmptyObject(obj) {
  1479. for (var key in obj) {
  1480. return false;
  1481. }
  1482. return true;
  1483. },
  1484. loadLastGpsInfo() {
  1485. var init = true;
  1486. const me = this;
  1487. const deviceInfo = storage.getSelectedDeviceInfo();
  1488. if (deviceInfo) {
  1489. http.postApi(
  1490. config.API_GPS_INFO, {
  1491. macid: deviceInfo.mac_id
  1492. },
  1493. (resp) => {
  1494. if (resp.data.code === 200) {
  1495. if (this.isEmptyObject(resp.data.data.info.last_location)) {
  1496. common.simpleToast(this,this.i18n['当前设备没有GPS坐标']);
  1497. return;
  1498. }
  1499. // var last_location = resp.data.data.info.last_location
  1500. // last_location.lng = 121.19023414159073
  1501. // last_location.lat = 31.390001627411883
  1502. // resp.data.data.info.last_location = last_location
  1503. let status;
  1504. let stat = '';
  1505. if (parseInt(resp.data.data.info.online) === 1) {
  1506. if (parseInt(resp.data.data.info.speed) === 0) {
  1507. // status = me.i18n['静止']+'(' + common.formatSeconds(me,resp.data.data.info.heart_time - resp.data.data.info.gps_time, false) + ')';
  1508. status = me.i18n['静止']+'(' + me.formatSeconds(resp.data.data.info.heart_time - resp.data.data.info.gps_time, false) + ')';
  1509. stat = 'static';
  1510. } else {
  1511. status = me.i18n['行驶']+'(' + resp.data.data.info.speed + 'Km/h)';
  1512. stat = 'running';
  1513. }
  1514. } else {
  1515. status =
  1516. me.i18n['离线']+'(' +
  1517. // common.formatSeconds(me,
  1518. me.formatSeconds(
  1519. new Date().getTime() / 1000 -
  1520. (resp.data.data.info.heart_time === undefined ? resp.data.data.info
  1521. .gps_time : resp.data.data.info.heart_time),
  1522. false
  1523. ) +
  1524. ')';
  1525. stat = 'offline';
  1526. }
  1527. if (init) {
  1528. this.longitude = resp.data.data.info.last_location.lng
  1529. this.latitude = resp.data.data.info.last_location.lat
  1530. }
  1531. var device_info = resp.data.data.info;
  1532. device_info.signalType = '0';
  1533. this.locationGpsType = device_info.signalType
  1534. var device_marker = {
  1535. id: 2,
  1536. latitude: resp.data.data.info.last_location.lat,
  1537. longitude: resp.data.data.info.last_location.lng,
  1538. name: '',
  1539. iconPath: this.iconList[resp.data.data.info.icon] ? this.iconList[resp.data
  1540. .data.info.icon][stat] : '/static/resource/images/weizhi2.png',
  1541. width: 35,
  1542. height: 35,
  1543. zIndex: 10
  1544. };
  1545. // this.setData({
  1546. // marker: this.data.marker.concat(device_marker)
  1547. // })
  1548. this.gpsMarker = [device_marker]
  1549. this.marker = this.gpsMarker.concat(this.trackMarker, this.alarmMarker, this
  1550. .playMarker, this.deviceMarker)
  1551. // this.setData({
  1552. // marker: this.data.deviceMarker.concat(this.data.trackMarker, this.data.alarmMarker, this.data.playMarker)
  1553. // })
  1554. //this.data.deviceMarker.concat(this.data.trackMarker, this.data.alarmMarker, this.data.playMarker)
  1555. this.macid = deviceInfo.mac_id
  1556. this.deviceInfo = device_info
  1557. this.gps = resp.data.data.info.gpscount
  1558. this.gsm = parseInt(resp.data.data.info.online) === 0 ? 0 : resp.data.data.info
  1559. .gsmlevel <= 15 ? 3 : resp.data.data.info.gsmlevel > 18 ? 5 : 4
  1560. this.status = status
  1561. this.deviceMarker = [device_marker]
  1562. this.circles = [{
  1563. latitude: resp.data.data.info.last_location.lat,
  1564. longitude: resp.data.data.info.last_location.lng,
  1565. color: '#6495ED1F',
  1566. fillColor: '#6495ED1F',
  1567. radius: 1000,
  1568. strokeWidth: 1
  1569. }]
  1570. //this.setMarkers()
  1571. // this.setData({
  1572. // marker: this.data.deviceMarker.concat(this.data.deviceMarker)
  1573. // })
  1574. this.batteryWidth = parseInt((this.deviceInfo.quantity / 100) * 37)
  1575. const me = this;
  1576. const pData = {
  1577. lng: resp.data.data.info.last_location.lng,
  1578. lat: resp.data.data.info.last_location.lat,
  1579. pi: 'wx_deviceLocal'
  1580. };
  1581. http.postApi(config.API_MAP_REGEO, pData, function(resp) {
  1582. if (resp.data.code === 200) {
  1583. var jsonData = resp.data.data.data;
  1584. if (jsonData.code === 0) {
  1585. const address = jsonData.address;
  1586. me.address = address
  1587. me.locationGpsAdress = address
  1588. }
  1589. }
  1590. });
  1591. // qqmapsdk.reverseGeocoder({
  1592. // location: {
  1593. // latitude: resp.data.data.info.last_location.latitude,
  1594. // longitude: resp.data.data.info.last_location.longitude
  1595. // },
  1596. // success: function (res) {
  1597. // console.log(res)
  1598. // const formatted_addresses = res.result.formatted_addresses
  1599. // const address = res.result.address //+ formatted_addresses.recommend
  1600. // me.setData({
  1601. // address: address,
  1602. // locationGpsAdress: address
  1603. // })
  1604. // }
  1605. // })
  1606. } else {
  1607. common.simpleToast(this,resp.data.msg);
  1608. clearInterval(this.locationTimer);
  1609. setTimeout(function() {
  1610. uni.navigateBack({
  1611. delta: 1
  1612. });
  1613. }, 1500);
  1614. }
  1615. }
  1616. );
  1617. }
  1618. },
  1619. bindMarkertap(e) {
  1620. if (e.detail.markerId == 1 || e.detail.markerId == 2) {
  1621. if (e.detail.markerId == 1) {
  1622. var deviceInfo = this.deviceInfo;
  1623. deviceInfo.signalType = this.locationType;
  1624. this.deviceInfo = deviceInfo
  1625. this.address = this.locationAdress
  1626. }
  1627. if (e.detail.markerId == 2) {
  1628. var deviceInfo = this.deviceInfo;
  1629. deviceInfo.signalType = this.locationGpsType;
  1630. this.deviceInfo = deviceInfo
  1631. this.address = this.locationGpsAdress
  1632. }
  1633. this.showInfo = !this.showInfo
  1634. }
  1635. },
  1636. bindTapMap(e) {
  1637. this.showInfo = false
  1638. if (this.selectFence != null) {
  1639. var fence = this.selectFence;
  1640. fence.latitude = e.detail.latitude;
  1641. fence.longitude = e.detail.longitude;
  1642. this.selectFence = fence
  1643. this.circles = [{
  1644. latitude: fence.latitude,
  1645. longitude: fence.longitude,
  1646. radius: parseInt(fence.radius),
  1647. color: '#6495ED1F',
  1648. fillColor: '#6495ED1F',
  1649. strokeWidth: 1
  1650. }]
  1651. }
  1652. },
  1653. bindSendCommand: function(e) {
  1654. this.sendCommand(e.currentTarget.dataset.cmd);
  1655. },
  1656. sendCommand: function(cmd) {
  1657. const me = this
  1658. uni.showModal({
  1659. content: me.i18n['确定发送指令吗?'],
  1660. showCancel: true,
  1661. cancelText: me.i18n['取消'],
  1662. confirmText: me.i18n['确定'],
  1663. success: (res) => {
  1664. console.log(res);
  1665. if (res.confirm) {
  1666. common.loading(this);
  1667. http.postApi(
  1668. config.API_BATTERY_SEND_COMMAND, {
  1669. macid: this.macid,
  1670. cmd: cmd
  1671. },
  1672. function(resp) {
  1673. if (resp.data.code === 200) {
  1674. uni.hideLoading();
  1675. common.simpleToast(me,me.i18n['操作成功']);
  1676. } else {
  1677. common.simpleToast(me,resp.data.msg);
  1678. }
  1679. }
  1680. );
  1681. }
  1682. },
  1683. fail: function(res) {},
  1684. complete: function(res) {}
  1685. });
  1686. },
  1687. bindTrace() {
  1688. if (this.trace) {
  1689. this.trace = false
  1690. this.tracePoints = []
  1691. this.setPolylines();
  1692. clearInterval(this.traceTimer);
  1693. } else {
  1694. this.trace = true
  1695. this.traceTimer = setInterval(() => {
  1696. this.traceTime = this.traceTime + 1
  1697. }, 1000);
  1698. }
  1699. },
  1700. bindNavigate() {
  1701. //使用微信内置地图查看标记点位置,并进行导航
  1702. const latitude = this.latitude;
  1703. const longitude = this.longitude;
  1704. const address = this.address;
  1705. uni.openLocation({
  1706. latitude,
  1707. //要去的纬度-地址
  1708. longitude,
  1709. //要去的经度-地址
  1710. address,
  1711. scale: 11
  1712. });
  1713. },
  1714. bindCloseTrack() {
  1715. this.trackPoints = []
  1716. this.trackMarker = []
  1717. this.trackStopList = []
  1718. this.nowPlayIndex = 0
  1719. this.playMarker = []
  1720. this.setMarkers();
  1721. this.setPolylines();
  1722. },
  1723. bindFencePopupOpen() {
  1724. this.fencePopupShow = true
  1725. },
  1726. bindFencePopupClose() {
  1727. this.fencePopupShow = false
  1728. },
  1729. MoveToFence(event, _dataset) {
  1730. /* ---处理dataset begin--- */
  1731. // this.handleDataset(event, _dataset);
  1732. /* ---处理dataset end--- */
  1733. var map = uni.createMapContext('myMap');
  1734. const fence = Object.assign({}, event.currentTarget.dataset.p);
  1735. this.selectFence = fence
  1736. this.circles = [{
  1737. latitude: fence.latitude,
  1738. longitude: fence.longitude,
  1739. radius: parseInt(fence.radius),
  1740. color: '#6495ED1F',
  1741. fillColor: '#6495ED1F',
  1742. strokeWidth: 1
  1743. }]
  1744. this.fencePopupShow = false
  1745. this.latitude = fence.latitude
  1746. this.longitude = fence.longitude
  1747. /*map.moveToLocation({
  1748. latitude: event.currentTarget.dataset.p.latitude,
  1749. longitude: event.currentTarget.dataset.p.longitude
  1750. })*/
  1751. },
  1752. addFence() {
  1753. var map = uni.createMapContext('myMap');
  1754. map.getCenterLocation({
  1755. success: (res) => {
  1756. const fence = {
  1757. name: '',
  1758. type: '0',
  1759. latitude: res.latitude,
  1760. longitude: res.longitude,
  1761. radius: 100
  1762. };
  1763. console.log(fence, 'fence');
  1764. this.selectFence = fence
  1765. this.circles = [{
  1766. latitude: fence.latitude,
  1767. longitude: fence.longitude,
  1768. radius: parseInt(fence.radius),
  1769. color: '#6495ED1F',
  1770. fillColor: '#6495ED1F',
  1771. strokeWidth: 1
  1772. }]
  1773. this.fencePopupShow = false
  1774. }
  1775. });
  1776. },
  1777. loadFenceList() {
  1778. common.loading(this);
  1779. const deviceInfo = storage.getSelectedDeviceInfo();
  1780. http.postApi(
  1781. config.API_FENCE_LIST, {
  1782. macid: deviceInfo.mac_id
  1783. },
  1784. (resp) => {
  1785. uni.hideLoading();
  1786. if (resp.data.code === 200) {
  1787. var fenceList = resp.data.data.list;
  1788. this.fenceList = fenceList
  1789. } else {
  1790. common.simpleToast(this,resp.data.msg);
  1791. }
  1792. }
  1793. );
  1794. },
  1795. bindFenceClose() {
  1796. this.selectFence = null
  1797. this.circles = []
  1798. this.fencePopupShow = true
  1799. },
  1800. onFenceNameChange(e) {
  1801. var fence = this.selectFence;
  1802. fence.name = e.detail.value;
  1803. this.selectFence = fence
  1804. },
  1805. onFenceTypeChange(e) {
  1806. var fence = this.selectFence;
  1807. fence.type = e.detail;
  1808. this.selectFence = fence
  1809. },
  1810. onFenceRadiusDrag(e) {
  1811. var fence = this.selectFence;
  1812. fence.radius = e.detail.value;
  1813. this.selectFence = fence
  1814. /*circles: [{
  1815. latitude: fence.latitude,
  1816. longitude: fence.longitude,
  1817. radius: parseInt(fence.radius),
  1818. color: '#6495EDBB',
  1819. fillColor: '#6495ED1F',
  1820. strokeWidth: 1
  1821. }],*/
  1822. },
  1823. onFenceRadiusChange(e) {
  1824. var fence = this.selectFence;
  1825. fence.radius = e.detail.value;
  1826. // this.setData({circles:[]})
  1827. var startSlide = new Date().getTime();
  1828. if (startSlide - this.endSlide > 100) {
  1829. this.endSlide = startSlide
  1830. this.selectFence = fence
  1831. this.circles = [{
  1832. latitude: fence.latitude,
  1833. longitude: fence.longitude,
  1834. radius: parseInt(fence.radius),
  1835. color: '#6495ED1F',
  1836. fillColor: '#6495ED1F',
  1837. strokeWidth: 1
  1838. }]
  1839. }
  1840. },
  1841. onFenceRadiusMinus() {
  1842. var fence = this.selectFence;
  1843. if (fence.radius > 1) {
  1844. fence.radius = parseInt(fence.radius) - 100;
  1845. this.selectFence = fence
  1846. this.circles = [{
  1847. latitude: fence.latitude,
  1848. longitude: fence.longitude,
  1849. radius: parseInt(fence.radius),
  1850. color: '#6495ED1F',
  1851. fillColor: '#6495ED1F',
  1852. strokeWidth: 1
  1853. }]
  1854. }
  1855. },
  1856. onFenceRadiusPlus() {
  1857. var fence = this.selectFence;
  1858. if (fence.radius < 10000) {
  1859. fence.radius = parseInt(fence.radius) + 100;
  1860. this.selectFence = fence
  1861. this.circles = [{
  1862. latitude: fence.latitude,
  1863. longitude: fence.longitude,
  1864. radius: parseInt(fence.radius),
  1865. color: '#6495ED1F',
  1866. fillColor: '#6495ED1F',
  1867. strokeWidth: 1
  1868. }]
  1869. }
  1870. },
  1871. bindFenceSave() {
  1872. var fence = this.selectFence;
  1873. if (!fence.name) {
  1874. common.simpleToast(this,this.i18n['请输入围栏名称']);
  1875. return;
  1876. }
  1877. if (fence != null) {
  1878. common.loading(this);
  1879. const deviceInfo = storage.getSelectedDeviceInfo();
  1880. if (fence.id) {
  1881. http.postApi(
  1882. config.API_FENCE_EDIT,
  1883. Object.assign({
  1884. macid: deviceInfo.mac_id
  1885. },
  1886. fence
  1887. ),
  1888. (resp) => {
  1889. uni.hideLoading();
  1890. if (resp.data.code === 200) {
  1891. this.loadFenceList();
  1892. } else {
  1893. common.simpleToast(this,resp.data.msg);
  1894. }
  1895. this.selectFence = null
  1896. this.circles = []
  1897. this.fencePopupShow = true
  1898. }
  1899. );
  1900. } else {
  1901. http.postApi(
  1902. config.API_FENCE_ADD,
  1903. Object.assign({
  1904. macid: deviceInfo.mac_id,
  1905. type: fence.type.value-0,
  1906. name: fence.name,
  1907. latitude: fence.latitude,
  1908. longitude: fence.longitude,
  1909. radius: fence.radius
  1910. },
  1911. // fence
  1912. ),
  1913. (resp) => {
  1914. uni.hideLoading();
  1915. if (resp.data.code === 200) {
  1916. this.loadFenceList();
  1917. } else {
  1918. common.simpleToast(this,resp.data.msg);
  1919. }
  1920. this.selectFence = null
  1921. this.circles = []
  1922. this.fencePopupShow = true
  1923. }
  1924. );
  1925. }
  1926. }
  1927. },
  1928. delFence() {
  1929. var fence = this.selectFence;
  1930. if (fence != null && fence.id) {
  1931. common.loading(this);
  1932. const deviceInfo = storage.getSelectedDeviceInfo();
  1933. http.postApi(config.API_FENCE_DEL, {
  1934. macid: deviceInfo.mac_id,
  1935. id: fence.id
  1936. },(resp) => {
  1937. uni.hideLoading();
  1938. if (resp.data.code === 200) {
  1939. this.loadFenceList();
  1940. } else {
  1941. common.simpleToast(this,resp.data.msg);
  1942. }
  1943. this.selectFence = null
  1944. this.circles = []
  1945. this.fencePopupShow = true
  1946. });
  1947. }
  1948. },
  1949. moveToLocation: function() {
  1950. uni.createMapContext("myMap", this).moveToLocation({
  1951. latitude: this.latitude,
  1952. longitude: this.longitude
  1953. });
  1954. // this.mapCtx = uni.createMapContext('myMap');
  1955. // this.mapCtx.moveToLocation();
  1956. // this.setData({ showShopInfo: false, scale: 14 })
  1957. },
  1958. mapChange: function(e) {
  1959. this.mapParams = e.detail.mapParams
  1960. }
  1961. }
  1962. };
  1963. </script>
  1964. <style scoped>
  1965. @import './deviceLocalnvue.css';
  1966. </style>