detail.vue 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492
  1. <template>
  2. <view class="content" >
  3. <view class="header" :style='"background-image:url("+imgUrl+"/detail/bg.png);background-repeat: no-repeat;background-size: 100% 200%;"'>
  4. <view class="status_info">
  5. <view class="status_detail">
  6. <view class="status_text">{{ getStatusText() }}</view>
  7. <view v-if="deviceInfo.status == 3" class="online_text online">·在线</view>
  8. <view v-if="deviceInfo.status == 4" class="online_text">·离线</view>
  9. </view>
  10. <view class="device_info">机器编号: {{deviceInfo.serialNumber}}</view>
  11. </view>
  12. <view style="position: absolute;right:10vw;top:9vh;z-index: 9" @click="showDrawer">
  13. <image :src="imgUrl+'/detail/setting2.png'" style="width: 50rpx;height: 50rpx;"/>
  14. </view>
  15. <view style="position: relative;top:8%;width: 100%;text-align: center">
  16. <image :src="imgUrl+'/detail/product.png'" style="width: 330rpx;height: 550rpx;"/>
  17. </view>
  18. <view class="tabs">
  19. <view class="child_tab" v-for="item in (summary)" @click="changeTab(item)">
  20. <image :src="imgUrl+'/detail/tab.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  21. <image class="child_img" v-if="item.checked" :src="imgUrl+'/detail/jianyao_on.png'" />
  22. <image class="child_img" v-if="!item.checked" :src="imgUrl+'/detail/jianyao_off.png'" />
  23. <view class="child_title" :class="item.checked?'active_on':''">
  24. {{item.name}}
  25. </view>
  26. </view>
  27. <view class="child_tab" @click="changeTab({name:'baozhuang'})">
  28. <image :src="imgUrl+'/detail/tab.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  29. <image class="child_img" v-if="firstTab" :src="imgUrl+'/detail/baozhuang_off.png'" />
  30. <image class="child_img" v-if="!firstTab" :src="imgUrl+'/detail/baozhuang_on.png'" />
  31. <view class="child_title" :class="firstTab?'':'active_on'">
  32. 包装机
  33. </view>
  34. </view>
  35. </view>
  36. <view v-if="firstTab">
  37. <view class="control">
  38. <view class="control_item">
  39. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  40. <view class="control_item_detail">
  41. <view class="control_item_left" @click="subTemperature(1)">-</view>
  42. <view class="control_item_center">
  43. <view style="position: absolute">
  44. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" @change="changeTemperature()" v-model="temperature"></u-input>
  45. </view>
  46. </view>
  47. <view class="control_item_center_unit" :style="unitFixedStyle">℃</view>
  48. <view class="control_item_right" @click="addTemperature(1)">+</view>
  49. </view>
  50. <view class="control_item_title">
  51. 温度设置
  52. </view>
  53. </view>
  54. <view class="control_item">
  55. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  56. <view class="control_item_detail">
  57. <view class="control_item_left" @click="subTemperatureTime()">-</view>
  58. <view class="control_item_center">
  59. <view style="position: absolute">
  60. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" @change="changeTemperatureTime()" v-model="temperatureTime"></u-input>
  61. </view>
  62. </view>
  63. <view class="control_item_center_unit" :style="unitFixedStyle">分钟</view>
  64. <view class="control_item_right" style="left: 70%;" @click="addTemperatureTime()">+</view>
  65. </view>
  66. <view class="control_item_title">
  67. 时间设置
  68. </view>
  69. </view>
  70. <view class="control_item">
  71. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  72. <view class="control_item_detail">
  73. <view class="control_item_center">
  74. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" :value="currentTemperature"></u-input>
  75. </view>
  76. <view class="control_item_center_unit" :style="unitFixedStyle">℃</view>
  77. </view>
  78. <view class="control_item_title">
  79. 当前温度
  80. </view>
  81. </view>
  82. <view class="control_item">
  83. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  84. <view class="control_item_detail">
  85. <view class="control_item_center">
  86. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" :value="hightTemperature"></u-input>
  87. </view>
  88. <view class="control_item_center_unit" :style="unitFixedStyle">分钟</view>
  89. </view>
  90. <view class="control_item_title">
  91. 高温时间
  92. </view>
  93. </view>
  94. </view>
  95. <view class="bottom">
  96. <image :src="imgUrl+'/detail/bg_large.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  97. <view class="bottom_item" @click="decoctControlOnOffChange">
  98. <image v-if="decoctControlOnOffStatus" :src="imgUrl+'/detail/open_on.png'" style="width: 32%;height:32%;"/>
  99. <image v-if="!decoctControlOnOffStatus" :src="imgUrl+'/detail/open_off.png'" style="width: 32%;height:32%;"/>
  100. <view :class="decoctControlOnOffStatus?'active_on':''">开关</view>
  101. </view>
  102. <view class="bottom_item" @click="decoctControlChange">
  103. <image v-if="decoctControlStatus" :src="imgUrl+'/detail/jianing_on.png'" style="width: 32%;height:32%;"/>
  104. <image v-if="!decoctControlStatus" :src="imgUrl+'/detail/jianing_off.png'" style="width: 32%;height:32%;"/>
  105. <view :class="decoctControlStatus?'active_on':''">煎药</view>
  106. </view>
  107. <view class="bottom_item" @click="stopDecoctControlChange">
  108. <image v-if="!decoctControlStatus" :src="imgUrl+'/detail/stop_on.png'" style="width: 32%;height:32%;"/>
  109. <image v-if="decoctControlStatus" :src="imgUrl+'/detail/stop_off.png'" style="width: 32%;height:32%;"/>
  110. <view :class="!decoctControlStatus?'active_on':''">停止</view>
  111. </view>
  112. <view class="bottom_item" @click="toPlan">
  113. <image v-if="leftAppointmentTime>0" :src="imgUrl+'/detail/plan_on.png'" style="width: 32%;height:32%;"/>
  114. <image v-else :src="imgUrl+'/detail/plan_off.png'" style="width: 32%;height:32%;"/>
  115. <view :class="leftAppointmentTime>0?'active_on':''">预约</view>
  116. </view>
  117. </view>
  118. </view>
  119. <view v-if="!firstTab">
  120. <view class="control">
  121. <view class="control_item">
  122. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  123. <view class="control_item_detail">
  124. <view class="control_item_center">
  125. <u-input customStyle="width:150rpx;border:0px;background:none;" disabledColor="white" placeholder="0" disabled v-model="edegTemperature"></u-input>
  126. </view>
  127. <view class="control_item_center_unit" :style="unitFixedStyle">℃</view>
  128. <view class="control_item_right" style="left:75%;top:10rpx" @click="showBaozhuangDlg(1)">
  129. <uni-icons type="gear-filled" size="20"></uni-icons>
  130. </view>
  131. </view>
  132. <view class="control_item_title">
  133. 当前封边温度
  134. </view>
  135. </view>
  136. <view class="control_item">
  137. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  138. <view class="control_item_detail">
  139. <view class="control_item_center">
  140. <u-input customStyle="width:150rpx;border:0px;background:none;" disabledColor="white" placeholder="0" disabled v-model="sealingTemperature"></u-input>
  141. </view>
  142. <view class="control_item_center_unit" :style="unitFixedStyle">℃</view>
  143. <view class="control_item_right" style="left:75%;top:10rpx" @click="showBaozhuangDlg(2)">
  144. <uni-icons type="gear-filled" size="20"></uni-icons>
  145. </view>
  146. </view>
  147. <view class="control_item_title">
  148. 当前封口温度
  149. </view>
  150. </view>
  151. <view class="control_item">
  152. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  153. <view class="control_item_detail">
  154. <view class="control_item_left" @click="subPackageNumber()">-</view>
  155. <view class="control_item_center">
  156. <view style="position: absolute">
  157. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" @change="changePackageNumber" :value="packageNumber"></u-input>
  158. </view>
  159. </view>
  160. <view class="control_item_center_unit" :style="unitFixedStyle">袋</view>
  161. <view class="control_item_right" @click="addPackageNumber()">+</view>
  162. </view>
  163. <view class="control_item_title">
  164. 包装数量
  165. </view>
  166. </view>
  167. <view class="control_item">
  168. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  169. <view class="control_item_detail">
  170. <view class="control_item_left" @click="subPackageVolume()">-</view>
  171. <view class="control_item_center">
  172. <view style="position: absolute">
  173. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" @change="changePackageVolume" :value="packageVolume"></u-input>
  174. </view>
  175. </view>
  176. <view class="control_item_center_unit" :style="unitFixedStyle">ml</view>
  177. <view class="control_item_right" @click="addPackageVolume()">+</view>
  178. </view>
  179. <view class="control_item_title">
  180. 包装容量
  181. </view>
  182. </view>
  183. </view>
  184. <view class="bottom">
  185. <image :src="imgUrl+'/detail/bg_large.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  186. <view class="bottom_item" @click="packageControlOnOffChange">
  187. <image v-if="packageControlOnOffStatus" :src="imgUrl+'/detail/open_on.png'" style="width: 32%;height:32%;"/>
  188. <image v-if="!packageControlOnOffStatus" :src="imgUrl+'/detail/open_off.png'" style="width: 32%;height:32%;"/>
  189. <view :class="packageControlOnOffStatus?'active_on':''">开关</view>
  190. </view>
  191. <view class="bottom_item" @click="turnChange(1)">
  192. <image v-if="qitingTurn" :src="imgUrl+'/detail/open_on.png'" style="width: 32%;height:32%;"/>
  193. <image v-if="!qitingTurn" :src="imgUrl+'/detail/open_off.png'" style="width: 32%;height:32%;"/>
  194. <view :class="qitingTurn?'active_on':''">启停</view>
  195. </view>
  196. <view class="bottom_item" @click="turnChange(2)">
  197. <image v-if="baozhuangTurn" :src="imgUrl+'/detail/bao_on.png'" style="width: 32%;height:32%;"/>
  198. <image v-if="!baozhuangTurn" :src="imgUrl+'/detail/bao_off.png'" style="width: 32%;height:32%;"/>
  199. <view :class="baozhuangTurn?'active_on':''">包装</view>
  200. </view>
  201. <view class="bottom_item" @click="turnChange(3)">
  202. <image v-if="qingxiTurn" :src="imgUrl+'/detail/xi_on.png'" style="width: 32%;height:32%;"/>
  203. <image v-if="!qingxiTurn" :src="imgUrl+'/detail/xi_off.png'" style="width: 32%;height:32%;"/>
  204. <view :class="qingxiTurn?'active_on':''">清洗</view>
  205. </view>
  206. </view>
  207. </view>
  208. </view>
  209. <u-popup :show="popDlg" @close="closePop" mode="center" bgColor="transparent" :closeable="true">
  210. <view style="position: relative;width: 400rpx;background: none">
  211. <view class="control_item" style="width: 100%" v-if="fengbianDlgShow">
  212. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  213. <view class="control_item_detail">
  214. <view class="control_item_left" @click="subEdegTemperature(1)">-</view>
  215. <view class="control_item_center">
  216. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" @change="changeEdegTemperature" v-model="setEdegTemperature"></u-input>
  217. </view>
  218. <view class="control_item_center_unit" :style="unitFixedStyle">℃</view>
  219. <view class="control_item_right" @click="addEdegTemperature(1)">+</view>
  220. </view>
  221. <view class="control_item_title">
  222. 封边温度设置
  223. </view>
  224. </view>
  225. <view class="control_item" style="width: 100%" v-if="fengkouDlgShow">
  226. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  227. <view class="control_item_detail">
  228. <view class="control_item_left" @click="subSealingTemperature(1)">-</view>
  229. <view class="control_item_center">
  230. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" @change="changeSealingTemperature" v-model="setSealingTemperature"></u-input>
  231. </view>
  232. <view class="control_item_center_unit" :style="unitFixedStyle">℃</view>
  233. <view class="control_item_right" @click="addSealingTemperature(1)">+</view>
  234. </view>
  235. <view class="control_item_title">
  236. 封口温度设置
  237. </view>
  238. </view>
  239. </view>
  240. </u-popup>
  241. <u-popup :show="planPopDlg" @close="closePlanPop" mode="center" :closeable="true">
  242. <view style="position: relative;width: 400rpx;background: none;padding:40rpx;">
  243. <view class="control_item" style="width: 100%">
  244. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  245. <view class="control_item_detail">
  246. <view class="control_item_left" @click="subPlanTime(1)" style="left: 18%;">-</view>
  247. <view class="control_item_center">
  248. <view style="position: absolute">
  249. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" v-model="planTime"></u-input>
  250. </view>
  251. </view>
  252. <view class="control_item_center_unit" :style="unitFixedStyle">分钟</view>
  253. <view class="control_item_right" style="left: 80%;" @click="addPlanTime(1)">+</view>
  254. </view>
  255. <view class="control_item_title">
  256. 预约时间
  257. </view>
  258. </view>
  259. <view class="control_item" style="width: 100%">
  260. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  261. <view class="control_item_detail">
  262. <view class="control_item_left" @click="subTemperature(1)" style="left: 18%;">-</view>
  263. <view class="control_item_center">
  264. <view style="position: absolute">
  265. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" @change="changeTemperature()" v-model="temperature"></u-input>
  266. </view>
  267. </view>
  268. <view class="control_item_center_unit" :style="unitFixedStyle">℃</view>
  269. <view class="control_item_right" @click="addTemperature(1)" style="left: 80%;">+</view>
  270. </view>
  271. <view class="control_item_title">
  272. 温度设置
  273. </view>
  274. </view>
  275. <view class="control_item" style="width: 100%">
  276. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  277. <view class="control_item_detail">
  278. <view class="control_item_left" @click="subTemperatureTime()" style="left: 18%;">-</view>
  279. <view class="control_item_center">
  280. <view style="position: absolute">
  281. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" @change="changeTemperatureTime()" v-model="temperatureTime"></u-input>
  282. </view>
  283. </view>
  284. <view class="control_item_center_unit" :style="unitFixedStyle">分钟</view>
  285. <view class="control_item_right" @click="addTemperatureTime()" style="left: 80%;">+</view>
  286. </view>
  287. <view class="control_item_title">
  288. 时间设置
  289. </view>
  290. </view>
  291. <view>
  292. <button style="background: white;" @click="plan">确认</button>
  293. </view>
  294. </view>
  295. </u-popup>
  296. <!-- 预约框-->
  297. <u-popup :show="yuyueIngPop" @close="closeYuyueIngPop" mode="center" :closeable="true">
  298. <view style="position: relative;width: 400rpx;background: none;padding:40rpx;">
  299. <view class="control_item" style="width: 100%">
  300. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  301. <view class="control_item_detail">
  302. <view class="control_item_center">
  303. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" :value="leftAppointmentTime"></u-input>
  304. </view>
  305. <view class="control_item_center_unit" :style="unitFixedStyle">℃</view>
  306. </view>
  307. <view class="control_item_title">
  308. 剩余时间
  309. </view>
  310. </view>
  311. <view>
  312. <button style="background: white;" @click="cancelPlan">取消</button>
  313. </view>
  314. </view>
  315. </u-popup>
  316. <u-popup :show="planIngPopDlg" @close="closePlanIngPop" mode="center" :closeable="true">
  317. <view style="position: relative;width: 400rpx;background: none;padding:40rpx;">
  318. <view class="control_item" style="width: 100%">
  319. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  320. <view class="control_item_detail" style="width: 100%; padding: 40rpx;">
  321. <u-line-progress :percentage="step" activeColor="#50ACFF"></u-line-progress>
  322. </view>
  323. <view class="control_item_title">
  324. 正在煎药,请稍等
  325. </view>
  326. </view>
  327. <view class="control_item" style="width: 100%">
  328. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  329. <view class="control_item_detail">
  330. <view class="control_item_center">
  331. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" :value="currentTemperature"></u-input>
  332. </view>
  333. <view class="control_item_center_unit" :style="unitFixedStyle">℃</view>
  334. </view>
  335. <view class="control_item_title">
  336. 当前温度
  337. </view>
  338. </view>
  339. <view class="control_item" style="width: 100%">
  340. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  341. <view class="control_item_detail">
  342. <view class="control_item_center">
  343. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" :value="hightTemperature"></u-input>
  344. </view>
  345. <view class="control_item_center_unit" :style="unitFixedStyle">分钟</view>
  346. </view>
  347. <view class="control_item_title">
  348. 高温时间
  349. </view>
  350. </view>
  351. <!-- <view>-->
  352. <!-- <button style="background: white;" @click="cancelPlan">暂停</button>-->
  353. <!-- </view>-->
  354. </view>
  355. </u-popup>
  356. <uni-drawer ref="showLeft" :width="320" :maskClick="true" mode="right" @change="change($event,'showLeft')">
  357. <scroll-view style="height: 88%;padding:20% 0%;" scroll-y="true">
  358. <view style="text-align:center">设置</view>
  359. <view>
  360. <view class="prop-item">
  361. <view class="prop-item-image">
  362. <image :src="imgUrl+'/setting/net.png'" style="width: 100%;height:100%;"/>
  363. </view>
  364. <view class="prop-item-left">网络连接</view>
  365. <view class="prop-item-right">
  366. <view v-if="deviceInfo.status == 3">
  367. 已连接
  368. </view>
  369. <view v-else>
  370. 未连接
  371. <!-- <uni-icons type="forward" size="16"></uni-icons>-->
  372. </view>
  373. </view>
  374. </view>
  375. <view class="prop-item" v-if="firstTab">
  376. <view class="prop-item-image">
  377. <image :src="imgUrl+'/setting/oper_temp.png'" style="width: 100%;height:100%;"/>
  378. </view>
  379. <view class="prop-item-left">温度校准</view>
  380. <view class="prop-item-right" @click="showJiaozhunProp">
  381. {{jiaozhunTemp}}℃<uni-icons type="forward" size="16"></uni-icons>
  382. </view>
  383. </view>
  384. <view class="prop-item" v-if="firstTab">
  385. <view class="prop-item-image">
  386. <image :src="imgUrl+'/setting/list.png'" style="width: 100%;height:100%;"/>
  387. </view>
  388. <view class="prop-item-left">工作模式</view>
  389. <view class="prop-item-right" @click="showModelPicker = true">
  390. <view v-if="workMode == 1">
  391. 微压循环<uni-icons type="forward" size="16"></uni-icons>
  392. </view>
  393. <view v-if="workMode == 2">
  394. 常温二煎的一煎<uni-icons type="forward" size="16"></uni-icons>
  395. </view>
  396. <view v-if="workMode == 3">
  397. 常温二煎的二煎<uni-icons type="forward" size="16"></uni-icons>
  398. </view>
  399. </view>
  400. </view>
  401. <view class="prop-item">
  402. <view class="prop-item-image">
  403. <image :src="imgUrl+'/setting/no.png'" style="width: 100%;height:100%;"/>
  404. </view>
  405. <view class="prop-item-left">二维码编号</view>
  406. <view class="prop-item-right">
  407. <text class="text-right">{{deviceInfo.qrcodeId==null?"未绑定":deviceInfo.qrcodeId}}</text>
  408. </view>
  409. </view>
  410. <view class="prop-item">
  411. <view class="prop-item-image">
  412. <image :src="imgUrl+'/setting/learn.png'" style="width: 100%;height:100%;"/>
  413. </view>
  414. <view class="prop-item-left">使用教程</view>
  415. <view class="prop-item-right">
  416. <uni-icons type="forward" size="16"></uni-icons>
  417. </view>
  418. </view>
  419. <view class="prop-item">
  420. <view class="prop-item-image">
  421. <image :src="imgUrl+'/setting/video.png'" style="width: 100%;height:100%;"/>
  422. </view>
  423. <view class="prop-item-left">维修视频</view>
  424. <view class="prop-item-right">
  425. <uni-icons type="forward" size="16"></uni-icons>
  426. </view>
  427. </view>
  428. <view class="prop-item">
  429. <view class="prop-item-image">
  430. <image :src="imgUrl+'/setting/upload.png'" style="width: 100%;height:100%;"/>
  431. </view>
  432. <view class="prop-item-left">在线升级</view>
  433. <view class="prop-item-right">
  434. <uni-icons type="forward" size="16"></uni-icons>
  435. </view>
  436. </view>
  437. <view class="prop-item">
  438. <view class="prop-item-image">
  439. <image :src="imgUrl+'/setting/shou.png'" style="width: 100%;height:100%;"/>
  440. </view>
  441. <view class="prop-item-left">售后服务</view>
  442. <view class="prop-item-right">
  443. <uni-icons type="forward" size="16"></uni-icons>
  444. </view>
  445. </view>
  446. <view class="prop-item">
  447. <view class="prop-item-image">
  448. <image :src="imgUrl+'/setting/reset.png'" style="width: 100%;height:100%;"/>
  449. </view>
  450. <view class="prop-item-left">恢复出厂</view>
  451. <view class="prop-item-right" @click="reset">
  452. <uni-icons type="forward" size="16"></uni-icons>
  453. </view>
  454. </view>
  455. </view>
  456. </scroll-view>
  457. </uni-drawer>
  458. <u-popup :show="jiaozhunPopDlg" @close="closejiaozhunPop" mode="center" :closeable="true">
  459. <view style="position: relative;width: 400rpx;background: none;padding:40rpx;">
  460. <view class="control_item" style="width: 100%">
  461. <image :src="imgUrl+'/detail/bg_mid.png'" style="width: 100%;height:100%;position: absolute;top:0px;"/>
  462. <view class="control_item_detail">
  463. <view class="control_item_left" @click="subJiaoZhunTemperature(1)" style="left: 18%;">-</view>
  464. <view class="control_item_center">
  465. <view style="position: absolute">
  466. <u-input customStyle="width:150rpx;border:0px;" disabledColor="white" v-model="jiaozhunTemp_temp"></u-input>
  467. </view>
  468. </view>
  469. <view class="control_item_center_unit" :style="unitFixedStyle">℃</view>
  470. <view class="control_item_right" @click="addJiaoZhunTemperature(1)" style="left: 80%;">+</view>
  471. </view>
  472. <view class="control_item_title">
  473. 校准温度
  474. </view>
  475. </view>
  476. <view>
  477. <button style="background: white;" @click="confirmJiaozhunTemp">确认</button>
  478. </view>
  479. </view>
  480. </u-popup>
  481. <u-picker :show="showModelPicker" @cancel="closeModelPicker" @confirm="confirmMode" :columns="modeList" keyName="text"></u-picker>
  482. </view>
  483. </template>
  484. <script>
  485. import { getDetail,getDeviceStatus,cacheJsonThingsModel,reportError ,getDeviceRunTime} from '@/api/device/device.js'
  486. import config from '@/config'
  487. import UImage from "../../uni_modules/uview-ui/components/u--image/u--image";
  488. export default {
  489. components: {UImage},
  490. data(){
  491. return {
  492. modeList:[[
  493. {id:1,text:"微压循环"},
  494. {id:2,text:"常温二煎的一煎"},
  495. {id:3,text:"常温二煎的二煎"},
  496. ]],
  497. showModelPicker:false,
  498. unitFixedStyle:"",
  499. planTime:10,
  500. setSealingTemperature:160,
  501. setEdegTemperature:160,
  502. sealingTemperature:0,
  503. edegTemperature:0,
  504. hightTemperature:0,
  505. currentTemperature:0,
  506. temperatureTime:0,
  507. temperature:0,
  508. packageNumber:0,
  509. packageVolume:50,
  510. firstTab:true,
  511. decoctControlStatus:false,
  512. decoctControlOnOffStatus:false,
  513. packageControlOnOffStatus:false,
  514. subDecoctTabList:[
  515. {name:'子煎药1'},
  516. {name:'子煎药2'},
  517. {name:'子煎药3'},
  518. ],
  519. DecoctControlStatus:false,
  520. PackagControlStatus:false,
  521. baozhuangTurn:false,
  522. qitingTurn:false,
  523. qingxiTurn:false,
  524. subCurrent:0,
  525. current:0,
  526. inputStyle:{height:'44rpx','fontSize':'20rpx'},
  527. modelKey:['PowerControl','LockControl'],
  528. jianyaoKeys : ["TempSetting","TimeSetting"],
  529. baozhuangKeys:["SetSealTemp","SetBandingTemp","PackageQuantity","PackingVolume"],
  530. power:{
  531. loading:true,
  532. value:0,
  533. },
  534. lock:{
  535. loading:true,
  536. value:0,
  537. },
  538. showTimeDlg:false,
  539. showErrDlg:null,
  540. errorMsg:"asdasdasdasd",
  541. show:null,
  542. value:"",
  543. deviceInfo:{},
  544. id:0,
  545. summary:[
  546. ],
  547. tabs:[
  548. {tabName:"煎药控制"},
  549. {tabName:"包装控制"},
  550. ],
  551. activeName:0,
  552. childId:0,
  553. oneToMul:false,
  554. inputProp:[],
  555. watchProp:[],
  556. columns:[],
  557. location:{},
  558. sysDept:null,
  559. timeobj:{alltime:0,avgtime:0},
  560. publishMsg:false,
  561. checkTimer:null,
  562. functions:[],
  563. properties:[],
  564. propMap:{},
  565. jianyaoTimer:null,
  566. baozhuangTimer:null,
  567. editing:false,
  568. workMode:2,
  569. leftAppointmentTime:0,
  570. leftJianyaoTime:0,
  571. imgUrl:"",
  572. popDlg:false,
  573. fengbianDlgShow:false,
  574. fengkouDlgShow:false,
  575. planPopDlg:false,
  576. planIngPopDlg:false,
  577. maxWidth:320,
  578. jiaozhunTemp:0,//校准温度,
  579. jiaozhunTemp_temp:0,//校准温度,
  580. jiaozhunPopDlg:false,
  581. step:0,
  582. yuyueIngPop:false,
  583. }
  584. },
  585. onLoad: function(opt) {
  586. this.id = opt.id;
  587. // this.id = 61;
  588. this.connectMqtt();
  589. this.getDetail();
  590. this.imgUrl = config.imgUrl
  591. this.fixStyle();
  592. },
  593. destroyed() {
  594. // 取消订阅主题
  595. this.mqttUnSubscribe(this.deviceInfo);
  596. clearTimeout(this.checkTimer);
  597. },
  598. methods:{
  599. getStatusText(){
  600. if(this.baozhuangRunning()){
  601. return "工作中";
  602. }
  603. if(this.jianyaoIng()){
  604. return "工作中";
  605. }
  606. if(this.leftAppointmentTime>0){
  607. return "已预约";
  608. }
  609. return "空闲中";
  610. },
  611. closeYuyueIngPop(){
  612. this.yuyueIngPop = false;
  613. },
  614. confirmMode(item){
  615. console.log(item)
  616. this.workMode = item.value[0].id;
  617. this.setMode(this.workMode);
  618. this.closeModelPicker();
  619. },
  620. closeModelPicker(){
  621. this.showModelPicker = false;
  622. },
  623. confirmJiaozhunTemp(){
  624. this.jiaozhunTemp = this.jiaozhunTemp_temp;
  625. this.temperNumber();
  626. this.closejiaozhunPop();
  627. },
  628. addJiaoZhunTemperature(){
  629. this.jiaozhunTemp_temp ++;
  630. if(this.jiaozhunTemp_temp>20){
  631. this.jiaozhunTemp_temp = 20;
  632. }
  633. },
  634. subJiaoZhunTemperature(){
  635. this.jiaozhunTemp_temp --;
  636. if(this.jiaozhunTemp_temp<-20){
  637. this.jiaozhunTemp_temp = -20;
  638. }
  639. },
  640. closejiaozhunPop(){
  641. this.jiaozhunPopDlg = false;
  642. },
  643. showJiaozhunProp(){
  644. this.jiaozhunTemp_temp = this.jiaozhunTemp;
  645. this.jiaozhunPopDlg = true;
  646. },
  647. fixStyle(){
  648. let self = this;
  649. wx.getSystemInfo({
  650. success: res => {
  651. const { windowWidth, windowHeight, statusBarHeight } = res;
  652. // 在这里可以获取到屏幕的宽度和高度
  653. console.log(windowWidth, windowHeight, statusBarHeight);
  654. if(windowWidth<=350){
  655. self.unitFixedStyle = ";padding-top:6px;left: 28vw;";
  656. }else if(windowWidth>=360){
  657. self.unitFixedStyle = ";padding-top:3px;";
  658. }
  659. self.maxWidth = windowWidth;
  660. }
  661. })
  662. },
  663. closePlanIngPop(){
  664. this.planIngPopDlg = false;
  665. },
  666. closePlanPop(){
  667. this.planPopDlg = false;
  668. },
  669. showBaozhuangDlg(type){
  670. this.popDlg = true;
  671. if(type == 1){
  672. this.fengbianDlgShow = true;
  673. }else{
  674. this.fengkouDlgShow = true;
  675. }
  676. },
  677. closePop(){
  678. this.popDlg = false;
  679. this.fengbianDlgShow = false;
  680. this.fengkouDlgShow = false;
  681. },
  682. changeTab(item){
  683. let summary = this.summary;
  684. let self = this;
  685. this.resetChoose();
  686. if(item.name == 'baozhuang'){
  687. this.firstTab = false;
  688. getDeviceStatus(this.id,0).then(res=>{
  689. let data =res.data;
  690. this.deviceInfo = data;
  691. self.parseStatusData(data)
  692. });
  693. }else{
  694. item.checked = true;
  695. this.firstTab = true;
  696. if(summary.length>1){
  697. this.childId = item.id;
  698. this.getDeviceStatus()
  699. }else{
  700. this.getDeviceStatus()
  701. }
  702. }
  703. },
  704. resetChoose(){
  705. for (let i = 0; i <this.summary.length; i++) {
  706. let data = this.summary[i];
  707. data.checked = false;
  708. }
  709. },
  710. changePackageVolume(){
  711. if(this.packageVolume<50){
  712. this.packageVolume = 50;
  713. }
  714. if(this.packageVolume>300){
  715. this.packageVolume = 300;
  716. }
  717. this.sendBaozhuang("PackingVolume");
  718. },
  719. changePackageNumber(){
  720. let min = 1;
  721. let max = 999;
  722. if(this.packageNumber<min){
  723. this.packageNumber = min;
  724. }
  725. if(this.packageNumber>max){
  726. this.packageNumber = max;
  727. }
  728. this.sendBaozhuang("PackageQuantity");
  729. },
  730. changeEdegTemperature(){
  731. let min = 80;
  732. let max = 220;
  733. if(this.setEdegTemperature<min){
  734. this.setEdegTemperature = min;
  735. }
  736. if(this.setEdegTemperature>max){
  737. this.setEdegTemperature = max;
  738. }
  739. console.log("current setEdegTemperature is :"+this.setEdegTemperature)
  740. this.sendBaozhuang("SetBandingTemp");
  741. },
  742. changeSealingTemperature(){
  743. let min = 80;
  744. let max = 220;
  745. if(this.setSealingTemperature<min){
  746. this.setSealingTemperature = min;
  747. }
  748. if(this.setSealingTemperature>max){
  749. this.setSealingTemperature = max;
  750. }
  751. console.log("current setSealingTemperature is :"+this.setSealingTemperature)
  752. this.sendBaozhuang("SetSealTemp");
  753. },
  754. changeTemperature(){
  755. let max = 140;
  756. let min = 100;
  757. if(this.workMode == 2){
  758. min = 1;
  759. }
  760. if(this.temperature<min){
  761. this.temperature = min;
  762. }
  763. if(this.temperature>max){
  764. this.temperature = max;
  765. }
  766. console.log("current temperature is :"+this.temperature)
  767. this.sendJianYao("TempSetting");
  768. },
  769. changeTemperatureTime(){
  770. let min = 1;
  771. let max = 600;
  772. if(this.temperatureTime<min){
  773. this.temperatureTime = min;
  774. }
  775. if(this.temperatureTime>max){
  776. this.temperatureTime = max;
  777. }
  778. console.log("current temperatureTime is :"+this.temperatureTime)
  779. this.sendJianYao("TimeSetting");
  780. },
  781. jianyaoOpen(){
  782. if(this.decoctControlOnOffStatus){
  783. return true;
  784. }
  785. return false;
  786. },
  787. baozhuangOpen(){
  788. if(this.packageControlOnOffStatus){
  789. return true;
  790. }
  791. return false;
  792. },
  793. baozhuangRunning(){
  794. if(this.qingxiTurn || this.baozhuangTurn || this.qitingTurn){
  795. return true;
  796. }
  797. return false;
  798. },
  799. jianyaoIng(){
  800. if(this.decoctControlStatus){
  801. return true;
  802. }
  803. return false;
  804. },
  805. cancelPlan(){
  806. let arr = [];
  807. let obj = {};
  808. obj.id = "AppointmentTime";
  809. obj.shadow = 0;
  810. arr.push(obj);
  811. this.mqttPublish(2,this.deviceInfo,arr,true);
  812. this.closeYuyueIngPop();
  813. },
  814. toPlan(){
  815. if(!this.jianyaoOpen()){
  816. this.$modal.showToast('煎药机已经关机')
  817. return;
  818. }
  819. if(this.jianyaoIng()){
  820. this.$modal.showToast('正在煎药')
  821. return;
  822. }
  823. if(this.leftAppointmentTime>0){
  824. this.yuyueIngPop = true;
  825. }else{
  826. this.planPopDlg = true;
  827. }
  828. },
  829. calcuStep(){
  830. let currentTemperature = this.currentTemperature;
  831. let hightTemperature = this.hightTemperature;//设置的高温时间
  832. let targetTemperature =100;// this.temperature;
  833. let targetTemperatureTime = this.temperatureTime;//倒计时
  834. if(targetTemperature>100){
  835. targetTemperature = 100;
  836. }
  837. let step = 0;
  838. if(currentTemperature<100){
  839. let tem = currentTemperature/200*100;
  840. step = tem.toFixed(2);
  841. }else{
  842. step = 50;
  843. let rate = hightTemperature/targetTemperatureTime;
  844. rate = rate/2;
  845. rate = rate*100;
  846. rate = rate.toFixed(2)
  847. step = step + parseFloat(rate);
  848. }
  849. this.step = step.toFixed(2);
  850. },
  851. plan(){
  852. let self = this;
  853. if(this.planTime>600){
  854. this.$modal.showToast('预约时间最大为600分钟')
  855. return;
  856. }
  857. if(this.planTime == 0){
  858. this.$modal.showToast('预约时间不能为空')
  859. }else{
  860. let arr = [];
  861. let obj = {};
  862. obj.id = "AppointmentTime";
  863. obj.shadow = this.planTime;
  864. arr.push(obj);
  865. this.mqttPublish(2,this.deviceInfo,arr,true);
  866. }
  867. this.$modal.showToast('预约成功')
  868. this.planPopDlg = false;
  869. },
  870. lockCtrl(key){
  871. let arr = [];
  872. let obj = {};
  873. obj.id = "LockControl";
  874. if(key == 0){
  875. obj.shadow = 1;
  876. this.lock.value = 1;
  877. }else{
  878. obj.shadow = 0;
  879. this.lock.value = 0;
  880. }
  881. arr.push(obj);
  882. this.mqttPublish(2,this.deviceInfo,arr)
  883. },
  884. setMode(type){
  885. let arr = [];
  886. let obj = {};
  887. obj.id = "WorkMode";
  888. obj.shadow = type;
  889. arr.push(obj);
  890. this.mqttPublish(2,this.deviceInfo,arr,true)
  891. this.workMode = type;
  892. },
  893. temperNumber(value){
  894. let arr = [];
  895. let obj = {};
  896. obj.id = "CalibrationTemp";
  897. obj.shadow = this.jiaozhunTemp;
  898. arr.push(obj);
  899. this.mqttPublish(2,this.deviceInfo,arr,true)
  900. },
  901. volumeNumber(){
  902. let arr = [];
  903. let obj = {};
  904. obj.id = "CapacityCalibration";
  905. obj.shadow = 1;
  906. arr.push(obj);
  907. this.mqttPublish(2,this.deviceInfo,arr,true)
  908. },
  909. showConfirm(title,content,yes,no){
  910. uni.showModal({
  911. title: title,
  912. content: content,
  913. success: function (res) {
  914. if (res.confirm) {
  915. yes();
  916. } else if (res.cancel) {
  917. no();
  918. }
  919. }
  920. });
  921. },
  922. reset(){
  923. let self = this;
  924. this.showConfirm("提示","确认恢复出厂吗",function(){
  925. let arr = [];
  926. let obj = {};
  927. obj.id = "RestoreFactory";
  928. obj.shadow = 1;
  929. arr.push(obj);
  930. self.mqttPublish(2,self.deviceInfo,arr)
  931. },function(){});
  932. },
  933. turnChange(type){
  934. let flag = false;
  935. let obj = {};
  936. if(type ==3){
  937. if(this.baozhuangTurn || this.qitingTurn){
  938. this.$modal.showToast("启停、包装、清洗不能同时打开")
  939. return;
  940. }
  941. flag = this.qingxiTurn;
  942. obj.id = "WashSwitch";
  943. }else if(type == 2){
  944. if(this.qingxiTurn || this.qitingTurn){
  945. this.$modal.showToast("启停、包装、清洗不能同时打开")
  946. return;
  947. }
  948. flag = this.baozhuangTurn;
  949. obj.id = "PackageSwitch";
  950. }else if(type == 1) {
  951. if(this.qingxiTurn || this.baozhuangTurn){
  952. this.$modal.showToast("启停、包装、清洗不能同时打开")
  953. return;
  954. }
  955. flag = this.qitingTurn;
  956. obj.id = "CarrybagSwitch";
  957. }
  958. flag = !flag;
  959. let arr = [];
  960. if(flag){
  961. obj.shadow = 1;
  962. }else{
  963. obj.shadow = 0;
  964. }
  965. arr.push(obj);
  966. this.mqttPublish(2,this.deviceInfo,arr)
  967. },
  968. addPackageVolume(){
  969. this.packageVolume++;
  970. console.log("增加包装容量")
  971. this.changePackageVolume()
  972. },
  973. subPackageVolume(){
  974. this.packageVolume--;
  975. console.log("减少包装容量")
  976. this.changePackageVolume()
  977. },
  978. addPackageNumber(){
  979. this.packageNumber++;
  980. console.log("增加包装数量")
  981. this.changePackageNumber();
  982. },
  983. subPackageNumber(){
  984. this.packageNumber--;
  985. console.log("减少包装数量")
  986. this.changePackageNumber();
  987. },
  988. addSealingTemperature(){
  989. console.log("增加封口温度")
  990. this.setSealingTemperature++;
  991. this.changeSealingTemperature();
  992. },
  993. subSealingTemperature(){
  994. console.log("减少封口温度")
  995. this.setSealingTemperature--;
  996. this.changeSealingTemperature();
  997. },
  998. addEdegTemperature(){
  999. console.log("增加封边温度")
  1000. this.editing = true;
  1001. this.setEdegTemperature++;
  1002. this.changeEdegTemperature();
  1003. },
  1004. subEdegTemperature(){
  1005. console.log("减少封边温度")
  1006. this.editing = true;
  1007. this.setEdegTemperature--;
  1008. this.changeEdegTemperature();
  1009. },
  1010. addTemperatureTime(){
  1011. console.log("增加煎药时间")
  1012. this.temperatureTime++;
  1013. this.changeTemperatureTime()
  1014. },
  1015. subTemperatureTime(){
  1016. console.log("减少煎药时间")
  1017. this.temperatureTime--;
  1018. this.changeTemperatureTime()
  1019. },
  1020. addTemperature(){
  1021. console.log("增加煎药温度")
  1022. this.temperature++;
  1023. this.changeTemperature();
  1024. },
  1025. subTemperature(type){
  1026. console.log("减少煎药温度")
  1027. this.temperature--;
  1028. this.changeTemperature();
  1029. },
  1030. addPlanTime(){
  1031. console.log("增加预约时间")
  1032. this.planTime++;
  1033. },
  1034. subPlanTime(){
  1035. console.log("减少预约时间")
  1036. this.planTime--;
  1037. },
  1038. sendBaozhuang(targetKey){
  1039. let self = this;
  1040. let arr = [];
  1041. if(this.baozhuangTimer != null){
  1042. clearTimeout(this.baozhuangTimer);
  1043. }
  1044. this.baozhuangTimer = setTimeout(function (){
  1045. for (let i = 0; i <this.baozhuangKeys.length; i++) {
  1046. let key = this.baozhuangKeys[i];
  1047. let obj = {};
  1048. obj.id = key;
  1049. if(key === "PackingVolume"){
  1050. obj.shadow = this.packageVolume;
  1051. }
  1052. if(key === "PackageQuantity"){
  1053. obj.shadow = this.packageNumber;
  1054. }
  1055. if(key === "SetSealTemp"){
  1056. obj.shadow = this.setSealingTemperature;
  1057. }
  1058. if(key === "SetBandingTemp"){
  1059. obj.shadow = this.setEdegTemperature;
  1060. }
  1061. if(targetKey == key){
  1062. arr.push(obj);
  1063. break;
  1064. }
  1065. }
  1066. this.mqttPublish(2,this.deviceInfo,arr)
  1067. }.bind(this),500);
  1068. },
  1069. sendJianYao(targetKey){
  1070. let arr = [];
  1071. if(this.jianyaoTimer != null){
  1072. clearTimeout(this.jianyaoTimer);
  1073. }
  1074. this.jianyaoTimer = setTimeout(function (){
  1075. for (let i = 0; i <this.jianyaoKeys.length; i++) {
  1076. let key = this.jianyaoKeys[i];
  1077. let obj = {};
  1078. obj.id = key;
  1079. if(key === "TempSetting"){
  1080. obj.shadow = this.temperature;
  1081. }
  1082. if(key === "TimeSetting"){
  1083. obj.shadow = this.temperatureTime;
  1084. }
  1085. if(targetKey == key){
  1086. arr.push(obj);
  1087. break;
  1088. }
  1089. }
  1090. this.mqttPublish(2,this.deviceInfo,arr,true)
  1091. }.bind(this),500);
  1092. },
  1093. buildPropKey(key){
  1094. if(this.childId !=0){
  1095. return key+"_"+this.childId;
  1096. }else{
  1097. return key;
  1098. }
  1099. },
  1100. decoctControlChange(){
  1101. let obj = {};
  1102. let arr = [];
  1103. if(!this.decoctControlOnOffStatus){
  1104. this.notifyError("请先开机后再进行操作")
  1105. return;
  1106. }
  1107. if(this.decoctControlStatus){
  1108. this.showJianyao();
  1109. return;
  1110. }
  1111. this.decoctControlStatus = !this.decoctControlStatus;
  1112. obj.id = "DecoctingSwitch";
  1113. if(this.decoctControlStatus){
  1114. obj.shadow = 1;
  1115. console.log("煎药状态打开")
  1116. this.checkJianyao();
  1117. }else{
  1118. obj.shadow = 0;
  1119. console.log("煎药状态关闭")
  1120. }
  1121. arr.push(obj);
  1122. this.mqttPublish(2,this.deviceInfo,arr,true)
  1123. },
  1124. stopDecoctControlChange(){
  1125. let obj = {};
  1126. let arr = [];
  1127. if(!this.decoctControlOnOffStatus){
  1128. this.notifyError("请先开机后再进行操作")
  1129. return;
  1130. }
  1131. if(!this.decoctControlStatus){
  1132. return;
  1133. }
  1134. this.decoctControlStatus = !this.decoctControlStatus;
  1135. obj.id = "DecoctingSwitch";
  1136. if(this.decoctControlStatus){
  1137. obj.shadow = 1;
  1138. console.log("煎药状态打开")
  1139. }else{
  1140. obj.shadow = 0;
  1141. console.log("煎药状态关闭")
  1142. }
  1143. arr.push(obj);
  1144. this.mqttPublish(2,this.deviceInfo,arr,true)
  1145. },
  1146. decoctControlOnOffChange(){
  1147. let obj = {};
  1148. this.decoctControlOnOffStatus = !this.decoctControlOnOffStatus;
  1149. let arr = [];
  1150. obj.id = "PowerControl";
  1151. let isMul = false;
  1152. if(this.decoctControlStatus){
  1153. this.$modal.showToast('请先结束煎药后操作')
  1154. this.decoctControlOnOffStatus = !this.decoctControlOnOffStatus;
  1155. return;
  1156. }
  1157. if(this.oneToMul && this.firstTab){
  1158. obj.id = "PowerCtl";
  1159. isMul = true;
  1160. }
  1161. if(this.decoctControlOnOffStatus){
  1162. obj.shadow = 1;
  1163. console.log("煎药机开关打开")
  1164. }else{
  1165. obj.shadow = 0;
  1166. console.log("煎药机开关关闭")
  1167. }
  1168. arr.push(obj);
  1169. this.mqttPublish(2,this.deviceInfo,arr,isMul)
  1170. },
  1171. packageControlOnOffChange(){
  1172. let obj = {};
  1173. let arr = [];
  1174. if(this.baozhuangRunning()){
  1175. this.$modal.showToast('请先停止运行后操作')
  1176. return;
  1177. }
  1178. obj.id = "PackagePowerControl";
  1179. this.packageControlOnOffStatus = !this.packageControlOnOffStatus;
  1180. if(this.packageControlOnOffStatus){
  1181. console.log("包装机器开关打开")
  1182. obj.shadow = 1;
  1183. }else{
  1184. console.log("包装机器开关关闭")
  1185. obj.shadow = 0;
  1186. }
  1187. arr.push(obj);
  1188. this.mqttPublish(2,this.deviceInfo,arr)
  1189. },
  1190. containKey(arr,key){
  1191. for (let i = 0; i < arr.length; i++) {
  1192. const data = arr[i];
  1193. if(data == key){
  1194. return true;
  1195. }
  1196. }
  1197. return false;
  1198. },
  1199. // 抽屉状态发生变化触发
  1200. change(e, type) {
  1201. console.log(e);
  1202. },
  1203. showDrawer() {
  1204. this.$refs.showLeft.open();
  1205. },
  1206. closeDrawer() {
  1207. this.$refs.showLeft.close();
  1208. },
  1209. checkItemValue(item){
  1210. if(!item.shadow){
  1211. item.shadow = 0;
  1212. }
  1213. if(!item.unit){
  1214. item.unit = "";
  1215. }
  1216. return true;
  1217. },
  1218. sendProperties(){
  1219. let properties = this.properties;
  1220. for (let i = 0; i < properties; i++) {
  1221. let property = this.properties[i];
  1222. let shadow = property.shadow;
  1223. if(shadow){
  1224. arr.push(property);
  1225. }
  1226. }
  1227. this.mqttPublish(1,this.deviceInfo,arr)
  1228. },
  1229. sendFunctions(){
  1230. let arr = [];
  1231. let functions = this.functions;
  1232. for (let i = 0; i < functions.length; i++) {
  1233. let functionObj = this.functions[i];
  1234. let shadow = functionObj.shadow;
  1235. if(shadow){
  1236. arr.push(functionObj);
  1237. }
  1238. }
  1239. this.mqttPublish(2,this.deviceInfo,arr)
  1240. },
  1241. changeProp(key,val){
  1242. let item = null;
  1243. let obj = null;
  1244. let oneToMul = this.oneToMul;
  1245. if(key === "LockControl"){
  1246. this.lock.value = val;
  1247. item = this.lock;
  1248. }else if(key === "PowerControl"){
  1249. this.power.value = val;
  1250. item = this.power;
  1251. }
  1252. let value = val;
  1253. obj = item.item;
  1254. if(value){
  1255. obj.value = 1;
  1256. obj.shadow = 1;
  1257. }else{
  1258. obj.value = 0;
  1259. obj.shadow = 0;
  1260. }
  1261. if(!oneToMul){
  1262. }
  1263. this.publishThingsModel(this.deviceInfo,obj);
  1264. },
  1265. checkCommonProp(item){
  1266. let id =item.id;
  1267. let isCommonKey = this.modelKey.some(res=>{
  1268. return id === res;
  1269. })
  1270. return !isCommonKey;
  1271. },
  1272. getRunTime(){
  1273. let self = this;
  1274. getDeviceRunTime(this.id).then(res=>{
  1275. self.timeobj = res.data;
  1276. if(self.timeobj.avgtime == ""){
  1277. self.timeobj.avgtime = 0;
  1278. }
  1279. if(self.timeobj.alltime == ""){
  1280. self.timeobj.alltime = 0;
  1281. }
  1282. })
  1283. },
  1284. seeTime(){
  1285. this.showTimeDlg = true;
  1286. this.getRunTime();
  1287. },
  1288. closeTime(){
  1289. this.showTimeDlg = false;
  1290. },
  1291. cancel(){
  1292. this.showErrDlg = false;
  1293. },
  1294. reportError(){
  1295. this.showErrDlg = true;
  1296. },
  1297. doReportError(){
  1298. if(!this.errorMsg){
  1299. this.$modal.showToast('异常信息不能为空')
  1300. }else{
  1301. let self = this;
  1302. let errObj = {};
  1303. errObj.deviceId = this.deviceInfo.deviceId;
  1304. errObj.deviceName = this.deviceInfo.deviceName
  1305. errObj.desc = this.errorMsg;
  1306. errObj.deptId= this.deviceInfo.deptId;
  1307. reportError(errObj).then(res=>{
  1308. self.$modal.showToast(res.msg)
  1309. self.cancel();
  1310. })
  1311. }
  1312. },
  1313. openLocation(){
  1314. uni.openLocation({
  1315. latitude: this.location.latitude,
  1316. longitude: this.location.longitude,
  1317. success: function () {
  1318. console.log('success');
  1319. }
  1320. });
  1321. },
  1322. confirmItemData(e){
  1323. let data = e.value[0];
  1324. this.show.text = data.text;
  1325. this.show.shadow=data.value;
  1326. this.show = null;
  1327. console.log(data);
  1328. },
  1329. send(){
  1330. let shadow = false
  1331. let _arr = []
  1332. this.inputProp.forEach((item)=>{
  1333. _arr.push(item.value)
  1334. })
  1335. // if(_arr.some(val => val === '' || val.length < 0)){
  1336. // shadow = true
  1337. // }
  1338. if(this.deviceInfo.status != 3){
  1339. uni.showToast({
  1340. title:"设备暂未上线",
  1341. icon:"error"
  1342. })
  1343. return;
  1344. }
  1345. if(shadow){
  1346. uni.showToast({
  1347. title:"数据不能为空",
  1348. icon:"error"
  1349. })
  1350. return;
  1351. }
  1352. this.publishThingsModel(this.deviceInfo,this.inputProp.map(item=>{return{"id":item.id,"value":item.value}}))
  1353. },
  1354. /** 更新设备状态 */
  1355. updateDeviceStatus(device) {
  1356. },
  1357. chooseItemData(data){
  1358. if(this.deviceInfo.status != 3){
  1359. uni.showToast({
  1360. title:"设备暂未上线",
  1361. icon:"error"
  1362. })
  1363. return;
  1364. }
  1365. this.columns = [data.enumList];
  1366. this.show =data;
  1367. },
  1368. getDetail(){
  1369. let self = this;
  1370. getDetail(this.id).then(res=>{
  1371. self.deviceInfo = res.data;
  1372. self.location = {
  1373. latitude: self.deviceInfo.latitude,
  1374. longitude: self.deviceInfo.longitude};
  1375. self.sysDept = self.deviceInfo.sysDept;
  1376. self.parseSummay(res.data.summary)
  1377. self.mqttSubscribe(res.data);
  1378. self.getDeviceStatus();
  1379. self.seeTime();
  1380. self.summary[0].checked = true;
  1381. });
  1382. },
  1383. getDeviceStatus(){
  1384. let self = this;
  1385. if(this.summary.length>1){
  1386. }else{
  1387. this.childId = 0;
  1388. }
  1389. getDeviceStatus(this.id,this.childId).then(res=>{
  1390. let data =res.data;
  1391. this.deviceInfo = data;
  1392. self.parseStatusData(data)
  1393. });
  1394. },
  1395. getNewDeviceStatus(item){
  1396. console.log(item);
  1397. let self = this;
  1398. if(item.index == 0){
  1399. this.firstTab = true;
  1400. this.getDeviceStatus();
  1401. }
  1402. if(item.index == 1){
  1403. this.firstTab = false;
  1404. getDeviceStatus(this.id,0).then(res=>{
  1405. let data =res.data;
  1406. this.deviceInfo = data;
  1407. self.parseStatusData(data)
  1408. });
  1409. }
  1410. },
  1411. changeSub(item){
  1412. this.childId = item.id;
  1413. this.getDeviceStatus()
  1414. },
  1415. parseEnumList(){
  1416. let enumList = this.deviceInfo.enumList;
  1417. for (let enumListElement of enumList) {
  1418. let id = enumListElement.id;
  1419. if(id.indexOf("LockControl") !=-1){
  1420. let shadow = enumListElement.shadow;
  1421. this.lock.item = enumListElement;
  1422. if(shadow == 1){
  1423. this.lock.value = true;
  1424. this.lock.loading = false;
  1425. }else if(shadow == 0){
  1426. this.lock.value = false;
  1427. this.lock.loading = false;
  1428. }else{
  1429. this.lock.loading = true;
  1430. }
  1431. }
  1432. if(id.indexOf("PowerControl") !=-1){
  1433. let shadow = enumListElement.shadow;
  1434. if(this.oneToMul){
  1435. if(!this.firstTab){
  1436. if(shadow == 1){
  1437. this.decoctControlOnOffStatus = true;
  1438. }else if(shadow == 0){
  1439. this.decoctControlOnOffStatus = false;
  1440. }
  1441. }
  1442. }else{
  1443. if(shadow == 1){
  1444. this.decoctControlOnOffStatus = true;
  1445. }else if(shadow == 0){
  1446. this.decoctControlOnOffStatus = false;
  1447. }
  1448. }
  1449. }
  1450. if(id.indexOf("PowerCtl") !=-1){
  1451. if(this.oneToMul && this.firstTab){
  1452. let shadow = enumListElement.shadow;
  1453. if(shadow == 1){
  1454. this.decoctControlOnOffStatus = true;
  1455. }else if(shadow == 0){
  1456. this.decoctControlOnOffStatus = false;
  1457. }
  1458. }
  1459. }
  1460. this.formatValue(id,enumListElement,"PackagePowerControl","packageControlOnOffStatus")
  1461. this.formatValue(id,enumListElement,"DecoctingSwitch","decoctControlStatus")
  1462. this.formatValue(id,enumListElement,"CarrybagSwitch","qitingTurn")
  1463. this.formatValue(id,enumListElement,"WashSwitch","qingxiTurn")
  1464. this.formatValue(id,enumListElement,"PackageSwitch","baozhuangTurn");
  1465. if(id.indexOf("WorkMode") !=-1){
  1466. let shadow = enumListElement.shadow;
  1467. if(!shadow){
  1468. shadow = 1;
  1469. }
  1470. this.workMode = shadow;
  1471. }
  1472. let shadow = enumListElement.shadow
  1473. let valueList = enumListElement.enumList;
  1474. for (let valueObj of valueList){
  1475. if(valueObj.value == shadow){
  1476. enumListElement.text = valueObj.text;
  1477. }
  1478. }
  1479. }
  1480. },
  1481. formatValue(id,enumListElement,key,propkey){
  1482. if(id.indexOf(key) !=-1){
  1483. let shadow = enumListElement.shadow;
  1484. if(shadow == 1){
  1485. this[propkey] = true;
  1486. }else if(shadow == 0){
  1487. this[propkey] = false;
  1488. }
  1489. }
  1490. },
  1491. parseStatusData(data){
  1492. let self = this;
  1493. cacheJsonThingsModel(data.productId).then(res=>{
  1494. let thingsModel = JSON.parse(res.data);
  1495. let arr = [];
  1496. let arrayList = data.arrayList;
  1497. arr = arr.concat(arrayList);
  1498. let enumList = data.enumList;
  1499. arr = arr.concat(enumList);
  1500. let integerList = data.integerList;
  1501. arr = arr.concat(integerList);
  1502. let stringList = data.stringList;
  1503. arr = arr.concat(stringList);
  1504. self.inputProp = arr;
  1505. for (let i = 0; i < thingsModel.functions.length; i++) {
  1506. for (let j = 0; j < arr.length; j++) {
  1507. let model = arr[j];
  1508. if(model.id == thingsModel.functions[i].id){
  1509. self.functions.push(model);
  1510. }
  1511. }
  1512. }
  1513. for (let i = 0; i < thingsModel.properties.length; i++) {
  1514. for (let j = 0; j < arr.length; j++) {
  1515. let model = arr[j];
  1516. if(model.id == thingsModel.properties[i].id){
  1517. self.properties.push(model);
  1518. }
  1519. }
  1520. }
  1521. let readOnlyList = data.readOnlyList;
  1522. self.watchProp = readOnlyList;
  1523. self.parseEnumList();
  1524. self.parseProp();
  1525. self.checkJianyao();
  1526. })
  1527. },
  1528. showJianyao(){
  1529. this.calcuStep();
  1530. this.planIngPopDlg = true;
  1531. },
  1532. parseProp(){
  1533. let self = this;
  1534. for (let i = 0; i <self.inputProp.length; i++) {
  1535. let prop = self.inputProp[i];
  1536. let value = prop.shadow||0;
  1537. let id = prop.id;
  1538. if(id === "TimeSetting"){//温度设置
  1539. self.temperatureTime = value;
  1540. }
  1541. if(id === "TempSetting"){
  1542. self.temperature = value;
  1543. }
  1544. this.setPropValue(id,"HighTempTime","hightTemperature",value,0)
  1545. this.setPropValue(id,"CurrentTemp","currentTemperature",value,0)
  1546. this.setPropValue(id,"CalibrationTemp","jiaozhunTemp",value,0)
  1547. this.setPropValue(id,"PackingVolume","packageVolume",value,50)
  1548. this.setPropValue(id,"PackageQuantity","packageNumber",value,1)
  1549. this.setPropValue(id,"SealTemp","sealingTemperature",value)
  1550. this.setPropValue(id,"BandingTemp","edegTemperature",value)
  1551. this.setPropValue(id,"SetSealTemp","setSealingTemperature",value,160)
  1552. this.setPropValue(id,"SetBandingTemp","setEdegTemperature",value,160)
  1553. this.setPropValue(id,"LeftAppointmentTime","leftAppointmentTime",value,0)
  1554. self.propMap[id] = prop;
  1555. }
  1556. },
  1557. setPropValue(id,key,propKey,value,defaultValue){
  1558. if(!value && defaultValue){
  1559. value = defaultValue;
  1560. }
  1561. if(id === key){
  1562. this[propKey] = value;
  1563. }
  1564. },
  1565. parseSummay(summary){
  1566. let self = this;
  1567. if(!summary){
  1568. summary = "";
  1569. }
  1570. if(summary.length>0){
  1571. this.summary = JSON.parse(summary);
  1572. if(self.summary.length>0){
  1573. this.oneToMul = true;
  1574. for (let i = 0; i < self.summary.length; i++) {
  1575. self.summary[i].tabName = self.summary[i].id+"_"+self.summary[i].name
  1576. }
  1577. let childId = "";
  1578. if(this.oneToMul){
  1579. this.childId = self.summary[0].id;
  1580. }
  1581. }else{
  1582. this.summary = [{name:"煎药机一"}]
  1583. }
  1584. }else{
  1585. this.summary = [{name:"煎药机一"}]
  1586. }
  1587. },
  1588. goDeviceDetail(id){
  1589. uni.navigateTo({
  1590. url: '/pages/device/detail/detail?id='+id
  1591. });
  1592. },
  1593. async connectMqtt() {
  1594. if (this.$mqttTool.client == null) {
  1595. await this.$mqttTool.connect(this.vuex_token);
  1596. }
  1597. this.mqttCallback();
  1598. this.startCheck();
  1599. },
  1600. /** Mqtt订阅主题 */
  1601. mqttSubscribe(device) {
  1602. // 订阅当前设备状态和实时监测
  1603. let topicStatus = '/' + device.productId + '/' + device.serialNumber + '/status/post';
  1604. let topicProperty = '/' + device.productId + '/' + device.serialNumber + '/property/post';
  1605. let topicFunction = '/' + device.productId + '/' + device.serialNumber + '/function/post';
  1606. let topics = [];
  1607. topics.push(topicStatus);
  1608. topics.push(topicProperty);
  1609. topics.push(topicFunction);
  1610. this.$mqttTool.subscribe(topics);
  1611. },
  1612. /** Mqtt取消订阅主题 */
  1613. mqttUnSubscribe(device) {
  1614. // 订阅当前设备状态和实时监测
  1615. let topicStatus = '/' + device.productId + '/' + device.serialNumber + '/status/post';
  1616. let topicProperty = '/' + device.productId + '/' + device.serialNumber + '/property/post';
  1617. let topicFunction = '/' + device.productId + '/' + device.serialNumber + '/function/post';
  1618. let topics = [];
  1619. topics.push(topicStatus);
  1620. topics.push(topicProperty);
  1621. topics.push(topicFunction);
  1622. console.log('取消订阅', topics);
  1623. this.$mqttTool.unsubscribe(topics);
  1624. },
  1625. /* Mqtt回调处理 */
  1626. mqttCallback() {
  1627. this.$mqttTool.client.on('message', (topic, message, buffer) => {
  1628. let topics = topic.split('/');
  1629. let productId = topics[1];
  1630. let deviceNum = topics[2];
  1631. console.log('接收到内容:'+message);
  1632. message = JSON.parse(message.toString());
  1633. if (topics[3] == 'status') {
  1634. console.log('接收到【设备状态-运行】主题:', topic);
  1635. console.log('接收到【设备状态-运行】内容:', message);
  1636. // 更新列表中设备的状态
  1637. if (this.deviceInfo.serialNumber == deviceNum) {
  1638. this.deviceInfo.status = message.status;
  1639. this.deviceInfo.isShadow = message.isShadow;
  1640. this.deviceInfo.rssi = message.rssi;
  1641. this.updateDeviceStatus(this.deviceInfo);
  1642. }
  1643. }
  1644. if (topics[3] == 'property' || topics[3] == 'function') {
  1645. console.log('接收到【物模型】主题:', topic);
  1646. console.log('接收到【物模型】内容:', message);
  1647. if(this.oneToMul){
  1648. let curTabId = this.childId;
  1649. let msg = [];
  1650. for (let i = 0; i < message.length; i++) {
  1651. let curMsg = message[i];
  1652. let id = curMsg.id;
  1653. let ids = id.split("_");
  1654. let value = curMsg.value;
  1655. if(ids.length == 2){
  1656. if(curTabId == ids[1]){
  1657. msg.push({id:ids[0],value:value});
  1658. }
  1659. }else{
  1660. msg.push(curMsg);
  1661. }
  1662. }
  1663. message = msg;
  1664. }
  1665. // 更新列表中设备的属性
  1666. if (this.deviceInfo.serialNumber == deviceNum) {
  1667. for (let j = 0; j < message.length; j++) {
  1668. let isComplete = false;
  1669. let msgId = message[j].id;
  1670. this.exchangeData(msgId,message[j]);
  1671. // 布尔类型
  1672. for (let k = 0; k < this.deviceInfo.boolList.length && !isComplete; k++) {
  1673. if (this.deviceInfo.boolList[k].id == message[j].id) {
  1674. this.deviceInfo.boolList[k].shadow = message[j].value;
  1675. isComplete = true;
  1676. break;
  1677. }
  1678. }
  1679. // 枚举类型
  1680. for (let k = 0; k < this.deviceInfo.enumList.length && !isComplete; k++) {
  1681. if (this.deviceInfo.enumList[k].id == message[j].id) {
  1682. this.deviceInfo.enumList[k].shadow = message[j].value;
  1683. isComplete = true;
  1684. break;
  1685. }
  1686. }
  1687. // 字符串类型
  1688. for (let k = 0; k < this.deviceInfo.stringList.length && !isComplete; k++) {
  1689. if (this.deviceInfo.stringList[k].id == message[j].id) {
  1690. this.deviceInfo.stringList[k].shadow = message[j].value;
  1691. isComplete = true;
  1692. break;
  1693. }
  1694. }
  1695. // 数组类型
  1696. for (let k = 0; k < this.deviceInfo.arrayList.length && !isComplete; k++) {
  1697. if (this.deviceInfo.arrayList[k].id == message[j].id) {
  1698. this.deviceInfo.arrayList[k].shadow = message[j].value;
  1699. isComplete = true;
  1700. break;
  1701. }
  1702. }
  1703. // 整数类型
  1704. for (let k = 0; k < this.deviceInfo.integerList.length && !isComplete; k++) {
  1705. if (this.deviceInfo.integerList[k].id == message[j].id) {
  1706. this.deviceInfo.integerList[k].shadow = message[j].value;
  1707. isComplete = true;
  1708. break;
  1709. }
  1710. }
  1711. // 小数类型
  1712. for (let k = 0; k < this.deviceInfo.decimalList.length && !isComplete; k++) {
  1713. if (this.deviceInfo.decimalList[k].id == message[j].id) {
  1714. this.deviceInfo.decimalList[k].shadow = message[j].value;
  1715. isComplete = true;
  1716. break;
  1717. }
  1718. }
  1719. // 监测数据
  1720. for (let k = 0; k < this.deviceInfo.readOnlyList.length && !isComplete; k++) {
  1721. if (this.deviceInfo.readOnlyList[k].id == message[j].id) {
  1722. this.deviceInfo.readOnlyList[k].shadow = message[j].value;
  1723. // 更新图表
  1724. // for (let m = 0; m < this.monitorChart.length; m++) {
  1725. // if (message[j].id == this.monitorChart[m].data.id) {
  1726. // let data = [{
  1727. // value: message[j].value,
  1728. // name: this.monitorChart[m].data.name
  1729. // }];
  1730. // this.monitorChart[m].chart.setOption({
  1731. // series: [{
  1732. // data: data
  1733. // }]
  1734. // });
  1735. // break;
  1736. // }
  1737. // }
  1738. isComplete = true;
  1739. break;
  1740. }
  1741. }
  1742. }
  1743. this.parseEnumList();
  1744. this.checkJianyao();
  1745. }
  1746. this.$forceUpdate();
  1747. }
  1748. });
  1749. },
  1750. checkJianyao(){
  1751. let self = this;
  1752. setTimeout(function(){
  1753. if(self.decoctControlStatus){
  1754. self.showJianyao();
  1755. }
  1756. },1000);
  1757. },
  1758. exchangeData(msgId,obj){
  1759. if(msgId === "TempSetting"){
  1760. this.temperature = obj.value;
  1761. }
  1762. if(msgId === "TimeSetting"){
  1763. this.temperatureTime = obj.value;
  1764. }
  1765. if(msgId === "CurrentTemp"){
  1766. this.currentTemperature = obj.value;
  1767. }
  1768. if(msgId === "HighTempTime"){
  1769. this.hightTemperature = obj.value;
  1770. }
  1771. if(msgId === "SealTemp"){
  1772. if(!this.editing){
  1773. this.sealingTemperature = obj.value;
  1774. }
  1775. }
  1776. if(msgId === "BandingTemp"){
  1777. if(!this.editing){
  1778. this.edegTemperature = obj.value;
  1779. }
  1780. }
  1781. if(msgId === "PackingVolume"){
  1782. if(!this.editing){
  1783. this.packageVolume = obj.value;
  1784. }
  1785. }
  1786. if(msgId === "PackageQuantity"){
  1787. if(!this.editing){
  1788. this.packageNumber = obj.value;
  1789. }
  1790. }
  1791. if(msgId === "LeftAppointmentTime"){
  1792. this.leftAppointmentTime = obj.value;
  1793. }
  1794. if(msgId === "SlowfireTiem"){
  1795. this.leftJianyaoTime = obj.value;
  1796. }
  1797. if(msgId === "CalibrationTemp"){
  1798. this.jiaozhunTemp = obj.value;
  1799. }
  1800. },
  1801. /** 发布物模型 类型(1=属性,2=功能) */
  1802. publishThingsModel(device, model) {
  1803. // 获取缓存的Json物模型
  1804. cacheJsonThingsModel(device.productId).then(response => {
  1805. let thingsModel = JSON.parse(response.data);
  1806. let type = 0;
  1807. for (let i = 0; i < thingsModel.functions.length; i++) {
  1808. if (model.id == thingsModel.functions[i].id) {
  1809. type = 2;
  1810. break;
  1811. }
  1812. }
  1813. if (type == 0) {
  1814. for (let i = 0; i < thingsModel.properties.length; i++) {
  1815. if (model.id == thingsModel.properties[i].id) {
  1816. type = 1;
  1817. break;
  1818. }
  1819. }
  1820. }
  1821. if (type != 0) {
  1822. this.mqttPublish(type, device, [model]);
  1823. }
  1824. });
  1825. },
  1826. notifyError(res){
  1827. uni.showToast({
  1828. title:res,
  1829. icon:"error"
  1830. })
  1831. },
  1832. notifySuccess(res){
  1833. uni.showToast({
  1834. title:res,
  1835. icon:"success"
  1836. })
  1837. },
  1838. /**
  1839. * Mqtt发布消息
  1840. * @type 类型(1=属性,2=功能,3=OTA升级,4=实时监测)
  1841. * @device 设备
  1842. * @model 物模型
  1843. * */
  1844. mqttPublish(type, device, modelList,needMore) {
  1845. if(this.deviceInfo.status != 3){
  1846. this.notifyError("请等待设备上线后操作")
  1847. return;
  1848. }
  1849. if(modelList.length == 0){
  1850. return;
  1851. }
  1852. let topic = "";
  1853. let message = ""
  1854. let oneToMul = false;
  1855. if(this.summary.length>1){
  1856. oneToMul = true;
  1857. }
  1858. if(!needMore){
  1859. oneToMul = false;
  1860. }
  1861. if(this.firstTab){
  1862. let isKaijiKey = false;
  1863. if(modelList.length == 1){
  1864. let modelData = modelList[0];
  1865. let curKeyId = modelData.id;
  1866. if(!this.decoctControlOnOffStatus){
  1867. if(oneToMul){
  1868. if(curKeyId.indexOf("PowerCtl") !=-1){
  1869. isKaijiKey = true;
  1870. }
  1871. }else{
  1872. if(curKeyId.indexOf("PowerControl") !=-1){
  1873. isKaijiKey = true;
  1874. }
  1875. }
  1876. }else{
  1877. isKaijiKey = true;
  1878. }
  1879. }
  1880. if(!isKaijiKey){
  1881. this.notifyError("请先开机后再进行操作")
  1882. return;
  1883. }
  1884. }else{
  1885. let isKaijiKey = false;
  1886. if(modelList.length == 1){
  1887. let modelData = modelList[0];
  1888. let curKeyId = modelData.id;
  1889. if(!this.packageControlOnOffStatus){
  1890. if(curKeyId.indexOf("PackagePowerControl") !=-1){
  1891. isKaijiKey = true;
  1892. }
  1893. }else{
  1894. isKaijiKey = true;
  1895. }
  1896. }
  1897. if(!isKaijiKey){
  1898. this.notifyError("请先开机后再进行操作")
  1899. return;
  1900. }
  1901. }
  1902. if (type == 1) {
  1903. if (device.status == 3) {
  1904. // 属性,在线模式
  1905. topic = "/" + device.productId + "/" + device.serialNumber + "/property-online/get";
  1906. }
  1907. } else if (type == 2) {
  1908. if (device.status == 3) {
  1909. // 功能,在线模式
  1910. topic = "/" + device.productId + "/" + device.serialNumber + "/function-online/get";
  1911. }
  1912. } else if (type == 3) {
  1913. // OTA升级
  1914. topic = "/" + device.productId + "/" + device.serialNumber + "/ota/get";
  1915. } else {
  1916. return;
  1917. }
  1918. let title = "";
  1919. if(type == 1){
  1920. title = "属性";
  1921. }else if(type == 2){
  1922. title = "功能";
  1923. }
  1924. if (topic != "") {
  1925. // 发布
  1926. let arr = [];
  1927. for (let i = 0; i <modelList.length; i++) {
  1928. let model = modelList[i];
  1929. let modelId = model.id;
  1930. if(oneToMul){
  1931. let childId = this.childId;
  1932. if(childId){
  1933. modelId = modelId+"_"+childId;
  1934. }
  1935. }
  1936. let shadow = model.shadow+"";
  1937. let modelType = model.type;
  1938. let shadowInt = parseInt(shadow,10);
  1939. let isNumber = false;
  1940. let shadowStr = shadowInt+"";
  1941. if(shadowStr === shadow){
  1942. isNumber = true;
  1943. shadow = shadowInt;
  1944. }
  1945. if(modelType == "integer" && !isNumber){
  1946. this.$modal.showToast(model.name+'的值必须是数字类型')
  1947. return;
  1948. }
  1949. arr.push({id:modelId,value:shadow+""});
  1950. }
  1951. message = JSON.stringify(arr);
  1952. let self = this;
  1953. this.$mqttTool.publish(topic, message,title).then(res => {
  1954. this.notifySuccess(res);
  1955. }).catch(res => {
  1956. this.notifyError(res);
  1957. });
  1958. }
  1959. },
  1960. startCheck(){
  1961. let self = this;
  1962. this.checkTimer = setTimeout(function (){
  1963. self.sendHeart();
  1964. self.startCheck();
  1965. },20000);
  1966. },
  1967. checkActive(){
  1968. let self = this;
  1969. setTimeout(function (){
  1970. if(self.publishMsg){
  1971. self.resetConn()
  1972. }
  1973. },3000);
  1974. },
  1975. sendHeart(){
  1976. console.log("发送心跳111")
  1977. let device = this.deviceInfo;
  1978. let self = this;
  1979. let topic = "/property-offline/post";
  1980. self.publishMsg = true;
  1981. self.checkActive();
  1982. this.$mqttTool.publish(topic, "ok", "heart").then(res => {
  1983. self.publishMsg = false;
  1984. }).catch(res => {
  1985. self.publishMsg = false;
  1986. });
  1987. },
  1988. resetConn(){
  1989. console.log("检测异常,重连")
  1990. this.$mqttTool.end();
  1991. this.$mqttTool.client = null;
  1992. this.connectMqtt();
  1993. this.getDetail();
  1994. }
  1995. }
  1996. }
  1997. </script>
  1998. <style>
  1999. .send_btn{
  2000. width: 160rpx !important;
  2001. height: 40rpx !important;
  2002. font-size: 10px !important;
  2003. margin-top: 5px;
  2004. }
  2005. uni-col{
  2006. width: 150px;
  2007. }
  2008. .header{
  2009. width: 100%;
  2010. background: white;
  2011. padding:0px 20rpx;
  2012. position: relative;
  2013. height: 100vh;
  2014. position: relative;
  2015. }
  2016. .content {
  2017. display: flex;
  2018. align-items: center;
  2019. justify-content: center;
  2020. color: #060B25;
  2021. }
  2022. .logo {
  2023. height: 200rpx;
  2024. width: 200rpx;
  2025. margin-top: 200rpx;
  2026. margin-left: auto;
  2027. margin-right: auto;
  2028. margin-bottom: 50rpx;
  2029. }
  2030. .text-area {
  2031. margin:10px;
  2032. padding-bottom: 10px;
  2033. justify-content: center;
  2034. width: 100%;
  2035. }
  2036. .grid-text {
  2037. font-size: 14px;
  2038. color: #909399;
  2039. padding: 10rpx 0 20rpx 0rpx;
  2040. /* #ifndef APP-PLUS */
  2041. box-sizing: border-box;
  2042. /* #endif */
  2043. }
  2044. .title {
  2045. font-size: 36rpx;
  2046. color: #8f8f94;
  2047. }
  2048. .item{
  2049. height: 80rpx;
  2050. line-height: 80rpx;
  2051. }
  2052. .bg{
  2053. position: relative;
  2054. }
  2055. .text-left{
  2056. color: #8A92A5;
  2057. }
  2058. .text-right{
  2059. color: #545454;
  2060. }
  2061. .prop-text{
  2062. position: relative;
  2063. margin:20rpx 0;
  2064. font-size: 26rpx;
  2065. }
  2066. .prop-card-area{
  2067. }
  2068. .prop-card{
  2069. width: 28%;
  2070. height: 100rpx;
  2071. text-align: center;
  2072. display: inline-block;
  2073. background: #F5FCFF;
  2074. box-shadow: 0px 9rpx 8rpx 0px rgba(0,0,0,0.09);
  2075. border-radius: 8rpx;
  2076. margin:0px 15rpx;
  2077. line-height: 48rpx;
  2078. }
  2079. .prop-card-top{
  2080. color: #3E9CFC;
  2081. }
  2082. .prop-card-bottom{
  2083. color: #8A92A5;
  2084. }
  2085. .tab-area {
  2086. background: white;
  2087. position: absolute;
  2088. left: 0px;
  2089. right: 0px;
  2090. top:480rpx;
  2091. bottom:-20px;
  2092. min-height: 200rpx;
  2093. box-shadow: 0rpx 5rpx 27rpx 0rpx rgba(195, 195, 195, 0.4);
  2094. border-radius: 40rpx;
  2095. overflow-y: auto;
  2096. padding-bottom:80rpx;
  2097. }
  2098. .prop-item{
  2099. position: relative;
  2100. display: flex;
  2101. flex-direction: row;
  2102. height: 100rpx;
  2103. line-height: 100rpx;
  2104. margin:0 20rpx;
  2105. }
  2106. .prop-item-left{
  2107. color: #545454;
  2108. width: 100%;
  2109. font-size: 16px;
  2110. border-bottom: 1px solid lightgray;
  2111. margin-left: 120rpx;
  2112. }
  2113. .prop-item-image{
  2114. width: 120rpx;
  2115. height: 120rpx;
  2116. position: absolute;
  2117. bottom:-10rpx;
  2118. }
  2119. .prop-item-right{
  2120. position: absolute;
  2121. right:10rpx;
  2122. top:10rpx;
  2123. }
  2124. input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{
  2125. color:#666;
  2126. font-size:12px;
  2127. }
  2128. .clearfix::after {
  2129. content: "";
  2130. display: block;
  2131. clear: both;
  2132. }
  2133. .decoctControlHeader {
  2134. display: flex;
  2135. align-items: center;
  2136. font-weight: 600;
  2137. }
  2138. .decoctControlTop {
  2139. display: flex;
  2140. height: 240rpx;
  2141. border-bottom:1px #B2B2B2 dotted;
  2142. margin:0 40rpx;
  2143. }
  2144. .decoctControlTopLeft {
  2145. width:40%;
  2146. line-height: 2;
  2147. text-align: center;
  2148. margin: 0 15px;
  2149. position: relative;
  2150. }
  2151. .addTemperature {
  2152. border-radius:5px;
  2153. position:absolute;
  2154. background-color: dodgerblue;
  2155. color:white;
  2156. width: 30px;
  2157. height: 30px;
  2158. left:15px;
  2159. top:80px;
  2160. }
  2161. .addTemperatureBtn {
  2162. border-radius:10px;
  2163. position:absolute;
  2164. clip-path: polygon(50% 0,100% 100%,0 100%);
  2165. transform: scale(0.5);
  2166. left: 0;
  2167. top:0;
  2168. bottom: 0;
  2169. right: 0;
  2170. margin: auto;
  2171. }
  2172. .subTemperature {
  2173. border-radius:5px;
  2174. position:absolute;
  2175. background-color: dodgerblue;
  2176. color:white;
  2177. width: 30px;
  2178. height: 30px;
  2179. right:15px;
  2180. top:80px;
  2181. }
  2182. .subTemperatureBtn {
  2183. border-radius:10px;
  2184. position:absolute;
  2185. clip-path: polygon(50% 0,100% 100%,0 100%);
  2186. transform: scale(0.5);
  2187. left: 0;
  2188. top:0;
  2189. bottom: 0;
  2190. right: 0;
  2191. margin: auto;
  2192. }
  2193. .decoctControlTopRight {
  2194. width:40%;
  2195. line-height: 2;
  2196. text-align: center;
  2197. margin: 0 15px;
  2198. position: relative;
  2199. }
  2200. .decoctControlBottom {
  2201. border-bottom:1px #B2B2B2 dotted;
  2202. width:91vw;
  2203. margin:0 auto;
  2204. padding:10px;
  2205. display: flex;
  2206. justify-content:space-between;
  2207. align-items: center;
  2208. }
  2209. .addTime {
  2210. border-radius:5px;
  2211. position:absolute;
  2212. background-color: dodgerblue;
  2213. color:white;
  2214. width: 30px;
  2215. height: 30px;
  2216. left:15px;
  2217. top:80px;
  2218. }
  2219. .addTimeBtn {
  2220. border-radius:10px;
  2221. position:absolute;
  2222. clip-path: polygon(50% 0,100% 100%,0 100%);
  2223. transform: scale(0.5);
  2224. left: 0;
  2225. top:0;
  2226. bottom: 0;
  2227. right: 0;
  2228. margin: auto;
  2229. }
  2230. .subTime {
  2231. border-radius:5px;
  2232. position:absolute;
  2233. background-color: dodgerblue;
  2234. color:white;
  2235. width: 30px;
  2236. height: 30px;
  2237. right:15px;
  2238. top:80px;
  2239. }
  2240. .subTimeBtn {
  2241. border-radius:10px;
  2242. position:absolute;
  2243. clip-path: polygon(50% 0,100% 100%,0 100%);
  2244. transform: scale(0.5);
  2245. left: 0;
  2246. top:0;
  2247. bottom: 0;
  2248. right: 0;
  2249. margin: auto;
  2250. }
  2251. .packageControlBottomRight {
  2252. border-radius:5px;
  2253. padding:5px 10px;
  2254. margin-right: 15px;
  2255. background-color: #3c9cff;
  2256. color: #fff;
  2257. }
  2258. .packageControlBottomClear {
  2259. border-radius:5px;
  2260. padding:5px 10px;
  2261. background-color: #B2B2B2;
  2262. color: #fff;
  2263. }
  2264. .active_btn{
  2265. background-color: #3c9cff;
  2266. }
  2267. .baozhuang-sub{
  2268. right: 10rpx !important;
  2269. }
  2270. .baozhuang-add{
  2271. left: 6rpx !important;
  2272. }
  2273. .control-input-box{
  2274. display: flex;
  2275. flex-direction: row;
  2276. padding-left: 26rpx;
  2277. }
  2278. .control-input-box-danwei{
  2279. padding-top:12rpx;
  2280. margin-left:4rpx;
  2281. }
  2282. .tabs{
  2283. position: relative;
  2284. top:7vh;
  2285. }
  2286. .child_tab{
  2287. position: relative;
  2288. display: inline-block;
  2289. width: 25%;
  2290. height: 180rpx;
  2291. }
  2292. .child_img{
  2293. width: 50rpx;
  2294. height: 50rpx;
  2295. left: 66rpx;
  2296. top: 66rpx;
  2297. position: relative;
  2298. }
  2299. .child_title{
  2300. position: absolute;
  2301. left: 0px;
  2302. right: 0px;
  2303. text-align: center;
  2304. font-size: 12px;
  2305. bottom: -12rpx;
  2306. color: #060B25;
  2307. }
  2308. .control{
  2309. width: 100%;
  2310. margin-top:8vh;
  2311. position: relative;
  2312. }
  2313. .control_item{
  2314. position: relative;
  2315. width: 50%;
  2316. display: inline-block;
  2317. height: 150rpx;
  2318. }
  2319. .control_item_detail{
  2320. position: relative;
  2321. top:25rpx;
  2322. }
  2323. .control_item_left{
  2324. position:absolute;;
  2325. left:25%;
  2326. font-size: 55px;
  2327. z-index: 999;
  2328. top:-34rpx
  2329. }
  2330. .control_item_center{
  2331. position:absolute;;
  2332. left:34%;
  2333. top:0vh;
  2334. }
  2335. .control_item_right{
  2336. position:absolute;;
  2337. left:67%;
  2338. font-size: 34px;
  2339. z-index: 999;
  2340. }
  2341. .control_item_center_unit{
  2342. position: absolute;
  2343. left:26vw;
  2344. top: 0.8vh;
  2345. width:200rpx;
  2346. }
  2347. .control_item_title{
  2348. position: absolute;
  2349. bottom:34rpx;
  2350. font-size: 12px;
  2351. width: 100%;
  2352. text-align: center;
  2353. }
  2354. .bottom{
  2355. height: 140rpx;
  2356. position: absolute;
  2357. left: 0px;
  2358. width: 94%;
  2359. margin: 0 3%;
  2360. padding-top: 10rpx;
  2361. }
  2362. .bottom_item{
  2363. display: inline-block;
  2364. width: 25%;
  2365. font-size: 12px;
  2366. height: 100%;
  2367. position: relative;
  2368. text-align: center;
  2369. margin-top: 2vh;
  2370. }
  2371. .active_on{
  2372. color: #50ACFF;
  2373. }
  2374. .status_info{
  2375. position: absolute;
  2376. left: 5vw;
  2377. top: 8vh;
  2378. }
  2379. .status_detail{
  2380. display: flex;
  2381. flex-direction: row;
  2382. }
  2383. .status_text{
  2384. font-size: 16px;
  2385. }
  2386. .online_text{
  2387. font-size: 12px;
  2388. padding-top: 3px;
  2389. }
  2390. .online{
  2391. color: #017128;
  2392. }
  2393. .device_info{
  2394. font-size: 13px;
  2395. }
  2396. </style>