loop.js 117 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300
  1. const {
  2. getBasic,
  3. getData,
  4. postData,
  5. } = require('../../api/intell')
  6. const {
  7. getDevice,
  8. getloop,
  9. postloop,
  10. looplightlist,
  11. } = require('../../api/device')
  12. const enloop = require('../../utils/loop')
  13. // pages/loop/loop.js
  14. Page({
  15. /**
  16. * 页面的初始数据
  17. */
  18. data: {
  19. array: [],
  20. //回路调控
  21. crr: [],
  22. indexes: 0,
  23. //时间调控
  24. time: ["00:00", "00:00", "00:00", "00:00"],
  25. //时间调控(开关选择器)
  26. state: [false, false, false, false], //控制时控一开关和光控开关的状态
  27. state1: [false, false], //控制时控二开关的状态
  28. fixed1: "固定",
  29. fixed2: "固定",
  30. fixed3: "固定",
  31. fixed4: "固定",
  32. type1: "",
  33. type2: "",
  34. type3: "",
  35. type4: "",
  36. //时间调控(背景颜色)
  37. timecontrolcolor1: "#888888",
  38. timecontrolcolor2: "#888888",
  39. timecontrolcolor3: "#888888",
  40. timecontrolcolor4: "#888888",
  41. //时间调控(字体颜色)
  42. fontcolor1: "#cccccc",
  43. fontcolor2: "#cccccc",
  44. fontcolor3: "#cccccc",
  45. fontcolor4: "#cccccc",
  46. //固定经纬切换
  47. //日期调控
  48. address: ["/image/false.png", "/image/false.png", "/image/false.png", "/image/false.png",
  49. "/image/false.png",
  50. "/image/false.png", "/image/false.png"
  51. ],
  52. recorddate: "", //记录后台传过来的日期参数
  53. //光控调整
  54. arr: [0],
  55. brr: [0],
  56. index: 0,
  57. indexs: 0,
  58. Lightcontrolcolor1: "#888888",
  59. Lightcontrolcolor2: "#888888",
  60. fontcolor5: "#cccccc",
  61. fontcolor6: "#cccccc",
  62. select1: "",
  63. select2: "",
  64. //报警状态
  65. radio1: false,
  66. radio2: false,
  67. radio3: false,
  68. alert: "",
  69. //扫码
  70. Title: "",
  71. status: "离线",
  72. zoom: 0.8,
  73. Modecontrol: "",
  74. groupName: [],
  75. deviceName: [],
  76. groupIndex: 0,
  77. deviceIndex: 0,
  78. deviceId: '',
  79. deviceKey: '',
  80. num: 0, //记录回路数量
  81. play: 0, //新老设备的页面切换
  82. //新设备数据
  83. timeValue: ['00:00', '00:00', '00:00', '00:00', '00:00', '00:00'],
  84. newcolor: ["#888888", "#888888", "#888888"],
  85. newfont: ["#cccccc", "#cccccc", "#cccccc"],
  86. newSwitch: [false, false, false],
  87. newSwitchstate: ["", "", ""],
  88. equipment: 0, //记录当前设备的序号(服务器传的id)
  89. subset: 0, //记录当前分组的id
  90. ID: 0, //记录设备的ID
  91. // 启动条件(多选框)
  92. disabled: false,
  93. choice: [],
  94. lightlist: [], //新设备回路开启条件,
  95. popup: false, //开启条件弹窗
  96. newChange: 0, //新设备回路固定经纬模式切换
  97. beginTime:'',
  98. closeTimes:''
  99. },
  100. //分组下拉
  101. changegroup: function(e) {
  102. wx.showToast({
  103. title: '刷新中',
  104. icon: 'loading',
  105. duration: 2000
  106. })
  107. var that = this
  108. that.setData({
  109. groupIndex: e.detail.value
  110. })
  111. wx.setStorageSync('groupIndex', e.detail.value)
  112. var groupName = that.data.groupName[that.data.groupIndex] //选择的分组名称
  113. wx.setStorageSync('groupName', groupName) //将修改的分组名称放入缓存
  114. var group = wx.getStorageSync('group')
  115. var deviceName = []
  116. for (let i = 0; i < group.length; i++) {
  117. if (group[i].groupName == groupName) {
  118. if (group[i].devices != null && group[i].devices.length != 0) {
  119. for (let j = 0; j < group[i].devices.length; j++) {
  120. deviceName.push(group[i].devices[j].deviceName)
  121. }
  122. that.setData({
  123. deviceName: deviceName,
  124. deviceIndex: 0
  125. })
  126. var groupNames = that.data.groupName[that.data.groupIndex]
  127. var deviceNames = that.data.deviceName[that.data.deviceIndex]
  128. wx.setStorageSync('deviceName', deviceNames) //将修改的设备名放入缓存
  129. //获取设备信息
  130. var Message = enloop.deviceMessage(groupNames, deviceNames)
  131. that.setData({
  132. equipment: Message.Device,
  133. subset: Message.id,
  134. ID: Message.ID,
  135. indexes: 0
  136. }) //记录当前的设备id和分组id
  137. if (Message.modules == 0) {
  138. that.setData({
  139. play: 0,
  140. deviceKey: Message.deviceKey,
  141. deviceId: Message.deviceId
  142. })
  143. getBasic(Message.deviceId, Message.deviceKey).then(res => {
  144. if (res.data.errno == 0) {
  145. if (res.data.data.online == true) {
  146. that.setData({
  147. status: '在线'
  148. })
  149. } else {
  150. that.setData({
  151. status: '离线'
  152. })
  153. }
  154. getData(Message.deviceId, Message.deviceKey).then(ever => {
  155. if (ever.data.errno == 0) {
  156. let {
  157. data
  158. } = ever.data
  159. //判断设备是否处于初始化状态
  160. var initialization = true
  161. for (let t = 0; t < data.length; t++) {
  162. if ('current_value' in data[t] == false) {
  163. initialization = false
  164. }
  165. }
  166. if (initialization == true) {
  167. let loopnum = Message.loopnum
  168. var Summary = enloop.deviceinfo(data, loopnum,
  169. that.data.arr, that.data.brr, that.data
  170. .time, that.data.state,
  171. that.data.state1, that.data.fixed1, that
  172. .data.fixed2, that.data.fixed3,
  173. that.data.fixed4, that.data.address,
  174. that.data.radio1, that.data.radio2,
  175. that.data.radio3, that.data.index, that
  176. .data.indexs)
  177. that.setData({
  178. crr: Summary.crr,
  179. arr: Summary.arr,
  180. brr: Summary.brr,
  181. fixed1: Summary.fixed1,
  182. fixed2: Summary.fixed2,
  183. fixed3: Summary.fixed3,
  184. fixed4: Summary.fixed4,
  185. index: Summary.index,
  186. indexs: Summary.indexs,
  187. radio1: Summary.radio1,
  188. radio2: Summary.radio2,
  189. radio3: Summary.radio3,
  190. recorddate: Summary.recorddate,
  191. state: Summary.state,
  192. state1: Summary.state1,
  193. time: Summary.time,
  194. address: Summary.address,
  195. play: 0
  196. })
  197. //监视开关状态(改变颜色,调整功能)
  198. switch (that.data.state[0]) {
  199. case true:
  200. that.setData({
  201. type1: "time",
  202. timecontrolcolor1: "blue",
  203. fontcolor1: "white",
  204. })
  205. break;
  206. default:
  207. that.setData({
  208. type1: "",
  209. timecontrolcolor1: "#888888",
  210. fontcolor1: "#cccccc",
  211. })
  212. break;
  213. }
  214. switch (that.data.state[1]) {
  215. case true:
  216. that.setData({
  217. type2: "time",
  218. timecontrolcolor2: "blue",
  219. fontcolor2: "white",
  220. })
  221. break;
  222. default:
  223. that.setData({
  224. type2: "",
  225. timecontrolcolor2: "#888888",
  226. fontcolor2: "#cccccc",
  227. })
  228. break;
  229. }
  230. switch (that.data.state1[0]) {
  231. case true:
  232. that.setData({
  233. type3: "time",
  234. timecontrolcolor3: "blue",
  235. fontcolor3: "white",
  236. })
  237. break;
  238. default:
  239. that.setData({
  240. type3: "",
  241. timecontrolcolor3: "#888888",
  242. fontcolor3: "#cccccc",
  243. })
  244. break;
  245. }
  246. switch (that.data.state1[1]) {
  247. case true:
  248. that.setData({
  249. type4: "time",
  250. timecontrolcolor4: "blue",
  251. fontcolor4: "white",
  252. })
  253. break;
  254. default:
  255. that.setData({
  256. type4: "",
  257. timecontrolcolor4: "#888888",
  258. fontcolor4: "#cccccc",
  259. })
  260. break;
  261. }
  262. switch (that.data.state[2]) {
  263. case true:
  264. that.setData({
  265. Lightcontrolcolor1: "blue",
  266. fontcolor5: "white",
  267. select1: "selector"
  268. })
  269. break;
  270. default:
  271. that.setData({
  272. Lightcontrolcolor1: "#888888",
  273. fontcolor5: "#cccccc",
  274. select1: ""
  275. })
  276. break;
  277. }
  278. switch (that.data.state[3]) {
  279. case true:
  280. that.setData({
  281. Lightcontrolcolor2: "blue",
  282. fontcolor6: "white",
  283. select2: "selector"
  284. })
  285. break;
  286. default:
  287. that.setData({
  288. Lightcontrolcolor2: "#888888",
  289. fontcolor6: "#cccccc",
  290. select2: ""
  291. })
  292. break;
  293. }
  294. } else {
  295. getDevice(Message.Device, Message.id).then(
  296. rgb => {
  297. if (rgb.data.code == 0) {
  298. var rgbs = rgb.data.data
  299. .circuits
  300. rgbs = rgbs.split(',')
  301. that.setData({
  302. crr: rgbs
  303. })
  304. } else {
  305. wx.showModal({
  306. title: '错误',
  307. content: rgb.data
  308. .msg,
  309. showCancel: false
  310. })
  311. }
  312. })
  313. }
  314. } else {
  315. wx.showModal({
  316. title: '错误',
  317. content: ever.data.error,
  318. showCancel: false
  319. })
  320. }
  321. })
  322. } else {
  323. wx.showModal({
  324. title: '错误',
  325. content: res.data.error,
  326. showCancel: false
  327. })
  328. }
  329. })
  330. } else {
  331. that.setData({
  332. play: 1
  333. })
  334. //新设备在线状态
  335. getDevice(Message.Device, Message.id).then(nrg => {
  336. if (nrg.data.code == 0) {
  337. var nrg = nrg.data.data
  338. if (nrg.status == 1) {
  339. that.setData({
  340. status: '在线'
  341. })
  342. } else {
  343. that.setData({
  344. status: '离线'
  345. })
  346. }
  347. getloop(Message.Device).then(suc => {
  348. if (suc.data.code == 0) {
  349. var suc = suc.data.data
  350. var index = that.data.indexes
  351. for (let i = 0; i < suc.length; i++) {
  352. if (index == i) {
  353. let Suc = suc[i]
  354. var newSwitch = that.data.newSwitch
  355. var timeValue = that.data.timeValue
  356. var newSwitchstate = that.data.newSwitchstate
  357. var choice = that.data.choice
  358. var model = Suc.ctlMode
  359. var beginTime = Suc.realTimeCondition1OnTime
  360. var closeTimes = Suc.realTimeCondition1OffTime
  361. //光控启动条件
  362. if (Suc.lightControlCondition.includes(
  363. ',') == true) {
  364. var light = Suc.lightControlCondition
  365. .split(',')
  366. for (let i = 0; i < light.length; i++) {
  367. switch (light[i]) {
  368. case '晴天':
  369. choice[0] = true
  370. break;
  371. case '多云':
  372. choice[1] = true
  373. break;
  374. case '阴天':
  375. choice[2] = true
  376. break;
  377. case '大阴天':
  378. choice[3] = true
  379. break;
  380. }
  381. }
  382. } else {
  383. choice = [false, false, false, false]
  384. switch (Suc.lightControlCondition) {
  385. case '晴天':
  386. choice[0] = true
  387. break;
  388. case '多云':
  389. choice[1] = true
  390. break;
  391. case '阴天':
  392. choice[2] = true
  393. break;
  394. case '大阴天':
  395. choice[3] = true
  396. break;
  397. }
  398. }
  399. that.setData({
  400. choice: choice
  401. })
  402. var lightCondition = Suc
  403. .lightControlCondition
  404. //光控启动条件
  405. looplightlist().then(res => {
  406. if (res.data.code == 0) {
  407. var lightlist = res.data
  408. .data
  409. that.setData({
  410. lightlist: lightlist
  411. })
  412. for (let i = 0; i <
  413. lightlist.length; i++) {
  414. choice[i] = false
  415. }
  416. if (lightCondition.includes(
  417. ',') == true) {
  418. lightCondition =
  419. lightCondition
  420. .split(',')
  421. for (let j = 0; j <
  422. lightCondition
  423. .length; j++) {
  424. if (lightCondition[
  425. j] == '1') {
  426. choice[0] = true
  427. } else if (
  428. lightCondition[
  429. j] == '2') {
  430. choice[1] = true
  431. } else if (
  432. lightCondition[
  433. j] == '3') {
  434. choice[2] = true
  435. } else if (
  436. lightCondition[
  437. j] == '4') {
  438. choice[3] = true
  439. }
  440. }
  441. } else {
  442. if (lightCondition ==
  443. '1') {
  444. choice[0] = true
  445. } else if (
  446. lightCondition ==
  447. '2') {
  448. choice[1] = true
  449. } else if (
  450. lightCondition ==
  451. '3') {
  452. choice[2] = true
  453. } else if (
  454. lightCondition ==
  455. '4') {
  456. choice[3] = true
  457. }
  458. }
  459. that.setData({
  460. choice: choice
  461. })
  462. } else {
  463. wx.showModal({
  464. title: '错误',
  465. content: res
  466. .data.msg,
  467. showCancel: false
  468. })
  469. }
  470. })
  471. //时控1
  472. if (Suc.timeCondition1Switch == 1) {
  473. newSwitch[0] = true
  474. newSwitchstate[0] = 'time'
  475. } else {
  476. newSwitch[0] = false
  477. newSwitchstate[0] = ''
  478. }
  479. timeValue[0] = Suc.timeCondition1OnTime
  480. timeValue[1] = Suc.timeCondition1OffTime
  481. //时控2
  482. if (Suc.timeCondition2Switch == 1) {
  483. newSwitch[1] = true
  484. newSwitchstate[1] = 'time'
  485. } else {
  486. newSwitch[1] = false
  487. newSwitchstate[1] = ''
  488. }
  489. timeValue[2] = Suc.timeCondition2OnTime
  490. timeValue[3] = Suc.timeCondition2OffTime
  491. //光控
  492. if (Suc.lightControlSwitch == 1) {
  493. newSwitch[2] = true
  494. newSwitchstate[2] = 'time'
  495. } else {
  496. newSwitch[2] = false
  497. newSwitchstate[2] = ''
  498. }
  499. timeValue[4] = Suc.lightControlStart
  500. timeValue[5] = Suc.lightControlEnd
  501. for (let j = 0; j < timeValue.length; j++) {
  502. if (timeValue[j] == "") {
  503. timeValue[j] = '00:00'
  504. }
  505. }
  506. var messageNum = Message.loopnum
  507. messageNum.push('所有回路')
  508. that.setData({
  509. crr: messageNum,
  510. timeValue: timeValue,
  511. newSwitch: newSwitch,
  512. newChange:model,
  513. beginTime:beginTime,
  514. closeTimes:closeTimes
  515. })
  516. //监视新设备开关状态
  517. var newSwitchs = that.data.newSwitch
  518. var newfonts = that.data.newfont
  519. var newcolors = that.data.newcolor
  520. var newSwitchstates = that.data
  521. .newSwitchstate
  522. var disableds = that.data.disabled
  523. if (newSwitchs[0] == true) {
  524. newfonts[0] = "white"
  525. newcolors[0] = "blue"
  526. newSwitchstates[0] = "time"
  527. } else {
  528. newfonts[0] = "#cccccc"
  529. newcolors[0] = "#888888"
  530. newSwitchstates[0] = ""
  531. }
  532. if (newSwitchs[1] == true) {
  533. newfonts[1] = "white"
  534. newcolors[1] = "blue"
  535. newSwitchstates[1] = "time"
  536. } else {
  537. newfonts[1] = "#cccccc"
  538. newcolors[1] = "#888888"
  539. newSwitchstates[1] = ""
  540. }
  541. if (newSwitchs[2] == true) {
  542. newfonts[2] = "white"
  543. newcolors[2] = "blue"
  544. newSwitchstates[2] = "time"
  545. disableds = false
  546. } else {
  547. newfonts[2] = "#cccccc"
  548. newcolors[2] = "#888888"
  549. newSwitchstates[2] = ""
  550. disableds = true
  551. }
  552. that.setData({
  553. newcolor: newcolors,
  554. newfont: newfonts,
  555. newSwitch: newSwitchs,
  556. newSwitchstate: newSwitchstates,
  557. disabled: disableds
  558. })
  559. }
  560. }
  561. } else {
  562. console.log('获取新设备回路参数失败')
  563. wx.showModal({
  564. title: '错误',
  565. content: suc.data.msg,
  566. showCancel: false
  567. })
  568. }
  569. })
  570. } else {
  571. console.log('新设备获取信息失败')
  572. wx.showModal({
  573. title: '错误',
  574. content: nrg.data.msg,
  575. showCancel: false
  576. })
  577. }
  578. })
  579. }
  580. } else {
  581. wx.setStorageSync('deviceName', '')
  582. that.setData({
  583. status: '离线',
  584. deviceName: []
  585. })
  586. }
  587. }
  588. }
  589. },
  590. //设备下拉
  591. changedevice: function(e) {
  592. var that = this
  593. wx.showToast({
  594. title: '刷新中',
  595. icon: 'loading',
  596. duration: 2000
  597. })
  598. that.setData({
  599. deviceIndex: e.detail.value
  600. })
  601. var groupName = that.data.groupName[that.data.groupIndex]
  602. var deviceName = that.data.deviceName[that.data.deviceIndex]
  603. wx.setStorageSync('groupName', groupName) //分组名称
  604. wx.setStorageSync('deviceName', deviceName) //设备名称
  605. //获取设备信息
  606. var Message = enloop.deviceMessage(groupName, deviceName)
  607. that.setData({
  608. equipment: Message.Device,
  609. subset: Message.id,
  610. ID: Message.ID,
  611. indexes: 0
  612. }) //记录当前的设备id和分组id
  613. if (Message.modules == 0) {
  614. that.setData({
  615. play: 0,
  616. deviceKey: Message.deviceKey,
  617. deviceId: Message.deviceId
  618. })
  619. getBasic(Message.deviceId, Message.deviceKey).then(res => {
  620. if (res.data.errno == 0) {
  621. if (res.data.data.online == true) {
  622. that.setData({
  623. status: '在线'
  624. })
  625. } else {
  626. that.setData({
  627. status: '离线'
  628. })
  629. }
  630. getData(Message.deviceId, Message.deviceKey).then(ever => {
  631. if (ever.data.errno == 0) {
  632. let {
  633. data
  634. } = ever.data
  635. //判断设备是否处于初始化状态
  636. var initialization = true
  637. for (let t = 0; t < data.length; t++) {
  638. if ('current_value' in data[t] == false) {
  639. initialization = false
  640. }
  641. }
  642. if (initialization == true) {
  643. let loopnum = Message.loopnum
  644. var Summary = enloop.deviceinfo(data, loopnum, that.data
  645. .arr, that.data.brr, that.data.time, that.data
  646. .state,
  647. that.data.state1, that.data.fixed1, that.data
  648. .fixed2, that.data.fixed3,
  649. that.data.fixed4, that.data.address, that.data
  650. .radio1, that.data.radio2,
  651. that.data.radio3, that.data.index, that.data.indexs)
  652. that.setData({
  653. crr: Summary.crr,
  654. arr: Summary.arr,
  655. brr: Summary.brr,
  656. fixed1: Summary.fixed1,
  657. fixed2: Summary.fixed2,
  658. fixed3: Summary.fixed3,
  659. fixed4: Summary.fixed4,
  660. index: Summary.index,
  661. indexs: Summary.indexs,
  662. radio1: Summary.radio1,
  663. radio2: Summary.radio2,
  664. radio3: Summary.radio3,
  665. recorddate: Summary.recorddate,
  666. state: Summary.state,
  667. state1: Summary.state1,
  668. time: Summary.time,
  669. address: Summary.address,
  670. play: 0
  671. })
  672. //监视开关状态(改变颜色,调整功能)
  673. switch (that.data.state[0]) {
  674. case true:
  675. that.setData({
  676. type1: "time",
  677. timecontrolcolor1: "blue",
  678. fontcolor1: "white",
  679. })
  680. break;
  681. default:
  682. that.setData({
  683. type1: "",
  684. timecontrolcolor1: "#888888",
  685. fontcolor1: "#cccccc",
  686. })
  687. break;
  688. }
  689. switch (that.data.state[1]) {
  690. case true:
  691. that.setData({
  692. type2: "time",
  693. timecontrolcolor2: "blue",
  694. fontcolor2: "white",
  695. })
  696. break;
  697. default:
  698. that.setData({
  699. type2: "",
  700. timecontrolcolor2: "#888888",
  701. fontcolor2: "#cccccc",
  702. })
  703. break;
  704. }
  705. switch (that.data.state1[0]) {
  706. case true:
  707. that.setData({
  708. type3: "time",
  709. timecontrolcolor3: "blue",
  710. fontcolor3: "white",
  711. })
  712. break;
  713. default:
  714. that.setData({
  715. type3: "",
  716. timecontrolcolor3: "#888888",
  717. fontcolor3: "#cccccc",
  718. })
  719. break;
  720. }
  721. switch (that.data.state1[1]) {
  722. case true:
  723. that.setData({
  724. type4: "time",
  725. timecontrolcolor4: "blue",
  726. fontcolor4: "white",
  727. })
  728. break;
  729. default:
  730. that.setData({
  731. type4: "",
  732. timecontrolcolor4: "#888888",
  733. fontcolor4: "#cccccc",
  734. })
  735. break;
  736. }
  737. switch (that.data.state[2]) {
  738. case true:
  739. that.setData({
  740. Lightcontrolcolor1: "blue",
  741. fontcolor5: "white",
  742. select1: "selector"
  743. })
  744. break;
  745. default:
  746. that.setData({
  747. Lightcontrolcolor1: "#888888",
  748. fontcolor5: "#cccccc",
  749. select1: ""
  750. })
  751. break;
  752. }
  753. switch (that.data.state[3]) {
  754. case true:
  755. that.setData({
  756. Lightcontrolcolor2: "blue",
  757. fontcolor6: "white",
  758. select2: "selector"
  759. })
  760. break;
  761. default:
  762. that.setData({
  763. Lightcontrolcolor2: "#888888",
  764. fontcolor6: "#cccccc",
  765. select2: ""
  766. })
  767. break;
  768. }
  769. } else {
  770. getDevice(Message.Device, Message.id).then(rgb => {
  771. if (rgb.data.code == 0) {
  772. var rgbs = rgb.data.data.circuits
  773. rgbs = rgbs.split(',')
  774. that.setData({
  775. crr: rgbs
  776. })
  777. } else {
  778. wx.showModal({
  779. title: '错误',
  780. content: rgb.data.msg,
  781. showCancel: false
  782. })
  783. }
  784. })
  785. }
  786. } else {
  787. wx.showModal({
  788. title: '错误',
  789. content: ever.data.error,
  790. showCancel: false
  791. })
  792. }
  793. })
  794. } else {
  795. wx.showModal({
  796. title: '错误',
  797. content: res.data.error,
  798. showCancel: false
  799. })
  800. }
  801. })
  802. } else {
  803. that.setData({
  804. play: 1
  805. })
  806. //新设备在线状态
  807. getDevice(Message.Device, Message.id).then(nrg => {
  808. if (nrg.data.code == 0) {
  809. var nrg = nrg.data.data
  810. if (nrg.status == 1) {
  811. that.setData({
  812. status: '在线'
  813. })
  814. } else {
  815. that.setData({
  816. status: '离线'
  817. })
  818. }
  819. getloop(Message.Device).then(suc => {
  820. if (suc.data.code == 0) {
  821. var suc = suc.data.data
  822. var index = that.data.indexes
  823. for (let i = 0; i < suc.length; i++) {
  824. if (index == i) {
  825. let Suc = suc[i]
  826. var newSwitch = that.data.newSwitch
  827. var timeValue = that.data.timeValue
  828. var newSwitchstate = that.data.newSwitchstate
  829. var choice = that.data.choice
  830. var lightCondition = Suc.lightControlCondition
  831. var model = Suc.ctlMode
  832. var beginTime = Suc.realTimeCondition1OnTime
  833. var closeTimes = Suc.realTimeCondition1OffTime
  834. //光控启动条件
  835. looplightlist().then(res => {
  836. if (res.data.code == 0) {
  837. var lightlist = res.data.data
  838. that.setData({
  839. lightlist: lightlist
  840. })
  841. for (let i = 0; i < lightlist
  842. .length; i++) {
  843. choice[i] = false
  844. }
  845. if (lightCondition.includes(',') ==
  846. true) {
  847. lightCondition = lightCondition
  848. .split(',')
  849. for (let j = 0; j < lightCondition
  850. .length; j++) {
  851. if (lightCondition[j] == '1') {
  852. choice[0] = true
  853. } else if (lightCondition[j] ==
  854. '2') {
  855. choice[1] = true
  856. } else if (lightCondition[j] ==
  857. '3') {
  858. choice[2] = true
  859. } else if (lightCondition[j] ==
  860. '4') {
  861. choice[3] = true
  862. }
  863. }
  864. } else {
  865. if (lightCondition == '1') {
  866. choice[0] = true
  867. } else if (lightCondition == '2') {
  868. choice[1] = true
  869. } else if (lightCondition == '3') {
  870. choice[2] = true
  871. } else if (lightCondition == '4') {
  872. choice[3] = true
  873. }
  874. }
  875. that.setData({
  876. choice: choice
  877. })
  878. } else {
  879. wx.showModal({
  880. title: '错误',
  881. content: res.data.msg,
  882. showCancel: false
  883. })
  884. }
  885. })
  886. //时控1
  887. if (Suc.timeCondition1Switch == 1) {
  888. newSwitch[0] = true
  889. newSwitchstate[0] = 'time'
  890. } else {
  891. newSwitch[0] = false
  892. newSwitchstate[0] = ''
  893. }
  894. timeValue[0] = Suc.timeCondition1OnTime
  895. timeValue[1] = Suc.timeCondition1OffTime
  896. //时控2
  897. if (Suc.timeCondition2Switch == 1) {
  898. newSwitch[1] = true
  899. newSwitchstate[1] = 'time'
  900. } else {
  901. newSwitch[1] = false
  902. newSwitchstate[1] = ''
  903. }
  904. timeValue[2] = Suc.timeCondition2OnTime
  905. timeValue[3] = Suc.timeCondition2OffTime
  906. //光控
  907. if (Suc.lightControlSwitch == 1) {
  908. newSwitch[2] = true
  909. newSwitchstate[2] = 'time'
  910. } else {
  911. newSwitch[2] = false
  912. newSwitchstate[2] = ''
  913. }
  914. timeValue[4] = Suc.lightControlStart
  915. timeValue[5] = Suc.lightControlEnd
  916. for (let j = 0; j < timeValue.length; j++) {
  917. if (timeValue[j] == "") {
  918. timeValue[j] = '00:00'
  919. }
  920. }
  921. var messageNum = Message.loopnum
  922. messageNum.push('所有回路')
  923. that.setData({
  924. crr:messageNum,
  925. timeValue: timeValue,
  926. newSwitch: newSwitch,
  927. })
  928. //监视新设备开关状态
  929. var newSwitchs = that.data.newSwitch
  930. var newfonts = that.data.newfont
  931. var newcolors = that.data.newcolor
  932. var newSwitchstates = that.data.newSwitchstate
  933. var disableds = that.data.disabled
  934. if (newSwitchs[0] == true) {
  935. newfonts[0] = "white"
  936. newcolors[0] = "blue"
  937. newSwitchstates[0] = "time"
  938. } else {
  939. newfonts[0] = "#cccccc"
  940. newcolors[0] = "#888888"
  941. newSwitchstates[0] = ""
  942. }
  943. if (newSwitchs[1] == true) {
  944. newfonts[1] = "white"
  945. newcolors[1] = "blue"
  946. newSwitchstates[1] = "time"
  947. } else {
  948. newfonts[1] = "#cccccc"
  949. newcolors[1] = "#888888"
  950. newSwitchstates[1] = ""
  951. }
  952. if (newSwitchs[2] == true) {
  953. newfonts[2] = "white"
  954. newcolors[2] = "blue"
  955. newSwitchstates[2] = "time"
  956. disableds = false
  957. } else {
  958. newfonts[2] = "#cccccc"
  959. newcolors[2] = "#888888"
  960. newSwitchstates[2] = ""
  961. disableds = true
  962. }
  963. that.setData({
  964. newcolor: newcolors,
  965. newfont: newfonts,
  966. newSwitch: newSwitchs,
  967. newSwitchstate: newSwitchstates,
  968. disabled: disableds,
  969. newChange:model,
  970. beginTime:beginTime,
  971. closeTimes:closeTimes
  972. })
  973. }
  974. }
  975. } else {
  976. console.log('获取新设备回路参数失败')
  977. wx.showModal({
  978. title: '错误',
  979. content: suc.data.msg,
  980. showCancel: false
  981. })
  982. }
  983. })
  984. } else {
  985. console.log('新设备获取信息失败')
  986. wx.showModal({
  987. title: '错误',
  988. content: nrg.data.msg,
  989. showCancel: false
  990. })
  991. }
  992. })
  993. }
  994. },
  995. //回路调控
  996. bindPickerChange3: function(e) {
  997. wx.showToast({
  998. title: '刷新中',
  999. icon: 'loading',
  1000. duration: 2000
  1001. })
  1002. var that = this
  1003. var play = that.data.play
  1004. var indexes = parseInt(e.detail.value)
  1005. that.setData({
  1006. indexes: indexes
  1007. })
  1008. //旧设备
  1009. if (play == 0) {
  1010. getData(that.data.deviceId, that.data.deviceKey).then(res => {
  1011. if (res.data.errno == 0) {
  1012. var {
  1013. data
  1014. } = res.data
  1015. var Indexes = that.data.indexes
  1016. Indexes = Indexes + 1
  1017. var crr = that.data.crr.length
  1018. if (Indexes == crr) {
  1019. } else {
  1020. //以下为回路
  1021. for (let i = 1; i < data.length; i++) {
  1022. //时控一开时间
  1023. if (data[i].id == "R" + Indexes + "_DayOpenTime1") {
  1024. var timeopen1 = data[i].current_value
  1025. }
  1026. //时控一关时间
  1027. else if (data[i].id == "R" + Indexes + "_DayCloseTime1") {
  1028. var timeshut1 = data[i].current_value
  1029. }
  1030. //时控二开时间
  1031. else if (data[i].id == "R" + Indexes + "_DayOpenTime2") {
  1032. var timeopen2 = data[i].current_value
  1033. }
  1034. //时控二关时间
  1035. else if (data[i].id == "R" + Indexes + "_DayCloseTime2") {
  1036. var timeshut2 = data[i].current_value
  1037. }
  1038. //日期调控
  1039. else if (data[i].id == "R" + Indexes + "_Week") {
  1040. var weeks = data[i].current_value
  1041. that.setData({
  1042. recorddate: weeks
  1043. })
  1044. weeks = parseInt(weeks)
  1045. weeks = weeks.toString(2)
  1046. weeks = weeks + ''
  1047. if (weeks != '0') {
  1048. weeks = weeks.slice(1)
  1049. }
  1050. }
  1051. //功能一
  1052. else if (data[i].id == "R" + Indexes + "_FunctionStatus1") {
  1053. var Function1 = data[i].current_value
  1054. var par = parseInt(Function1)
  1055. par = par.toString(2)
  1056. par = par + ''
  1057. switch (par.length) {
  1058. case 1:
  1059. par = '00000' + par
  1060. break;
  1061. case 2:
  1062. par = '0000' + par
  1063. break;
  1064. case 3:
  1065. par = '000' + par
  1066. break;
  1067. case 4:
  1068. par = '00' + par
  1069. break;
  1070. case 5:
  1071. par = '0' + par
  1072. break;
  1073. default:
  1074. par = par
  1075. }
  1076. }
  1077. //功能二
  1078. else if (data[i].id == "R" + Indexes + "_FunctionStatus2") {
  1079. var Function2 = data[i].current_value
  1080. var qur = parseInt(Function2)
  1081. qur = qur.toString(2)
  1082. qur = qur + ''
  1083. switch (qur.length) {
  1084. case 1:
  1085. qur = '000' + qur
  1086. break;
  1087. case 2:
  1088. qur = '00' + qur
  1089. break;
  1090. case 3:
  1091. qur = '0' + qur
  1092. break;
  1093. case 4:
  1094. qur = qur
  1095. break;
  1096. }
  1097. }
  1098. //报警
  1099. else if (data[i].id == "R" + Indexes + "_RelayStatus") {
  1100. var police = data[i].current_value
  1101. }
  1102. //光控开
  1103. else if (data[i].id == "R" + Indexes + "_LcOn") {
  1104. var Lightcontrolopen = data[i].current_value
  1105. var trr = that.data.arr
  1106. for (let i = 0; i < 100; i++) {
  1107. trr[i] = i
  1108. }
  1109. Lightcontrolopen = parseInt(Lightcontrolopen)
  1110. that.setData({
  1111. arr: trr,
  1112. index: Lightcontrolopen
  1113. })
  1114. }
  1115. //光控关
  1116. else if (data[i].id == "R" + Indexes + "_LcOff") {
  1117. var Lightcontrolshut = data[i].current_value
  1118. var prr = that.data.brr
  1119. for (let j = 0; j < 100; j++) {
  1120. prr[j] = j
  1121. }
  1122. Lightcontrolshut = parseInt(Lightcontrolshut)
  1123. that.setData({
  1124. brr: prr,
  1125. indexs: Lightcontrolshut
  1126. })
  1127. }
  1128. }
  1129. //时控一开时间
  1130. var timeOpen1
  1131. switch (timeopen1.length) {
  1132. case 1:
  1133. timeOpen1 = '00' + ':' + '0' + timeopen1.substring(0, 1)
  1134. break;
  1135. case 2:
  1136. timeOpen1 = '00' + ':' + timeopen1.substring(0, 2)
  1137. break;
  1138. case 3:
  1139. var timeOpen1 = '0' + timeopen1.substring(0, 1) + ':' + timeopen1
  1140. .substring(1, 3)
  1141. break;
  1142. case 4:
  1143. var timeOpen1 = timeopen1.substring(0, 2) + ':' + timeopen1
  1144. .substring(2, 4)
  1145. break;
  1146. }
  1147. //时控一关时间
  1148. var timeShut1
  1149. switch (timeshut1.length) {
  1150. case 1:
  1151. timeShut1 = '00' + ':' + '0' + timeshut1.substring(0, 1)
  1152. break;
  1153. case 2:
  1154. timeShut1 = '00' + ':' + timeshut1.substring(0, 2)
  1155. break;
  1156. case 3:
  1157. var timeShut1 = '0' + timeshut1.substring(0, 1) + ':' + timeshut1
  1158. .substring(1, 3)
  1159. break;
  1160. case 4:
  1161. var timeShut1 = timeshut1.substring(0, 2) + ':' + timeshut1
  1162. .substring(2, 4)
  1163. break;
  1164. }
  1165. //时控二开时间
  1166. var timeOpen2
  1167. switch (timeopen2.length) {
  1168. case 1:
  1169. timeOpen2 = '00' + ':' + '0' + timeopen2.substring(0, 1)
  1170. break;
  1171. case 2:
  1172. timeOpen2 = '00' + ':' + timeopen2.substring(0, 2)
  1173. break;
  1174. case 3:
  1175. var timeOpen2 = '0' + timeopen2.substring(0, 1) + ':' + timeopen2
  1176. .substring(1, 3)
  1177. break;
  1178. case 4:
  1179. var timeOpen2 = timeopen2.substring(0, 2) + ':' + timeopen2
  1180. .substring(2, 4)
  1181. break;
  1182. }
  1183. //时控二关时间
  1184. var timeShut2
  1185. switch (timeshut2.length) {
  1186. case 1:
  1187. timeShut2 = '00' + ':' + '0' + timeshut2.substring(0, 1)
  1188. break;
  1189. case 2:
  1190. timeShut2 = '00' + ':' + timeshut2.substring(0, 2)
  1191. break;
  1192. case 3:
  1193. var timeShut2 = '0' + timeshut2.substring(0, 1) + ':' + timeshut2
  1194. .substring(1, 3)
  1195. break;
  1196. case 4:
  1197. var timeShut2 = timeshut2.substring(0, 2) + ':' + timeshut2
  1198. .substring(2, 4)
  1199. break;
  1200. }
  1201. //功能1
  1202. for (var i = 0; i < par.length; i++) {
  1203. var engry = that.data.state
  1204. switch (par.substring(i, i + 1)) {
  1205. case "0":
  1206. switch (i) {
  1207. case 0:
  1208. engry[3] = false
  1209. that.setData({
  1210. state: engry
  1211. })
  1212. break;
  1213. case 1:
  1214. engry[2] = false
  1215. that.setData({
  1216. state: engry
  1217. })
  1218. break;
  1219. case 2:
  1220. that.setData({
  1221. fixed2: "固定"
  1222. })
  1223. break;
  1224. case 3:
  1225. that.setData({
  1226. fixed1: "固定"
  1227. })
  1228. break;
  1229. case 4:
  1230. engry[1] = false
  1231. that.setData({
  1232. state: engry
  1233. })
  1234. break;
  1235. case 5:
  1236. engry[0] = false
  1237. that.setData({
  1238. state: engry
  1239. })
  1240. break;
  1241. }
  1242. break;
  1243. case "1":
  1244. switch (i) {
  1245. case 0:
  1246. engry[3] = true
  1247. that.setData({
  1248. state: engry
  1249. })
  1250. break;
  1251. case 1:
  1252. engry[2] = true
  1253. that.setData({
  1254. state: engry
  1255. })
  1256. break;
  1257. case 2:
  1258. that.setData({
  1259. fixed2: "经纬"
  1260. })
  1261. break;
  1262. case 3:
  1263. that.setData({
  1264. fixed1: "经纬"
  1265. })
  1266. break;
  1267. case 4:
  1268. engry[1] = true
  1269. that.setData({
  1270. state: engry
  1271. })
  1272. break;
  1273. case 5:
  1274. engry[0] = true
  1275. that.setData({
  1276. state: engry
  1277. })
  1278. break;
  1279. }
  1280. break;
  1281. }
  1282. }
  1283. //功能2
  1284. for (let j = 0; j < qur.length; j++) {
  1285. var Engry = that.data.state1
  1286. switch (qur.substring(j, j + 1)) {
  1287. case "0":
  1288. switch (j) {
  1289. case 0:
  1290. that.setData({
  1291. fixed4: "固定"
  1292. })
  1293. break;
  1294. case 1:
  1295. that.setData({
  1296. fixed3: "固定"
  1297. })
  1298. break;
  1299. case 2:
  1300. Engry[1] = false
  1301. that.setData({
  1302. state1: Engry
  1303. })
  1304. break;
  1305. case 3:
  1306. Engry[0] = false
  1307. that.setData({
  1308. state1: Engry
  1309. })
  1310. break;
  1311. }
  1312. break;
  1313. case "1":
  1314. switch (j) {
  1315. case 0:
  1316. that.setData({
  1317. fixed4: "经纬"
  1318. })
  1319. break;
  1320. case 1:
  1321. that.setData({
  1322. fixed3: "经纬"
  1323. })
  1324. break;
  1325. case 2:
  1326. Engry[1] = true
  1327. that.setData({
  1328. state1: Engry
  1329. })
  1330. break;
  1331. case 3:
  1332. Engry[0] = true
  1333. that.setData({
  1334. state1: Engry
  1335. })
  1336. break;
  1337. }
  1338. break;
  1339. }
  1340. }
  1341. //日期调控
  1342. var controladdress = that.data.address
  1343. if (weeks == '0') {
  1344. for (let x = 0; x < 7; x++) {
  1345. controladdress[x] = "/image/false.png"
  1346. }
  1347. that.setData({
  1348. address: controladdress,
  1349. })
  1350. } else {
  1351. for (let i = 0; i < weeks.length; i++) {
  1352. switch (weeks.substring(i, i + 1)) {
  1353. case '0':
  1354. controladdress[weeks.length - i - 1] = "/image/false.png"
  1355. that.setData({
  1356. address: controladdress,
  1357. })
  1358. break;
  1359. case '1':
  1360. controladdress[weeks.length - i - 1] = "/image/true.png"
  1361. that.setData({
  1362. address: controladdress,
  1363. })
  1364. break;
  1365. }
  1366. }
  1367. }
  1368. //报警状态
  1369. police = parseInt(police)
  1370. police = police.toString(2)
  1371. switch (police.length) {
  1372. case 1:
  1373. police = '000' + police
  1374. break;
  1375. case 2:
  1376. police = '00' + police
  1377. break;
  1378. case 3:
  1379. police = '0' + police
  1380. break;
  1381. default:
  1382. police = police
  1383. break;
  1384. }
  1385. if (police.substring(1, 2) == '0' && police.substring(0, 1) == '0') {
  1386. that.setData({
  1387. radio1: true
  1388. })
  1389. } else if (police.substring(1, 2) == '1' && police.substring(0, 1) == '0') {
  1390. that.setData({
  1391. radio2: true
  1392. })
  1393. } else if (police.substring(1, 2) == '0' && police.substring(0, 1) == '1') {
  1394. that.setData({
  1395. radio3: true
  1396. })
  1397. }
  1398. var time = that.data.time
  1399. time[0] = timeOpen1
  1400. time[1] = timeShut1
  1401. time[2] = timeOpen2
  1402. time[3] = timeShut2
  1403. that.setData({
  1404. time: time
  1405. })
  1406. switch (that.data.state[0]) {
  1407. case true:
  1408. that.setData({
  1409. type1: "time",
  1410. timecontrolcolor1: "blue",
  1411. fontcolor1: "white",
  1412. })
  1413. break;
  1414. default:
  1415. that.setData({
  1416. type1: "",
  1417. timecontrolcolor1: "#888888",
  1418. fontcolor1: "#cccccc",
  1419. })
  1420. break;
  1421. }
  1422. switch (that.data.state[1]) {
  1423. case true:
  1424. that.setData({
  1425. type2: "time",
  1426. timecontrolcolor2: "blue",
  1427. fontcolor2: "white",
  1428. })
  1429. break;
  1430. default:
  1431. that.setData({
  1432. type2: "",
  1433. timecontrolcolor2: "#888888",
  1434. fontcolor2: "#cccccc",
  1435. })
  1436. break;
  1437. }
  1438. switch (that.data.state1[0]) {
  1439. case true:
  1440. that.setData({
  1441. type3: "time",
  1442. timecontrolcolor3: "blue",
  1443. fontcolor3: "white",
  1444. })
  1445. break;
  1446. default:
  1447. that.setData({
  1448. type3: "",
  1449. timecontrolcolor3: "#888888",
  1450. fontcolor3: "#cccccc",
  1451. })
  1452. break;
  1453. }
  1454. switch (that.data.state1[1]) {
  1455. case true:
  1456. that.setData({
  1457. type4: "time",
  1458. timecontrolcolor4: "blue",
  1459. fontcolor4: "white",
  1460. })
  1461. break;
  1462. default:
  1463. that.setData({
  1464. type4: "",
  1465. timecontrolcolor4: "#888888",
  1466. fontcolor4: "#cccccc",
  1467. })
  1468. break;
  1469. }
  1470. switch (that.data.state[2]) {
  1471. case true:
  1472. that.setData({
  1473. Lightcontrolcolor1: "blue",
  1474. fontcolor5: "white",
  1475. select1: "selector"
  1476. })
  1477. break;
  1478. default:
  1479. that.setData({
  1480. Lightcontrolcolor1: "#888888",
  1481. fontcolor5: "#cccccc",
  1482. select1: ""
  1483. })
  1484. break;
  1485. }
  1486. switch (that.data.state[3]) {
  1487. case true:
  1488. that.setData({
  1489. Lightcontrolcolor2: "blue",
  1490. fontcolor6: "white",
  1491. select2: "selector"
  1492. })
  1493. break;
  1494. default:
  1495. that.setData({
  1496. Lightcontrolcolor2: "#888888",
  1497. fontcolor6: "#cccccc",
  1498. select2: ""
  1499. })
  1500. break;
  1501. }
  1502. }
  1503. } else {
  1504. wx.showModal({
  1505. title: '错误',
  1506. content: res.data.error,
  1507. showCancel: false
  1508. })
  1509. }
  1510. })
  1511. }
  1512. //新设备
  1513. else {
  1514. var Equip = that.data.equipment //设备id
  1515. var crr = that.data.crr
  1516. if(crr[indexes] == '所有回路'){
  1517. return
  1518. }
  1519. getloop(Equip).then(suc => {
  1520. if (suc.data.code == 0) {
  1521. var suc = suc.data.data
  1522. var index = that.data.indexes
  1523. for (let i = 0; i < suc.length; i++) {
  1524. if (index == i) {
  1525. let Suc = suc[i]
  1526. var newSwitch = that.data.newSwitch
  1527. var timeValue = that.data.timeValue
  1528. var newSwitchstate = that.data.newSwitchstate
  1529. var choice = that.data.choice
  1530. var lightCondition = Suc.lightControlCondition
  1531. var model = Suc.ctlMode
  1532. var beginTime = Suc.realTimeCondition1OnTime
  1533. var closeTimes = Suc.realTimeCondition1OffTime
  1534. //光控启动条件
  1535. looplightlist().then(res => {
  1536. if (res.data.code == 0) {
  1537. var lightlist = res.data.data
  1538. that.setData({
  1539. lightlist: lightlist
  1540. })
  1541. for (let i = 0; i < lightlist.length; i++) {
  1542. choice[i] = false
  1543. }
  1544. if (lightCondition.includes(',') == true) {
  1545. lightCondition = lightCondition.split(',')
  1546. for (let j = 0; j < lightCondition.length; j++) {
  1547. if (lightCondition[j] == '1') {
  1548. choice[0] = true
  1549. } else if (lightCondition[j] == '2') {
  1550. choice[1] = true
  1551. } else if (lightCondition[j] == '3') {
  1552. choice[2] = true
  1553. } else if (lightCondition[j] == '4') {
  1554. choice[3] = true
  1555. }
  1556. }
  1557. } else {
  1558. if (lightCondition == '1') {
  1559. choice[0] = true
  1560. } else if (lightCondition == '2') {
  1561. choice[1] = true
  1562. } else if (lightCondition == '3') {
  1563. choice[2] = true
  1564. } else if (lightCondition == '4') {
  1565. choice[3] = true
  1566. }
  1567. }
  1568. that.setData({
  1569. choice: choice
  1570. })
  1571. } else {
  1572. wx.showModal({
  1573. title: '错误',
  1574. content: res.data.msg,
  1575. showCancel: false
  1576. })
  1577. }
  1578. })
  1579. //时控1
  1580. if (Suc.timeCondition1Switch == 1) {
  1581. newSwitch[0] = true
  1582. newSwitchstate[0] = 'time'
  1583. } else {
  1584. newSwitch[0] = false
  1585. newSwitchstate[0] = ''
  1586. }
  1587. timeValue[0] = Suc.timeCondition1OnTime
  1588. timeValue[1] = Suc.timeCondition1OffTime
  1589. //时控2
  1590. if (Suc.timeCondition2Switch == 1) {
  1591. newSwitch[1] = true
  1592. newSwitchstate[1] = 'time'
  1593. } else {
  1594. newSwitch[1] = false
  1595. newSwitchstate[1] = ''
  1596. }
  1597. timeValue[2] = Suc.timeCondition2OnTime
  1598. timeValue[3] = Suc.timeCondition2OffTime
  1599. //光控
  1600. if (Suc.lightControlSwitch == 1) {
  1601. newSwitch[2] = true
  1602. newSwitchstate[2] = 'time'
  1603. newSwitchstate[3] = 'selector'
  1604. } else {
  1605. newSwitch[2] = false
  1606. newSwitchstate[2] = ''
  1607. newSwitchstate[3] = ''
  1608. }
  1609. timeValue[4] = Suc.lightControlStart
  1610. timeValue[5] = Suc.lightControlEnd
  1611. for (let j = 0; j < timeValue.length; j++) {
  1612. if (timeValue[j] == "") {
  1613. timeValue[j] = '00:00'
  1614. }
  1615. }
  1616. that.setData({
  1617. timeValue: timeValue,
  1618. newSwitch: newSwitch,
  1619. newChange:model,
  1620. beginTime:beginTime,
  1621. closeTimes:closeTimes
  1622. })
  1623. //监视新设备开关状态
  1624. var newSwitchs = that.data.newSwitch
  1625. var newfonts = that.data.newfont
  1626. var newcolors = that.data.newcolor
  1627. var newSwitchstates = that.data.newSwitchstate
  1628. var disableds = that.data.disabled
  1629. if (newSwitchs[0] == true) {
  1630. newfonts[0] = "white"
  1631. newcolors[0] = "blue"
  1632. newSwitchstates[0] = "time"
  1633. } else {
  1634. newfonts[0] = "#cccccc"
  1635. newcolors[0] = "#888888"
  1636. newSwitchstates[0] = ""
  1637. }
  1638. if (newSwitchs[1] == true) {
  1639. newfonts[1] = "white"
  1640. newcolors[1] = "blue"
  1641. newSwitchstates[1] = "time"
  1642. } else {
  1643. newfonts[1] = "#cccccc"
  1644. newcolors[1] = "#888888"
  1645. newSwitchstates[1] = ""
  1646. }
  1647. if (newSwitchs[2] == true) {
  1648. newfonts[2] = "white"
  1649. newcolors[2] = "blue"
  1650. newSwitchstates[2] = "time"
  1651. disableds = false
  1652. } else {
  1653. newfonts[2] = "#cccccc"
  1654. newcolors[2] = "#888888"
  1655. newSwitchstates[2] = ""
  1656. disableds = true
  1657. }
  1658. that.setData({
  1659. newcolor: newcolors,
  1660. newfont: newfonts,
  1661. newSwitch: newSwitchs,
  1662. newSwitchstate: newSwitchstates,
  1663. disabled: disableds
  1664. })
  1665. }
  1666. }
  1667. } else {
  1668. console.log('获取新设备回路参数失败')
  1669. wx.showModal({
  1670. title: '错误',
  1671. content: suc.data.msg,
  1672. showCancel: false
  1673. })
  1674. }
  1675. })
  1676. }
  1677. },
  1678. //新设备模式切换
  1679. newChange: function(e) {
  1680. var that = this
  1681. var beginTime = that.data.beginTime
  1682. var closeTimes = that.data.closeTimes
  1683. if (that.data.newChange == 0) {
  1684. wx.showModal({
  1685. title: '切换为经纬模式',
  1686. content: '经纬时间:开启时间:' + beginTime + ',关闭时间:' + closeTimes,
  1687. success(res) {
  1688. if (res.confirm) {
  1689. that.setData({
  1690. newChange: 1
  1691. })
  1692. }
  1693. }
  1694. })
  1695. } else {
  1696. wx.showModal({
  1697. title: '切换为手动模式',
  1698. content: '经纬时间:开启时间:' + beginTime + ',关闭时间:' + closeTimes,
  1699. success(res) {
  1700. if (res.confirm) {
  1701. that.setData({
  1702. newChange: 0
  1703. })
  1704. }
  1705. }
  1706. })
  1707. }
  1708. },
  1709. //时间调控
  1710. //时控开关选择器(1-4旧设备,5-6新设备)
  1711. Controltime1: function() {
  1712. var obtain1 = this.data.state
  1713. obtain1[0] = !obtain1[0]
  1714. if (obtain1[0] == true) {
  1715. this.setData({
  1716. type1: "time",
  1717. timecontrolcolor1: "blue",
  1718. fontcolor1: "white",
  1719. state: obtain1
  1720. })
  1721. } else {
  1722. this.setData({
  1723. type1: "",
  1724. timecontrolcolor1: "#888888",
  1725. fontcolor1: "#cccccc",
  1726. state: obtain1
  1727. })
  1728. }
  1729. },
  1730. Controltime2: function() {
  1731. var obtain2 = this.data.state
  1732. obtain2[1] = !obtain2[1]
  1733. if (obtain2[1] == true) {
  1734. this.setData({
  1735. type2: "time",
  1736. timecontrolcolor2: "blue",
  1737. fontcolor2: "white",
  1738. state: obtain2
  1739. })
  1740. } else {
  1741. this.setData({
  1742. type2: "",
  1743. timecontrolcolor2: "#888888",
  1744. fontcolor2: "#cccccc",
  1745. state: obtain2
  1746. })
  1747. }
  1748. },
  1749. Controltime3: function() {
  1750. var obtain3 = this.data.state1
  1751. obtain3[0] = !obtain3[0]
  1752. if (obtain3[0] == true) {
  1753. this.setData({
  1754. type3: "time",
  1755. timecontrolcolor3: "blue",
  1756. fontcolor3: "white",
  1757. state1: obtain3
  1758. })
  1759. } else {
  1760. this.setData({
  1761. type3: "",
  1762. timecontrolcolor3: "#888888",
  1763. fontcolor3: "#cccccc",
  1764. state1: obtain3
  1765. })
  1766. }
  1767. },
  1768. Controltime4: function() {
  1769. var obtain4 = this.data.state1
  1770. obtain4[1] = !obtain4[1]
  1771. if (obtain4[1] == true) {
  1772. this.setData({
  1773. type4: "time",
  1774. timecontrolcolor4: "blue",
  1775. fontcolor4: "white",
  1776. state1: obtain4
  1777. })
  1778. } else {
  1779. this.setData({
  1780. type4: "",
  1781. timecontrolcolor4: "#888888",
  1782. fontcolor4: "#cccccc",
  1783. state1: obtain4
  1784. })
  1785. }
  1786. },
  1787. Controltime5: function() {
  1788. let newSwitch = this.data.newSwitch
  1789. let newcolor = this.data.newcolor
  1790. let newfont = this.data.newfont
  1791. let newSwitchstate = this.data.newSwitchstate
  1792. newSwitch[0] = !newSwitch[0]
  1793. if (newSwitch[0] == true) {
  1794. newcolor[0] = "blue"
  1795. newfont[0] = "white"
  1796. newSwitchstate[0] = "time"
  1797. } else {
  1798. newcolor[0] = "#888888"
  1799. newfont[0] = "#cccccc"
  1800. newSwitchstate[0] = ""
  1801. }
  1802. this.setData({
  1803. newSwitch: newSwitch,
  1804. newcolor: newcolor,
  1805. newfont,
  1806. newfont,
  1807. newSwitchstate: newSwitchstate
  1808. })
  1809. },
  1810. Controltime6: function() {
  1811. let newSwitch = this.data.newSwitch
  1812. let newcolor = this.data.newcolor
  1813. let newfont = this.data.newfont
  1814. let newSwitchstate = this.data.newSwitchstate
  1815. newSwitch[1] = !newSwitch[1]
  1816. if (newSwitch[1] == true) {
  1817. newcolor[1] = "blue"
  1818. newfont[1] = "white"
  1819. newSwitchstate[1] = "time"
  1820. } else {
  1821. newcolor[1] = "#888888"
  1822. newfont[1] = "#cccccc"
  1823. newSwitchstate[1] = ""
  1824. }
  1825. this.setData({
  1826. newSwitch: newSwitch,
  1827. newcolor: newcolor,
  1828. newfont: newfont,
  1829. newSwitchstate: newSwitchstate
  1830. })
  1831. },
  1832. Controltime7: function() {
  1833. let newSwitch = this.data.newSwitch
  1834. let newcolor = this.data.newcolor
  1835. let newfont = this.data.newfont
  1836. let newSwitchstate = this.data.newSwitchstate
  1837. let disabled = this.data.disabled
  1838. newSwitch[2] = !newSwitch[2]
  1839. if (newSwitch[2] == true) {
  1840. newcolor[2] = "blue"
  1841. newfont[2] = "white"
  1842. newSwitchstate[2] = "time"
  1843. newSwitchstate[3] = "selector"
  1844. disabled = false
  1845. } else {
  1846. newcolor[2] = "#888888"
  1847. newfont[2] = "#cccccc"
  1848. newSwitchstate[2] = ""
  1849. newSwitchstate[3] = ""
  1850. disabled = true
  1851. }
  1852. this.setData({
  1853. newSwitch: newSwitch,
  1854. newcolor: newcolor,
  1855. newfont: newfont,
  1856. newSwitchstate: newSwitchstate,
  1857. disabled: disabled
  1858. })
  1859. },
  1860. //固定与经纬的切换
  1861. change1: function() {
  1862. var change1 = this.data.fixed1
  1863. if (change1 == "固定" && this.data.state[0] == true) {
  1864. this.setData({
  1865. fixed1: "经纬"
  1866. })
  1867. } else if (change1 == "经纬" && this.data.state[0] == true) {
  1868. this.setData({
  1869. fixed1: "固定"
  1870. })
  1871. }
  1872. },
  1873. change2: function() {
  1874. var change2 = this.data.fixed2
  1875. if (change2 == "固定" && this.data.state[1] == true) {
  1876. this.setData({
  1877. fixed2: "经纬"
  1878. })
  1879. } else if (change2 == "经纬" && this.data.state[1] == true) {
  1880. this.setData({
  1881. fixed2: "固定"
  1882. })
  1883. }
  1884. },
  1885. change3: function() {
  1886. var change3 = this.data.fixed3
  1887. if (change3 == "固定") {
  1888. this.setData({
  1889. fixed3: "经纬"
  1890. })
  1891. } else {
  1892. this.setData({
  1893. fixed3: "固定"
  1894. })
  1895. }
  1896. },
  1897. change4: function() {
  1898. var change4 = this.data.fixed4
  1899. if (change4 == "固定") {
  1900. this.setData({
  1901. fixed4: "经纬"
  1902. })
  1903. } else {
  1904. this.setData({
  1905. fixed4: "固定"
  1906. })
  1907. }
  1908. },
  1909. //显示改变后的时间的值(1-4旧设备,5-11新设备)
  1910. bindTimeChange1: function(e) {
  1911. let time = this.data.time
  1912. time[0] = e.detail.value
  1913. this.setData({
  1914. time: time
  1915. })
  1916. },
  1917. bindTimeChange2: function(e) {
  1918. let time = this.data.time
  1919. time[1] = e.detail.value
  1920. this.setData({
  1921. time: time
  1922. })
  1923. },
  1924. bindTimeChange3: function(e) {
  1925. let time = this.data.time
  1926. time[2] = e.detail.value
  1927. this.setData({
  1928. time: time
  1929. })
  1930. },
  1931. bindTimeChange4: function(e) {
  1932. let time = this.data.time
  1933. time[3] = e.detail.value
  1934. this.setData({
  1935. time: time
  1936. })
  1937. },
  1938. bindTimeChange5: function(e) {
  1939. let time = this.data.timeValue
  1940. time[0] = e.detail.value
  1941. this.setData({
  1942. timeValue: time
  1943. })
  1944. },
  1945. bindTimeChange6: function(e) {
  1946. let time = this.data.timeValue
  1947. time[1] = e.detail.value
  1948. this.setData({
  1949. timeValue: time
  1950. })
  1951. },
  1952. bindTimeChange7: function(e) {
  1953. let time = this.data.timeValue
  1954. time[2] = e.detail.value
  1955. this.setData({
  1956. timeValue: time
  1957. })
  1958. },
  1959. bindTimeChange8: function(e) {
  1960. let time = this.data.timeValue
  1961. time[3] = e.detail.value
  1962. this.setData({
  1963. timeValue: time
  1964. })
  1965. },
  1966. bindTimeChange9: function(e) {
  1967. let time = this.data.timeValue
  1968. time[4] = e.detail.value
  1969. this.setData({
  1970. timeValue: time
  1971. })
  1972. },
  1973. bindTimeChange10: function(e) {
  1974. let time = this.data.timeValue
  1975. time[5] = e.detail.value
  1976. this.setData({
  1977. timeValue: time
  1978. })
  1979. },
  1980. //日期调控(图片切换)
  1981. setbuty0: function() {
  1982. var that = this
  1983. var a0 = that.data.address
  1984. if (that.data.address[0] == "/image/true.png") {
  1985. a0[0] = "/image/false.png"
  1986. this.setData({
  1987. address: a0,
  1988. })
  1989. } else {
  1990. a0[0] = "/image/true.png"
  1991. this.setData({
  1992. address: a0,
  1993. })
  1994. }
  1995. },
  1996. setbuty1: function() {
  1997. var that = this
  1998. var a1 = that.data.address
  1999. if (that.data.address[1] == "/image/true.png") {
  2000. a1[1] = "/image/false.png"
  2001. this.setData({
  2002. address: a1,
  2003. })
  2004. } else {
  2005. a1[1] = "/image/true.png"
  2006. this.setData({
  2007. address: a1,
  2008. })
  2009. }
  2010. },
  2011. setbuty2: function() {
  2012. var that = this
  2013. var a2 = that.data.address
  2014. if (that.data.address[2] == "/image/true.png") {
  2015. a2[2] = "/image/false.png"
  2016. this.setData({
  2017. address: a2,
  2018. })
  2019. } else {
  2020. a2[2] = "/image/true.png"
  2021. this.setData({
  2022. address: a2,
  2023. })
  2024. }
  2025. },
  2026. setbuty3: function() {
  2027. var that = this
  2028. var a3 = that.data.address
  2029. if (that.data.address[3] == "/image/true.png") {
  2030. a3[3] = "/image/false.png"
  2031. this.setData({
  2032. address: a3,
  2033. })
  2034. } else {
  2035. a3[3] = "/image/true.png"
  2036. this.setData({
  2037. address: a3,
  2038. })
  2039. }
  2040. },
  2041. setbuty4: function() {
  2042. var that = this
  2043. var a4 = that.data.address
  2044. if (that.data.address[4] == "/image/true.png") {
  2045. a4[4] = "/image/false.png"
  2046. this.setData({
  2047. address: a4,
  2048. })
  2049. } else {
  2050. a4[4] = "/image/true.png"
  2051. this.setData({
  2052. address: a4,
  2053. })
  2054. }
  2055. },
  2056. setbuty5: function() {
  2057. var that = this
  2058. var a5 = that.data.address
  2059. if (that.data.address[5] == "/image/true.png") {
  2060. a5[5] = "/image/false.png"
  2061. this.setData({
  2062. address: a5,
  2063. })
  2064. } else {
  2065. a5[5] = "/image/true.png"
  2066. this.setData({
  2067. address: a5,
  2068. })
  2069. }
  2070. },
  2071. setbuty6: function() {
  2072. var that = this
  2073. var a6 = that.data.address
  2074. if (that.data.address[6] == "/image/true.png") {
  2075. a6[6] = "/image/false.png"
  2076. this.setData({
  2077. address: a6,
  2078. })
  2079. } else {
  2080. a6[6] = "/image/true.png"
  2081. this.setData({
  2082. address: a6,
  2083. })
  2084. }
  2085. },
  2086. //光控
  2087. //光控开关选择器
  2088. Controllight1: function() {
  2089. var Lightstatus = this.data.state
  2090. Lightstatus[2] = !Lightstatus[2]
  2091. if (Lightstatus[2] == true) {
  2092. for (let a = 0; a < 100; a++) {
  2093. var arr1 = this.data.arr
  2094. arr1[a] = a
  2095. }
  2096. this.setData({
  2097. arr: arr1,
  2098. fontcolor5: "white",
  2099. Lightcontrolcolor1: "blue",
  2100. select1: "selector"
  2101. })
  2102. } else {
  2103. this.setData({
  2104. Lightcontrolcolor1: "#888888",
  2105. fontcolor5: "#cccccc",
  2106. select1: ""
  2107. })
  2108. }
  2109. },
  2110. Controllight2: function() {
  2111. var Lightstatus = this.data.state
  2112. Lightstatus[3] = !Lightstatus[3]
  2113. if (Lightstatus[3] == true) {
  2114. for (let a = 0; a < 100; a++) {
  2115. var arr1 = this.data.arr
  2116. arr1[a] = a
  2117. }
  2118. this.setData({
  2119. arr: arr1,
  2120. fontcolor6: "white",
  2121. Lightcontrolcolor2: "blue",
  2122. select2: "selector"
  2123. })
  2124. } else {
  2125. this.setData({
  2126. Lightcontrolcolor2: "#888888",
  2127. fontcolor6: "#cccccc",
  2128. select2: ""
  2129. })
  2130. }
  2131. },
  2132. //调整光控显示的值
  2133. bindPickerChange1: function(e) {
  2134. this.setData({
  2135. index: e.detail.value
  2136. })
  2137. },
  2138. bindPickerChange2: function(e) {
  2139. this.setData({
  2140. indexs: e.detail.value
  2141. })
  2142. },
  2143. //报警状态
  2144. Changestate1: function() {
  2145. this.setData({
  2146. radio1: true,
  2147. radio2: false,
  2148. radio3: false,
  2149. alert: "1"
  2150. })
  2151. },
  2152. Changestate2: function() {
  2153. this.setData({
  2154. radio1: false,
  2155. radio2: true,
  2156. radio3: false,
  2157. alert: "5"
  2158. })
  2159. },
  2160. Changestate3: function() {
  2161. this.setData({
  2162. radio1: false,
  2163. radio2: false,
  2164. radio3: true,
  2165. alert: "9"
  2166. })
  2167. },
  2168. //刷新页面
  2169. RefreshPage: function() {
  2170. wx.showToast({
  2171. title: '刷新中',
  2172. icon: 'loading',
  2173. duration: 2000
  2174. })
  2175. var that = this
  2176. //获取机型改变switch大小
  2177. wx.getSystemInfo({
  2178. success: function(res) {
  2179. if (res.model == 'iPad' || res.model == 'iPad Pro 10.5-inch' || res.model ==
  2180. 'iPad Pro 12.9-inch') {
  2181. that.setData({
  2182. zoom: 1
  2183. })
  2184. }
  2185. }
  2186. })
  2187. var group = wx.getStorageSync('group')
  2188. if (group != null && group.length != 0) {
  2189. //分组下拉
  2190. var group = wx.getStorageSync('group')
  2191. var groups = []
  2192. for (let i = 0; i < group.length; i++) {
  2193. groups.push(group[i].groupName)
  2194. }
  2195. that.setData({
  2196. groupName: groups
  2197. })
  2198. //改变分组下标
  2199. if (wx.getStorageSync('groupName') != '') {
  2200. let GroupName = groups
  2201. for (let n = 0; n < GroupName.length; n++) {
  2202. if (GroupName[n] == wx.getStorageSync('groupName')) {
  2203. that.setData({
  2204. groupIndex: n
  2205. })
  2206. }
  2207. }
  2208. } else {
  2209. wx.setStorageSync('groupName', groups[0])
  2210. }
  2211. //设备下拉
  2212. var device = []
  2213. var groupName = that.data.groupName
  2214. var groupIndex = that.data.groupIndex
  2215. for (let j = 0; j < group.length; j++) {
  2216. if (groupName[groupIndex] == group[j].groupName) {
  2217. if (group[j].devices != null && group[j].devices.length != 0) {
  2218. for (let p = 0; p < group[j].devices.length; p++) {
  2219. device.push(group[j].devices[p].deviceName)
  2220. }
  2221. that.setData({
  2222. deviceName: device
  2223. })
  2224. //改变设备下标
  2225. if (wx.getStorageSync('deviceName') != '') {
  2226. for (let m = 0; m < device.length; m++) {
  2227. if (device[m] == wx.getStorageSync('deviceName')) {
  2228. that.setData({
  2229. deviceIndex: m
  2230. })
  2231. }
  2232. }
  2233. } else {
  2234. wx.setStorageSync('deviceName', device[0])
  2235. }
  2236. //获取设备信息
  2237. var currentGroup = that.data.groupName[that.data.groupIndex]
  2238. var currentDevice = that.data.deviceName[that.data.deviceIndex]
  2239. var message = enloop.deviceMessage(currentGroup, currentDevice)
  2240. that.setData({
  2241. equipment: message.Device,
  2242. subset: message.id,
  2243. }) //记录当前的设备id和分组id
  2244. //旧设备
  2245. if (message.modules == 0) {
  2246. that.setData({
  2247. play: 0,
  2248. deviceKey: message.deviceKey,
  2249. deviceId: message.deviceId
  2250. })
  2251. getBasic(message.deviceId, message.deviceKey).then(res => {
  2252. if (res.data.errno == 0) {
  2253. if (res.data.data.online == true) {
  2254. that.setData({
  2255. status: '在线'
  2256. })
  2257. } else {
  2258. that.setData({
  2259. status: '离线'
  2260. })
  2261. }
  2262. getData(message.deviceId, message.deviceKey).then(ever => {
  2263. if (ever.data.errno == 0) {
  2264. var {
  2265. data
  2266. } = ever.data
  2267. //判断设备是否处于初始化状态
  2268. var initialization = true
  2269. for (let t = 0; t < data.length; t++) {
  2270. if ('current_value' in data[t] == false) {
  2271. initialization = false
  2272. }
  2273. }
  2274. if (initialization == true) {
  2275. var Indexes = that.data.indexes
  2276. Indexes = Indexes + 1
  2277. var crr = that.data.crr.length
  2278. if (Indexes == crr) {
  2279. } else {
  2280. //以下为回路
  2281. for (let i = 1; i < data.length; i++) {
  2282. //时控一开时间
  2283. if (data[i].id == "R" + Indexes +
  2284. "_DayOpenTime1") {
  2285. var timeopen1 = data[i]
  2286. .current_value
  2287. }
  2288. //时控一关时间
  2289. else if (data[i].id == "R" +
  2290. Indexes + "_DayCloseTime1") {
  2291. var timeshut1 = data[i]
  2292. .current_value
  2293. }
  2294. //时控二开时间
  2295. else if (data[i].id == "R" +
  2296. Indexes + "_DayOpenTime2") {
  2297. var timeopen2 = data[i]
  2298. .current_value
  2299. }
  2300. //时控二关时间
  2301. else if (data[i].id == "R" +
  2302. Indexes + "_DayCloseTime2") {
  2303. var timeshut2 = data[i]
  2304. .current_value
  2305. }
  2306. //日期调控
  2307. else if (data[i].id == "R" +
  2308. Indexes + "_Week") {
  2309. var weeks = data[i]
  2310. .current_value
  2311. that.setData({
  2312. recorddate: weeks
  2313. })
  2314. weeks = parseInt(weeks)
  2315. weeks = weeks.toString(2)
  2316. weeks = weeks + ''
  2317. if (weeks != '0') {
  2318. weeks = weeks.slice(1)
  2319. }
  2320. }
  2321. //功能一
  2322. else if (data[i].id == "R" +
  2323. Indexes + "_FunctionStatus1") {
  2324. var Function1 = data[i]
  2325. .current_value
  2326. var par = parseInt(Function1)
  2327. par = par.toString(2)
  2328. par = par + ''
  2329. switch (par.length) {
  2330. case 1:
  2331. par = '00000' + par
  2332. break;
  2333. case 2:
  2334. par = '0000' + par
  2335. break;
  2336. case 3:
  2337. par = '000' + par
  2338. break;
  2339. case 4:
  2340. par = '00' + par
  2341. break;
  2342. case 5:
  2343. par = '0' + par
  2344. break;
  2345. default:
  2346. par = par
  2347. }
  2348. }
  2349. //功能二
  2350. else if (data[i].id == "R" +
  2351. Indexes + "_FunctionStatus2") {
  2352. var Function2 = data[i]
  2353. .current_value
  2354. var qur = parseInt(Function2)
  2355. qur = qur.toString(2)
  2356. qur = qur + ''
  2357. switch (qur.length) {
  2358. case 1:
  2359. qur = '000' + qur
  2360. break;
  2361. case 2:
  2362. qur = '00' + qur
  2363. break;
  2364. case 3:
  2365. qur = '0' + qur
  2366. break;
  2367. case 4:
  2368. qur = qur
  2369. break;
  2370. }
  2371. }
  2372. //报警
  2373. else if (data[i].id == "R" +
  2374. Indexes + "_RelayStatus") {
  2375. var police = data[i]
  2376. .current_value
  2377. }
  2378. //光控开
  2379. else if (data[i].id == "R" +
  2380. Indexes + "_LcOn") {
  2381. var Lightcontrolopen = data[i]
  2382. .current_value
  2383. var trr = that.data.arr
  2384. for (let i = 0; i < 100; i++) {
  2385. trr[i] = i
  2386. }
  2387. Lightcontrolopen = parseInt(
  2388. Lightcontrolopen)
  2389. that.setData({
  2390. arr: trr,
  2391. index: Lightcontrolopen
  2392. })
  2393. }
  2394. //光控关
  2395. else if (data[i].id == "R" +
  2396. Indexes + "_LcOff") {
  2397. var Lightcontrolshut = data[i]
  2398. .current_value
  2399. var prr = that.data.brr
  2400. for (let j = 0; j < 100; j++) {
  2401. prr[j] = j
  2402. }
  2403. Lightcontrolshut = parseInt(
  2404. Lightcontrolshut)
  2405. that.setData({
  2406. brr: prr,
  2407. indexs: Lightcontrolshut
  2408. })
  2409. }
  2410. }
  2411. //时控一开时间
  2412. var timeOpen1
  2413. switch (timeopen1.length) {
  2414. case 1:
  2415. timeOpen1 = '00' + ':' + '0' +
  2416. timeopen1.substring(0, 1)
  2417. break;
  2418. case 2:
  2419. timeOpen1 = '00' + ':' +
  2420. timeopen1.substring(0, 2)
  2421. break;
  2422. case 3:
  2423. var timeOpen1 = '0' + timeopen1
  2424. .substring(0, 1) + ':' +
  2425. timeopen1.substring(1, 3)
  2426. break;
  2427. case 4:
  2428. var timeOpen1 = timeopen1
  2429. .substring(0, 2) + ':' +
  2430. timeopen1.substring(2, 4)
  2431. break;
  2432. }
  2433. //时控一关时间
  2434. var timeShut1
  2435. switch (timeshut1.length) {
  2436. case 1:
  2437. timeShut1 = '00' + ':' + '0' +
  2438. timeshut1.substring(0, 1)
  2439. break;
  2440. case 2:
  2441. timeShut1 = '00' + ':' +
  2442. timeshut1.substring(0, 2)
  2443. break;
  2444. case 3:
  2445. var timeShut1 = '0' + timeshut1
  2446. .substring(0, 1) + ':' +
  2447. timeshut1.substring(1, 3)
  2448. break;
  2449. case 4:
  2450. var timeShut1 = timeshut1
  2451. .substring(0, 2) + ':' +
  2452. timeshut1.substring(2, 4)
  2453. break;
  2454. }
  2455. //时控二开时间
  2456. var timeOpen2
  2457. switch (timeopen2.length) {
  2458. case 1:
  2459. timeOpen2 = '00' + ':' + '0' +
  2460. timeopen2.substring(0, 1)
  2461. break;
  2462. case 2:
  2463. timeOpen2 = '00' + ':' +
  2464. timeopen2.substring(0, 2)
  2465. break;
  2466. case 3:
  2467. var timeOpen2 = '0' + timeopen2
  2468. .substring(0, 1) + ':' +
  2469. timeopen2.substring(1, 3)
  2470. break;
  2471. case 4:
  2472. var timeOpen2 = timeopen2
  2473. .substring(0, 2) + ':' +
  2474. timeopen2.substring(2, 4)
  2475. break;
  2476. }
  2477. //时控二关时间
  2478. var timeShut2
  2479. switch (timeshut2.length) {
  2480. case 1:
  2481. timeShut2 = '00' + ':' + '0' +
  2482. timeshut2.substring(0, 1)
  2483. break;
  2484. case 2:
  2485. timeShut2 = '00' + ':' +
  2486. timeshut2.substring(0, 2)
  2487. break;
  2488. case 3:
  2489. var timeShut2 = '0' + timeshut2
  2490. .substring(0, 1) + ':' +
  2491. timeshut2.substring(1, 3)
  2492. break;
  2493. case 4:
  2494. var timeShut2 = timeshut2
  2495. .substring(0, 2) + ':' +
  2496. timeshut2.substring(2, 4)
  2497. break;
  2498. }
  2499. //功能1
  2500. for (var i = 0; i < par.length; i++) {
  2501. var engry = that.data.state
  2502. switch (par.substring(i, i + 1)) {
  2503. case "0":
  2504. switch (i) {
  2505. case 0:
  2506. engry[3] = false
  2507. that.setData({
  2508. state: engry
  2509. })
  2510. break;
  2511. case 1:
  2512. engry[2] = false
  2513. that.setData({
  2514. state: engry
  2515. })
  2516. break;
  2517. case 2:
  2518. that.setData({
  2519. fixed2: "固定"
  2520. })
  2521. break;
  2522. case 3:
  2523. that.setData({
  2524. fixed1: "固定"
  2525. })
  2526. break;
  2527. case 4:
  2528. engry[1] = false
  2529. that.setData({
  2530. state: engry
  2531. })
  2532. break;
  2533. case 5:
  2534. engry[0] = false
  2535. that.setData({
  2536. state: engry
  2537. })
  2538. break;
  2539. }
  2540. break;
  2541. case "1":
  2542. switch (i) {
  2543. case 0:
  2544. engry[3] = true
  2545. that.setData({
  2546. state: engry
  2547. })
  2548. break;
  2549. case 1:
  2550. engry[2] = true
  2551. that.setData({
  2552. state: engry
  2553. })
  2554. break;
  2555. case 2:
  2556. that.setData({
  2557. fixed2: "经纬"
  2558. })
  2559. break;
  2560. case 3:
  2561. that.setData({
  2562. fixed1: "经纬"
  2563. })
  2564. break;
  2565. case 4:
  2566. engry[1] = true
  2567. that.setData({
  2568. state: engry
  2569. })
  2570. break;
  2571. case 5:
  2572. engry[0] = true
  2573. that.setData({
  2574. state: engry
  2575. })
  2576. break;
  2577. }
  2578. break;
  2579. }
  2580. }
  2581. //功能2
  2582. for (let j = 0; j < qur.length; j++) {
  2583. var Engry = that.data.state1
  2584. switch (qur.substring(j, j + 1)) {
  2585. case "0":
  2586. switch (j) {
  2587. case 0:
  2588. that.setData({
  2589. fixed4: "固定"
  2590. })
  2591. break;
  2592. case 1:
  2593. that.setData({
  2594. fixed3: "固定"
  2595. })
  2596. break;
  2597. case 2:
  2598. Engry[1] = false
  2599. that.setData({
  2600. state1: Engry
  2601. })
  2602. break;
  2603. case 3:
  2604. Engry[0] = false
  2605. that.setData({
  2606. state1: Engry
  2607. })
  2608. break;
  2609. }
  2610. break;
  2611. case "1":
  2612. switch (j) {
  2613. case 0:
  2614. that.setData({
  2615. fixed4: "经纬"
  2616. })
  2617. break;
  2618. case 1:
  2619. that.setData({
  2620. fixed3: "经纬"
  2621. })
  2622. break;
  2623. case 2:
  2624. Engry[1] = true
  2625. that.setData({
  2626. state1: Engry
  2627. })
  2628. break;
  2629. case 3:
  2630. Engry[0] = true
  2631. that.setData({
  2632. state1: Engry
  2633. })
  2634. break;
  2635. }
  2636. break;
  2637. }
  2638. }
  2639. //日期调控
  2640. var controladdress = that.data.address
  2641. if (weeks == '0') {
  2642. for (let x = 0; x < 7; x++) {
  2643. controladdress[x] =
  2644. "/image/false.png"
  2645. }
  2646. that.setData({
  2647. address: controladdress,
  2648. })
  2649. } else {
  2650. for (let i = 0; i < weeks
  2651. .length; i++) {
  2652. switch (weeks.substring(i, i +
  2653. 1)) {
  2654. case '0':
  2655. controladdress[weeks
  2656. .length - i - 1
  2657. ] =
  2658. "/image/false.png"
  2659. that.setData({
  2660. address: controladdress,
  2661. })
  2662. break;
  2663. case '1':
  2664. controladdress[weeks
  2665. .length - i - 1
  2666. ] =
  2667. "/image/true.png"
  2668. that.setData({
  2669. address: controladdress,
  2670. })
  2671. break;
  2672. }
  2673. }
  2674. }
  2675. //报警状态
  2676. police = parseInt(police)
  2677. police = police.toString(2)
  2678. switch (police.length) {
  2679. case 1:
  2680. police = '000' + police
  2681. break;
  2682. case 2:
  2683. police = '00' + police
  2684. break;
  2685. case 3:
  2686. police = '0' + police
  2687. break;
  2688. default:
  2689. police = police
  2690. break;
  2691. }
  2692. if (police.substring(1, 2) == '0' &&
  2693. police.substring(0, 1) == '0') {
  2694. that.setData({
  2695. radio1: true
  2696. })
  2697. } else if (police.substring(1, 2) ==
  2698. '1' && police.substring(0, 1) == '0'
  2699. ) {
  2700. that.setData({
  2701. radio2: true
  2702. })
  2703. } else if (police.substring(1, 2) ==
  2704. '0' && police.substring(0, 1) == '1'
  2705. ) {
  2706. that.setData({
  2707. radio3: true
  2708. })
  2709. }
  2710. var time = that.data.time
  2711. time[0] = timeOpen1
  2712. time[1] = timeShut1
  2713. time[2] = timeOpen2
  2714. time[3] = timeShut2
  2715. that.setData({
  2716. time: time
  2717. })
  2718. switch (that.data.state[0]) {
  2719. case true:
  2720. that.setData({
  2721. type1: "time",
  2722. timecontrolcolor1: "blue",
  2723. fontcolor1: "white",
  2724. })
  2725. break;
  2726. default:
  2727. that.setData({
  2728. type1: "",
  2729. timecontrolcolor1: "#888888",
  2730. fontcolor1: "#cccccc",
  2731. })
  2732. break;
  2733. }
  2734. switch (that.data.state[1]) {
  2735. case true:
  2736. that.setData({
  2737. type2: "time",
  2738. timecontrolcolor2: "blue",
  2739. fontcolor2: "white",
  2740. })
  2741. break;
  2742. default:
  2743. that.setData({
  2744. type2: "",
  2745. timecontrolcolor2: "#888888",
  2746. fontcolor2: "#cccccc",
  2747. })
  2748. break;
  2749. }
  2750. switch (that.data.state1[0]) {
  2751. case true:
  2752. that.setData({
  2753. type3: "time",
  2754. timecontrolcolor3: "blue",
  2755. fontcolor3: "white",
  2756. })
  2757. break;
  2758. default:
  2759. that.setData({
  2760. type3: "",
  2761. timecontrolcolor3: "#888888",
  2762. fontcolor3: "#cccccc",
  2763. })
  2764. break;
  2765. }
  2766. switch (that.data.state1[1]) {
  2767. case true:
  2768. that.setData({
  2769. type4: "time",
  2770. timecontrolcolor4: "blue",
  2771. fontcolor4: "white",
  2772. })
  2773. break;
  2774. default:
  2775. that.setData({
  2776. type4: "",
  2777. timecontrolcolor4: "#888888",
  2778. fontcolor4: "#cccccc",
  2779. })
  2780. break;
  2781. }
  2782. switch (that.data.state[2]) {
  2783. case true:
  2784. that.setData({
  2785. Lightcontrolcolor1: "blue",
  2786. fontcolor5: "white",
  2787. select1: "selector"
  2788. })
  2789. break;
  2790. default:
  2791. that.setData({
  2792. Lightcontrolcolor1: "#888888",
  2793. fontcolor5: "#cccccc",
  2794. select1: ""
  2795. })
  2796. break;
  2797. }
  2798. switch (that.data.state[3]) {
  2799. case true:
  2800. that.setData({
  2801. Lightcontrolcolor2: "blue",
  2802. fontcolor6: "white",
  2803. select2: "selector"
  2804. })
  2805. break;
  2806. default:
  2807. that.setData({
  2808. Lightcontrolcolor2: "#888888",
  2809. fontcolor6: "#cccccc",
  2810. select2: ""
  2811. })
  2812. break;
  2813. }
  2814. }
  2815. } else {
  2816. getDevice(message.Device, message.id).then(
  2817. rgb => {
  2818. if (rgb.data.code == 0) {
  2819. var rgbs = rgb.data.data
  2820. .circuits
  2821. rgbs = rgbs.split(',')
  2822. that.setData({
  2823. crr: rgbs
  2824. })
  2825. } else {
  2826. wx.showModal({
  2827. title: '错误',
  2828. content: rgb
  2829. .data.msg,
  2830. showCancel: false
  2831. })
  2832. }
  2833. })
  2834. }
  2835. } else {
  2836. wx.showModal({
  2837. title: '错误',
  2838. content: ever.data.error,
  2839. showCancel: false
  2840. })
  2841. }
  2842. })
  2843. } else {
  2844. wx.showModal({
  2845. title: '错误',
  2846. content: res.data.error,
  2847. showCancel: false
  2848. })
  2849. }
  2850. })
  2851. }
  2852. //新设备
  2853. else {
  2854. that.setData({
  2855. play: 1
  2856. })
  2857. //新设备在线状态
  2858. getDevice(message.Device, message.id).then(nrg => {
  2859. if (nrg.data.code == 0) {
  2860. var nrg = nrg.data.data
  2861. if (nrg.status == 1) {
  2862. that.setData({
  2863. status: '在线'
  2864. })
  2865. } else {
  2866. that.setData({
  2867. status: '离线'
  2868. })
  2869. }
  2870. getloop(message.Device).then(suc => {
  2871. if (suc.data.code == 0) {
  2872. var suc = suc.data.data
  2873. var index = that.data.indexes
  2874. for (let i = 0; i < suc.length; i++) {
  2875. if (index == i) {
  2876. let Suc = suc[i]
  2877. var newSwitch = that.data.newSwitch
  2878. var timeValue = that.data.timeValue
  2879. var newSwitchstate = that.data.newSwitchstate
  2880. var choice = that.data.choice
  2881. var lightCondition = Suc.lightControlCondition
  2882. var model = Suc.ctlMode
  2883. var beginTime = Suc.realTimeCondition1OnTime
  2884. var closeTimes = Suc.realTimeCondition1OffTime
  2885. //光控启动条件
  2886. looplightlist().then(res => {
  2887. if (res.data.code == 0) {
  2888. var lightlist = res.data.data
  2889. that.setData({
  2890. lightlist: lightlist
  2891. })
  2892. for (let i = 0; i <
  2893. lightlist
  2894. .length; i++) {
  2895. choice[i] = false
  2896. }
  2897. if (lightCondition
  2898. .includes(',') ==
  2899. true) {
  2900. lightCondition =
  2901. lightCondition
  2902. .split(',')
  2903. for (let j = 0; j <
  2904. lightCondition
  2905. .length; j++) {
  2906. if (lightCondition[
  2907. j] ==
  2908. '1') {
  2909. choice[0] =
  2910. true
  2911. } else if (
  2912. lightCondition[
  2913. j] ==
  2914. '2') {
  2915. choice[1] =
  2916. true
  2917. } else if (
  2918. lightCondition[
  2919. j] ==
  2920. '3') {
  2921. choice[2] =
  2922. true
  2923. } else if (
  2924. lightCondition[
  2925. j] ==
  2926. '4') {
  2927. choice[3] =
  2928. true
  2929. }
  2930. }
  2931. } else {
  2932. if (lightCondition ==
  2933. '1') {
  2934. choice[0] = true
  2935. } else if (
  2936. lightCondition ==
  2937. '2') {
  2938. choice[1] = true
  2939. } else if (
  2940. lightCondition ==
  2941. '3') {
  2942. choice[2] = true
  2943. } else if (
  2944. lightCondition ==
  2945. '4') {
  2946. choice[3] = true
  2947. }
  2948. }
  2949. that.setData({
  2950. choice: choice
  2951. })
  2952. } else {
  2953. wx.showModal({
  2954. title: '错误',
  2955. content: res
  2956. .data
  2957. .msg,
  2958. showCancel: false
  2959. })
  2960. }
  2961. })
  2962. //时控1
  2963. if (Suc.timeCondition1Switch == 1) {
  2964. newSwitch[0] = true
  2965. newSwitchstate[0] = 'time'
  2966. } else {
  2967. newSwitch[0] = false
  2968. newSwitchstate[0] = ''
  2969. }
  2970. timeValue[0] = Suc.timeCondition1OnTime
  2971. timeValue[1] = Suc.timeCondition1OffTime
  2972. //时控2
  2973. if (Suc.timeCondition2Switch == 1) {
  2974. newSwitch[1] = true
  2975. newSwitchstate[1] = 'time'
  2976. } else {
  2977. newSwitch[1] = false
  2978. newSwitchstate[1] = ''
  2979. }
  2980. timeValue[2] = Suc.timeCondition2OnTime
  2981. timeValue[3] = Suc.timeCondition2OffTime
  2982. //光控
  2983. if (Suc.lightControlSwitch == 1) {
  2984. newSwitch[2] = true
  2985. newSwitchstate[2] = 'time'
  2986. newSwitchstate[3] = 'selector'
  2987. } else {
  2988. newSwitch[2] = false
  2989. newSwitchstate[2] = ''
  2990. newSwitchstate[3] = ''
  2991. }
  2992. timeValue[4] = Suc.lightControlStart
  2993. timeValue[5] = Suc.lightControlEnd
  2994. for (let j = 0; j < timeValue
  2995. .length; j++) {
  2996. if (timeValue[j] == "") {
  2997. timeValue[j] = '00:00'
  2998. }
  2999. }
  3000. var messageNum = message.loopnum
  3001. messageNum.push('所有回路')
  3002. that.setData({
  3003. crr: messageNum,
  3004. timeValue: timeValue,
  3005. newSwitch: newSwitch
  3006. })
  3007. //监视新设备开关状态
  3008. var newSwitchs = that.data.newSwitch
  3009. var newfonts = that.data.newfont
  3010. var newcolors = that.data.newcolor
  3011. var newSwitchstates = that.data
  3012. .newSwitchstate
  3013. var disableds = that.data.disabled
  3014. if (newSwitchs[0] == true) {
  3015. newfonts[0] = "white"
  3016. newcolors[0] = "blue"
  3017. newSwitchstates[0] = "time"
  3018. } else {
  3019. newfonts[0] = "#cccccc"
  3020. newcolors[0] = "#888888"
  3021. newSwitchstates[0] = ""
  3022. }
  3023. if (newSwitchs[1] == true) {
  3024. newfonts[1] = "white"
  3025. newcolors[1] = "blue"
  3026. newSwitchstates[1] = "time"
  3027. } else {
  3028. newfonts[1] = "#cccccc"
  3029. newcolors[1] = "#888888"
  3030. newSwitchstates[1] = ""
  3031. }
  3032. if (newSwitchs[2] == true) {
  3033. newfonts[2] = "white"
  3034. newcolors[2] = "blue"
  3035. newSwitchstates[2] = "time"
  3036. disableds = false
  3037. } else {
  3038. newfonts[2] = "#cccccc"
  3039. newcolors[2] = "#888888"
  3040. newSwitchstates[2] = ""
  3041. disableds = true
  3042. }
  3043. that.setData({
  3044. newcolor: newcolors,
  3045. newfont: newfonts,
  3046. newSwitch: newSwitchs,
  3047. newSwitchstate: newSwitchstates,
  3048. disabled: disableds,
  3049. newChange:model,
  3050. beginTime:beginTime,
  3051. closeTimes:closeTimes
  3052. })
  3053. }
  3054. }
  3055. } else {
  3056. console.log('获取新设备回路参数失败')
  3057. wx.showModal({
  3058. title: '错误',
  3059. content: suc.data.msg,
  3060. showCancel: false
  3061. })
  3062. }
  3063. })
  3064. } else {
  3065. console.log('新设备获取信息失败')
  3066. wx.showModal({
  3067. title: '错误',
  3068. content: nrg.data.msg,
  3069. showCancel: false
  3070. })
  3071. }
  3072. })
  3073. }
  3074. } else {
  3075. that.setData({
  3076. status: '离线',
  3077. deviceName: []
  3078. })
  3079. }
  3080. }
  3081. }
  3082. } else {
  3083. that.setData({
  3084. deviceName: [],
  3085. groupName: []
  3086. })
  3087. }
  3088. },
  3089. //新设备多选框
  3090. point1: function() {
  3091. var choice = this.data.choice
  3092. if (choice[0] == true) {
  3093. choice[0] = false
  3094. } else {
  3095. choice[0] = true
  3096. }
  3097. this.setData({
  3098. choice: choice
  3099. })
  3100. },
  3101. point2: function() {
  3102. var choice = this.data.choice
  3103. if (choice[1] == true) {
  3104. choice[1] = false
  3105. } else {
  3106. choice[1] = true
  3107. }
  3108. this.setData({
  3109. choice: choice
  3110. })
  3111. },
  3112. point3: function() {
  3113. var choice = this.data.choice
  3114. if (choice[2] == true) {
  3115. choice[2] = false
  3116. } else {
  3117. choice[2] = true
  3118. }
  3119. this.setData({
  3120. choice: choice
  3121. })
  3122. },
  3123. point4: function() {
  3124. var choice = this.data.choice
  3125. if (choice[3] == true) {
  3126. choice[3] = false
  3127. } else {
  3128. choice[3] = true
  3129. }
  3130. this.setData({
  3131. choice: choice
  3132. })
  3133. },
  3134. //存储数据
  3135. Storedata: function() {
  3136. wx.showToast({
  3137. title: '存储数据中',
  3138. icon: 'loading',
  3139. duration: 3000
  3140. })
  3141. var that = this
  3142. var play = that.data.play
  3143. //旧设备
  3144. if (play == 0) {
  3145. var indexes = that.data.indexes
  3146. var lamp = wx.getStorageSync('lamp')
  3147. var radio1 = that.data.radio1
  3148. var radio2 = that.data.radio2
  3149. var radio3 = that.data.radio3
  3150. var jude
  3151. if (lamp[indexes] ==
  3152. 'https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png' && radio1 ==
  3153. true) {
  3154. jude = 0
  3155. } else if (lamp[indexes] ==
  3156. 'https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png' && radio2 ==
  3157. true) {
  3158. jude = 4
  3159. } else if (lamp[indexes] ==
  3160. 'https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png' && radio3 ==
  3161. true) {
  3162. jude = 8
  3163. } else if (lamp[indexes] ==
  3164. 'https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp1.png' && radio1 ==
  3165. true) {
  3166. jude = 1
  3167. } else if (lamp[indexes] ==
  3168. 'https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp1.png' && radio2 ==
  3169. true) {
  3170. jude = 5
  3171. } else if (lamp[indexes] ==
  3172. 'https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp1.png' && radio3 ==
  3173. true) {
  3174. jude = 9
  3175. }
  3176. //功能一
  3177. var Storagetimeopen1
  3178. var Storagetimeshut1
  3179. var Storagetimeopenstate1
  3180. var Storagetimeshutstate1
  3181. var Storageopticalopen
  3182. var Storageopticalshut
  3183. //时控一开
  3184. switch (that.data.state[0]) {
  3185. case true:
  3186. Storagetimeopen1 = "1"
  3187. break;
  3188. case false:
  3189. Storagetimeopen1 = "0"
  3190. break;
  3191. }
  3192. //时控一关
  3193. switch (that.data.state[1]) {
  3194. case true:
  3195. Storagetimeshut1 = "1"
  3196. break;
  3197. case false:
  3198. Storagetimeshut1 = "0"
  3199. break;
  3200. }
  3201. //时控一开经纬
  3202. switch (that.data.fixed1) {
  3203. case "经纬":
  3204. Storagetimeopenstate1 = "1"
  3205. break;
  3206. case "固定":
  3207. Storagetimeopenstate1 = "0"
  3208. break;
  3209. }
  3210. //时控一关经纬
  3211. switch (that.data.fixed2) {
  3212. case "经纬":
  3213. Storagetimeshutstate1 = "1"
  3214. break;
  3215. case "固定":
  3216. Storagetimeshutstate1 = "0"
  3217. break;
  3218. }
  3219. //光控开
  3220. switch (that.data.state[2]) {
  3221. case true:
  3222. Storageopticalopen = "1"
  3223. break;
  3224. case false:
  3225. Storageopticalopen = "0"
  3226. break;
  3227. }
  3228. //光控关
  3229. switch (that.data.state[3]) {
  3230. case true:
  3231. Storageopticalshut = "1"
  3232. break;
  3233. case false:
  3234. Storageopticalshut = "0"
  3235. break;
  3236. }
  3237. var use1 = Storageopticalshut + Storageopticalopen + Storagetimeshutstate1 +
  3238. Storagetimeopenstate1 + Storagetimeshut1 + Storagetimeopen1
  3239. use1 = parseInt(use1, 2)
  3240. use1 = use1 //传给后台的功能一数据
  3241. //功能二
  3242. var Storagetimeopen2
  3243. var Storagetimeshut2
  3244. var Storagetimeopenstate2
  3245. var Storagetimeshutstate2
  3246. //时控二开
  3247. switch (that.data.state1[0]) {
  3248. case true:
  3249. Storagetimeopen2 = "1"
  3250. break;
  3251. case false:
  3252. Storagetimeopen2 = "0"
  3253. break;
  3254. }
  3255. //时控二关
  3256. switch (that.data.state1[1]) {
  3257. case true:
  3258. Storagetimeshut2 = "1"
  3259. break;
  3260. case false:
  3261. Storagetimeshut2 = "0"
  3262. break;
  3263. }
  3264. //时控二开经纬
  3265. switch (that.data.fixed3) {
  3266. case "经纬":
  3267. Storagetimeopenstate2 = "1"
  3268. break;
  3269. case "固定":
  3270. Storagetimeopenstate2 = "0"
  3271. break;
  3272. }
  3273. //时控二关经纬
  3274. switch (that.data.fixed4) {
  3275. case "经纬":
  3276. Storagetimeshutstate2 = "1"
  3277. break;
  3278. case "固定":
  3279. Storagetimeshutstate2 = "0"
  3280. break;
  3281. }
  3282. var use2 = Storagetimeshutstate2 + Storagetimeopenstate2 + Storagetimeshut2 + Storagetimeopen2
  3283. use2 = parseInt(use2, 2)
  3284. use2 = use2 //传给后台的功能二数据
  3285. //时控一开时间
  3286. var Ontime1 = that.data.time[0]
  3287. var ontime1 //传给后台的时控一开时间
  3288. if (Ontime1.substring(0, 2) == '00' && Ontime1.substring(3, 5) == '00') {
  3289. ontime1 = '0'
  3290. } else if (Ontime1.substring(0, 1) != '0') {
  3291. ontime1 = Ontime1.substring(0, 2) + Ontime1.substring(3, 5)
  3292. } else if (Ontime1.substring(0, 1) == '0' && Ontime1.substring(1, 2) != '0') {
  3293. ontime1 = Ontime1.substring(1, 2) + Ontime1.substring(3, 5)
  3294. } else if (Ontime1.substring(0, 2) == '00' && Ontime1.substring(3, 4) != '0') {
  3295. ontime1 = Ontime1.substring(3, 5)
  3296. } else {
  3297. ontime1 = Ontime1.substring(4, 5)
  3298. }
  3299. ontime1 = parseInt(ontime1)
  3300. //时控一关时间
  3301. var Closingtime1 = that.data.time[1]
  3302. var closingtime1 //传给后台的时控一关时间
  3303. if (Closingtime1.substring(0, 2) == '00' && Closingtime1.substring(3, 5) == '00') {
  3304. closingtime1 = '0'
  3305. } else if (Closingtime1.substring(0, 1) != '0') {
  3306. closingtime1 = Closingtime1.substring(0, 2) + Closingtime1.substring(3, 5)
  3307. } else if (Closingtime1.substring(0, 1) == '0' && Closingtime1.substring(1, 2) != '0') {
  3308. closingtime1 = Closingtime1.substring(1, 2) + Closingtime1.substring(3, 5)
  3309. } else if (Closingtime1.substring(0, 2) == '00' && Closingtime1.substring(3, 4) != '0') {
  3310. closingtime1 = Closingtime1.substring(3, 5)
  3311. } else {
  3312. closingtime1 = Closingtime1.substring(4, 5)
  3313. }
  3314. closingtime1 = parseInt(closingtime1)
  3315. //时控二开时间
  3316. var Ontime2 = that.data.time[2]
  3317. var ontime2 //传给后台的时控二开时间
  3318. if (Ontime2.substring(0, 2) == '00' && Ontime2.substring(3, 5) == '00') {
  3319. ontime2 = '0'
  3320. } else if (Ontime2.substring(0, 1) != '0') {
  3321. ontime2 = Ontime2.substring(0, 2) + Ontime2.substring(3, 5)
  3322. } else if (Ontime2.substring(0, 1) == '0' && Ontime2.substring(1, 2) != '0') {
  3323. ontime2 = Ontime2.substring(1, 2) + Ontime2.substring(3, 5)
  3324. } else if (Ontime2.substring(0, 2) == '00' && Ontime2.substring(3, 4) != '0') {
  3325. ontime2 = Ontime2.substring(3, 5)
  3326. } else {
  3327. ontime2 = Ontime2.substring(4, 5)
  3328. }
  3329. ontime2 = parseInt(ontime2)
  3330. //时控二关时间
  3331. var Closingtime2 = that.data.time[3]
  3332. var closingtime2 //传给后台的时控二关时间
  3333. if (Closingtime2.substring(0, 2) == '00' && Closingtime2.substring(3, 5) == '00') {
  3334. closingtime2 = '0'
  3335. } else if (Closingtime2.substring(0, 1) != '0') {
  3336. closingtime2 = Closingtime2.substring(0, 2) + Closingtime2.substring(3, 5)
  3337. } else if (Closingtime2.substring(0, 1) == '0' && Closingtime2.substring(1, 2) != '0') {
  3338. closingtime2 = Closingtime2.substring(1, 2) + Closingtime2.substring(3, 5)
  3339. } else if (Closingtime2.substring(0, 2) == '00' && Closingtime2.substring(3, 4) != '0') {
  3340. closingtime2 = Closingtime2.substring(3, 5)
  3341. } else {
  3342. closingtime2 = Closingtime2.substring(4, 5)
  3343. }
  3344. closingtime2 = parseInt(closingtime2)
  3345. //光控开
  3346. var Lightcontrolon = that.data.arr[that.data.index]
  3347. Lightcontrolon = Lightcontrolon
  3348. //光控关
  3349. var Lightcontroloff = that.data.brr[that.data.indexs]
  3350. Lightcontroloff = Lightcontroloff
  3351. //星期
  3352. var myweek = ""
  3353. var address = that.data.address
  3354. for (let w = 0; w < address.length; w++) {
  3355. switch (address[w]) {
  3356. case "/image/false.png":
  3357. myweek += '0'
  3358. break;
  3359. default:
  3360. myweek += '1'
  3361. break;
  3362. }
  3363. }
  3364. if (myweek == "0000000") {
  3365. myweek = 0
  3366. } else {
  3367. myweek = "1" + myweek.split("").reverse().join("")
  3368. myweek = parseInt(myweek, 2)
  3369. myweek = myweek
  3370. }
  3371. //发起post请求
  3372. getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
  3373. if (res.data.errno == 0) {
  3374. if (res.data.data.online == true) {
  3375. that.setData({
  3376. status: '在线'
  3377. })
  3378. } else {
  3379. that.setData({
  3380. status: '离线'
  3381. })
  3382. }
  3383. } else {
  3384. wx.showModal({
  3385. title: '错误',
  3386. content: res.data.error,
  3387. showCancel: false
  3388. })
  3389. }
  3390. })
  3391. if (that.data.status == "在线") {
  3392. var indexes = that.data.indexes
  3393. indexes = parseInt(indexes)
  3394. var crr = that.data.crr
  3395. if (crr[indexes] != '所有回路') {
  3396. var reflash = [11, 12, 13, 14, 15, 16, 17, 18]
  3397. var i = indexes + 1
  3398. var week = "R" + i + "_Week"
  3399. var FunctionStatus1 = 'R' + i + '_FunctionStatus1'
  3400. var FunctionStatus2 = 'R' + i + '_FunctionStatus2'
  3401. var DayOpenTime1 = 'R' + i + '_DayOpenTime1'
  3402. var DayCloseTime1 = 'R' + i + '_DayCloseTime1'
  3403. var DayOpenTime2 = 'R' + i + '_DayOpenTime2'
  3404. var DayCloseTime2 = 'R' + i + '_DayCloseTime2'
  3405. var LcOn = 'R' + i + '_LcOn'
  3406. var LcOff = 'R' + i + '_LcOff'
  3407. var RelayStatus = 'R' + i + '_RelayStatus'
  3408. var object = {
  3409. "Reflash": reflash[indexes],
  3410. [week]: myweek,
  3411. [FunctionStatus1]: use1,
  3412. [FunctionStatus2]: use2,
  3413. [DayOpenTime1]: ontime1,
  3414. [DayCloseTime1]: closingtime1,
  3415. [DayOpenTime2]: ontime2,
  3416. [DayCloseTime2]: closingtime2,
  3417. [LcOn]: Lightcontrolon,
  3418. [LcOff]: Lightcontroloff,
  3419. [RelayStatus]: jude,
  3420. }
  3421. postData(that.data.deviceId, that.data.deviceKey, JSON.stringify(object)).then(res => {
  3422. if (res.data.errno != 0) {
  3423. wx.showModal({
  3424. title: '错误',
  3425. content: res.data.error,
  3426. showCancel: false
  3427. })
  3428. }
  3429. })
  3430. } else {
  3431. var object1 = {
  3432. "Reflash": 11,
  3433. "R1_Week": myweek, //星期
  3434. "R1_FunctionStatus1": use1, //功能1
  3435. "R1_FunctionStatus2": use2, //功能2
  3436. "R1_DayOpenTime1": ontime1, //时控1开
  3437. "R1_DayCloseTime1": closingtime1, //时控1关
  3438. "R1_DayOpenTime2": ontime2, //时控2开
  3439. "R1_DayCloseTime2": closingtime2, //时控2关
  3440. "R1_LcOn": Lightcontrolon, //光控开
  3441. "R1_LcOff": Lightcontroloff, //光控关
  3442. "R1_RelayStatus": jude, //开关状态
  3443. }
  3444. var object2 = {
  3445. "Reflash": 12,
  3446. "R2_FunctionStatus1": use1, //功能1
  3447. "R2_FunctionStatus2": use2, //功能2
  3448. "R2_DayOpenTime1": ontime1, //时控1开
  3449. "R2_DayCloseTime1": closingtime1, //时控1关
  3450. "R2_DayOpenTime2": ontime2, //时控2开
  3451. "R2_DayCloseTime2": closingtime2, //时控2关
  3452. "R2_Week": myweek, //星期
  3453. "R2_LcOn": Lightcontrolon, //光控开
  3454. "R2_LcOff": Lightcontroloff, //光控关
  3455. "R2_RelayStatus": jude, //开关状态
  3456. }
  3457. var object3 = {
  3458. "Reflash": 13,
  3459. "R3_FunctionStatus1": use1, //功能1
  3460. "R3_FunctionStatus2": use2, //功能2
  3461. "R3_DayOpenTime1": ontime1, //时控1开
  3462. "R3_DayCloseTime1": closingtime1, //时控1关
  3463. "R3_DayOpenTime2": ontime2, //时控2开
  3464. "R3_DayCloseTime2": closingtime2, //时控2关
  3465. "R3_Week": myweek, //星期
  3466. "R3_LcOn": Lightcontrolon, //光控开
  3467. "R3_LcOff": Lightcontroloff, //光控关
  3468. "R3_RelayStatus": jude, //开关状态
  3469. }
  3470. var object4 = {
  3471. "Reflash": 14,
  3472. "R4_FunctionStatus1": use1, //功能1
  3473. "R4_FunctionStatus2": use2, //功能2
  3474. "R4_DayOpenTime1": ontime1, //时控1开
  3475. "R4_DayCloseTime1": closingtime1, //时控1关
  3476. "R4_DayOpenTime2": ontime2, //时控2开
  3477. "R4_DayCloseTime2": closingtime2, //时控2关
  3478. "R4_Week": myweek, //星期
  3479. "R4_LcOn": Lightcontrolon, //光控开
  3480. "R4_LcOff": Lightcontroloff, //光控关
  3481. "R4_RelayStatus": jude, //开关状态
  3482. }
  3483. var object5 = {
  3484. "Reflash": 15,
  3485. "R5_FunctionStatus1": use1, //功能1
  3486. "R5_FunctionStatus2": use2, //功能2
  3487. "R5_DayOpenTime1": ontime1, //时控1开
  3488. "R5_DayCloseTime1": closingtime1, //时控1关
  3489. "R5_DayOpenTime2": ontime2, //时控2开
  3490. "R5_DayCloseTime2": closingtime2, //时控2关
  3491. "R5_Week": myweek, //星期
  3492. "R5_LcOn": Lightcontrolon, //光控开
  3493. "R5_LcOff": Lightcontroloff, //光控关
  3494. "R5_RelayStatus": jude, //开关状态
  3495. }
  3496. var object6 = {
  3497. "Reflash": 16,
  3498. "R6_FunctionStatus1": use1, //功能1
  3499. "R6_FunctionStatus2": use2, //功能2
  3500. "R6_DayOpenTime1": ontime1, //时控1开
  3501. "R6_DayCloseTime1": closingtime1, //时控1关
  3502. "R6_DayOpenTime2": ontime2, //时控2开
  3503. "R6_DayCloseTime2": closingtime2, //时控2关
  3504. "R6_Week": myweek, //星期
  3505. "R6_LcOn": Lightcontrolon, //光控开
  3506. "R6_LcOff": Lightcontroloff, //光控关
  3507. "R6_RelayStatus": jude, //开关状态
  3508. }
  3509. var object7 = {
  3510. "Reflash": 17,
  3511. "R7_FunctionStatus1": use1, //功能1
  3512. "R7_FunctionStatus2": use2, //功能2
  3513. "R7_DayOpenTime1": ontime1, //时控1开
  3514. "R7_DayCloseTime1": closingtime1, //时控1关
  3515. "R7_DayOpenTime2": ontime2, //时控2开
  3516. "R7_DayCloseTime2": closingtime2, //时控2关
  3517. "R7_Week": myweek, //星期
  3518. "R7_LcOn": Lightcontrolon, //光控开
  3519. "R7_LcOff": Lightcontroloff, //光控关
  3520. "R7_RelayStatus": jude, //开关状态
  3521. }
  3522. var object8 = {
  3523. "Reflash": 18,
  3524. "R8_FunctionStatus1": use1, //功能1
  3525. "R8_FunctionStatus2": use2, //功能2
  3526. "R8_DayOpenTime1": ontime1, //时控1开
  3527. "R8_DayCloseTime1": closingtime1, //时控1关
  3528. "R8_DayOpenTime2": ontime2, //时控2开
  3529. "R8_DayCloseTime2": closingtime2, //时控2关
  3530. "R8_Week": myweek, //星期
  3531. "R8_LcOn": Lightcontrolon, //光控开
  3532. "R8_LcOff": Lightcontroloff, //光控关
  3533. "R8_RelayStatus": jude, //开关状态
  3534. }
  3535. postData(that.data.deviceId, that.data.deviceKey, JSON.stringify(object1)).then(res => {
  3536. if (res.data.errno != 0) {
  3537. wx.showModal({
  3538. title: '错误',
  3539. content: res.data.error,
  3540. showCancel: false
  3541. })
  3542. }
  3543. })
  3544. postData(that.data.deviceId, that.data.deviceKey, JSON.stringify(object2)).then(res => {
  3545. if (res.data.errno != 0) {
  3546. wx.showModal({
  3547. title: '错误',
  3548. content: res.data.error,
  3549. showCancel: false
  3550. })
  3551. }
  3552. })
  3553. postData(that.data.deviceId, that.data.deviceKey, JSON.stringify(object3)).then(res => {
  3554. if (res.data.errno != 0) {
  3555. wx.showModal({
  3556. title: '错误',
  3557. content: res.data.error,
  3558. showCancel: false
  3559. })
  3560. }
  3561. })
  3562. postData(that.data.deviceId, that.data.deviceKey, JSON.stringify(object4)).then(res => {
  3563. if (res.data.errno != 0) {
  3564. wx.showModal({
  3565. title: '错误',
  3566. content: res.data.error,
  3567. showCancel: false
  3568. })
  3569. }
  3570. })
  3571. postData(that.data.deviceId, that.data.deviceKey, JSON.stringify(object5)).then(res => {
  3572. if (res.data.errno != 0) {
  3573. wx.showModal({
  3574. title: '错误',
  3575. content: res.data.error,
  3576. showCancel: false
  3577. })
  3578. }
  3579. })
  3580. postData(that.data.deviceId, that.data.deviceKey, JSON.stringify(object6)).then(res => {
  3581. if (res.data.errno != 0) {
  3582. wx.showModal({
  3583. title: '错误',
  3584. content: res.data.error,
  3585. showCancel: false
  3586. })
  3587. }
  3588. })
  3589. postData(that.data.deviceId, that.data.deviceKey, JSON.stringify(object7)).then(res => {
  3590. if (res.data.errno != 0) {
  3591. wx.showModal({
  3592. title: '错误',
  3593. content: res.data.error,
  3594. showCancel: false
  3595. })
  3596. }
  3597. })
  3598. postData(that.data.deviceId, that.data.deviceKey, JSON.stringify(object8)).then(res => {
  3599. if (res.data.errno != 0) {
  3600. wx.showModal({
  3601. title: '错误',
  3602. content: res.data.error,
  3603. showCancel: false
  3604. })
  3605. }
  3606. })
  3607. }
  3608. } else {
  3609. setTimeout(function() {
  3610. wx.showModal({
  3611. title: '提示',
  3612. content: '存储数据失败,请检查设备是否在线或者刷新页面',
  3613. showCancel: false,
  3614. })
  3615. }, 3000)
  3616. }
  3617. }
  3618. //新设备
  3619. else {
  3620. getDevice(that.data.equipment, that.data.subset).then(nrg => {
  3621. if (nrg.data.code == 0) {
  3622. var nrg = nrg.data.data
  3623. if (nrg.status == 1) {
  3624. that.setData({
  3625. status: '在线'
  3626. })
  3627. } else {
  3628. that.setData({
  3629. status: '离线'
  3630. })
  3631. }
  3632. } else {
  3633. wx.showModal({
  3634. title: '错误',
  3635. content: res.data.msg,
  3636. showCancel: false
  3637. })
  3638. }
  3639. })
  3640. if (that.data.status == "在线") {
  3641. var timeValues = that.data.timeValue //时间
  3642. var newChange = that.data.newChange
  3643. var crrs = that.data.crr //回路名称集合
  3644. var Crrindex = that.data.indexes //回路下标
  3645. Crrindex = Crrindex + 1
  3646. var ID = that.data.equipment
  3647. ID = parseInt(ID)
  3648. var newSwitch = that.data.newSwitch //设备开关
  3649. for (let x = 0; x < newSwitch.length; x++) {
  3650. if (newSwitch[x] == true) {
  3651. newSwitch[x] = 1
  3652. } else {
  3653. newSwitch[x] = 0
  3654. }
  3655. }
  3656. //开启条件(天气)
  3657. var choice = that.data.choice
  3658. var Choice = ''
  3659. for (let q = 0; q < choice.length; q++) {
  3660. if (choice[q] == true) {
  3661. Choice += ((q + 1) + ',')
  3662. }
  3663. }
  3664. if (Choice.length > 0) {
  3665. Choice = Choice.slice(0, Choice.length - 1)
  3666. }
  3667. if(crrs[Crrindex - 1] != '所有回路'){
  3668. var postobject = {
  3669. "deviceId": ID,
  3670. "relays": [{
  3671. "relayId": Crrindex,
  3672. "name": crrs[Crrindex - 1],
  3673. "timeCondition1Switch": newSwitch[0],
  3674. "timeCondition1OnTime": timeValues[0],
  3675. "timeCondition1OffTime": timeValues[1],
  3676. "timeCondition2Switch": newSwitch[1],
  3677. "timeCondition2OnTime": timeValues[2],
  3678. "timeCondition2OffTime": timeValues[3],
  3679. "lightControlSwitch": newSwitch[2],
  3680. "lightControlStart": timeValues[4],
  3681. "lightControlEnd": timeValues[5],
  3682. "lightControlCondition": Choice,
  3683. "ctlMode":newChange
  3684. }]
  3685. }
  3686. }
  3687. else{
  3688. var postobject = {
  3689. "deviceId": ID
  3690. }
  3691. var relays = []
  3692. for(let e = 0; e < crrs.length - 1; e++){
  3693. relays.push(
  3694. {
  3695. "relayId": e+1,
  3696. "timeCondition1Switch": newSwitch[0],
  3697. "timeCondition1OnTime": timeValues[0],
  3698. "timeCondition1OffTime": timeValues[1],
  3699. "timeCondition2Switch": newSwitch[1],
  3700. "timeCondition2OnTime": timeValues[2],
  3701. "timeCondition2OffTime": timeValues[3],
  3702. "lightControlSwitch": newSwitch[2],
  3703. "lightControlStart": timeValues[4],
  3704. "lightControlEnd": timeValues[5],
  3705. "lightControlCondition": Choice,
  3706. "ctlMode":newChange
  3707. }
  3708. )
  3709. }
  3710. postobject.relays = relays
  3711. }
  3712. console.log(postobject)
  3713. postloop(postobject).then(upload => {
  3714. if (upload.data.code != 0) {
  3715. wx.showModal({
  3716. title: '错误',
  3717. content: upload.data.msg,
  3718. showCancel: false
  3719. })
  3720. }
  3721. })
  3722. } else {
  3723. wx.showModal({
  3724. title: '提示',
  3725. content: '存储数据失败,请检查设备是否在线或者刷新页面',
  3726. showCancel: false,
  3727. })
  3728. }
  3729. }
  3730. },
  3731. //开启条件按钮
  3732. Opening: function() {
  3733. var disabled = this.data.disabled
  3734. if (disabled == true) {
  3735. this.setData({
  3736. popup: false
  3737. })
  3738. } else {
  3739. this.setData({
  3740. popup: true
  3741. })
  3742. }
  3743. },
  3744. //对话框确定回调
  3745. complete: function() {
  3746. this.setData({
  3747. popup: false
  3748. })
  3749. },
  3750. /**
  3751. * 生命周期函数--监听页面加载
  3752. */
  3753. onLoad(options) {},
  3754. /**
  3755. * 生命周期函数--监听页面初次渲染完成
  3756. */
  3757. onReady() {
  3758. },
  3759. /**
  3760. * 生命周期函数--监听页面显示
  3761. */
  3762. onShow() {
  3763. wx.showToast({
  3764. title: '获取数据中',
  3765. icon: 'loading',
  3766. duration: 2000
  3767. })
  3768. var that = this
  3769. //获取机型改变switch大小
  3770. wx.getSystemInfo({
  3771. success: function(res) {
  3772. if (res.model == 'iPad' || res.model == 'iPad Pro 10.5-inch' || res.model ==
  3773. 'iPad Pro 12.9-inch') {
  3774. that.setData({
  3775. zoom: 1
  3776. })
  3777. }
  3778. }
  3779. })
  3780. var group = wx.getStorageSync('group')
  3781. if (group != null && group.length != 0) {
  3782. //分组下拉
  3783. var group = wx.getStorageSync('group')
  3784. var groups = []
  3785. for (let i = 0; i < group.length; i++) {
  3786. groups.push(group[i].groupName)
  3787. }
  3788. that.setData({
  3789. groupName: groups
  3790. })
  3791. //改变分组下标
  3792. if (wx.getStorageSync('groupName') != '') {
  3793. let GroupName = groups
  3794. for (let n = 0; n < GroupName.length; n++) {
  3795. if (GroupName[n] == wx.getStorageSync('groupName')) {
  3796. that.setData({
  3797. groupIndex: n
  3798. })
  3799. }
  3800. }
  3801. } else {
  3802. that.setData({
  3803. groupIndex: 0
  3804. })
  3805. wx.setStorageSync('groupName', that.data.groupName[that.data.groupIndex])
  3806. }
  3807. //设备下拉
  3808. var device = []
  3809. var groupName = that.data.groupName
  3810. var groupIndex = that.data.groupIndex
  3811. for (let j = 0; j < group.length; j++) {
  3812. if (groupName[groupIndex] == group[j].groupName) {
  3813. if (group[j].devices != null && group[j].devices.length != 0) {
  3814. for (let p = 0; p < group[j].devices.length; p++) {
  3815. device.push(group[j].devices[p].deviceName)
  3816. }
  3817. that.setData({
  3818. deviceName: device
  3819. })
  3820. //改变设备下标
  3821. if (wx.getStorageSync('deviceName') != '') {
  3822. for (let m = 0; m < device.length; m++) {
  3823. if (device[m] == wx.getStorageSync('deviceName')) {
  3824. that.setData({
  3825. deviceIndex: m
  3826. })
  3827. }
  3828. }
  3829. } else {
  3830. that.setData({
  3831. deviceIndex: 0
  3832. })
  3833. wx.setStorageSync('deviceName', that.data.deviceName[that.data.deviceIndex])
  3834. }
  3835. //获取设备信息
  3836. var currentGroup = that.data.groupName[that.data.groupIndex]
  3837. var currentDevice = that.data.deviceName[that.data.deviceIndex]
  3838. var message = enloop.deviceMessage(currentGroup, currentDevice)
  3839. that.setData({
  3840. equipment: message.Device,
  3841. subset: message.id,
  3842. ID: message.ID,
  3843. indexes: 0 //将回路重新调回回路1
  3844. }) //记录当前的设备id和分组id
  3845. //旧设备
  3846. if (message.modules == 0) {
  3847. that.setData({
  3848. play: 0,
  3849. deviceKey: message.deviceKey,
  3850. deviceId: message.deviceId
  3851. })
  3852. getBasic(message.deviceId, message.deviceKey).then(res => {
  3853. if (res.data.errno == 0) {
  3854. if (res.data.data.online == true) {
  3855. that.setData({
  3856. status: '在线'
  3857. })
  3858. } else {
  3859. that.setData({
  3860. status: '离线'
  3861. })
  3862. }
  3863. getData(message.deviceId, message.deviceKey).then(ever => {
  3864. if (ever.data.errno == 0) {
  3865. let {
  3866. data
  3867. } = ever.data
  3868. //判断设备是否处于初始化状态
  3869. var initialization = true
  3870. for (let t = 0; t < data.length; t++) {
  3871. if ('current_value' in data[t] == false) {
  3872. initialization = false
  3873. }
  3874. }
  3875. if (initialization == true) {
  3876. let loopnum = message.loopnum
  3877. var Summary = enloop.deviceinfo(data, loopnum,
  3878. that.data.arr, that.data.brr, that.data
  3879. .time, that.data.state,
  3880. that.data.state1, that.data.fixed1, that
  3881. .data.fixed2, that.data.fixed3,
  3882. that.data.fixed4, that.data.address,
  3883. that.data.radio1, that.data.radio2,
  3884. that.data.radio3, that.data.index, that
  3885. .data.indexs)
  3886. that.setData({
  3887. crr: Summary.crr,
  3888. arr: Summary.arr,
  3889. brr: Summary.brr,
  3890. fixed1: Summary.fixed1,
  3891. fixed2: Summary.fixed2,
  3892. fixed3: Summary.fixed3,
  3893. fixed4: Summary.fixed4,
  3894. index: Summary.index,
  3895. indexs: Summary.indexs,
  3896. radio1: Summary.radio1,
  3897. radio2: Summary.radio2,
  3898. radio3: Summary.radio3,
  3899. recorddate: Summary.recorddate,
  3900. state: Summary.state,
  3901. state1: Summary.state1,
  3902. time: Summary.time,
  3903. address: Summary.address,
  3904. play: 0
  3905. })
  3906. //监视开关状态(改变颜色,调整功能)
  3907. switch (that.data.state[0]) {
  3908. case true:
  3909. that.setData({
  3910. type1: "time",
  3911. timecontrolcolor1: "blue",
  3912. fontcolor1: "white",
  3913. })
  3914. break;
  3915. default:
  3916. that.setData({
  3917. type1: "",
  3918. timecontrolcolor1: "#888888",
  3919. fontcolor1: "#cccccc",
  3920. })
  3921. break;
  3922. }
  3923. switch (that.data.state[1]) {
  3924. case true:
  3925. that.setData({
  3926. type2: "time",
  3927. timecontrolcolor2: "blue",
  3928. fontcolor2: "white",
  3929. })
  3930. break;
  3931. default:
  3932. that.setData({
  3933. type2: "",
  3934. timecontrolcolor2: "#888888",
  3935. fontcolor2: "#cccccc",
  3936. })
  3937. break;
  3938. }
  3939. switch (that.data.state1[0]) {
  3940. case true:
  3941. that.setData({
  3942. type3: "time",
  3943. timecontrolcolor3: "blue",
  3944. fontcolor3: "white",
  3945. })
  3946. break;
  3947. default:
  3948. that.setData({
  3949. type3: "",
  3950. timecontrolcolor3: "#888888",
  3951. fontcolor3: "#cccccc",
  3952. })
  3953. break;
  3954. }
  3955. switch (that.data.state1[1]) {
  3956. case true:
  3957. that.setData({
  3958. type4: "time",
  3959. timecontrolcolor4: "blue",
  3960. fontcolor4: "white",
  3961. })
  3962. break;
  3963. default:
  3964. that.setData({
  3965. type4: "",
  3966. timecontrolcolor4: "#888888",
  3967. fontcolor4: "#cccccc",
  3968. })
  3969. break;
  3970. }
  3971. switch (that.data.state[2]) {
  3972. case true:
  3973. that.setData({
  3974. Lightcontrolcolor1: "blue",
  3975. fontcolor5: "white",
  3976. select1: "selector"
  3977. })
  3978. break;
  3979. default:
  3980. that.setData({
  3981. Lightcontrolcolor1: "#888888",
  3982. fontcolor5: "#cccccc",
  3983. select1: ""
  3984. })
  3985. break;
  3986. }
  3987. switch (that.data.state[3]) {
  3988. case true:
  3989. that.setData({
  3990. Lightcontrolcolor2: "blue",
  3991. fontcolor6: "white",
  3992. select2: "selector"
  3993. })
  3994. break;
  3995. default:
  3996. that.setData({
  3997. Lightcontrolcolor2: "#888888",
  3998. fontcolor6: "#cccccc",
  3999. select2: ""
  4000. })
  4001. break;
  4002. }
  4003. } else {
  4004. getDevice(message.Device, message.id).then(
  4005. rgb => {
  4006. if (rgb.data.code == 0) {
  4007. var rgbs = rgb.data.data
  4008. .circuits
  4009. rgbs = rgbs.split(',')
  4010. that.setData({
  4011. crr: rgbs
  4012. })
  4013. } else {
  4014. wx.showModal({
  4015. title: '错误',
  4016. content: rgb.data
  4017. .msg,
  4018. showCancel: false
  4019. })
  4020. }
  4021. })
  4022. }
  4023. } else {
  4024. wx.showModal({
  4025. title: '错误',
  4026. content: ever.data.error,
  4027. showCancel: false
  4028. })
  4029. }
  4030. })
  4031. } else {
  4032. wx.showModal({
  4033. title: '错误',
  4034. content: res.data.error,
  4035. showCancel: false
  4036. })
  4037. }
  4038. })
  4039. }
  4040. //新设备
  4041. else {
  4042. that.setData({
  4043. play: 1
  4044. })
  4045. //新设备在线状态
  4046. getDevice(message.Device, message.id).then(nrg => {
  4047. if (nrg.data.code == 0) {
  4048. var nrg = nrg.data.data
  4049. if (nrg.status == 1) {
  4050. that.setData({
  4051. status: '在线'
  4052. })
  4053. } else {
  4054. that.setData({
  4055. status: '离线'
  4056. })
  4057. }
  4058. getloop(message.Device).then(suc => {
  4059. if (suc.data.code == 0) {
  4060. var suc = suc.data.data
  4061. var index = that.data.indexes
  4062. for (let i = 0; i < suc.length; i++) {
  4063. if (index == i) {
  4064. let Suc = suc[i]
  4065. var newSwitch = that.data.newSwitch
  4066. var timeValue = that.data.timeValue
  4067. var newSwitchstate = that.data.newSwitchstate
  4068. var choice = that.data.choice
  4069. var lightCondition = Suc.lightControlCondition
  4070. var model = Suc.ctlMode
  4071. //光控启动条件
  4072. looplightlist().then(res => {
  4073. if (res.data.code == 0) {
  4074. var lightlist = res.data.data
  4075. that.setData({
  4076. lightlist: lightlist
  4077. })
  4078. for (let i = 0; i < lightlist.length; i++) {
  4079. choice[i] = false
  4080. }
  4081. if (lightCondition.includes(',') == true) {
  4082. lightCondition = lightCondition.split(',')
  4083. for (let j = 0; j < lightCondition.length; j++) {
  4084. if (lightCondition[j] == '1') {
  4085. choice[0] = true
  4086. } else if (
  4087. lightCondition[
  4088. j] == '2') {
  4089. choice[1] = true
  4090. } else if (
  4091. lightCondition[
  4092. j] == '3') {
  4093. choice[2] = true
  4094. } else if (
  4095. lightCondition[
  4096. j] == '4') {
  4097. choice[3] = true
  4098. }
  4099. }
  4100. } else {
  4101. if (lightCondition ==
  4102. '1') {
  4103. choice[0] = true
  4104. } else if (
  4105. lightCondition ==
  4106. '2') {
  4107. choice[1] = true
  4108. } else if (
  4109. lightCondition ==
  4110. '3') {
  4111. choice[2] = true
  4112. } else if (
  4113. lightCondition ==
  4114. '4') {
  4115. choice[3] = true
  4116. }
  4117. }
  4118. that.setData({
  4119. choice: choice
  4120. })
  4121. } else {
  4122. wx.showModal({
  4123. title: '错误',
  4124. content: res
  4125. .data.msg,
  4126. showCancel: false
  4127. })
  4128. }
  4129. })
  4130. //时控1
  4131. if (Suc.timeCondition1Switch == 1) {
  4132. newSwitch[0] = true
  4133. newSwitchstate[0] = 'time'
  4134. } else {
  4135. newSwitch[0] = false
  4136. newSwitchstate[0] = ''
  4137. }
  4138. timeValue[0] = Suc.timeCondition1OnTime
  4139. timeValue[1] = Suc.timeCondition1OffTime
  4140. //时控2
  4141. if (Suc.timeCondition2Switch == 1) {
  4142. newSwitch[1] = true
  4143. newSwitchstate[1] = 'time'
  4144. } else {
  4145. newSwitch[1] = false
  4146. newSwitchstate[1] = ''
  4147. }
  4148. timeValue[2] = Suc.timeCondition2OnTime
  4149. timeValue[3] = Suc.timeCondition2OffTime
  4150. //光控
  4151. if (Suc.lightControlSwitch == 1) {
  4152. newSwitch[2] = true
  4153. newSwitchstate[2] = 'time'
  4154. newSwitchstate[3] = 'selector'
  4155. } else {
  4156. newSwitch[2] = false
  4157. newSwitchstate[2] = ''
  4158. newSwitchstate[3] = ''
  4159. }
  4160. timeValue[4] = Suc.lightControlStart
  4161. timeValue[5] = Suc.lightControlEnd
  4162. for (let j = 0; j < timeValue.length; j++) {
  4163. if (timeValue[j] == "") {
  4164. timeValue[j] = '00:00'
  4165. }
  4166. }
  4167. var messageNum = message.loopnum
  4168. messageNum.push('所有回路')
  4169. that.setData({
  4170. crr: messageNum,
  4171. timeValue: timeValue,
  4172. newSwitch: newSwitch,
  4173. beginTime:Suc.realTimeCondition1OnTime,
  4174. closeTimes:Suc.realTimeCondition1OffTime,
  4175. newChange:model
  4176. })
  4177. //监视新设备开关状态
  4178. var newSwitchs = that.data.newSwitch
  4179. var newfonts = that.data.newfont
  4180. var newcolors = that.data.newcolor
  4181. var newSwitchstates = that.data
  4182. .newSwitchstate
  4183. var disableds = that.data.disabled
  4184. if (newSwitchs[0] == true) {
  4185. newfonts[0] = "white"
  4186. newcolors[0] = "blue"
  4187. newSwitchstates[0] = "time"
  4188. } else {
  4189. newfonts[0] = "#cccccc"
  4190. newcolors[0] = "#888888"
  4191. newSwitchstates[0] = ""
  4192. }
  4193. if (newSwitchs[1] == true) {
  4194. newfonts[1] = "white"
  4195. newcolors[1] = "blue"
  4196. newSwitchstates[1] = "time"
  4197. } else {
  4198. newfonts[1] = "#cccccc"
  4199. newcolors[1] = "#888888"
  4200. newSwitchstates[1] = ""
  4201. }
  4202. if (newSwitchs[2] == true) {
  4203. newfonts[2] = "white"
  4204. newcolors[2] = "blue"
  4205. newSwitchstates[2] = "time"
  4206. disableds = false
  4207. } else {
  4208. newfonts[2] = "#cccccc"
  4209. newcolors[2] = "#888888"
  4210. newSwitchstates[2] = ""
  4211. disableds = true
  4212. }
  4213. that.setData({
  4214. newcolor: newcolors,
  4215. newfont: newfonts,
  4216. newSwitch: newSwitchs,
  4217. newSwitchstate: newSwitchstates,
  4218. disabled: disableds
  4219. })
  4220. }
  4221. }
  4222. } else {
  4223. console.log('获取新设备回路参数失败')
  4224. wx.showModal({
  4225. title: '错误',
  4226. content: suc.data.msg,
  4227. showCancel: false
  4228. })
  4229. }
  4230. })
  4231. } else {
  4232. console.log('新设备获取信息失败')
  4233. wx.showModal({
  4234. title: '错误',
  4235. content: nrg.data.msg,
  4236. showCancel: false
  4237. })
  4238. }
  4239. })
  4240. }
  4241. } else {
  4242. that.setData({
  4243. status: '离线',
  4244. deviceName: []
  4245. })
  4246. }
  4247. }
  4248. }
  4249. } else {
  4250. that.setData({
  4251. status: '离线',
  4252. deviceName: [],
  4253. groupName: []
  4254. })
  4255. }
  4256. },
  4257. /**
  4258. * 生命周期函数--监听页面隐藏
  4259. */
  4260. onHide() {
  4261. },
  4262. /**
  4263. * 生命周期函数--监听页面卸载
  4264. */
  4265. onUnload() {
  4266. },
  4267. /**
  4268. * 页面相关事件处理函数--监听用户下拉动作
  4269. */
  4270. onPullDownRefresh() {
  4271. },
  4272. /**
  4273. * 页面上拉触底事件的处理函数
  4274. */
  4275. onReachBottom() {
  4276. },
  4277. /**
  4278. * 用户点击右上角分享
  4279. */
  4280. onShareAppMessage() {
  4281. }
  4282. })