12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150 |
- <template>
- <view class="container">
- <map
- id="myMap"
- :longitude="longitude"
- :latitude="latitude"
- :scale="scale"
- :markers="marker"
- :polyline="polylines"
- :circles="circles"
- @markertap="bindMarkertap"
- show-location
- enable-3D
- show-compass
- enable-overlooking
- :enable-satellite="mapParams.enableSatellite"
- :enable-traffic="mapParams.enableTraffic"
- style="width: 100%; height: 100vh"
- @tap="bindTapMap"
- ></map>
- <map-control :mapParams="mapParams" @changeParams="mapChange"></map-control>
-
- <view v-if="showInfo" class="battery-group">
- <view class="battery-item">
- <view class="map-top">
- <view class="map-cross">
- <view class="map-top-box">
- <view class="map-top-text">GPS</view>
- <view :class="gps > 0 ? 'map-top-i' : 'map-top-n'" />
- <view :class="gps > 1 ? 'map-top-i' : 'map-top-n'" />
- <view :class="gps > 2 ? 'map-top-i' : 'map-top-n'" />
- <view :class="gps > 3 ? 'map-top-i' : 'map-top-n'" />
- <view :class="gps > 4 ? 'map-top-i' : 'map-top-n'" />
- </view>
- <view class="map-top-box gsm-view">
- <view class="map-top-text">GSM</view>
- <view :class="gsm > 0 ? 'map-top-i' : 'map-top-n'" />
- <view :class="gsm > 1 ? 'map-top-i' : 'map-top-n'" />
- <view :class="gsm > 2 ? 'map-top-i' : 'map-top-n'" />
- <view :class="gsm > 3 ? 'map-top-i' : 'map-top-n'" />
- <view :class="gsm > 4 ? 'map-top-i' : 'map-top-n'" />
- </view>
- </view>
- <view class="map-top-box-1">
- <view class="map-top-text-1">{{ deviceInfo.quantity }}%</view>
- <image src="https://qiniu.bms16.com/FikqU8xHYKBjolOPZ7uc9ZNJXfHU" class="bottom-img"></image>
- </view>
- <view v-if="deviceInfo.quantity >= 20" :style="'width: ' + batteryWidth + 'rpx;right:' + (71 + (37 - batteryWidth)) + 'rpx'" class="battery_num_view"></view>
- <view v-if="deviceInfo.quantity < 20" :style="'width: ' + batteryWidth + 'rpx;right:' + (71 + (37 - batteryWidth)) + 'rpx'" class="battery_num_view_red"></view>
- </view>
- <view class="batter-info-group">
- <view class="battery-desc flex-row flex-between">
- <view>{{ $t('名称') + ':' + deviceInfo.name }}</view>
- <view>{{ $t('状态') + ':' + status }}</view>
- </view>
- <view class="battery-desc flex-row flex-between">
- <view>{{ $t('编号') + ':' + macid }}</view>
- <view>{{ $t('设防状态') + ':' + deviceInfo.protectState ? (deviceInfo.protectState == 1 ? $t('设防') : $t('撤防')) : $t('未知') }}</view>
- </view>
- <view class="battery-desc flex-row flex-between">
- <view>{{ $t('控制') + ':' + deviceInfo.oilState == 1 ? $t('已通电') : $t('已断电') }}</view>
- <view>{{ $t('定位类型') + ':' + deviceInfo.signalType == 0 ? $t('北斗GPS') : deviceInfo.signalType == 1 ? 'WIFI' : deviceInfo.signalType == 16 ? 'LBS' : $t('未知') }}</view>
- </view>
- <view class="battery-desc flex-row flex-between">
- <view>{{ $t('当日里程') + ':' + deviceInfo.day_mil }}</view>
- <view>{{ $t('总里程') + ':' + deviceInfo.mil }}</view>
- </view>
- <view class="battery-desc flex-row flex-between">
- <view>
- {{ $t('电压') + ':' +
- (deviceInfo.voltage ? deviceInfo.voltage + 'V' : $t('未知')) +
- (deviceInfo.elecState ? (deviceInfo.elecState == 1 ? '('+ $t('主电接通')+')' : '('+ $t('主电断开')+')') : '')
- }}
- </view>
- <view v-if="deviceInfo && deviceInfo.temp && deviceInfo.temp != ''">{{ $t('温度') + ':' + deviceInfo.temp + '℃' }}</view>
- </view>
- <view class="battery-desc">{{ $t('通信') + ':' + deviceInfo.heart_time ? tools.formatTime(deviceInfo.heart_time) : $t('未知') }}</view>
- <view class="battery-desc">{{ $t('定位') + ':' + deviceInfo.gps_time ? tools.formatTime(deviceInfo.gps_time) : $t('未知') }}</view>
- <view v-if="address != ''" class="battery-desc">地址:{{ address }}</view>
- <!-- <view wx:if="{{ address != '' }}" class="battery-desc">GPS最近地址:{{ address }}</view> -->
- </view>
- </view>
- </view>
- <view class="bottom-view">
- <view class="bottom-center">
- <image :src="trace ? 'https://qiniu.bms16.com/FtYkQp4Nc2JD2SZ-_BjCI--DJWyi' : 'https://qiniu.bms16.com/FlRUmvzPd-BzkMAj04LwmX7UBrEP'" class="bottom-img"></image>
- </view>
- <view class="bottom-centent">
- <view class="bottom-item" @tap="bindTrackDialogOpen">
- <image :src="trackPoints.length == 0 ? 'https://qiniu.bms16.com/FqYJ3dMKvis19y8-onbNdRBEO5mT' : 'https://qiniu.bms16.com/FlH-IsasGFDH2QsRZixIFh7q7Tjv'" class="bottom-img"></image>
- <view class="bottom-text">{{$t('轨迹')}}</view>
- </view>
- <view class="bottom-item" @tap="bindAlarmPopupOpen">
- <image :src="alarmList.length == 0 ? 'https://qiniu.bms16.com/FkVJmibJNj0CvoIrQmtz_wKotWpO' : 'https://qiniu.bms16.com/Fu4mutL6ECkBLManyT_cvZ6C8iAT'" class="bottom-img"></image>
- <view class="bottom-text">{{$t('报警')}}</view>
- </view>
- <!--<view class="bottom-item" bindtap="bindTrace">
- <image class="bottom-img"></image>
- <view class="bottom-text">追踪</view>
- </view>-->
- <view class="bottom-item" @tap="bindNavigate">
- <image class="bottom-img"></image>
- <view class="bottom-text">{{$t('导航')}}</view>
- </view>
- <view class="bottom-item" @tap="bindSendCommand" data-cmd="CLOSERELAY">
- <image src="https://qiniu.bms16.com/Fr-g3_g0T5aZ_sLQB7Xs1qRpxGAS" class="bottom-img"></image>
- <view class="bottom-text">{{$t('断电')}}</view>
- </view>
- <view class="bottom-item" @tap="bindSendCommand" data-cmd="OPENRELAY">
- <image src="https://qiniu.bms16.com/Fv1eQozcTejKVdXbqkcea9syHOU3" class="bottom-img"></image>
- <view class="bottom-text">{{$t('通电')}}</view>
- </view>
- </view>
- <image v-if="trackPoints.length != 0" :src="inPlay ? 'https://qiniu.bms16.com/FrTpj-jPSkQIsRjPOFE25lzJ4H7Z' : 'https://qiniu.bms16.com/Fl6EjlB1RufKn7QeKdBJC7dXxC9M'" class="play-img" @tap="bindPlay"></image>
- <image v-if="trackPoints.length != 0" src="https://qiniu.bms16.com/FoMwbUuD37w4Ja13-NXtm3hhkUgZ" class="stop-img" @tap="bindStopPopupOpen"></image>
- <view v-if="trackStopList.length != 0" class="stop-img" @tap="bindStopPopupOpen">
- <view class="tip-top">{{ trackStopList.length }}</view>
- </view>
- <image v-if="trackPoints.length != 0" src="https://qiniu.bms16.com/FqZcllaWWt2WJ3QGDt3wfKJM3wgP" class="close-img" @tap="bindCloseTrack"></image>
- <view @tap="loadLastGpsInfo" class="gps_last">
- <view class="text_view">{{$t('最新')}}</view>
- <view class="text_view">GPS</view>
- </view>
- <image src="https://qiniu.bms16.com/Fg4wwTFjltC-0avrON1I0WLrIa82" class="fence-img" @tap="bindFencePopupOpen"></image>
- <view v-if="trace" class="trace-box">{{ $t('追踪时间') + ':' + tools.formatHourSeconds(traceTime) }}</view>
- <!--<van-grid>
- <van-grid-item text="轨迹" bind:click="bindTrackDialogOpen">
- <van-icon slot="icon" name="map-marked" color="#409EFF" />
- </van-grid-item>
- <van-grid-item text="报警" bind:click="bindAlarmPopupOpen">
- <van-icon slot="icon" name="bell" color="#F56C6C" info="{{ alarmList.length }}"/>
- </van-grid-item>
- <van-grid-item wx:if="{{trackPoints.length!=0}}" text="播放" bind:click="bindPlay">
- <van-icon wx:if="{{!inPlay}}" slot="icon" name="play" color="#67C23A" />
- <van-icon wx:if="{{inPlay}}" slot="icon" name="pause" color="#67C23A" />
- </van-grid-item>
- <van-grid-item wx:if="{{trackPoints.length!=0}}" text="停留" bind:click="bindStopPopupOpen">
- <van-icon slot="icon" name="location" color="#E6A23C" info="{{ trackStopList.length }}"/>
- </van-grid-item>
- </van-grid>-->
- </view>
- <view class="left-group">
- <view class="left-group-i">
- <image class="btn-ctr" src="https://qiniu.bms16.com/Fm-AhAqRdu14DZcE52vl85nw_vuD" @tap="moveToLocation"></image>
- </view>
- </view>
- <view v-if="trackPoints.length != 0" class="track_bottom">
- <view class="track_total_time">
- {{ $t('时间') + ':' + tools.formatTimeNoSecond(trackDialogFrom.startTime / 1000) + $t('至') + tools.formatTimeNoSecond(trackDialogFrom.endTime / 1000) + $t('共') + mileage_total + $t('公里')}}
- </view>
- <view class="track_slide flex-row flex-between">
- <slider @change="trackPlayChangeAdress" @changing="trackPlayChange" :value="nowPlayIndex" min="1" :max="totalTrackValue" style="width: 70%" />
- <view @tap="bindFastForward" class="flex-row fastForward">
- <image class="fastForward_img" src="https://qiniu.bms16.com/Fp6Kaid1eEQYqdGgwQD5TGZ1ir_7"></image>
- <text v-if="adjustSpeed == 0" class="fastForward_text">{{$t('慢')}}</text>
- <text v-if="adjustSpeed == 1" class="fastForward_text">{{$t('中')}}</text>
- <text v-if="adjustSpeed == 2" class="fastForward_text">{{$t('快')}}</text>
- </view>
- </view>
- </view>
- <!-- 下方点击轨迹弹窗 -->
- <view v-if="trackDialogShow" class="popup-black">
- <view class="popup-view">
- <view style="text-align: center;border-bottom: 4rpx solid #f7f7f7;margin-bottom: 20rpx;">{{$t('轨迹')}}</view>
- <view style="padding-left: 30rpx;padding-right: 30rpx;">
- <view class="flex-row" style="margin-bottom: 40rpx;">
- <view class="location_mark">{{$t('定位类型')}}:</view>
- <view @tap="bindLocationType" data-index="1" :class="isLocationType == 1 ? 'sel_location_view' : 'un_location_view'">GPS</view>
- <view @tap="bindLocationType" data-index="2" :class="isLocationType == 2 ? 'sel_location_view' : 'un_location_view'">LBS</view>
- <view @tap="bindLocationType" data-index="3" :class="isLocationType == 3 ? 'sel_location_view' : 'un_location_view'">GPS+LBS</view>
- </view>
- <view class="flex-row" style="margin-bottom: 50rpx;">
- <view class="flex-row" style="margin-right: 60rpx;">
- <img class="time-img" src="https://qiniu.bms16.com/Ful5wl2uV3-Ys8PdeFDGZRgBm6DX" />
- <text style="font-size: 28rpx;">{{$t('开始时间')}}</text>
- </view>
- <view style="height: 40rpx;">
- <time-picker :time="trackDialogFrom.formatStartTime" @confirmPickDate="confirmPickDate" />
- </view>
- </view>
- <view class="flex-row" style="margin-bottom: 70rpx;">
- <view class="flex-row" style="margin-right: 60rpx;">
- <img class="time-img" src="https://qiniu.bms16.com/Ful5wl2uV3-Ys8PdeFDGZRgBm6DX" />
- <text style="font-size: 28rpx;">{{$t('结束时间')}}</text>
- </view>
- <view style="height: 40rpx;">
- <time-picker :time="trackDialogFrom.formatEndTime" @confirmPickDate="confirmPickDate" />
- </view>
- </view>
- <view class="day-btn flex-row">
- <view @tap="bindTrackTimeSelectToday">{{$t('当天')}}</view>
- <view @tap="bindTrackTimeSelectYesterday">{{$t('昨天')}}</view>
- <view @tap="bindTrackTimeSelectLastday">{{$t('前天')}}</view>
- </view>
- </view>
- <view class="bottom-btn flex-row">
- <view @tap="bindTrackDialogClose" class="">{{$t('取消')}}</view>
- <view @tap="bindTrackDialogConfirm" class="">{{$t('查询')}}</view>
- </view>
- </view>
- </view>
-
- <!-- 下方点击报警弹窗 -->
- <view v-if="alarmPopupShow" class="popup-black">
- <scroll-view class="alarm-view" :scroll-y="true">
- <view class="alarm-top flex-row">
- <view>{{$t('报警')}}</view>
- <view @tap="bindAlarmPopupClose"><img src="https://qiniu.bms16.com/FjhcWGFGsI56rLZRu7_OnhGtpoUs" /></view>
- </view>
- <view class="alarm-content flex-row flex-between" @tap="MoveToAlarm($event, { p: item })" :data-p="item" v-for="(item, index) in alarmList" :key="index">
- <view>
- <view class="flex-row" style="margin-bottom: 10rpx;">
- <view class="danger-view">{{ item.alarm_desc }}</view>
- <view class="primary-view">{{ item.speed + $t('公里')+'/'+$t('小时')}}</view>
- </view>
- <view>{{ item.formatTime }}</view>
- </view>
- <view class="alarm-right">{{item.address}}</view>
- </view>
- </scroll-view>
- </view>
-
- <!-- 停留点 -->
- <view v-if="trackStopPopupShow" class="popup-black">
- <scroll-view class="stop-view flex-row">
- <view class="stop-top flex-row">
- <view>{{$t('停留点')}}</view>
- <view @tap="bindStopPopupClose"><img src="https://qiniu.bms16.com/FjhcWGFGsI56rLZRu7_OnhGtpoUs" /></view>
- </view>
- <view class="stop-content flex-row flex-between" @tap="MoveToStop($event, { p: item })" :data-p="item" v-for="(item, index) in trackStopList" :key="index">
- <view style="width: 50%;">
- <view class="flex-row" style="margin-bottom: 10rpx;">
- <view>{{ item.name }}</view>
- <view class="o-text">{{ item.format_stop_time }}</view>
- </view>
- <view style="white-space: break-spaces;">{{ item.time }} - {{ item.end_time }}</view>
- </view>
- <view class="stop-right">{{item.address}}</view>
- </view>
- </scroll-view>
- </view>
-
- <!-- 右下角围栏 -->
- <view v-if="fencePopupShow">
- <scroll-view class="fence-view" :scroll-y="true">
- <view class="fence-top flex-row flex-between">
- <view class="flex-row">
- <view style="margin-right: 20rpx;">{{$t('围栏')}}</view>
- <view class="fence-btn" @tap="addFence"><img src="https://qiniu.bms16.com/FkjjRjSiRHnbPJk_2PhaiAcfwY1f" />{{$t('添加')}}</view>
- </view>
- <view @tap="bindFencePopupClose"><img src="https://qiniu.bms16.com/FjhcWGFGsI56rLZRu7_OnhGtpoUs" /></view>
- </view>
- <view class="fence-content flex-row flex-between" @click="MoveToFence($event, { p: item })" :data-p="item" v-for="(item, index) in fenceList" :key="index">
- <view>
- <view class="van-cell-text">
- {{ item.name }}
- </view>
- <!-- <view class="van-cell-text"> {{ $t('报警类型') + ':' + item.type == 1 ? $t('进') : item.type == 2 ? $t('出') : item.type == 3 ? $t('双向') : $t('关闭') }}</view> -->
- <view class="van-cell-text"> {{ $t('报警类型') + ':' }}
- <text v-if="item.type == 2">{{$t('出')}}</text>
- <text v-if="item.type == 3">{{$t('双向')}}</text>
- <text v-if="item.type == 0">{{$t('关闭')}}</text>
- <text v-if="item.type == 1">{{$t('进')}}</text>
- </view>
- </view>
- <view class="">{{item.radius+$t('米')}}</view>
- </view>
- </scroll-view>
- </view>
-
- <!-- 围栏设置 -->
- <view v-if="selectFence != null">
- <scroll-view class="fence-view" :scroll-y="true">
- <view class="fence-top flex-row flex-between">
- <view style="margin-right: 20rpx;">{{$t('围栏设置')}}</view>
- <view @tap="bindFenceClose"><img src="https://qiniu.bms16.com/FjhcWGFGsI56rLZRu7_OnhGtpoUs" /></view>
- </view>
- <view class="">
- <view class="fence-config flex-row flex-between">
- <view>{{$t('围栏名称')}}</view>
- <input type="text" :placeholder="$t('请输入围栏名称')" @blur="onFenceNameChange" :value="selectFence.name" style="color: rgba(0, 0, 0, 1);text-align: right;" />
- </view>
- <view class="fence-config flex-row flex-between">
- <view>{{$t('报警类型')}}</view>
- <view class="flex-row">
- <radio-group class="radio-group" @change="onFenceTypeChange">
- <radio :checked="selectFence.type ==1" value="1" />{{$t('进')}}
- <radio :checked="selectFence.type ==2" value="2" />{{$t('出')}}
- <radio :checked="selectFence.type ==3" value="3" />{{$t('双向')}}
- <radio :checked="selectFence.type ==0" value="0" />{{$t('关闭')}}
- </radio-group>
- </view>
- </view>
- <view class="fence-config flex-row flex-between">
- <view>{{$t('围栏半径')}}</view>
- <view style="width: 75%;" class="flex-row flex-around">
- <image src="https://qiniu.bms16.com/Fgthw9jHOk5KP9wfiOEv_6iwCpt5" style="width: 40rpx; height: 40rpx" @tap="onFenceRadiusMinus"></image>
- <slider :value="selectFence.radius" @change="onFenceRadiusChange" @changing="onFenceRadiusChange" min="1" max="10000" show-value style="width: 75%" />
- <image src="https://qiniu.bms16.com/FnL1ghroP_oJRk1_0PpUXONI533U" style="width: 40rpx; height: 40rpx" @tap="onFenceRadiusPlus"></image>
- </view>
- </view>
- <view class="fence-config">
- <button class="save-btn" @tap="bindFenceSave">{{$t('保存')}}</button>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
- <script>
- import mapControl from '@/component/mapControl/mapControl';
- import timePicker from '@/component/time-pickers/time-pickers';
- // pages/deviceLocal/deviceLocal.js
- const config = require('../../common/config.js');
- const common = require('../../common/common.js');
- var http = require('../../common/http.js');
- var storage = require('../../common/storage.js');
- var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
- var qqmapsdk;
- export default {
- components: {
- mapControl,
- timePicker
- },
- data() {
- return {
- id: '',
- deviceInfo: {
- quantity: '',
- name: '',
- protectState: false,
- oilState: 0,
- signalType: 0,
- day_mil: '',
- mil: '',
- voltage: false,
- elecState: false,
- temp: '',
- heart_time: false,
- gps_time: false
- },
-
- marker: [],
- mileage_total: 0,
- deviceMarker: [],
- trackMarker: [],
- alarmMarker: [],
- playMarker: [],
- endSlide: 0,
- polylines: [],
- trackPoints: [],
- trackStopList: [],
- batteryWidth: 37,
- alarmList: [],
- adjustSpeed: 1,
- scale: 8,
- speedTime: 200,
-
- trackDialogFrom: {
- startTime: new Date().getTime(),
- endTime: new Date().getTime() + 3600,
- // startTime: new Date(new Date().getTime() - 3600000).getTime(),
- // endTime: new Date().getTime(),
- // formatStartTime: common.formatDateTime(new Date(new Date().getTime() - 3600000).getTime()),
- // formatEndTime: common.formatDateTime(new Date().getTime()),
- formatStartTime: common.formatDateTime(new Date().getTime()),
- formatEndTime: common.formatDateTime(new Date(new Date().getTime() + 3600000).getTime())
- },
- latitude_my: null,
- longitude_my: null,
- trackDialogShow: false,
- selectTime: new Date().getTime(),
- selectTimeType: '',
- alarmPopupShow: false,
- trackStopPopupShow: false,
- timeSelectShow: false,
- inPlay: false,
- playTimer: null,
- nowPlayIndex: 0,
- totalTrackValue: 0,
- currentTrackValue: 0,
- macid: '',
- gps: 0,
- gsm: 0,
- status: '',
- address: '',
- showInfo: true,
- iconList: [],
- locationTimer: null,
- longitude: null,
- latitude: null,
- trace: false,
- tracePoints: [],
- traceTime: 0,
- traceTimer: null,
- fencePopupShow: false,
- fenceList: [],
- isLocationType: 1,
- circles: [],
- selectFence: null,
- type: '1',
- mapParams: {
- enableSatellite: false,
- // 是否开启卫星图
- enableTraffic: false // 是否开启实时路况
- },
- isShowGPS: false,
- // locationInfo:{}
- locationType: '',
- locationAdress: '',
- locationGpsType: '',
- locationGpsAdress: '',
- gpsMarker: [],
- flase: '',
- };
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.loadIconList();
- this.readyDeviceInfo();
- this.loadAlarmList();
- this.loadFenceList();
- this.locationLoop(true);
- //this.loadLastGpsInfo()
- this.locationTimer = setInterval(this.locationLoop, 10000);
- //获取当前位置
- uni.getLocation({
- type: 'gcj02',
- success: (res) => {
- this.setData({
- latitude_my: res.latitude,
- longitude_my: res.longitude
- });
- }
- });
- const me=this
- setTimeout(function() {
- me.mapCtx = uni.createMapContext('myMap');
- }, 500);
- // this.mapCtx = uni.createMapContext('myMap');
- },
- onHide: function () {},
- onShow: function () {},
- onUnload: function () {
- clearInterval(this.locationTimer);
- clearInterval(this.traceTimer);
- clearInterval(this.playTimer);
- },
- methods: {
- loadIconList: function () {
- this.iconList = storage.getIconList();
- if (!this.iconList) {
- http.postApi(config.API_BATTERY_ICON_LIST, {}, (resp) => {
- if (resp.data.code === 200) {
- this.iconList = resp.data.data.list;
- storage.setIconList(resp.data.data.list);
- } else {
- common.simpleToast(this,resp.data.msg);
- }
- });
- }
- },
-
- onStartTimeChange(e) {
- console.log(1125);
- this.trackDialogFrom.startTime = e.detail.value;
- // 更新结束时间的最小值,确保结束时间不早于开始时间
- this.trackDialogFrom.endTime = Math.max(this.trackDialogFrom.endTime, this.trackDialogFrom.startTime);
- // trackDialogFrom.formatStartTime
- // trackDialogFrom.formatEndTime
- },
-
- onEndTimeChange(e) {
- this.trackDialogFrom.endTime = e.detail.value;
- },
-
- confirmPickDate(dataStr) {
- this.trackDialogFrom.formatStartTime = dataStr
- this.$emit("time", dateStr);
- },
- trackPlayChange(e) {
- var index = e.detail.value;
- this.setData({
- nowPlayIndex: index
- });
- this.playLoop();
- },
- bindLocationType(e) {
- const index = e.currentTarget.dataset.index;
- this.setData({
- isLocationType: index
- });
- },
- trackPlayChangeAdress(e) {
- var index = e.detail.value;
- this.setData({
- nowPlayIndex: index
- });
- const me = this;
- this.playLoop();
- if (me.playMarker.length > 0) {
- // qqmapsdk.reverseGeocoder({
- // location: {
- // latitude: me.data.playMarker[0].latitude,
- // longitude: me.data.playMarker[0].longitude
- // },
- // success: function (res) {
- // const formatted_addresses = res.result.formatted_addresses
- // const address = res.result.address
- // let ps = '';
- // let tmp_addr = '地址: ' + address
- // while (tmp_addr.length > 15) {
- // ps += tmp_addr.substring(0, 15) + "\n";
- // tmp_addr = tmp_addr.substring(15);
- // }
- // ps += tmp_addr
- // var playMark = me.data.playMarker
- // playMark[0].callout.content += ps
- // me.setData({
- // playMarker: playMark
- // })
- // me.setMarkers()
- // }
- // })
- const me = this;
- const pData = {
- lng: me.playMarker[0].longitude,
- lat: me.playMarker[0].latitude,
- pi: 'wx_deviceLocal'
- };
- http.postApi(config.API_MAP_REGEO, pData, function (resp) {
- if (resp.data.code === 200) {
- var jsonData = resp.data.data.data;
- if (jsonData.code === 0) {
- const address = jsonData.address;
- let ps = '';
- let tmp_addr = me.$t('地址')+':' + address;
- while (tmp_addr.length > 15) {
- ps += tmp_addr.substring(0, 15) + '\n';
- tmp_addr = tmp_addr.substring(15);
- }
- ps += tmp_addr;
- var playMark = me.playMarker;
- playMark[0].callout.content += ps;
- me.setData({
- playMarker: playMark
- });
- }
- }
- });
- }
- },
- bindFastForward() {
- if (this.adjustSpeed === 0) {
- this.setData({
- adjustSpeed: 1,
- speedTime: 400
- });
- clearInterval(this.playTimer);
- this.playTimer = setInterval(this.playLoop, this.speedTime);
- } else if (this.adjustSpeed === 1) {
- this.setData({
- adjustSpeed: 2,
- speedTime: 200
- });
- clearInterval(this.playTimer);
- this.playTimer = setInterval(this.playLoop, this.speedTime);
- } else if (this.adjustSpeed === 2) {
- this.setData({
- adjustSpeed: 0,
- speedTime: 600
- });
- clearInterval(this.playTimer);
- this.playTimer = setInterval(this.playLoop, this.speedTime);
- }
- },
- loadAlarmList() {
- common.loading(this);
- const me = this
- const deviceInfo = storage.getSelectedDeviceInfo();
- http.postApi(
- config.API_GPS_ALARM,
- {
- macid: deviceInfo.mac_id
- },
- (resp) => {
- uni.hideLoading();
- if (resp.data.code === 200) {
- var alarmList = resp.data.data.list;
- alarmList.forEach((p, i) => {
- alarmList[i].formatTime = common.formatDateTime(p.send_time * 1000);
- qqmapsdk.reverseGeocoder({
- location: {
- latitude: p.latitude,
- longitude: p.longitude
- },
- success: (res) => {
- const formatted_addresses = res.result.formatted_addresses;
- const address = res.result.address; //+ formatted_addresses.recommend
- let ps = '';
- let tmp_addr = me.$t('地址')+':' + address;
- while (tmp_addr.length > 15) {
- ps += tmp_addr.substring(0, 15) + '\n';
- tmp_addr = tmp_addr.substring(15);
- }
- ps += tmp_addr;
- alarmList[i].address = address;
- alarmList[i].ps = ps;
- this.setData({
- alarmList: alarmList
- });
- }
- });
- });
- this.setData({
- alarmList: alarmList
- });
- } else {
- common.simpleToast(this,resp.data.msg);
- }
- }
- );
- },
- readyDeviceInfo() {
- const me = this;
- // 实例化API核心类
- qqmapsdk = new QQMapWX({
- key: config.QQ_MAP_KEY
- });
- const deviceInfo = storage.getSelectedDeviceInfo();
- if (deviceInfo) {
- // this.batteryWidth = deviceInfo.quantity/100*37
- uni.setNavigationBarTitle({
- title: deviceInfo.mac_id
- });
- if (parseInt(deviceInfo.expire) === 1) {
- common.simpleToast(me,me.$t('设备到期'));
- setTimeout(function () {
- uni.navigateBack({
- delta: 1
- });
- }, 1500);
- }
- } else {
- clearInterval(this.locationTimer);
- setTimeout(function () {
- uni.navigateBack({
- delta: 1
- });
- }, 1500);
- }
- },
- setMarkers() {
- this.setData({
- marker: this.deviceMarker.concat(this.trackMarker, this.alarmMarker, this.playMarker, this.gpsMarker)
- });
- },
- setPolylines() {
- var polylines = [
- {
- points: this.trackPoints,
- color: '#1989FADD',
- width: 5,
- arrowLine: true
- }
- ]; /*, {
- points: this.data.trackPoints.slice(0,this.data.nowPlayIndex+1),
- color: '#F56C6CDD',
- width: 3,
- }]*/
- if (this.trace) {
- polylines.push({
- points: this.tracePoints,
- color: '#DD4C4CDD',
- width: 3,
- arrowLine: true
- });
- }
- this.setData({
- polylines: polylines
- });
- },
- bindTrackDialogOpen() {
- this.setData({
- trackDialogShow: true
- });
- },
- // 计算里程数
- calculateMileage(history) {
- let mileage = 0;
- for (let i = 0; i < history.length - 1; i++) {
- mileage += parseInt(common.getFlatternDistance(history[i].longitude, history[i].latitude, history[i + 1].longitude, history[i + 1].latitude));
- }
- var mileage_total = mileage == 0 ? 0 : (mileage / 1000).toFixed(2);
- this.setData({
- mileage_total: mileage_total
- });
- },
- getCurrentMil(mileage, i, history) {
- //var mileage = mileage_current
- mileage += parseInt(common.getFlatternDistance(history[i].longitude, history[i].latitude, history[i + 1].longitude, history[i + 1].latitude));
- return mileage;
- },
- loadTotalMil() {
- const deviceInfo = storage.getSelectedDeviceInfo();
- http.postApi(
- config.API_SHOW_MIL,
- {
- macid: deviceInfo.mac_id,
- location_type: this.isLocationType,
- from: parseInt(this.trackDialogFrom.startTime / 1000),
- to: parseInt(this.trackDialogFrom.endTime / 1000)
- },
- (resp) => {
- if (resp.data.code === 200) {
- this.setData({
- mileage_total: resp.data.data.distance
- });
- } else {
- common.simpleToast(this,this,resp.data.msg);
- }
- }
- );
- },
- bindTrackDialogConfirm() {
- this.bindTrackDialogClose();
- this.setData({
- inPlay: false
- });
- clearInterval(this.playTimer);
- common.loading(this);
- var me = this
- const deviceInfo = storage.getSelectedDeviceInfo();
- http.postApi(
- config.API_GPS_TRACK,
- {
- macid: deviceInfo.mac_id,
- location_type: this.isLocationType,
- from: parseInt(this.trackDialogFrom.startTime / 1000),
- to: parseInt(this.trackDialogFrom.endTime / 1000)
- },
- (resp) => {
- this.loadTotalMil();
- uni.hideLoading();
- if (resp.data.code === 200) {
- if (!resp.data.data.points || resp.data.data.points.length === 0) {
- common.simpleToast(me,me.$t('当前未有轨迹'));
- return;
- }
- // this.calculateMileage(resp.data.data.points)
- var points = [];
- var trackMarker = [];
- var trackStopList = [];
- var n = 1;
- this.setData({
- totalTrackValue: resp.data.data.points.length
- });
- var mileage = 0;
- resp.data.data.points.forEach((p, i) => {
- //移动坐标点
- if (resp.data.data.points.length - 1 > i) {
- mileage = this.getCurrentMil(mileage, i, resp.data.data.points);
- }
- points.push({
- latitude: parseFloat(p.latitude),
- longitude: parseFloat(p.longitude),
- time: p.time,
- speed: p.speed,
- voltage: p.voltage,
- time: p.time,
- mileage: (mileage / 1000).toFixed(2),
- stop_time: p.stop_time
- });
- //起点
- if (i === 0) {
- trackStopList.push({
- name: me.$t('起点'),
- latitude: parseFloat(p.latitude),
- longitude: parseFloat(p.longitude),
- time: p.time,
- end_time: common.formatDateTime(new Date(p.time).getTime() + p.stop_time * 1000),
- stop_time: p.stop_time,
- format_stop_time: common.formatSeconds(me,p.stop_time),
- address: ''
- });
- //mark弹出框坐标
- trackMarker.push({
- id: 0,
- latitude: p.latitude,
- longitude: p.longitude,
- name: '',
- iconPath: 'https://qiniu.bms16.com/FudnX-2lAHteUZHxpH6cAXFESNVs',
- width: 28,
- height: 35,
- zIndex: 2,
- callout: {
- content:
- '\u8D77\u70B9\n\u505C\u7559: ' +
- common.formatSeconds(me,p.stop_time) +
- '\n' +
- me.$t('开始')+':' +
- p.time +
- '\n' +
- me.$t('结束')+':' +
- common.formatDateTime(new Date(p.time).getTime() + p.stop_time * 1000) +
- '\n',
- padding: 10,
- borderRadius: 4,
- boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
- display: 'BYCLICK'
- }
- });
- const pData = {
- lng: parseFloat(p.longitude),
- lat: parseFloat(p.latitude),
- pi: 'wx_deviceLocal'
- };
- http.postApi(config.API_MAP_REGEO, pData, function (resp) {
- if (resp.data.code === 200) {
- var jsonData = resp.data.data.data;
- if (jsonData.code === 0) {
- const address = jsonData.address;
- let ps = '';
- let tmp_addr = me.$t('地址')+':' + address;
- while (tmp_addr.length > 15) {
- ps += tmp_addr.substring(0, 15) + '\n';
- tmp_addr = tmp_addr.substring(15);
- }
- ps += tmp_addr;
- trackMarker[0].callout.content += ps;
- trackStopList[0].address = address;
- me.setData({
- trackMarker: trackMarker,
- trackStopList: trackStopList
- });
- me.setMarkers();
- }
- }
- });
- // qqmapsdk.reverseGeocoder({
- // location: {
- // latitude: parseFloat(p.latitude),
- // longitude: parseFloat(p.longitude)
- // },
- // success: (res) => {
- // const formatted_addresses = res.result.formatted_addresses
- // const address = res.result.address + formatted_addresses.recommend
- // let ps = '';
- // let tmp_addr = '地址: ' + address
- // while (tmp_addr.length > 15) {
- // ps += tmp_addr.substring(0, 15) + "\n";
- // tmp_addr = tmp_addr.substring(15);
- // }
- // ps += tmp_addr
- // trackMarker[0].callout.content += ps
- // trackStopList[0].address = address
- // this.setData({
- // trackMarker: trackMarker,
- // trackStopList: trackStopList,
- // })
- // this.setMarkers()
- // }
- // })
- } else if (p.stop_time > 300 && i !== resp.data.data.points.length - 1) {
- //地图设置mark停留点
- trackStopList.push({
- name: 'P' + n,
- latitude: parseFloat(p.latitude),
- longitude: parseFloat(p.longitude),
- time: p.time,
- end_time: common.formatDateTime(new Date(p.time).getTime() + p.stop_time * 1000),
- stop_time: p.stop_time,
- format_stop_time: common.formatSeconds(me,p.stop_time),
- address: ''
- });
- //mark弹出框
- trackMarker.push({
- id: i,
- latitude: parseFloat(p.latitude),
- longitude: parseFloat(p.longitude),
- name: '',
- iconPath: 'https://qiniu.bms16.com/FtYXEurXCr7Ul2A1J8Kgn4BqF8Z7',
- width: 28,
- height: 35,
- zIndex: 1,
- callout: {
- content:
- 'P' +
- n +
- '\n' +
- me.$t('停留')+': ' +
- common.formatSeconds(me,p.stop_time) +
- '\n' +
- me.$t('开始')+': ' +
- p.time +
- '\n' +
- me.$t('结束')+': ' +
- common.formatDateTime(new Date(p.time).getTime() + p.stop_time * 1000) +
- '\n',
- padding: 10,
- borderRadius: 4,
- boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
- display: 'BYCLICK'
- }
- });
- var i = n;
- qqmapsdk.reverseGeocoder({
- location: {
- latitude: parseFloat(p.latitude),
- longitude: parseFloat(p.longitude)
- },
- success: (res) => {
- console.log(res);
- const formatted_addresses = res.result.formatted_addresses;
- const address = res.result.address + formatted_addresses.recommend;
- let ps = '';
- let tmp_addr = me.$t('地址')+': ' + address;
- while (tmp_addr.length > 15) {
- ps += tmp_addr.substring(0, 15) + '\n';
- tmp_addr = tmp_addr.substring(15);
- }
- ps += tmp_addr;
- trackMarker[i].callout.content += ps;
- trackStopList[i].address = address;
- this.setData({
- trackMarker: trackMarker,
- trackStopList: trackStopList
- });
- this.setMarkers();
- }
- });
- n++;
- }
- });
- //设置终点
- trackStopList.push({
- name: me.$t('终点'),
- latitude: parseFloat(points[points.length - 1].latitude),
- longitude: parseFloat(points[points.length - 1].longitude),
- time: points[points.length - 1].time,
- end_time: common.formatDateTime(new Date(points[points.length - 1].time).getTime() + points[points.length - 1].stop_time * 1000),
- stop_time: points[points.length - 1].stop_time,
- format_stop_time: common.formatSeconds(me,points[points.length - 1].stop_time),
- address: ''
- });
- trackMarker.push({
- id: points.length - 1,
- latitude: points[points.length - 1].latitude,
- longitude: points[points.length - 1].longitude,
- name: '',
- iconPath: '/static/resource/images/end_point.png',
- width: 28,
- height: 35,
- zIndex: 2,
- callout: {
- content:
- '\u7EC8\u70B9\n\u505C\u7559: ' +
- common.formatSeconds(me,points[points.length - 1].stop_time) +
- '\n' +
- me.$t('开始')+': ' +
- points[points.length - 1].time +
- '\n' +
- me.$t('结束')+': ' +
- common.formatDateTime(new Date(points[points.length - 1].time).getTime() + points[points.length - 1].stop_time * 1000) +
- '\n',
- padding: 10,
- borderRadius: 4,
- boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
- display: 'BYCLICK'
- }
- });
- qqmapsdk.reverseGeocoder({
- location: {
- latitude: parseFloat(points[points.length - 1].latitude),
- longitude: parseFloat(points[points.length - 1].longitude)
- },
- success: (res) => {
- console.log(res);
- const formatted_addresses = res.result.formatted_addresses;
- const address = res.result.address + formatted_addresses.recommend;
- let ps = '';
- let tmp_addr = me.$t('地址')+': ' + address;
- while (tmp_addr.length > 15) {
- ps += tmp_addr.substring(0, 15) + '\n';
- tmp_addr = tmp_addr.substring(15);
- }
- ps += tmp_addr;
- trackMarker[n].callout.content += ps;
- trackStopList[n].address = address;
- this.setData({
- trackMarker: trackMarker,
- trackStopList: trackStopList
- });
- this.setMarkers();
- }
- });
- var deviceMarker = this.deviceMarker;
- //deviceMarker[0].callout.display = 'BYCLICK'
- this.setData({
- trackPoints: points,
- trackMarker: trackMarker,
- deviceMarker: deviceMarker,
- trackStopList: trackStopList,
- nowPlayIndex: 0,
- playMarker: []
- });
- this.setMarkers();
- this.setPolylines();
- // this.mapCtx.scale = 8
- var map = uni.createMapContext('myMap');
- map.includePoints({
- points: points,
- padding: [10, 10, 10, 10]
- });
- this.setData({
- scale: 13
- });
- } else {
- common.simpleToast(this,resp.data.msg);
- }
- }
- );
- },
- bindTrackDialogClose() {
- this.setData({
- trackDialogShow: false
- });
- },
- bindTrackStartTimeSelect(e) {
- this.setData({
- selectTime: this.trackDialogFrom.formatStartTime,
- selectTimeType: 'track_start'
- });
- // this.bindTimeSelectOpen();
- },
- bindTrackEndTimeSelect() {
- this.setData({
- selectTime: this.trackDialogFrom.formatEndTime,
- selectTimeType: 'track_end'
- });
- // this.bindTimeSelectOpen();
- },
- bindTrackTimeSelectToday() {
- this.setData({
- trackDialogFrom: Object.assign(this.trackDialogFrom, {
- startTime: new Date(new Date().toLocaleDateString()).getTime(),
- formatStartTime: common.formatDateTime(new Date(new Date().toLocaleDateString()).getTime()),
- endTime: new Date().getTime(),
- formatEndTime: common.formatDateTime(new Date().getTime())
- })
- });
- this.bindTrackDialogConfirm();
- },
- bindTrackTimeSelectYesterday() {
- this.setData({
- trackDialogFrom: Object.assign(this.trackDialogFrom, {
- startTime: new Date(new Date().toLocaleDateString()).getTime() - 86400 * 1000,
- formatStartTime: common.formatDateTime(new Date(new Date().toLocaleDateString()).getTime() - 86400 * 1000),
- endTime: new Date(new Date().toLocaleDateString()).getTime() - 1,
- formatEndTime: common.formatDateTime(new Date(new Date().toLocaleDateString()).getTime() - 1)
- })
- });
- this.bindTrackDialogConfirm();
- },
- bindTrackTimeSelectLastday() {
- this.setData({
- trackDialogFrom: Object.assign(this.trackDialogFrom, {
- startTime: new Date(new Date().toLocaleDateString()).getTime() - 2880 * 60 * 1000,
- formatStartTime: common.formatDateTime(new Date(new Date().toLocaleDateString()).getTime() - 2880 * 60 * 1000),
- endTime: new Date(new Date().toLocaleDateString()).getTime() - 86400 * 1000 - 1,
- formatEndTime: common.formatDateTime(new Date(new Date().toLocaleDateString()).getTime() - 86400 * 1000 - 1)
- })
- });
- this.bindTrackDialogConfirm();
- },
- bindTimeSelectConfirm(event) {
- switch (this.selectTimeType) {
- case 'track_start':
- this.setData({
- trackDialogFrom: Object.assign(this.trackDialogFrom, {
- startTime: event.detail,
- formatStartTime: common.formatDateTime(event.detail)
- }),
- selectTimeType: ''
- });
- break;
- case 'track_end':
- this.setData({
- trackDialogFrom: Object.assign(this.trackDialogFrom, {
- endTime: event.detail,
- formatEndTime: common.formatDateTime(event.detail)
- }),
- selectTimeType: ''
- });
- break;
- }
- this.bindTimeSelectClose();
- },
- bindTimeSelectOpen() {
- this.setData({
- timeSelectShow: true
- });
- },
- bindTimeSelectClose() {
- this.setData({
- timeSelectShow: false
- });
- },
- bindStopPopupOpen() {
- this.setData({
- trackStopPopupShow: true
- });
- },
- bindStopPopupClose() {
- this.setData({
- trackStopPopupShow: false
- });
- },
- MoveToStop(event, _dataset) {
- /* ---处理dataset begin--- */
- this.handleDataset(event, _dataset);
- /* ---处理dataset end--- */
- var map = uni.createMapContext('myMap');
- this.setData({
- latitude: event.currentTarget.dataset.p.latitude,
- longitude: event.currentTarget.dataset.p.longitude
- });
- /*map.moveToLocation({
- latitude: event.currentTarget.dataset.p.latitude,
- longitude: event.currentTarget.dataset.p.longitude
- })*/
- },
- bindAlarmPopupOpen() {
- this.setData({
- alarmPopupShow: true
- });
- },
- bindAlarmPopupClose() {
- this.setData({
- alarmPopupShow: false
- });
- this.setData({
- alarmMarker: []
- });
- this.setMarkers();
- },
- MoveToAlarm(event, _dataset) {
- /* ---处理dataset begin--- */
- this.handleDataset(event, _dataset);
- /* ---处理dataset end--- */
- var map = uni.createMapContext('myMap');
- var me = this
- var alarmMarker = [
- {
- id: 0,
- latitude: event.currentTarget.dataset.p.latitude,
- longitude: event.currentTarget.dataset.p.longitude,
- name: '',
- iconPath: '/static/resource/images/alarm.png',
- width: 28,
- height: 35,
- zIndex: 10,
- callout: {
- content:
- event.currentTarget.dataset.p.alarm_desc +
- '\n' +
- me.$t('时间')+': ' +
- event.currentTarget.dataset.p.formatTime +
- '\n' +
- me.$t('速度')+': ' +
- event.currentTarget.dataset.p.speed +
- me.$t('公里')+'/'+me.$t('小时')+'\n' +
- event.currentTarget.dataset.p.ps +
- '\n',
- padding: 10,
- borderRadius: 4,
- boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
- display: 'ALWAYS'
- }
- }
- ];
- this.setData({
- alarmMarker: alarmMarker,
- latitude: event.currentTarget.dataset.p.latitude,
- longitude: event.currentTarget.dataset.p.longitude
- });
- this.setMarkers();
- },
- playLoop() {
- if (this.nowPlayIndex >= this.trackPoints.length - 1) {
- this.setData({
- inPlay: false
- });
- clearInterval(this.playTimer);
- return;
- }
- this.setData({
- showInfo: false
- });
- var map = uni.createMapContext('myMap');
- var leng = Math.sqrt(
- Math.pow(Math.abs(this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this.nowPlayIndex].longitude) * 111, 2) +
- Math.pow(
- Math.abs(this.trackPoints[this.nowPlayIndex + 1].latitude - this.trackPoints[this.nowPlayIndex].latitude) *
- 111 *
- Math.cos(((2 * Math.PI) / 360) * this.trackPoints[this.nowPlayIndex].latitude),
- 2
- )
- );
- while (leng < 0.1 && this.nowPlayIndex < this.trackPoints.length - 1) {
- leng += Math.sqrt(
- Math.pow(Math.abs(this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this.nowPlayIndex].longitude) * 111, 2) +
- Math.pow(
- Math.abs(this.trackPoints[this.nowPlayIndex + 1].latitude - this.trackPoints[this.nowPlayIndex].latitude) *
- 111 *
- Math.cos(((2 * Math.PI) / 360) * this.trackPoints[this.nowPlayIndex].latitude),
- 2
- )
- );
- this.nowPlayIndex = this.nowPlayIndex + 1;
- }
- var rotate =
- (Math.atan(
- (this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this.nowPlayIndex].longitude) /
- (this.trackPoints[this.nowPlayIndex + 1].latitude - this.trackPoints[this.nowPlayIndex].latitude) /
- Math.cos(((2 * Math.PI) / 360) * this.trackPoints[this.nowPlayIndex].latitude)
- ) *
- 180) /
- Math.PI;
- if (rotate === NaN) {
- if (this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this.nowPlayIndex].longitude > 0) {
- rotate = 90;
- } else {
- rotate = 270;
- }
- } else if (this.trackPoints[this.nowPlayIndex + 1].latitude - this.trackPoints[this.nowPlayIndex].latitude < 0) {
- rotate = 180 + rotate;
- } else if (this.trackPoints[this.nowPlayIndex + 1].longitude - this.trackPoints[this.nowPlayIndex].longitude < 0) {
- rotate = 360 + rotate;
- }
- var playMarker = [
- {
- id: -1,
- latitude: this.trackPoints[this.nowPlayIndex].latitude,
- longitude: this.trackPoints[this.nowPlayIndex].longitude,
- name: '',
- iconPath: '/static/resource/images/1.gif',
- width: 35,
- height: 35,
- zIndex: 20,
- callout: {
- content:
- this.$t('电压')+': ' +
- this.trackPoints[this.nowPlayIndex].voltage +
- '\n' +
- this.$t('速度')+': ' +
- this.trackPoints[this.nowPlayIndex].speed +
- 'km/'+this.$t('小时')+'\n' +
- this.$t('时间')+': ' +
- this.trackPoints[this.nowPlayIndex].time +
- '\n' +
- this.$t('里程')+': ' +
- this.trackPoints[this.nowPlayIndex].mileage +
- this.$t('公里')+'\n',
- padding: 10,
- borderRadius: 4,
- boxShadow: '4px 8px 16px 0 rgba(0,0,0,0.3)',
- display: 'ALWAYS'
- }
- }
- ];
- this.playMarker = playMarker;
- this.setMarkers();
- this.setData({
- latitude: this.trackPoints[this.nowPlayIndex].latitude,
- longitude: this.trackPoints[this.nowPlayIndex].longitude,
- nowPlayIndex: this.nowPlayIndex + 1
- });
- },
- bindPlay() {
- if (this.inPlay) {
- this.setData({
- inPlay: false
- });
- const me = this;
- clearInterval(this.playTimer);
- if (me.playMarker.length > 0) {
- const pData = {
- lng: me.playMarker[0].longitude,
- lat: me.playMarker[0].latitude,
- pi: 'wx_deviceLocal'
- };
- const me = this;
- http.postApi(config.API_MAP_REGEO, pData, function (resp) {
- if (resp.data.code === 200) {
- var jsonData = resp.data.data.data;
- if (jsonData.code === 0) {
- const address = jsonData.address;
- var ps = '';
- let tmp_addr = me.$t('地址')+': ' + address;
- while (tmp_addr.length > 15) {
- ps += tmp_addr.substring(0, 15) + '\n';
- tmp_addr = tmp_addr.substring(15);
- }
- ps += tmp_addr;
- var playMark = me.playMarker;
- playMark[0].callout.content += ps;
- me.setData({
- playMarker: playMark
- });
- me.setMarkers();
- }
- }
- });
- // qqmapsdk.reverseGeocoder({
- // location: {
- // latitude: me.data.playMarker[0].latitude,
- // longitude: me.data.playMarker[0].longitude
- // },
- // success: function (res) {
- // const formatted_addresses = res.result.formatted_addresses
- // const address = res.result.address
- // let ps = '';
- // let tmp_addr = '地址: ' + address
- // while (tmp_addr.length > 15) {
- // ps += tmp_addr.substring(0, 15) + "\n";
- // tmp_addr = tmp_addr.substring(15);
- // }
- // ps += tmp_addr
- // var playMark = me.data.playMarker
- // playMark[0].callout.content += ps
- // me.setData({
- // playMarker: playMark
- // })
- // me.setMarkers()
- // }
- // })
- }
- } else {
- if (this.nowPlayIndex >= this.trackPoints.length - 1) {
- this.setData({
- nowPlayIndex: 0
- });
- }
- this.setData({
- inPlay: true
- });
- this.playTimer = setInterval(this.playLoop, this.speedTime);
- }
- },
- // bindGPSLocation(){
- // this.setData({
- // isShowGPS:true
- // })
- // this.locationLoop(true)
- // },
- locationLoop(init = false) {
- const deviceInfo = storage.getSelectedDeviceInfo();
- if (deviceInfo) {
- //common.loading()
- http.postApi(
- config.API_GPS_INFO,
- {
- macid: deviceInfo.mac_id
- },
- (resp) => {
- //wx.hideLoading()
- if (resp.data.code === 200) {
- let status;
- let stat = '';
- if (parseInt(resp.data.data.info.online) === 1) {
- if (parseInt(resp.data.data.info.speed) === 0) {
- status = this.$t('静止')+'(' + common.formatSeconds(this,resp.data.data.info.heart_time - resp.data.data.info.gps_time, false) + ')';
- stat = 'static';
- } else {
- status = this.$t('行驶')+'(' + resp.data.data.info.speed + 'Km/h)';
- stat = 'running';
- }
- } else {
- status =
- this.$t('离线')+'(' +
- common.formatSeconds(
- this,new Date().getTime() / 1000 -
- (resp.data.data.info.heart_time === undefined ? resp.data.data.info.gps_time : resp.data.data.info.heart_time),
- false
- ) +
- ')';
- stat = 'offline';
- }
- if (init) {
- this.setData({
- longitude: resp.data.data.info.longitude,
- latitude: resp.data.data.info.latitude
- });
- }
- var device_info = resp.data.data.info;
- this.setData({
- locationType: device_info.signalType
- });
- this.setData({
- macid: deviceInfo.mac_id,
- deviceInfo: resp.data.data.info,
- gps: resp.data.data.info.gpscount,
- gsm: parseInt(resp.data.data.info.online) === 0 ? 0 : resp.data.data.info.gsmlevel <= 15 ? 3 : resp.data.data.info.gsmlevel > 18 ? 5 : 4,
- status: status,
- deviceMarker: [
- {
- id: 1,
- latitude: resp.data.data.info.latitude,
- longitude: resp.data.data.info.longitude,
- name: '',
- iconPath: this.iconList[resp.data.data.info.icon] ? this.iconList[resp.data.data.info.icon][stat] : '/static/resource/images/weizhi2.png',
- width: 35,
- height: 35,
- zIndex: 10
- }
- ],
- circles: [
- {
- latitude: resp.data.data.info.latitude,
- longitude: resp.data.data.info.longitude,
- color: '#6495ED1F',
- fillColor: '#6495ED1F',
- radius: 1000,
- strokeWidth: 1
- }
- ]
- });
- this.setMarkers();
- if (
- this.trace &&
- (this.tracePoints.length == 0 ||
- this.tracePoints[this.tracePoints.length - 1].latitude != resp.data.data.info.latitude ||
- this.tracePoints[this.tracePoints.length - 1].longitude != resp.data.data.info.longitude)
- ) {
- this.tracePoints.push({
- latitude: resp.data.data.info.latitude,
- longitude: resp.data.data.info.longitude
- });
- this.setPolylines();
- this.setData({
- latitude: resp.data.data.info.latitude,
- longitude: resp.data.data.info.longitude
- });
- }
- const pData = {
- lng: resp.data.data.info.longitude,
- lat: resp.data.data.info.latitude,
- pi: 'wx_deviceLocal'
- };
- const me = this;
- http.postApi(config.API_MAP_REGEO, pData, function (resp) {
- if (resp.data.code === 200) {
- var jsonData = resp.data.data.data;
- if (jsonData.code === 0) {
- me.setData({
- address: jsonData.address,
- locationAdress: jsonData.address
- });
- }
- }
- });
- // qqmapsdk.reverseGeocoder({
- // location: {
- // latitude: resp.data.data.info.latitude,
- // longitude: resp.data.data.info.longitude
- // },
- // success: function (res) {
- // console.log(res)
- // const formatted_addresses = res.result.formatted_addresses
- // const address = res.result.address //+ formatted_addresses.recommend
- // me.setData({
- // address: address,
- // locationAdress: address
- // })
- // }
- // })
- } else {
- common.simpleToast(this,resp.data.msg);
- clearInterval(this.locationTimer);
- setTimeout(function () {
- uni.navigateBack({
- delta: 1
- });
- }, 1500);
- }
- }
- );
- }
- },
- isEmptyObject(obj) {
- for (var key in obj) {
- return false;
- }
- return true;
- },
- loadLastGpsInfo() {
- var init = true;
- const me = this;
- const deviceInfo = storage.getSelectedDeviceInfo();
- if (deviceInfo) {
- http.postApi(
- config.API_GPS_INFO,
- {
- macid: deviceInfo.mac_id
- },
- (resp) => {
- if (resp.data.code === 200) {
- if (this.isEmptyObject(resp.data.data.info.last_location)) {
- common.simpleToast(me,me.$t('当前设备没有GPS坐标'));
- return;
- }
- // var last_location = resp.data.data.info.last_location
- // last_location.lng = 121.19023414159073
- // last_location.lat = 31.390001627411883
- // resp.data.data.info.last_location = last_location
- let status;
- let stat = '';
- if (parseInt(resp.data.data.info.online) === 1) {
- if (parseInt(resp.data.data.info.speed) === 0) {
- status = me.$t('静止')+'(' + common.formatSeconds(me,resp.data.data.info.heart_time - resp.data.data.info.gps_time, false) + ')';
- stat = 'static';
- } else {
- status = me.$t('行驶')+'(' + resp.data.data.info.speed + 'Km/h)';
- stat = 'running';
- }
- } else {
- status =
- me.$t('离线')+'(' +
- common.formatSeconds(
- me,new Date().getTime() / 1000 -
- (resp.data.data.info.heart_time === undefined ? resp.data.data.info.gps_time : resp.data.data.info.heart_time),
- false
- ) +
- ')';
- stat = 'offline';
- }
- if (init) {
- this.setData({
- longitude: resp.data.data.info.last_location.lng,
- latitude: resp.data.data.info.last_location.lat
- });
- }
- var device_info = resp.data.data.info;
- device_info.signalType = '0';
- this.setData({
- locationGpsType: device_info.signalType
- });
- var device_marker = {
- id: 2,
- latitude: resp.data.data.info.last_location.lat,
- longitude: resp.data.data.info.last_location.lng,
- name: '',
- iconPath: this.iconList[resp.data.data.info.icon] ? this.iconList[resp.data.data.info.icon][stat] : '/static/resource/images/weizhi2.png',
- width: 35,
- height: 35,
- zIndex: 10
- };
- // this.setData({
- // marker: this.data.marker.concat(device_marker)
- // })
- this.setData({
- gpsMarker: [device_marker]
- });
- this.setData({
- marker: this.gpsMarker.concat(this.trackMarker, this.alarmMarker, this.playMarker, this.deviceMarker)
- });
- // this.setData({
- // marker: this.data.deviceMarker.concat(this.data.trackMarker, this.data.alarmMarker, this.data.playMarker)
- // })
- //this.data.deviceMarker.concat(this.data.trackMarker, this.data.alarmMarker, this.data.playMarker)
- this.setData({
- macid: deviceInfo.mac_id,
- deviceInfo: device_info,
- gps: resp.data.data.info.gpscount,
- gsm: parseInt(resp.data.data.info.online) === 0 ? 0 : resp.data.data.info.gsmlevel <= 15 ? 3 : resp.data.data.info.gsmlevel > 18 ? 5 : 4,
- status: status,
- deviceMarker: [device_marker],
- circles: [
- {
- latitude: resp.data.data.info.last_location.lat,
- longitude: resp.data.data.info.last_location.lng,
- color: '#6495ED1F',
- fillColor: '#6495ED1F',
- radius: 1000,
- strokeWidth: 1
- }
- ]
- });
- //this.setMarkers()
- // this.setData({
- // marker: this.data.deviceMarker.concat(this.data.deviceMarker)
- // })
- this.setData({
- batteryWidth: parseInt((this.deviceInfo.quantity / 100) * 37)
- });
- // const me = this;
- const pData = {
- lng: resp.data.data.info.last_location.lng,
- lat: resp.data.data.info.last_location.lat,
- pi: 'wx_deviceLocal'
- };
- http.postApi(config.API_MAP_REGEO, pData, function (resp) {
- if (resp.data.code === 200) {
- var jsonData = resp.data.data.data;
- if (jsonData.code === 0) {
- const address = jsonData.address;
- me.setData({
- address: address,
- locationGpsAdress: address
- });
- }
- }
- });
- // qqmapsdk.reverseGeocoder({
- // location: {
- // latitude: resp.data.data.info.last_location.latitude,
- // longitude: resp.data.data.info.last_location.longitude
- // },
- // success: function (res) {
- // console.log(res)
- // const formatted_addresses = res.result.formatted_addresses
- // const address = res.result.address //+ formatted_addresses.recommend
- // me.setData({
- // address: address,
- // locationGpsAdress: address
- // })
- // }
- // })
- } else {
- common.simpleToast(this,resp.data.msg);
- clearInterval(this.locationTimer);
- setTimeout(function () {
- uni.navigateBack({
- delta: 1
- });
- }, 1500);
- }
- }
- );
- }
- },
- bindMarkertap(e) {
- if (e.markerId == 1 || e.markerId == 2) {
- if (e.markerId == 1) {
- var deviceInfo = this.deviceInfo;
- deviceInfo.signalType = this.locationType;
- this.setData({
- deviceInfo: deviceInfo,
- address: this.locationAdress
- });
- }
- if (e.markerId == 2) {
- var deviceInfo = this.deviceInfo;
- deviceInfo.signalType = this.locationGpsType;
- this.setData({
- deviceInfo: deviceInfo,
- address: this.locationGpsAdress
- });
- }
- this.setData({
- showInfo: !this.showInfo
- });
- }
- },
- bindTapMap(e) {
- this.setData({
- showInfo: false
- });
- if (this.selectFence != null) {
- var fence = this.selectFence;
- fence.latitude = e.detail.latitude;
- fence.longitude = e.detail.longitude;
- this.setData({
- selectFence: fence,
- circles: [
- {
- latitude: fence.latitude,
- longitude: fence.longitude,
- radius: parseInt(fence.radius),
- color: '#6495ED1F',
- fillColor: '#6495ED1F',
- strokeWidth: 1
- }
- ]
- });
- }
- },
- bindSendCommand: function (e) {
- this.sendCommand(e.currentTarget.dataset.cmd);
- },
- sendCommand: function (cmd) {
- var me = this
- uni.showModal({
- content: me.$t('确定发送指令吗?'),
- showCancel: true,
- cancelText: me.$t('取消'),
- confirmText: me.$t('确定'),
- success: (res) => {
- console.log(res);
- if (res.confirm) {
- common.loading(me);
- http.postApi(
- config.API_BATTERY_SEND_COMMAND,
- {
- macid: this.macid,
- cmd: cmd
- },
- function (resp) {
- if (resp.data.code === 200) {
- uni.hideLoading();
- common.simpleToast(me,me.$t('操作成功'));
- } else {
- common.simpleToast(me,resp.data.msg);
- }
- }
- );
- }
- },
- fail: function (res) {},
- complete: function (res) {}
- });
- },
- bindTrace() {
- if (this.trace) {
- this.setData({
- trace: false,
- tracePoints: []
- });
- this.setPolylines();
- clearInterval(this.traceTimer);
- } else {
- this.setData({
- trace: true
- });
- this.traceTimer = setInterval(() => {
- this.setData({
- traceTime: this.traceTime + 1
- });
- }, 1000);
- }
- },
- bindNavigate() {
- //使用微信内置地图查看标记点位置,并进行导航
- const latitude = this.latitude;
- const longitude = this.longitude;
- const address = this.address;
- const name = this.deviceInfo.name
- uni.openLocation({
- latitude,
- //要去的纬度-地址
- longitude,
- //要去的经度-地址
- address,
- name,
- scale: 11
- });
- },
- bindCloseTrack() {
- this.setData({
- trackPoints: [],
- trackMarker: [],
- trackStopList: [],
- nowPlayIndex: 0,
- playMarker: []
- });
- this.setMarkers();
- this.setPolylines();
- },
- bindFencePopupOpen() {
- this.setData({
- fencePopupShow: true
- });
- },
- bindFencePopupClose() {
- this.setData({
- fencePopupShow: false
- });
- },
- MoveToFence(event, _dataset) {
- clearInterval(this.locationTimer);
- /* ---处理dataset begin--- */
- this.handleDataset(event, _dataset);
- /* ---处理dataset end--- */
- var map = uni.createMapContext('myMap');
- const fence = Object.assign({}, event.currentTarget.dataset.p);
- this.setData({
- selectFence: fence,
- circles: [
- {
- latitude: fence.latitude,
- longitude: fence.longitude,
- radius: parseInt(fence.radius),
- color: '#6495ED1F',
- fillColor: '#6495ED1F',
- strokeWidth: 1
- }
- ],
- fencePopupShow: false,
- latitude: fence.latitude,
- longitude: fence.longitude
- });
- console.log(this.selectFence,'this.selectFence');
- /*map.moveToLocation({
- latitude: event.currentTarget.dataset.p.latitude,
- longitude: event.currentTarget.dataset.p.longitude
- })*/
- },
- addFence() {
- clearInterval(this.locationTimer);
- var map = uni.createMapContext('myMap');
- map.getCenterLocation({
- success: (res) => {
- const fence = {
- name: '',
- type: '0',
- latitude: res.latitude,
- longitude: res.longitude,
- radius: 100
- };
- console.log(fence,'fence');
- this.setData({
- selectFence: fence,
- circles: [
- {
- latitude: fence.latitude,
- longitude: fence.longitude,
- radius: parseInt(fence.radius),
- color: '#6495ED1F',
- fillColor: '#6495ED1F',
- strokeWidth: 1
- }
- ],
- fencePopupShow: false
- });
- }
- });
- },
- loadFenceList() {
- common.loading(this);
- const deviceInfo = storage.getSelectedDeviceInfo();
- http.postApi(
- config.API_FENCE_LIST,
- {
- macid: deviceInfo.mac_id
- },
- (resp) => {
- uni.hideLoading();
- if (resp.data.code === 200) {
- var fenceList = resp.data.data.list;
- this.setData({
- fenceList: fenceList
- });
- } else {
- common.simpleToast(this,resp.data.msg);
- }
- }
- );
- },
- bindFenceClose() {
- this.locationTimer = setInterval(this.locationLoop, 10000);
- this.setData({
- selectFence: null,
- circles: [],
- fencePopupShow: true
- });
- },
- onFenceNameChange(e) {
- var fence = this.selectFence;
- fence.name = e.detail.value;
- this.setData({
- selectFence: fence
- });
- },
- onFenceTypeChange(e) {
- var fence = this.selectFence;
- fence.type = e.detail.value;
- this.setData({
- selectFence: fence
- });
- },
- onFenceRadiusDrag(e) {
- var fence = this.selectFence;
- fence.radius = e.detail.value;
- this.setData({
- selectFence: fence
- /*circles: [{
- latitude: fence.latitude,
- longitude: fence.longitude,
- radius: parseInt(fence.radius),
- color: '#6495EDBB',
- fillColor: '#6495ED1F',
- strokeWidth: 1
- }],*/
- });
- },
- onFenceRadiusChange(e) {
- var fence = this.selectFence;
- fence.radius = e.detail.value;
- // this.setData({circles:[]})
- var startSlide = new Date().getTime();
- if (startSlide - this.endSlide > 100) {
- this.setData({
- endSlide: startSlide
- });
- this.setData({
- selectFence: fence,
- circles: [
- {
- latitude: fence.latitude,
- longitude: fence.longitude,
- radius: parseInt(fence.radius),
- color: '#6495ED1F',
- fillColor: '#6495ED1F',
- strokeWidth: 1
- }
- ]
- });
- }
- },
- onFenceRadiusMinus() {
- var fence = this.selectFence;
- if (fence.radius > 1) {
- fence.radius = parseInt(fence.radius) - 100;
- this.setData({
- selectFence: fence,
- circles: [
- {
- latitude: fence.latitude,
- longitude: fence.longitude,
- radius: parseInt(fence.radius),
- color: '#6495ED1F',
- fillColor: '#6495ED1F',
- strokeWidth: 1
- }
- ]
- });
- }
- },
- onFenceRadiusPlus() {
- var fence = this.selectFence;
- if (fence.radius < 10000) {
- fence.radius = parseInt(fence.radius) + 100;
- this.setData({
- selectFence: fence,
- circles: [
- {
- latitude: fence.latitude,
- longitude: fence.longitude,
- radius: parseInt(fence.radius),
- color: '#6495ED1F',
- fillColor: '#6495ED1F',
- strokeWidth: 1
- }
- ]
- });
- }
- },
- bindFenceSave() {
- var fence = this.selectFence;
- console.log(fence,'fence');
- if (!fence.name) {
- common.simpleToast(this,this.$t('请输入围栏名称'));
- return;
- }
- if (fence != null) {
- common.loading(this);
- const deviceInfo = storage.getSelectedDeviceInfo();
- console.log(this.selectFence,'selectFence');
- if (fence.id) {
- http.postApi(
- config.API_FENCE_EDIT,
- Object.assign(
- {
- macid: deviceInfo.mac_id,
- id: fence.id,
- type: fence.type.value?fence.type.value-0:fence.type.value,
- name: fence.name,
- latitude: fence.latitude,
- longitude: fence.longitude,
- radius: fence.radius
- },
- // fence
- ),
- (resp) => {
- uni.hideLoading();
- if (resp.data.code === 200) {
- this.loadFenceList();
- } else {
- common.simpleToast(this,resp.data.msg);
- }
- this.setData({
- selectFence: null,
- circles: [],
- fencePopupShow: true
- });
- }
- );
- } else {
- http.postApi(
- config.API_FENCE_ADD,
- Object.assign(
- {
- macid: deviceInfo.mac_id,
- type: fence.type.value-0,
- name: fence.name,
- latitude: fence.latitude,
- longitude: fence.longitude,
- radius: fence.radius
- },
- // fence
- ),
- (resp) => {
- uni.hideLoading();
- if (resp.data.code === 200) {
- this.loadFenceList();
- } else {
- common.simpleToast(this,resp.data.msg);
- }
- this.setData({
- selectFence: null,
- circles: [],
- fencePopupShow: true
- });
- }
- );
- }
- }
- this.locationTimer = setInterval(this.locationLoop, 10000);
- },
- delFence() {
- var fence = this.selectFence;
- if (fence != null && fence.id) {
- common.loading(this);
- const deviceInfo = storage.getSelectedDeviceInfo();
- http.postApi(
- config.API_FENCE_DEL,
- {
- macid: deviceInfo.mac_id,
- id: fence.id
- },
- (resp) => {
- uni.hideLoading();
- if (resp.data.code === 200) {
- this.loadFenceList();
- } else {
- common.simpleToast(this,resp.data.msg);
- }
- this.setData({
- selectFence: null,
- circles: [],
- fencePopupShow: true
- });
- }
- );
- }
- },
- moveToLocation: function () {
- uni.createMapContext("myMap", this).moveToLocation({
- latitude: this.latitude,
- longitude: this.longitude
- });
- // this.mapCtx.moveToLocation();
- //this.setData({ showShopInfo: false, scale: 14 })
- },
- mapChange: function (e) {
- this.setData({
- mapParams: e.detail.mapParams
- });
- }
- }
- };
- </script>
- <style>
- @import './deviceLocal.css';
- </style>
|