detail.vue 77 KB

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