deviceLocal.nvue 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  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="confirmPickStart" />
  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="confirmPickEnd" />
  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" :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 == 0" 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" :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 :checked="selectFence.type ==1" value="1" /><text style="font-size: 30rpx;">{{i18n['进']}}</text>
  291. <radio :checked="selectFence.type ==2" value="2" /><text style="font-size: 30rpx;">{{i18n['出']}}</text>
  292. <radio :checked="selectFence.type ==3" value="3" /><text style="font-size: 30rpx;">{{i18n['双向']}}</text>
  293. <radio :checked="selectFence.type ==0" 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. const commonEn = require('../../common/common-nv.js');
  327. var http = require('../../common/http.js');
  328. var storage = require('../../common/storage.js');
  329. var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
  330. var qqmapsdk;
  331. export default {
  332. components: {
  333. mapControl,
  334. timePicker
  335. },
  336. data() {
  337. return {
  338. id: '',
  339. deviceInfo: {
  340. quantity: '',
  341. name: '',
  342. protectState: false,
  343. oilState: 0,
  344. signalType: 0,
  345. day_mil: '',
  346. mil: '',
  347. voltage: false,
  348. elecState: false,
  349. temp: '',
  350. heart_time: false,
  351. gps_time: false
  352. },
  353. marker: [],
  354. mileage_total: 0,
  355. deviceMarker: [],
  356. trackMarker: [],
  357. alarmMarker: [],
  358. playMarker: [],
  359. endSlide: 0,
  360. polylines: [],
  361. trackPoints: [],
  362. trackStopList: [],
  363. batteryWidth: 37,
  364. alarmList: [],
  365. adjustSpeed: 1,
  366. scale: 8,
  367. speedTime: 200,
  368. trackDialogFrom: {
  369. startTime: new Date().getTime(),
  370. endTime: new Date().getTime() + 3600,
  371. // startTime: new Date(new Date().getTime() - 3600000).getTime(),
  372. // endTime: new Date().getTime(),
  373. // formatStartTime: common.formatDateTime(new Date(new Date().getTime() - 3600000).getTime()),
  374. // formatEndTime: common.formatDateTime(new Date().getTime()),
  375. formatStartTime: common.formatDateTime(new Date().getTime()),
  376. formatEndTime: common.formatDateTime(new Date(new Date().getTime() + 3600000).getTime())
  377. },
  378. latitude_my: null,
  379. longitude_my: null,
  380. trackDialogShow: false,
  381. selectTime: new Date().getTime(),
  382. selectTimeType: '',
  383. alarmPopupShow: false,
  384. trackStopPopupShow: false,
  385. timeSelectShow: false,
  386. inPlay: false,
  387. playTimer: null,
  388. nowPlayIndex: 0,
  389. totalTrackValue: 0,
  390. currentTrackValue: 0,
  391. macid: '',
  392. gps: 0,
  393. gsm: 0,
  394. status: '',
  395. address: '',
  396. showInfo: true,
  397. iconList: [],
  398. locationTimer: null,
  399. longitude: null,
  400. latitude: null,
  401. trace: false,
  402. tracePoints: [],
  403. traceTime: 0,
  404. traceTimer: null,
  405. fencePopupShow: false,
  406. fenceList: [],
  407. isLocationType: 1,
  408. circles: [],
  409. selectFence: null,
  410. mapParams: {
  411. enableSatellite: false,
  412. // 是否开启卫星图
  413. enableTraffic: false // 是否开启实时路况
  414. },
  415. isShowGPS: false,
  416. // locationInfo:{}
  417. locationType: '',
  418. locationAdress: '',
  419. locationGpsType: '',
  420. locationGpsAdress: '',
  421. gpsMarker: [],
  422. flase: '',
  423. screenHeight: 0,
  424. screenWidth: 0,
  425. i18n: {},
  426. };
  427. },
  428. /**
  429. * 生命周期函数--监听页面加载
  430. */
  431. onLoad: function(options) {
  432. // this.i18n = en
  433. this.i18n = zh
  434. this.screenHeight = uni.getSystemInfoSync().windowHeight + 40
  435. this.screenWidth = uni.getSystemInfoSync().windowWidth
  436. this.loadIconList();
  437. this.readyDeviceInfo();
  438. this.loadAlarmList();
  439. this.loadFenceList();
  440. this.locationLoop(true);
  441. //this.loadLastGpsInfo()
  442. this.locationTimer = setInterval(this.locationLoop, 10000);
  443. //获取当前位置
  444. uni.getLocation({
  445. type: 'gcj02',
  446. success: (res) => {
  447. this.latitude_my = res.latitude
  448. this.longitude_my = res.longitude
  449. }
  450. });
  451. setTimeout(function() {
  452. this.mapCtx = uni.createMapContext('myMap');
  453. }, 500);
  454. // this.mapCtx = uni.createMapContext('myMap');
  455. },
  456. onHide: function() {},
  457. onShow: function() {},
  458. onUnload: function() {
  459. clearInterval(this.locationTimer);
  460. clearInterval(this.traceTimer);
  461. clearInterval(this.playTimer);
  462. },
  463. methods: {
  464. formatTime (datetime) {
  465. if (!datetime) return '';
  466. var date = new Date(datetime * 1000);
  467. var year = date.getFullYear()
  468. var month = date.getMonth() + 1
  469. var day = date.getDate()
  470. var hour = date.getHours()
  471. var minute = date.getMinutes()
  472. var second = date.getSeconds()
  473. return year + '-' + this.formatNumber(month) + '-' + this.formatNumber(day) + ' ' + this.formatNumber(hour) + ':' + this.formatNumber(minute) + ':' + this.formatNumber(second);
  474. },
  475. formatNumber(n) {
  476. n = n.toString()
  477. return n[1] ? n : '0' + n
  478. },
  479. formatTimeNoSecond(datetime) {
  480. if (!datetime) return '';
  481. var date = new Date(datetime * 1000);
  482. var year = date.getFullYear()
  483. var month = date.getMonth() + 1
  484. var day = date.getDate()
  485. var hour = date.getHours()
  486. var minute = date.getMinutes()
  487. var second = date.getSeconds()
  488. return year + '-' + this.formatNumber(month) + '-' + this.formatNumber(day) + ' ' + this.formatNumber(hour) + ':' + this.formatNumber(minute);
  489. },
  490. loadIconList: function() {
  491. this.iconList = storage.getIconList();
  492. if (!this.iconList) {
  493. http.postApi(config.API_BATTERY_ICON_LIST, {}, (resp) => {
  494. if (resp.data.code === 200) {
  495. this.iconList = resp.data.data.list;
  496. storage.setIconList(resp.data.data.list);
  497. } else {
  498. commonEn.simpleToast(this,resp.data.msg);
  499. }
  500. });
  501. }
  502. },
  503. onStartTimeChange(e) {
  504. this.trackDialogFrom.startTime = e.detail.value;
  505. // 更新结束时间的最小值,确保结束时间不早于开始时间
  506. this.trackDialogFrom.endTime = Math.max(this.trackDialogFrom.endTime, this.trackDialogFrom.startTime);
  507. // trackDialogFrom.formatStartTime
  508. // trackDialogFrom.formatEndTime
  509. },
  510. onEndTimeChange(e) {
  511. this.trackDialogFrom.endTime = e.detail.value;
  512. },
  513. confirmPickStart(dataStr) {
  514. this.trackDialogFrom.formatStartTime = dataStr
  515. },
  516. confirmPickEnd(dataStr) {
  517. this.trackDialogFrom.formatEndTime = dataStr
  518. },
  519. trackPlayChange(e) {
  520. var index = e.detail.value;
  521. this.nowPlayIndex = index
  522. this.playLoop();
  523. },
  524. bindLocationType(e) {
  525. const index = e.currentTarget.dataset.index;
  526. this.isLocationType = index
  527. },
  528. trackPlayChangeAdress(e) {
  529. var index = e.detail.value;
  530. this.nowPlayIndex = index
  531. const me = this;
  532. this.playLoop();
  533. if (me.playMarker.length > 0) {
  534. // qqmapsdk.reverseGeocoder({
  535. // location: {
  536. // latitude: me.data.playMarker[0].latitude,
  537. // longitude: me.data.playMarker[0].longitude
  538. // },
  539. // success: function (res) {
  540. // const formatted_addresses = res.result.formatted_addresses
  541. // const address = res.result.address
  542. // let ps = '';
  543. // let tmp_addr = '地址: ' + address
  544. // while (tmp_addr.length > 15) {
  545. // ps += tmp_addr.substring(0, 15) + "\n";
  546. // tmp_addr = tmp_addr.substring(15);
  547. // }
  548. // ps += tmp_addr
  549. // var playMark = me.data.playMarker
  550. // playMark[0].callout.content += ps
  551. // me.setData({
  552. // playMarker: playMark
  553. // })
  554. // me.setMarkers()
  555. // }
  556. // })
  557. const me = this;
  558. const pData = {
  559. lng: me.playMarker[0].longitude,
  560. lat: me.playMarker[0].latitude,
  561. pi: 'wx_deviceLocal'
  562. };
  563. http.postApi(config.API_MAP_REGEO, pData, function(resp) {
  564. if (resp.data.code === 200) {
  565. var jsonData = resp.data.data.data;
  566. if (jsonData.code === 0) {
  567. const address = jsonData.address;
  568. let ps = '';
  569. let tmp_addr = me.i18n['地址']+':'+ address;
  570. while (tmp_addr.length > 15) {
  571. ps += tmp_addr.substring(0, 15) + '\n';
  572. tmp_addr = tmp_addr.substring(15);
  573. }
  574. ps += tmp_addr;
  575. var playMark = me.playMarker;
  576. playMark[0].callout.content += ps;
  577. me.playMarker = playMark
  578. }
  579. }
  580. });
  581. }
  582. },
  583. bindFastForward() {
  584. if (this.adjustSpeed === 0) {
  585. this.adjustSpeed = 1
  586. this.speedTime = 400
  587. clearInterval(this.playTimer);
  588. this.playTimer = setInterval(this.playLoop, this.speedTime);
  589. } else if (this.adjustSpeed === 1) {
  590. this.adjustSpeed = 2
  591. this.speedTime = 200
  592. clearInterval(this.playTimer);
  593. this.playTimer = setInterval(this.playLoop, this.speedTime);
  594. } else if (this.adjustSpeed === 2) {
  595. this.adjustSpeed = 0
  596. this.speedTime = 600
  597. clearInterval(this.playTimer);
  598. this.playTimer = setInterval(this.playLoop, this.speedTime);
  599. }
  600. },
  601. loadAlarmList() {
  602. commonEn.loading(this);
  603. const me = this
  604. const deviceInfo = storage.getSelectedDeviceInfo();
  605. http.postApi(
  606. config.API_GPS_ALARM, {
  607. macid: deviceInfo.mac_id
  608. },
  609. (resp) => {
  610. uni.hideLoading();
  611. if (resp.data.code === 200) {
  612. var alarmList = resp.data.data.list;
  613. alarmList.forEach((p, i) => {
  614. alarmList[i].formatTime = common.formatDateTime(p.send_time * 1000);
  615. qqmapsdk.reverseGeocoder({
  616. location: {
  617. latitude: p.latitude,
  618. longitude: p.longitude
  619. },
  620. success: (res) => {
  621. const formatted_addresses = res.result.formatted_addresses;
  622. const address = res.result
  623. .address; //+ formatted_addresses.recommend
  624. let ps = '';
  625. let tmp_addr = me.i18n['地址']+':'+ address;
  626. while (tmp_addr.length > 15) {
  627. ps += tmp_addr.substring(0, 15) + '\n';
  628. tmp_addr = tmp_addr.substring(15);
  629. }
  630. ps += tmp_addr;
  631. alarmList[i].address = address;
  632. alarmList[i].ps = ps;
  633. this.alarmList = alarmList
  634. }
  635. });
  636. });
  637. this.alarmList = alarmList
  638. } else {
  639. commonEn.simpleToast(this,resp.data.msg);
  640. }
  641. }
  642. );
  643. },
  644. readyDeviceInfo() {
  645. const me = this;
  646. // 实例化API核心类
  647. qqmapsdk = new QQMapWX({
  648. key: config.QQ_MAP_KEY
  649. });
  650. const deviceInfo = storage.getSelectedDeviceInfo();
  651. if (deviceInfo) {
  652. // this.batteryWidth = deviceInfo.quantity/100*37
  653. uni.setNavigationBarTitle({
  654. title: deviceInfo.mac_id
  655. });
  656. if (parseInt(deviceInfo.expire) === 1) {
  657. commonEn.simpleToast(me,me.i18n['设备到期']);
  658. setTimeout(function() {
  659. uni.navigateBack({
  660. delta: 1
  661. });
  662. }, 1500);
  663. }
  664. } else {
  665. clearInterval(this.locationTimer);
  666. setTimeout(function() {
  667. uni.navigateBack({
  668. delta: 1
  669. });
  670. }, 1500);
  671. }
  672. },
  673. setMarkers() {
  674. this.marker = this.deviceMarker.concat(this.trackMarker, this.alarmMarker, this.playMarker, this.gpsMarker)
  675. },
  676. setPolylines() {
  677. var polylines = [{
  678. points: this.trackPoints,
  679. color: '#1989FADD',
  680. width: 5,
  681. arrowLine: true
  682. }];
  683. /*, {
  684. points: this.data.trackPoints.slice(0,this.data.nowPlayIndex+1),
  685. color: '#F56C6CDD',
  686. width: 3,
  687. }]*/
  688. if (this.trace) {
  689. polylines.push({
  690. points: this.tracePoints,
  691. color: '#DD4C4CDD',
  692. width: 3,
  693. arrowLine: true
  694. });
  695. }
  696. this.polylines = polylines
  697. },
  698. bindTrackDialogOpen() {
  699. this.trackDialogShow = true
  700. },
  701. // 计算里程数
  702. calculateMileage(history) {
  703. let mileage = 0;
  704. for (let i = 0; i < history.length - 1; i++) {
  705. mileage += parseInt(common.getFlatternDistance(history[i].longitude, history[i].latitude, history[i +
  706. 1].longitude, history[i + 1].latitude));
  707. }
  708. var mileage_total = mileage == 0 ? 0 : (mileage / 1000).toFixed(2);
  709. this.mileage_total = mileage_total
  710. },
  711. getCurrentMil(mileage, i, history) {
  712. //var mileage = mileage_current
  713. mileage += parseInt(common.getFlatternDistance(history[i].longitude, history[i].latitude, history[i + 1]
  714. .longitude, history[i + 1].latitude));
  715. return mileage;
  716. },
  717. loadTotalMil() {
  718. const deviceInfo = storage.getSelectedDeviceInfo();
  719. http.postApi(
  720. config.API_SHOW_MIL, {
  721. macid: deviceInfo.mac_id,
  722. location_type: this.isLocationType,
  723. from: parseInt(this.trackDialogFrom.startTime / 1000),
  724. to: parseInt(this.trackDialogFrom.endTime / 1000)
  725. },
  726. (resp) => {
  727. if (resp.data.code === 200) {
  728. this.mileage_total = resp.data.data.distance
  729. } else {
  730. commonEn.simpleToast(this,resp.data.msg);
  731. }
  732. }
  733. );
  734. },
  735. bindTrackDialogConfirm() {
  736. var me = this;
  737. this.bindTrackDialogClose();
  738. this.inPlay = false
  739. clearInterval(this.playTimer);
  740. commonEn.loading(this);
  741. const deviceInfo = storage.getSelectedDeviceInfo();
  742. http.postApi(
  743. config.API_GPS_TRACK, {
  744. macid: deviceInfo.mac_id,
  745. location_type: this.isLocationType,
  746. from: parseInt(this.trackDialogFrom.startTime / 1000),
  747. to: parseInt(this.trackDialogFrom.endTime / 1000)
  748. },
  749. (resp) => {
  750. this.loadTotalMil();
  751. uni.hideLoading();
  752. if (resp.data.code === 200) {
  753. if (!resp.data.data.points || resp.data.data.points.length === 0) {
  754. commonEn.simpleToast(me,me.i18n['当前未有轨迹']);
  755. return;
  756. }
  757. // this.calculateMileage(resp.data.data.points)
  758. var points = [];
  759. var trackMarker = [];
  760. var trackStopList = [];
  761. var n = 1;
  762. this.totalTrackValue = resp.data.data.points.length
  763. var mileage = 0;
  764. resp.data.data.points.forEach((p, i) => {
  765. //移动坐标点
  766. if (resp.data.data.points.length - 1 > i) {
  767. mileage = this.getCurrentMil(mileage, i, resp.data.data.points);
  768. }
  769. points.push({
  770. latitude: parseFloat(p.latitude),
  771. longitude: parseFloat(p.longitude),
  772. time: p.time,
  773. speed: p.speed,
  774. voltage: p.voltage,
  775. time: p.time,
  776. mileage: (mileage / 1000).toFixed(2),
  777. stop_time: p.stop_time
  778. });
  779. //起点
  780. if (i === 0) {
  781. trackStopList.push({
  782. name: me.i18n['起点'],
  783. latitude: parseFloat(p.latitude),
  784. longitude: parseFloat(p.longitude),
  785. time: p.time,
  786. end_time: common.formatDateTime(new Date(p.time).getTime() + p
  787. .stop_time * 1000),
  788. stop_time: p.stop_time,
  789. format_stop_time: commonEn.formatSeconds(me,p.stop_time),
  790. address: ''
  791. });
  792. //mark弹出框坐标
  793. trackMarker.push({
  794. id: 0,
  795. latitude: p.latitude,
  796. longitude: p.longitude,
  797. name: '',
  798. iconPath: 'https://qiniu.bms16.com/FudnX-2lAHteUZHxpH6cAXFESNVs',
  799. width: 28,
  800. height: 35,
  801. zIndex: 2,
  802. callout: {
  803. content: '\u8D77\u70B9\n\u505C\u7559: ' +
  804. commonEn.formatSeconds(me,p.stop_time) +
  805. '\n' +
  806. me.i18n['开始'] + ':' +
  807. p.time +
  808. '\n' +
  809. me.i18n['结束'] + ':' +
  810. common.formatDateTime(new Date(p.time).getTime() + p
  811. .stop_time * 1000) +
  812. '\n',
  813. padding: 10,
  814. borderRadius: 4,
  815. boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
  816. display: 'BYCLICK'
  817. }
  818. });
  819. const pData = {
  820. lng: parseFloat(p.longitude),
  821. lat: parseFloat(p.latitude),
  822. pi: 'wx_deviceLocal'
  823. };
  824. http.postApi(config.API_MAP_REGEO, pData, function(resp) {
  825. if (resp.data.code === 200) {
  826. var jsonData = resp.data.data.data;
  827. if (jsonData.code === 0) {
  828. const address = jsonData.address;
  829. let ps = '';
  830. let tmp_addr = me.i18n['地址'] + ':' + address;
  831. while (tmp_addr.length > 15) {
  832. ps += tmp_addr.substring(0, 15) + '\n';
  833. tmp_addr = tmp_addr.substring(15);
  834. }
  835. ps += tmp_addr;
  836. trackMarker[0].callout.content += ps;
  837. trackStopList[0].address = address;
  838. me.trackMarker = trackMarker
  839. me.trackStopList = trackStopList
  840. me.setMarkers();
  841. }
  842. }
  843. });
  844. // qqmapsdk.reverseGeocoder({
  845. // location: {
  846. // latitude: parseFloat(p.latitude),
  847. // longitude: parseFloat(p.longitude)
  848. // },
  849. // success: (res) => {
  850. // const formatted_addresses = res.result.formatted_addresses
  851. // const address = res.result.address + formatted_addresses.recommend
  852. // let ps = '';
  853. // let tmp_addr = '地址: ' + address
  854. // while (tmp_addr.length > 15) {
  855. // ps += tmp_addr.substring(0, 15) + "\n";
  856. // tmp_addr = tmp_addr.substring(15);
  857. // }
  858. // ps += tmp_addr
  859. // trackMarker[0].callout.content += ps
  860. // trackStopList[0].address = address
  861. // this.setData({
  862. // trackMarker: trackMarker,
  863. // trackStopList: trackStopList,
  864. // })
  865. // this.setMarkers()
  866. // }
  867. // })
  868. } else if (p.stop_time > 300 && i !== resp.data.data.points.length - 1) {
  869. //地图设置mark停留点
  870. trackStopList.push({
  871. name: 'P' + n,
  872. latitude: parseFloat(p.latitude),
  873. longitude: parseFloat(p.longitude),
  874. time: p.time,
  875. end_time: common.formatDateTime(new Date(p.time).getTime() + p
  876. .stop_time * 1000),
  877. stop_time: p.stop_time,
  878. format_stop_time: commonEn.formatSeconds(me,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. commonEn.formatSeconds(me,p.stop_time) +
  897. '\n' +
  898. me.i18n['开始'] + ':' +
  899. p.time +
  900. '\n' +
  901. me.i18n['结束'] + ':' +
  902. common.formatDateTime(new Date(p.time).getTime() + p
  903. .stop_time * 1000) +
  904. '\n',
  905. padding: 10,
  906. borderRadius: 4,
  907. boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
  908. display: 'BYCLICK'
  909. }
  910. });
  911. var i = n;
  912. qqmapsdk.reverseGeocoder({
  913. location: {
  914. latitude: parseFloat(p.latitude),
  915. longitude: parseFloat(p.longitude)
  916. },
  917. success: (res) => {
  918. console.log(res);
  919. const formatted_addresses = res.result
  920. .formatted_addresses;
  921. const address = res.result.address +
  922. formatted_addresses.recommend;
  923. let ps = '';
  924. let tmp_addr = me.i18n['地址'] + ':' + address;
  925. while (tmp_addr.length > 15) {
  926. ps += tmp_addr.substring(0, 15) + '\n';
  927. tmp_addr = tmp_addr.substring(15);
  928. }
  929. ps += tmp_addr;
  930. trackMarker[i].callout.content += ps;
  931. trackStopList[i].address = address;
  932. this.trackMarker = trackMarker
  933. this.trackStopList =trackStopList
  934. this.setMarkers();
  935. }
  936. });
  937. n++;
  938. }
  939. });
  940. //设置终点
  941. trackStopList.push({
  942. name: me.i18n['终点'],
  943. latitude: parseFloat(points[points.length - 1].latitude),
  944. longitude: parseFloat(points[points.length - 1].longitude),
  945. time: points[points.length - 1].time,
  946. end_time: common.formatDateTime(new Date(points[points.length - 1].time)
  947. .getTime() + points[points.length - 1].stop_time * 1000),
  948. stop_time: points[points.length - 1].stop_time,
  949. format_stop_time: commonEn.formatSeconds(me,points[points.length - 1].stop_time),
  950. address: ''
  951. });
  952. trackMarker.push({
  953. id: points.length - 1,
  954. latitude: points[points.length - 1].latitude,
  955. longitude: points[points.length - 1].longitude,
  956. name: '',
  957. iconPath: '/static/resource/images/end_point.png',
  958. width: 28,
  959. height: 35,
  960. zIndex: 2,
  961. callout: {
  962. content: '\u7EC8\u70B9\n\u505C\u7559: ' +
  963. commonEn.formatSeconds(me,points[points.length - 1].stop_time) +
  964. '\n' +
  965. me.i18n['开始'] + ':' +
  966. points[points.length - 1].time +
  967. '\n' +
  968. me.i18n['结束'] + ':' +
  969. common.formatDateTime(new Date(points[points.length - 1].time)
  970. .getTime() + points[points.length - 1].stop_time * 1000) +
  971. '\n',
  972. padding: 10,
  973. borderRadius: 4,
  974. boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
  975. display: 'BYCLICK'
  976. }
  977. });
  978. qqmapsdk.reverseGeocoder({
  979. location: {
  980. latitude: parseFloat(points[points.length - 1].latitude),
  981. longitude: parseFloat(points[points.length - 1].longitude)
  982. },
  983. success: (res) => {
  984. console.log(res);
  985. const formatted_addresses = res.result.formatted_addresses;
  986. const address = res.result.address + formatted_addresses.recommend;
  987. let ps = '';
  988. let tmp_addr = me.i18n['地址'] + ':' + address;
  989. while (tmp_addr.length > 15) {
  990. ps += tmp_addr.substring(0, 15) + '\n';
  991. tmp_addr = tmp_addr.substring(15);
  992. }
  993. ps += tmp_addr;
  994. trackMarker[n].callout.content += ps;
  995. trackStopList[n].address = address;
  996. this.trackMarker = trackMarker
  997. this.trackStopList = trackStopList
  998. this.setMarkers();
  999. }
  1000. });
  1001. var deviceMarker = this.deviceMarker;
  1002. //deviceMarker[0].callout.display = 'BYCLICK'=
  1003. this.trackPoints= points
  1004. this.trackMarker= trackMarker
  1005. this.deviceMarker= deviceMarker
  1006. this.trackStopList= trackStopList
  1007. this.nowPlayIndex= 0
  1008. this.playMarker= []
  1009. this.setMarkers();
  1010. this.setPolylines();
  1011. // this.mapCtx.scale = 8
  1012. var map = uni.createMapContext('myMap');
  1013. map.includePoints({
  1014. points: points,
  1015. padding: [10, 10, 10, 10]
  1016. });
  1017. this.scale = 13
  1018. } else {
  1019. commonEn.simpleToast(this,resp.data.msg);
  1020. }
  1021. }
  1022. );
  1023. },
  1024. bindTrackDialogClose() {
  1025. this.trackDialogShow = false
  1026. },
  1027. bindTrackStartTimeSelect(e) {
  1028. this.selectTime = this.trackDialogFrom.formatStartTime
  1029. this.selectTimeType = 'track_start'
  1030. // this.bindTimeSelectOpen();
  1031. },
  1032. bindTrackEndTimeSelect() {
  1033. this.selectTime = this.trackDialogFrom.formatEndTime
  1034. this.selectTimeType = 'track_end'
  1035. // this.bindTimeSelectOpen();
  1036. },
  1037. bindTrackTimeSelectToday() {
  1038. this.trackDialogFrom = Object.assign(this.trackDialogFrom, {
  1039. startTime: new Date(new Date().toLocaleDateString()).getTime(),
  1040. formatStartTime: common.formatDateTime(new Date(new Date().toLocaleDateString())
  1041. .getTime()),
  1042. endTime: new Date().getTime(),
  1043. formatEndTime: common.formatDateTime(new Date().getTime())
  1044. })
  1045. this.bindTrackDialogConfirm();
  1046. },
  1047. bindTrackTimeSelectYesterday() {
  1048. this.trackDialogFrom = Object.assign(this.trackDialogFrom, {
  1049. startTime: new Date(new Date().toLocaleDateString()).getTime() - 86400 * 1000,
  1050. formatStartTime: common.formatDateTime(new Date(new Date().toLocaleDateString())
  1051. .getTime() - 86400 * 1000),
  1052. endTime: new Date(new Date().toLocaleDateString()).getTime() - 1,
  1053. formatEndTime: common.formatDateTime(new Date(new Date().toLocaleDateString())
  1054. .getTime() - 1)
  1055. })
  1056. this.bindTrackDialogConfirm();
  1057. },
  1058. bindTrackTimeSelectLastday() {
  1059. this.trackDialogFrom = Object.assign(this.trackDialogFrom, {
  1060. startTime: new Date(new Date().toLocaleDateString()).getTime() - 2880 * 60 * 1000,
  1061. formatStartTime: common.formatDateTime(new Date(new Date().toLocaleDateString())
  1062. .getTime() - 2880 * 60 * 1000),
  1063. endTime: new Date(new Date().toLocaleDateString()).getTime() - 86400 * 1000 - 1,
  1064. formatEndTime: common.formatDateTime(new Date(new Date().toLocaleDateString())
  1065. .getTime() - 86400 * 1000 - 1)
  1066. });
  1067. this.bindTrackDialogConfirm();
  1068. },
  1069. bindTimeSelectConfirm(event) {
  1070. switch (this.selectTimeType) {
  1071. case 'track_start':
  1072. this.trackDialogFrom = Object.assign(this.trackDialogFrom, {
  1073. startTime: event.detail,
  1074. formatStartTime: common.formatDateTime(event.detail)
  1075. }),
  1076. this.selectTimeType = ''
  1077. break;
  1078. case 'track_end':
  1079. this.trackDialogFrom = Object.assign(this.trackDialogFrom, {
  1080. endTime: event.detail,
  1081. formatEndTime: common.formatDateTime(event.detail)
  1082. }),
  1083. selectTimeType = ''
  1084. break;
  1085. }
  1086. this.bindTimeSelectClose();
  1087. },
  1088. bindTimeSelectOpen() {
  1089. this.timeSelectShow = true
  1090. },
  1091. bindTimeSelectClose() {
  1092. this.timeSelectShow = false
  1093. },
  1094. bindStopPopupOpen() {
  1095. this.trackStopPopupShow = true
  1096. },
  1097. bindStopPopupClose() {
  1098. this.trackStopPopupShow = false
  1099. },
  1100. MoveToStop(event, _dataset) {
  1101. /* ---处理dataset begin--- */
  1102. this.handleDataset(event, _dataset);
  1103. /* ---处理dataset end--- */
  1104. var map = uni.createMapContext('myMap');
  1105. this.latitude = event.currentTarget.dataset.p.latitude,
  1106. this.longitude = event.currentTarget.dataset.p.longitude
  1107. /*map.moveToLocation({
  1108. latitude: event.currentTarget.dataset.p.latitude,
  1109. longitude: event.currentTarget.dataset.p.longitude
  1110. })*/
  1111. },
  1112. bindAlarmPopupOpen() {
  1113. this.alarmPopupShow = true
  1114. },
  1115. bindAlarmPopupClose() {
  1116. this.alarmPopupShow = false
  1117. this.alarmMarker = []
  1118. this.setMarkers();
  1119. },
  1120. MoveToAlarm(event, _dataset) {
  1121. /* ---处理dataset begin--- */
  1122. this.handleDataset(event, _dataset);
  1123. /* ---处理dataset end--- */
  1124. var map = uni.createMapContext('myMap');
  1125. var me = this
  1126. var alarmMarker = [{
  1127. id: 0,
  1128. latitude: event.currentTarget.dataset.p.latitude,
  1129. longitude: event.currentTarget.dataset.p.longitude,
  1130. name: '',
  1131. iconPath: '/static/resource/images/alarm.png',
  1132. width: 28,
  1133. height: 35,
  1134. zIndex: 10,
  1135. callout: {
  1136. content: event.currentTarget.dataset.p.alarm_desc +
  1137. '\n' +
  1138. me.i18n['时间'] + ':' +
  1139. event.currentTarget.dataset.p.formatTime +
  1140. '\n' +
  1141. me.i18n['速度'] + ':' +
  1142. event.currentTarget.dataset.p.speed +
  1143. me.i18n['公里'] + '/' + me.i18n['小时'] +
  1144. event.currentTarget.dataset.p.ps +
  1145. '\n',
  1146. padding: 10,
  1147. borderRadius: 4,
  1148. boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
  1149. display: 'ALWAYS'
  1150. }
  1151. }];
  1152. this.alarmMarker = alarmMarker
  1153. this.latitude = event.currentTarget.dataset.p.latitude
  1154. this.longitude = event.currentTarget.dataset.p.longitude
  1155. this.setMarkers();
  1156. },
  1157. playLoop() {
  1158. if (this.nowPlayIndex >= this.trackPoints.length - 1) {
  1159. this.inPlay = false
  1160. clearInterval(this.playTimer);
  1161. return;
  1162. }
  1163. this.showInfo = false
  1164. var map = uni.createMapContext('myMap');
  1165. var leng = Math.sqrt(
  1166. Math.pow(Math.abs(this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this
  1167. .nowPlayIndex].longitude) * 111, 2) +
  1168. Math.pow(
  1169. Math.abs(this.trackPoints[this.nowPlayIndex + 1].latitude - this.trackPoints[this.nowPlayIndex]
  1170. .latitude) *
  1171. 111 *
  1172. Math.cos(((2 * Math.PI) / 360) * this.trackPoints[this.nowPlayIndex].latitude),
  1173. 2
  1174. )
  1175. );
  1176. while (leng < 0.1 && this.nowPlayIndex < this.trackPoints.length - 1) {
  1177. leng += Math.sqrt(
  1178. Math.pow(Math.abs(this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this
  1179. .nowPlayIndex].longitude) * 111, 2) +
  1180. Math.pow(
  1181. Math.abs(this.trackPoints[this.nowPlayIndex + 1].latitude - this.trackPoints[this
  1182. .nowPlayIndex].latitude) *
  1183. 111 *
  1184. Math.cos(((2 * Math.PI) / 360) * this.trackPoints[this.nowPlayIndex].latitude),
  1185. 2
  1186. )
  1187. );
  1188. this.nowPlayIndex = this.nowPlayIndex + 1;
  1189. }
  1190. var rotate =
  1191. (Math.atan(
  1192. (this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this.nowPlayIndex]
  1193. .longitude) /
  1194. (this.trackPoints[this.nowPlayIndex + 1].latitude - this.trackPoints[this.nowPlayIndex]
  1195. .latitude) /
  1196. Math.cos(((2 * Math.PI) / 360) * this.trackPoints[this.nowPlayIndex].latitude)
  1197. ) *
  1198. 180) /
  1199. Math.PI;
  1200. if (rotate === NaN) {
  1201. if (this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this.nowPlayIndex].longitude >
  1202. 0) {
  1203. rotate = 90;
  1204. } else {
  1205. rotate = 270;
  1206. }
  1207. } else if (this.trackPoints[this.nowPlayIndex + 1].latitude - this.trackPoints[this.nowPlayIndex]
  1208. .latitude < 0) {
  1209. rotate = 180 + rotate;
  1210. } else if (this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this.nowPlayIndex]
  1211. .longitude < 0) {
  1212. rotate = 360 + rotate;
  1213. }
  1214. var playMarker = [{
  1215. id: -1,
  1216. latitude: this.trackPoints[this.nowPlayIndex].latitude,
  1217. longitude: this.trackPoints[this.nowPlayIndex].longitude,
  1218. name: '',
  1219. iconPath: '/static/resource/images/1.gif',
  1220. width: 35,
  1221. height: 35,
  1222. zIndex: 20,
  1223. callout: {
  1224. content: this.i18n['电压'] + ':' +
  1225. this.trackPoints[this.nowPlayIndex].voltage +
  1226. '\n' +
  1227. this.i18n['速度'] + ':' +
  1228. this.trackPoints[this.nowPlayIndex].speed +
  1229. 'km/' + this.i18n['小时'] + '\n' +
  1230. this.i18n['时间'] + ':' +
  1231. this.trackPoints[this.nowPlayIndex].time +
  1232. '\n' +
  1233. this.i18n['里程'] + ':' +
  1234. this.trackPoints[this.nowPlayIndex].mileage +
  1235. this.i18n['公里'] + '\n',
  1236. padding: 10,
  1237. borderRadius: 4,
  1238. boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
  1239. display: 'ALWAYS'
  1240. }
  1241. }];
  1242. this.playMarker = playMarker;
  1243. this.setMarkers();
  1244. this.latitude = this.trackPoints[this.nowPlayIndex].latitude
  1245. this.longitude = this.trackPoints[this.nowPlayIndex].longitude
  1246. this.nowPlayIndex = this.nowPlayIndex + 1
  1247. },
  1248. bindPlay() {
  1249. if (this.inPlay) {
  1250. this.inPlay = false
  1251. const me = this;
  1252. clearInterval(this.playTimer);
  1253. if (me.playMarker.length > 0) {
  1254. const pData = {
  1255. lng: me.playMarker[0].longitude,
  1256. lat: me.playMarker[0].latitude,
  1257. pi: 'wx_deviceLocal'
  1258. };
  1259. const me = this;
  1260. http.postApi(config.API_MAP_REGEO, pData, function(resp) {
  1261. if (resp.data.code === 200) {
  1262. var jsonData = resp.data.data.data;
  1263. if (jsonData.code === 0) {
  1264. const address = jsonData.address;
  1265. var ps = '';
  1266. let tmp_addr = me.i18n['地址'] + ':' + address;
  1267. while (tmp_addr.length > 15) {
  1268. ps += tmp_addr.substring(0, 15) + '\n';
  1269. tmp_addr = tmp_addr.substring(15);
  1270. }
  1271. ps += tmp_addr;
  1272. var playMark = me.playMarker;
  1273. playMark[0].callout.content += ps;
  1274. me.playMarker = playMark
  1275. me.setMarkers();
  1276. }
  1277. }
  1278. });
  1279. // qqmapsdk.reverseGeocoder({
  1280. // location: {
  1281. // latitude: me.data.playMarker[0].latitude,
  1282. // longitude: me.data.playMarker[0].longitude
  1283. // },
  1284. // success: function (res) {
  1285. // const formatted_addresses = res.result.formatted_addresses
  1286. // const address = res.result.address
  1287. // let ps = '';
  1288. // let tmp_addr = '地址: ' + address
  1289. // while (tmp_addr.length > 15) {
  1290. // ps += tmp_addr.substring(0, 15) + "\n";
  1291. // tmp_addr = tmp_addr.substring(15);
  1292. // }
  1293. // ps += tmp_addr
  1294. // var playMark = me.data.playMarker
  1295. // playMark[0].callout.content += ps
  1296. // me.setData({
  1297. // playMarker: playMark
  1298. // })
  1299. // me.setMarkers()
  1300. // }
  1301. // })
  1302. }
  1303. } else {
  1304. if (this.nowPlayIndex >= this.trackPoints.length - 1) {
  1305. this.nowPlayIndex = 0
  1306. }
  1307. this.inPlay = true
  1308. this.playTimer = setInterval(this.playLoop, this.speedTime);
  1309. }
  1310. },
  1311. // bindGPSLocation(){
  1312. // this.setData({
  1313. // isShowGPS:true
  1314. // })
  1315. // this.locationLoop(true)
  1316. // },
  1317. locationLoop(init = false) {
  1318. const deviceInfo = storage.getSelectedDeviceInfo();
  1319. if (deviceInfo) {
  1320. //commonEn.loading()
  1321. http.postApi(
  1322. config.API_GPS_INFO, {
  1323. macid: deviceInfo.mac_id
  1324. },
  1325. (resp) => {
  1326. //wx.hideLoading()
  1327. if (resp.data.code === 200) {
  1328. let status;
  1329. let stat = '';
  1330. if (parseInt(resp.data.data.info.online) === 1) {
  1331. if (parseInt(resp.data.data.info.speed) === 0) {
  1332. status = this.i18n['静止'] + '(' + commonEn.formatSeconds(this,resp.data.data.info.heart_time - resp
  1333. .data.data.info.gps_time, false) + ')';
  1334. stat = 'static';
  1335. } else {
  1336. status = this.i18n['行驶']+'(' + resp.data.data.info.speed + 'Km/h)';
  1337. stat = 'running';
  1338. }
  1339. } else {
  1340. status =
  1341. this.i18n['离线']+'(' +
  1342. commonEn.formatSeconds(
  1343. this,new Date().getTime() / 1000 -
  1344. (resp.data.data.info.heart_time === undefined ? resp.data.data.info
  1345. .gps_time : resp.data.data.info.heart_time),
  1346. false
  1347. ) +
  1348. ')';
  1349. stat = 'offline';
  1350. }
  1351. if (init) {
  1352. this.longitude = resp.data.data.info.longitude
  1353. this.latitude = resp.data.data.info.latitude
  1354. }
  1355. var device_info = resp.data.data.info;
  1356. this.locationType = device_info.signalType
  1357. this.macid= deviceInfo.mac_id
  1358. this.deviceInfo= resp.data.data.info
  1359. this.gps= resp.data.data.info.gpscount
  1360. this.gsm= parseInt(resp.data.data.info.online) === 0 ? 0 : resp.data.data.info
  1361. .gsmlevel <= 15 ? 3 : resp.data.data.info.gsmlevel > 18 ? 5 : 4
  1362. this.status= status
  1363. this.deviceMarker= [{
  1364. id: 1,
  1365. latitude: resp.data.data.info.latitude,
  1366. longitude: resp.data.data.info.longitude,
  1367. name: '',
  1368. iconPath: this.iconList[resp.data.data.info.icon] ? this
  1369. .iconList[resp.data.data.info.icon][stat] :
  1370. '/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
  1388. .latitude ||
  1389. this.tracePoints[this.tracePoints.length - 1].longitude != resp.data.data.info
  1390. .longitude)
  1391. ) {
  1392. this.tracePoints.push({
  1393. latitude: resp.data.data.info.latitude,
  1394. longitude: resp.data.data.info.longitude
  1395. });
  1396. this.setPolylines();
  1397. this.latitude = resp.data.data.info.latitude
  1398. this.longitude = resp.data.data.info.longitude
  1399. }
  1400. const pData = {
  1401. lng: resp.data.data.info.longitude,
  1402. lat: resp.data.data.info.latitude,
  1403. pi: 'wx_deviceLocal'
  1404. };
  1405. const me = this;
  1406. http.postApi(config.API_MAP_REGEO, pData, function(resp) {
  1407. if (resp.data.code === 200) {
  1408. var jsonData = resp.data.data.data;
  1409. if (jsonData.code === 0) {
  1410. me.address = jsonData.address
  1411. me.locationAdress = jsonData.address
  1412. }
  1413. }
  1414. });
  1415. // qqmapsdk.reverseGeocoder({
  1416. // location: {
  1417. // latitude: resp.data.data.info.latitude,
  1418. // longitude: resp.data.data.info.longitude
  1419. // },
  1420. // success: function (res) {
  1421. // console.log(res)
  1422. // const formatted_addresses = res.result.formatted_addresses
  1423. // const address = res.result.address //+ formatted_addresses.recommend
  1424. // me.setData({
  1425. // address: address,
  1426. // locationAdress: address
  1427. // })
  1428. // }
  1429. // })
  1430. } else {
  1431. commonEn.simpleToast(me,resp.data.msg);
  1432. clearInterval(this.locationTimer);
  1433. setTimeout(function() {
  1434. uni.navigateBack({
  1435. delta: 1
  1436. });
  1437. }, 1500);
  1438. }
  1439. }
  1440. );
  1441. }
  1442. },
  1443. isEmptyObject(obj) {
  1444. for (var key in obj) {
  1445. return false;
  1446. }
  1447. return true;
  1448. },
  1449. loadLastGpsInfo() {
  1450. var init = true;
  1451. const me = this;
  1452. const deviceInfo = storage.getSelectedDeviceInfo();
  1453. if (deviceInfo) {
  1454. http.postApi(
  1455. config.API_GPS_INFO, {
  1456. macid: deviceInfo.mac_id
  1457. },
  1458. (resp) => {
  1459. if (resp.data.code === 200) {
  1460. if (this.isEmptyObject(resp.data.data.info.last_location)) {
  1461. commonEn.simpleToast(this,this.i18n['当前设备没有GPS坐标']);
  1462. return;
  1463. }
  1464. // var last_location = resp.data.data.info.last_location
  1465. // last_location.lng = 121.19023414159073
  1466. // last_location.lat = 31.390001627411883
  1467. // resp.data.data.info.last_location = last_location
  1468. let status;
  1469. let stat = '';
  1470. if (parseInt(resp.data.data.info.online) === 1) {
  1471. if (parseInt(resp.data.data.info.speed) === 0) {
  1472. status = me.i18n['静止']+'(' + commonEn.formatSeconds(me,resp.data.data.info.heart_time - resp
  1473. .data.data.info.gps_time, false) + ')';
  1474. stat = 'static';
  1475. } else {
  1476. status = me.i18n['行驶']+'(' + resp.data.data.info.speed + 'Km/h)';
  1477. stat = 'running';
  1478. }
  1479. } else {
  1480. status =
  1481. me.i18n['离线']+'(' +
  1482. commonEn.formatSeconds(
  1483. me,new Date().getTime() / 1000 -
  1484. (resp.data.data.info.heart_time === undefined ? resp.data.data.info
  1485. .gps_time : resp.data.data.info.heart_time),
  1486. false
  1487. ) +
  1488. ')';
  1489. stat = 'offline';
  1490. }
  1491. if (init) {
  1492. this.longitude = resp.data.data.info.last_location.lng
  1493. this.latitude = resp.data.data.info.last_location.lat
  1494. }
  1495. var device_info = resp.data.data.info;
  1496. device_info.signalType = '0';
  1497. this.locationGpsType = device_info.signalType
  1498. var device_marker = {
  1499. id: 2,
  1500. latitude: resp.data.data.info.last_location.lat,
  1501. longitude: resp.data.data.info.last_location.lng,
  1502. name: '',
  1503. iconPath: this.iconList[resp.data.data.info.icon] ? this.iconList[resp.data
  1504. .data.info.icon][stat] : '/static/resource/images/weizhi2.png',
  1505. width: 35,
  1506. height: 35,
  1507. zIndex: 10
  1508. };
  1509. // this.setData({
  1510. // marker: this.data.marker.concat(device_marker)
  1511. // })
  1512. this.gpsMarker = [device_marker]
  1513. this.marker = this.gpsMarker.concat(this.trackMarker, this.alarmMarker, this
  1514. .playMarker, this.deviceMarker)
  1515. // this.setData({
  1516. // marker: this.data.deviceMarker.concat(this.data.trackMarker, this.data.alarmMarker, this.data.playMarker)
  1517. // })
  1518. //this.data.deviceMarker.concat(this.data.trackMarker, this.data.alarmMarker, this.data.playMarker)
  1519. this.macid = deviceInfo.mac_id
  1520. this.deviceInfo = device_info
  1521. this.gps = resp.data.data.info.gpscount
  1522. this.gsm = parseInt(resp.data.data.info.online) === 0 ? 0 : resp.data.data.info
  1523. .gsmlevel <= 15 ? 3 : resp.data.data.info.gsmlevel > 18 ? 5 : 4
  1524. this.status = status
  1525. this.deviceMarker = [device_marker]
  1526. this.circles = [{
  1527. latitude: resp.data.data.info.last_location.lat,
  1528. longitude: resp.data.data.info.last_location.lng,
  1529. color: '#6495ED1F',
  1530. fillColor: '#6495ED1F',
  1531. radius: 1000,
  1532. strokeWidth: 1
  1533. }]
  1534. //this.setMarkers()
  1535. // this.setData({
  1536. // marker: this.data.deviceMarker.concat(this.data.deviceMarker)
  1537. // })
  1538. this.batteryWidth = parseInt((this.deviceInfo.quantity / 100) * 37)
  1539. const me = this;
  1540. const pData = {
  1541. lng: resp.data.data.info.last_location.lng,
  1542. lat: resp.data.data.info.last_location.lat,
  1543. pi: 'wx_deviceLocal'
  1544. };
  1545. http.postApi(config.API_MAP_REGEO, pData, function(resp) {
  1546. if (resp.data.code === 200) {
  1547. var jsonData = resp.data.data.data;
  1548. if (jsonData.code === 0) {
  1549. const address = jsonData.address;
  1550. me.address = address
  1551. me.locationGpsAdress = address
  1552. }
  1553. }
  1554. });
  1555. // qqmapsdk.reverseGeocoder({
  1556. // location: {
  1557. // latitude: resp.data.data.info.last_location.latitude,
  1558. // longitude: resp.data.data.info.last_location.longitude
  1559. // },
  1560. // success: function (res) {
  1561. // console.log(res)
  1562. // const formatted_addresses = res.result.formatted_addresses
  1563. // const address = res.result.address //+ formatted_addresses.recommend
  1564. // me.setData({
  1565. // address: address,
  1566. // locationGpsAdress: address
  1567. // })
  1568. // }
  1569. // })
  1570. } else {
  1571. commonEn.simpleToast(this,resp.data.msg);
  1572. clearInterval(this.locationTimer);
  1573. setTimeout(function() {
  1574. uni.navigateBack({
  1575. delta: 1
  1576. });
  1577. }, 1500);
  1578. }
  1579. }
  1580. );
  1581. }
  1582. },
  1583. bindMarkertap(e) {
  1584. if (e.detail.markerId == 1 || e.detail.markerId == 2) {
  1585. if (e.detail.markerId == 1) {
  1586. var deviceInfo = this.deviceInfo;
  1587. deviceInfo.signalType = this.locationType;
  1588. this.deviceInfo = deviceInfo
  1589. this.address = this.locationAdress
  1590. }
  1591. if (e.detail.markerId == 2) {
  1592. var deviceInfo = this.deviceInfo;
  1593. deviceInfo.signalType = this.locationGpsType;
  1594. this.deviceInfo = deviceInfo
  1595. this.address = this.locationGpsAdress
  1596. }
  1597. this.showInfo = !this.showInfo
  1598. }
  1599. },
  1600. bindTapMap(e) {
  1601. this.showInfo = false
  1602. const that = this
  1603. if (that.selectFence != null) {
  1604. var fence = that.selectFence;
  1605. fence.latitude = e.detail.latitude;
  1606. fence.longitude = e.detail.longitude;
  1607. that.selectFence = fence
  1608. that.circles = [{
  1609. latitude: fence.latitude,
  1610. longitude: fence.longitude,
  1611. radius: parseInt(fence.radius),
  1612. color: '#6495ED1F',
  1613. fillColor: '#6495ED1F',
  1614. strokeWidth: 1
  1615. }]
  1616. }
  1617. },
  1618. bindSendCommand: function(e) {
  1619. this.sendCommand(e.currentTarget.dataset.cmd);
  1620. },
  1621. sendCommand: function(cmd) {
  1622. const me = this
  1623. uni.showModal({
  1624. content: me.i18n['确定发送指令吗?'],
  1625. showCancel: true,
  1626. cancelText: me.i18n['取消'],
  1627. confirmText: me.i18n['确定'],
  1628. success: (res) => {
  1629. console.log(res);
  1630. if (res.confirm) {
  1631. commonEn.loading(this);
  1632. http.postApi(
  1633. config.API_BATTERY_SEND_COMMAND, {
  1634. macid: this.macid,
  1635. cmd: cmd
  1636. },
  1637. function(resp) {
  1638. if (resp.data.code === 200) {
  1639. uni.hideLoading();
  1640. commonEn.simpleToast(me,me.i18n['操作成功']);
  1641. } else {
  1642. commonEn.simpleToast(me,resp.data.msg);
  1643. }
  1644. }
  1645. );
  1646. }
  1647. },
  1648. fail: function(res) {},
  1649. complete: function(res) {}
  1650. });
  1651. },
  1652. bindTrace() {
  1653. if (this.trace) {
  1654. this.trace = false
  1655. this.tracePoints = []
  1656. this.setPolylines();
  1657. clearInterval(this.traceTimer);
  1658. } else {
  1659. this.trace = true
  1660. this.traceTimer = setInterval(() => {
  1661. this.traceTime = this.traceTime + 1
  1662. }, 1000);
  1663. }
  1664. },
  1665. bindNavigate() {
  1666. //使用微信内置地图查看标记点位置,并进行导航
  1667. const latitude = this.latitude;
  1668. const longitude = this.longitude;
  1669. const address = this.address;
  1670. uni.openLocation({
  1671. latitude,
  1672. //要去的纬度-地址
  1673. longitude,
  1674. //要去的经度-地址
  1675. address,
  1676. scale: 11
  1677. });
  1678. },
  1679. bindCloseTrack() {
  1680. this.trackPoints = []
  1681. this.trackMarker = []
  1682. this.trackStopList = []
  1683. this.nowPlayIndex = 0
  1684. this.playMarker = []
  1685. this.setMarkers();
  1686. this.setPolylines();
  1687. },
  1688. bindFencePopupOpen() {
  1689. this.fencePopupShow = true
  1690. },
  1691. bindFencePopupClose() {
  1692. this.fencePopupShow = false
  1693. },
  1694. MoveToFence(event, _dataset) {
  1695. clearInterval(this.locationTimer);
  1696. /* ---处理dataset begin--- */
  1697. // this.handleDataset(event, _dataset);
  1698. /* ---处理dataset end--- */
  1699. var map = uni.createMapContext('myMap');
  1700. const fence = Object.assign({}, event.currentTarget.dataset.p);
  1701. this.selectFence = fence
  1702. this.circles = [{
  1703. latitude: fence.latitude,
  1704. longitude: fence.longitude,
  1705. radius: parseInt(fence.radius),
  1706. color: '#6495ED1F',
  1707. fillColor: '#6495ED1F',
  1708. strokeWidth: 1
  1709. }]
  1710. this.fencePopupShow = false
  1711. this.latitude = fence.latitude
  1712. this.longitude = fence.longitude
  1713. /*map.moveToLocation({
  1714. latitude: event.currentTarget.dataset.p.latitude,
  1715. longitude: event.currentTarget.dataset.p.longitude
  1716. })*/
  1717. },
  1718. addFence() {
  1719. clearInterval(this.locationTimer);
  1720. var map = uni.createMapContext('myMap');
  1721. map.getCenterLocation({
  1722. success: (res) => {
  1723. const fence = {
  1724. name: '',
  1725. type: '0',
  1726. latitude: res.latitude,
  1727. longitude: res.longitude,
  1728. radius: 100
  1729. };
  1730. this.selectFence = fence
  1731. this.circles = [{
  1732. latitude: fence.latitude,
  1733. longitude: fence.longitude,
  1734. radius: parseInt(fence.radius),
  1735. color: '#6495ED1F',
  1736. fillColor: '#6495ED1F',
  1737. strokeWidth: 1
  1738. }]
  1739. this.fencePopupShow = false
  1740. }
  1741. });
  1742. },
  1743. loadFenceList() {
  1744. commonEn.loading(this);
  1745. const deviceInfo = storage.getSelectedDeviceInfo();
  1746. http.postApi(
  1747. config.API_FENCE_LIST, {
  1748. macid: deviceInfo.mac_id
  1749. },
  1750. (resp) => {
  1751. uni.hideLoading();
  1752. if (resp.data.code === 200) {
  1753. var fenceList = resp.data.data.list;
  1754. this.fenceList = fenceList
  1755. } else {
  1756. commonEn.simpleToast(this,resp.data.msg);
  1757. }
  1758. }
  1759. );
  1760. },
  1761. bindFenceClose() {
  1762. this.locationTimer = setInterval(this.locationLoop, 10000);
  1763. this.selectFence = null
  1764. this.circles = []
  1765. this.fencePopupShow = true
  1766. },
  1767. onFenceNameChange(e) {
  1768. var fence = this.selectFence;
  1769. fence.name = e.detail.value;
  1770. this.selectFence = fence
  1771. },
  1772. onFenceTypeChange(e) {
  1773. console.log(e.detail,'detail');
  1774. var fence = this.selectFence;
  1775. fence.type = e.detail.value;
  1776. this.selectFence = fence
  1777. },
  1778. onFenceRadiusDrag(e) {
  1779. var fence = this.selectFence;
  1780. fence.radius = e.detail.value;
  1781. this.selectFence = fence
  1782. /*circles: [{
  1783. latitude: fence.latitude,
  1784. longitude: fence.longitude,
  1785. radius: parseInt(fence.radius),
  1786. color: '#6495EDBB',
  1787. fillColor: '#6495ED1F',
  1788. strokeWidth: 1
  1789. }],*/
  1790. },
  1791. onFenceRadiusChange(e) {
  1792. var fence = this.selectFence;
  1793. fence.radius = e.detail.value;
  1794. // this.setData({circles:[]})
  1795. var startSlide = new Date().getTime();
  1796. if (startSlide - this.endSlide > 100) {
  1797. this.endSlide = startSlide
  1798. this.selectFence = fence
  1799. this.circles = [{
  1800. latitude: fence.latitude,
  1801. longitude: fence.longitude,
  1802. radius: parseInt(fence.radius),
  1803. color: '#6495ED1F',
  1804. fillColor: '#6495ED1F',
  1805. strokeWidth: 1
  1806. }]
  1807. }
  1808. },
  1809. onFenceRadiusMinus() {
  1810. var fence = this.selectFence;
  1811. if (fence.radius > 1) {
  1812. fence.radius = parseInt(fence.radius) - 100;
  1813. this.selectFence = fence
  1814. this.circles = [{
  1815. latitude: fence.latitude,
  1816. longitude: fence.longitude,
  1817. radius: parseInt(fence.radius),
  1818. color: '#6495ED1F',
  1819. fillColor: '#6495ED1F',
  1820. strokeWidth: 1
  1821. }]
  1822. }
  1823. },
  1824. onFenceRadiusPlus() {
  1825. var fence = this.selectFence;
  1826. if (fence.radius < 10000) {
  1827. fence.radius = parseInt(fence.radius) + 100;
  1828. this.selectFence = fence
  1829. this.circles = [{
  1830. latitude: fence.latitude,
  1831. longitude: fence.longitude,
  1832. radius: parseInt(fence.radius),
  1833. color: '#6495ED1F',
  1834. fillColor: '#6495ED1F',
  1835. strokeWidth: 1
  1836. }]
  1837. }
  1838. },
  1839. bindFenceSave() {
  1840. var fence = this.selectFence;
  1841. if (!fence.name) {
  1842. commonEn.simpleToast(this,this.i18n['请输入围栏名称']);
  1843. return;
  1844. }
  1845. console.log(fence,'fence');
  1846. if (fence != null) {
  1847. commonEn.loading(this);
  1848. const deviceInfo = storage.getSelectedDeviceInfo();
  1849. if (fence.id) {
  1850. http.postApi(
  1851. config.API_FENCE_EDIT,
  1852. Object.assign({
  1853. macid: deviceInfo.mac_id
  1854. },
  1855. fence
  1856. ),
  1857. (resp) => {
  1858. uni.hideLoading();
  1859. if (resp.data.code === 200) {
  1860. this.loadFenceList();
  1861. } else {
  1862. commonEn.simpleToast(this,resp.data.msg);
  1863. }
  1864. this.selectFence = null
  1865. this.circles = []
  1866. this.fencePopupShow = true
  1867. }
  1868. );
  1869. } else {
  1870. console.log(Object.assign({macid: deviceInfo.mac_id,type: fence.type-0}),'eeeeee');
  1871. http.postApi(
  1872. config.API_FENCE_ADD,
  1873. Object.assign({
  1874. macid: deviceInfo.mac_id,
  1875. type: fence.type-0,
  1876. name: fence.name,
  1877. latitude: fence.latitude,
  1878. longitude: fence.longitude,
  1879. radius: fence.radius
  1880. },
  1881. // fence
  1882. ),
  1883. (resp) => {
  1884. uni.hideLoading();
  1885. if (resp.data.code === 200) {
  1886. this.loadFenceList();
  1887. } else {
  1888. commonEn.simpleToast(this,resp.data.msg);
  1889. }
  1890. this.selectFence = null
  1891. this.circles = []
  1892. this.fencePopupShow = true
  1893. }
  1894. );
  1895. }
  1896. }
  1897. this.locationTimer = setInterval(this.locationLoop, 10000);
  1898. },
  1899. delFence() {
  1900. var fence = this.selectFence;
  1901. if (fence != null && fence.id) {
  1902. commonEn.loading(this);
  1903. const deviceInfo = storage.getSelectedDeviceInfo();
  1904. http.postApi(config.API_FENCE_DEL, {
  1905. macid: deviceInfo.mac_id,
  1906. id: fence.id
  1907. },(resp) => {
  1908. uni.hideLoading();
  1909. if (resp.data.code === 200) {
  1910. this.loadFenceList();
  1911. } else {
  1912. commonEn.simpleToast(this,resp.data.msg);
  1913. }
  1914. this.selectFence = null
  1915. this.circles = []
  1916. this.fencePopupShow = true
  1917. });
  1918. }
  1919. },
  1920. moveToLocation: function() {
  1921. uni.createMapContext("myMap", this).moveToLocation({
  1922. latitude: this.latitude,
  1923. longitude: this.longitude
  1924. });
  1925. // this.mapCtx = uni.createMapContext('myMap');
  1926. // this.mapCtx.moveToLocation();
  1927. // this.setData({ showShopInfo: false, scale: 14 })
  1928. },
  1929. mapChange: function(e) {
  1930. this.mapParams = e.detail.mapParams
  1931. }
  1932. }
  1933. };
  1934. </script>
  1935. <style scoped>
  1936. @import './deviceLocalnvue.css';
  1937. </style>