Selaa lähdekoodia

新设备固定经纬切换

Administrator 2 vuotta sitten
vanhempi
commit
b88253fe1f
8 muutettua tiedostoa jossa 6540 lisäystä ja 6103 poistoa
  1. 257 227
      pages/control/control.js
  2. 4256 3964
      pages/loop/loop.js
  3. 3 0
      pages/loop/loop.wxml
  4. 21 1
      pages/loop/loop.wxss
  5. 1 2
      pages/scene/scene.js
  6. 1999 1907
      pages/system/system.js
  7. 2 1
      project.config.json
  8. 1 1
      project.private.config.json

+ 257 - 227
pages/control/control.js

@@ -79,9 +79,13 @@ Page({
 			getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
 				if (res.data.errno == 0) {
 					if (res.data.data.online == true) {
-						that.setData({ status: '在线' })
+						that.setData({
+							status: '在线'
+						})
 					} else {
-						that.setData({ status: '离线' })
+						that.setData({
+							status: '离线'
+						})
 					}
 				} else {
 					wx.showModal({
@@ -390,9 +394,13 @@ Page({
 			getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
 				if (res.data.errno == 0) {
 					if (res.data.data.online == true) {
-						that.setData({ status: '在线' })
+						that.setData({
+							status: '在线'
+						})
 					} else {
-						that.setData({ status: '离线' })
+						that.setData({
+							status: '离线'
+						})
 					}
 				} else {
 					wx.showModal({
@@ -1406,9 +1414,13 @@ Page({
 		getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
 			if (res.data.errno == 0) {
 				if (res.data.data.online == true) {
-					that.setData({ status: '在线' })
+					that.setData({
+						status: '在线'
+					})
 				} else {
-					that.setData({ status: '离线' })
+					that.setData({
+						status: '离线'
+					})
 				}
 			} else {
 				wx.showModal({
@@ -1441,7 +1453,7 @@ Page({
 					for (let h = 0; h < 12; h++) {
 						lamp.push(
 							"https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png"
-							)
+						)
 					}
 					setTimeout(function() {
 						getData(that.data.deviceId, that.data.deviceKey).then(bind => {
@@ -1526,9 +1538,13 @@ Page({
 		getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
 			if (res.data.errno == 0) {
 				if (res.data.data.online == true) {
-					that.setData({ status: '在线' })
+					that.setData({
+						status: '在线'
+					})
 				} else {
-					that.setData({ status: '离线' })
+					that.setData({
+						status: '离线'
+					})
 				}
 			} else {
 				wx.showModal({
@@ -1561,7 +1577,7 @@ Page({
 					for (let h = 0; h < 12; h++) {
 						lamp.push(
 							"https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png"
-							)
+						)
 					}
 					setTimeout(function() {
 						getData(that.data.deviceId, that.data.deviceKey).then(bind => {
@@ -1711,7 +1727,7 @@ Page({
 					for (let h = 0; h < 12; h++) {
 						lamp.push(
 							"https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png"
-							)
+						)
 					}
 					//旧设备
 					if (moudule == 0) {
@@ -1754,228 +1770,228 @@ Page({
 												})
 											}
 											getData(deviceId, deviceKey).then(
-											ver => {
-												if (ver.data.errno == 0) {
-													let data = ver.data.data
-													for (let i = 0; i < data
-														.length; i++) {
-														if (data[i].id ==
-															"RelayCount") {
-															var quantity =
-																data[i]
-																.current_value
-															that.setData({
-																loops: quantity
-															})
-														} else if (data[i]
-															.id ==
-															"ManualStatus"
-															) {
-															if (data[i]
-																.current_value ==
-																0) {
-																that.setData({
-																	Modecontrol: "自动"
-																})
-															} else {
+												ver => {
+													if (ver.data.errno == 0) {
+														let data = ver.data.data
+														for (let i = 0; i < data
+															.length; i++) {
+															if (data[i].id ==
+																"RelayCount") {
+																var quantity =
+																	data[i]
+																	.current_value
 																that.setData({
-																	Modecontrol: "手动"
+																	loops: quantity
 																})
+															} else if (data[i]
+																.id ==
+																"ManualStatus"
+															) {
+																if (data[i]
+																	.current_value ==
+																	0) {
+																	that.setData({
+																		Modecontrol: "自动"
+																	})
+																} else {
+																	that.setData({
+																		Modecontrol: "手动"
+																	})
+																}
 															}
-														}
-														//回路1
-														else if (data[i]
-															.id ==
-															'R1_RelayStatus'
+															//回路1
+															else if (data[i]
+																.id ==
+																'R1_RelayStatus'
 															) {
-															let police =
-																data[i]
-																.current_value
-															var lamps =
-																control
-																.switchReal(
-																	police,
-																	lamp, 0)
-														} else if (data[i]
-															.id ==
-															'R2_RelayStatus'
+																let police =
+																	data[i]
+																	.current_value
+																var lamps =
+																	control
+																	.switchReal(
+																		police,
+																		lamp, 0)
+															} else if (data[i]
+																.id ==
+																'R2_RelayStatus'
 															) {
-															let police =
-																data[i]
-																.current_value
-															var lamps =
-																control
-																.switchReal(
-																	police,
-																	lamp, 1)
-														} else if (data[i]
-															.id ==
-															'R3_RelayStatus'
+																let police =
+																	data[i]
+																	.current_value
+																var lamps =
+																	control
+																	.switchReal(
+																		police,
+																		lamp, 1)
+															} else if (data[i]
+																.id ==
+																'R3_RelayStatus'
 															) {
-															let police =
-																data[i]
-																.current_value
-															var lamps =
-																control
-																.switchReal(
-																	police,
-																	lamp, 2)
-														} else if (data[i]
-															.id ==
-															'R4_RelayStatus'
+																let police =
+																	data[i]
+																	.current_value
+																var lamps =
+																	control
+																	.switchReal(
+																		police,
+																		lamp, 2)
+															} else if (data[i]
+																.id ==
+																'R4_RelayStatus'
 															) {
-															let police =
-																data[i]
-																.current_value
-															var lamps =
-																control
-																.switchReal(
-																	police,
-																	lamp, 3)
-														} else if (data[i]
-															.id ==
-															'R5_RelayStatus'
+																let police =
+																	data[i]
+																	.current_value
+																var lamps =
+																	control
+																	.switchReal(
+																		police,
+																		lamp, 3)
+															} else if (data[i]
+																.id ==
+																'R5_RelayStatus'
 															) {
-															let police =
-																data[i]
-																.current_value
-															var lamps =
-																control
-																.switchReal(
-																	police,
-																	lamp, 4)
-														} else if (data[i]
-															.id ==
-															'R6_RelayStatus'
+																let police =
+																	data[i]
+																	.current_value
+																var lamps =
+																	control
+																	.switchReal(
+																		police,
+																		lamp, 4)
+															} else if (data[i]
+																.id ==
+																'R6_RelayStatus'
 															) {
-															let police =
-																data[i]
-																.current_value
-															var lamps =
-																control
-																.switchReal(
-																	police,
-																	lamp, 5)
-														} else if (data[i]
-															.id ==
-															'R7_RelayStatus'
+																let police =
+																	data[i]
+																	.current_value
+																var lamps =
+																	control
+																	.switchReal(
+																		police,
+																		lamp, 5)
+															} else if (data[i]
+																.id ==
+																'R7_RelayStatus'
 															) {
-															let police =
-																data[i]
-																.current_value
-															var lamps =
-																control
-																.switchReal(
-																	police,
-																	lamp, 6)
-														} else if (data[i]
-															.id ==
-															'R8_RelayStatus'
+																let police =
+																	data[i]
+																	.current_value
+																var lamps =
+																	control
+																	.switchReal(
+																		police,
+																		lamp, 6)
+															} else if (data[i]
+																.id ==
+																'R8_RelayStatus'
 															) {
-															let police =
-																data[i]
-																.current_value
-															var lamps =
-																control
-																.switchReal(
-																	police,
-																	lamp, 7)
-														} else if (data[i]
-															.id ==
-															'R9_RelayStatus'
+																let police =
+																	data[i]
+																	.current_value
+																var lamps =
+																	control
+																	.switchReal(
+																		police,
+																		lamp, 7)
+															} else if (data[i]
+																.id ==
+																'R9_RelayStatus'
 															) {
-															let police =
-																data[i]
-																.current_value
-															var lamps =
-																control
-																.switchReal(
-																	police,
-																	lamp, 8)
-														} else if (data[i]
-															.id ==
-															'R10_RelayStatus'
+																let police =
+																	data[i]
+																	.current_value
+																var lamps =
+																	control
+																	.switchReal(
+																		police,
+																		lamp, 8)
+															} else if (data[i]
+																.id ==
+																'R10_RelayStatus'
 															) {
-															let police =
-																data[i]
-																.current_value
-															var lamps =
-																control
-																.switchReal(
-																	police,
-																	lamp, 9)
-														} else if (data[i]
-															.id ==
-															'R11_RelayStatus'
+																let police =
+																	data[i]
+																	.current_value
+																var lamps =
+																	control
+																	.switchReal(
+																		police,
+																		lamp, 9)
+															} else if (data[i]
+																.id ==
+																'R11_RelayStatus'
 															) {
-															let police =
-																data[i]
-																.current_value
-															var lamps =
-																control
-																.switchReal(
-																	police,
-																	lamp, 10
+																let police =
+																	data[i]
+																	.current_value
+																var lamps =
+																	control
+																	.switchReal(
+																		police,
+																		lamp, 10
 																	)
-														} else if (data[i]
-															.id ==
-															'R12_RelayStatus'
+															} else if (data[i]
+																.id ==
+																'R12_RelayStatus'
 															) {
-															let police =
-																data[i]
-																.current_value
-															var lamps =
-																control
-																.switchReal(
-																	police,
-																	lamp, 11
+																let police =
+																	data[i]
+																	.current_value
+																var lamps =
+																	control
+																	.switchReal(
+																		police,
+																		lamp, 11
+																	)
+															}
+															wx.setStorageSync(
+																'lamp',
+																lamps)
+															that.setData({
+																lamp: wx
+																	.getStorageSync(
+																		'lamp'
 																	)
+															})
+														}
+														var Loop = that.data
+															.Loop
+														var color = that.data
+															.Color
+														var size = that.data
+															.Size
+														var Address = that.data
+															.address
+														var enloop = that.data
+															.loop
+														for (let i = 0; i <
+															quantity; i++) {
+															Loop[i] = enloop[i]
+															color[i] = "black"
+															size[i] =
+																"calc(100vw * 16/375)",
+																Address[i] =
+																"/image/modify.png"
 														}
-														wx.setStorageSync(
-															'lamp',
-															lamps)
 														that.setData({
-															lamp: wx
-																.getStorageSync(
-																	'lamp'
-																	)
+															Color: color,
+															Size: size,
+															address: Address,
+															Loop: Loop
+														})
+													} else {
+														wx.showModal({
+															title: '错误',
+															content: ver
+																.data
+																.error,
+															showCancel: false
 														})
 													}
-													var Loop = that.data
-														.Loop
-													var color = that.data
-														.Color
-													var size = that.data
-														.Size
-													var Address = that.data
-														.address
-													var enloop = that.data
-														.loop
-													for (let i = 0; i <
-														quantity; i++) {
-														Loop[i] = enloop[i]
-														color[i] = "black"
-														size[i] =
-															"calc(100vw * 16/375)",
-															Address[i] =
-															"/image/modify.png"
-													}
-													that.setData({
-														Color: color,
-														Size: size,
-														address: Address,
-														Loop: Loop
-													})
-												} else {
-													wx.showModal({
-														title: '错误',
-														content: ver
-															.data
-															.error,
-														showCancel: false
-													})
-												}
-											})
+												})
 										} else {
 											wx.showModal({
 												title: '错误',
@@ -2365,7 +2381,9 @@ Page({
 					}, 2000)
 				} else if (res.data.errno == 10) {
 					setTimeout(function() {
-						that.setData({ status: '离线' })
+						that.setData({
+							status: '离线'
+						})
 					}, 2000)
 				} else {
 					setTimeout(function() {
@@ -2421,7 +2439,8 @@ Page({
 			}
 			that.setData({
 				loop: loop
-			})
+      })
+      console.log(id)
 			getloop(id).then(res => {
 				if (res.data.code == 0) {
 					let loopState = res.data.data
@@ -2487,9 +2506,13 @@ Page({
 		getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
 			if (res.data.errno == 0) {
 				if (res.data.data.online == true) {
-					that.setData({ status: '在线' })
+					that.setData({
+						status: '在线'
+					})
 				} else {
-					that.setData({ status: '离线' })
+					that.setData({
+						status: '离线'
+					})
 				}
 			} else {
 				wx.showModal({
@@ -2555,9 +2578,13 @@ Page({
 		getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
 			if (res.data.errno == 0) {
 				if (res.data.data.online == true) {
-					that.setData({ status: '在线' })
+					that.setData({
+						status: '在线'
+					})
 				} else {
-					that.setData({ status: '离线' })
+					that.setData({
+						status: '离线'
+					})
 				}
 			} else {
 				wx.showModal({
@@ -2661,7 +2688,9 @@ Page({
 					}
 				}
 			} else {
-				that.setData({ groupIndex: 0 })
+				that.setData({
+					groupIndex: 0
+				})
 				wx.setStorageSync('groupName', that.data.groupName[that.data.groupIndex])
 			}
 			//获取设备下拉
@@ -2688,7 +2717,9 @@ Page({
 								}
 							}
 						} else {
-							that.setData({ deviceIndex: 0 })
+							that.setData({
+								deviceIndex: 0
+							})
 							wx.setStorageSync('deviceName', that.data.deviceName[that.data.deviceIndex])
 						}
 						//根据分组名和设备信息
@@ -2740,7 +2771,7 @@ Page({
 						for (let h = 0; h < 12; h++) {
 							lamp.push(
 								"https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png"
-								)
+							)
 						}
 						//旧设备
 						if (moudule == 0) {
@@ -2920,7 +2951,7 @@ Page({
 															lamp: wx
 																.getStorageSync(
 																	'lamp'
-																	)
+																)
 														})
 													}
 													var Loop = that.data.Loop
@@ -3021,8 +3052,8 @@ Page({
 									for (let n = 0; n < loopState.length; n++) {
 										Loop[n] = that.data.Loop[n]
 										color[n] = "black"
-										size[n] = "calc(100vw * 16/375)",
-											Address[n] = "/image/modify.png"
+										size[n] = "calc(100vw * 16/375)"
+										Address[n] = "/image/modify.png"
 									}
 									that.setData({
 										Color: color,
@@ -3040,7 +3071,7 @@ Page({
 							})
 							loopSwitchstate(id).then(ret => {
 								if (ret.data.code == 0) {
-									var relay = ret.data.data
+                  var relay = ret.data.data
 									for (let e = 0; e < relay.length; e++) {
 										if (relay[e].status == 1) {
 											lamp[e] =
@@ -3119,5 +3150,4 @@ Page({
 	onShareAppMessage() {
 
 	}
-})
-
+})

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 4256 - 3964
pages/loop/loop.js


+ 3 - 0
pages/loop/loop.wxml

@@ -22,6 +22,9 @@
       {{crr[indexes]}}
     </view>
   </picker>
+  <view wx:if="{{play == 1}}" class="newChange">
+    <button bindtap = "newChange">{{newChange == 0 ? '手动' : '经纬'}}</button>
+  </view>
 </view>
 <!-- 旧设备 -->
 <view class="subject" wx:if="{{play == 0 ? true : false}}">

+ 21 - 1
pages/loop/loop.wxss

@@ -375,4 +375,24 @@ page{
 
 .check{
   margin:8px auto;
-}
+}
+
+.newChange{
+  width: 20%;
+  height: 80%;
+  position: absolute;
+  right: 5%;
+  top: 10%;
+}
+
+.newChange button{
+  width: 100%;
+  height: 100%;
+  font-size: calc(100vw * 18/375);
+  background-color: cornflowerblue;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  color: #ffffff;
+}
+

+ 1 - 2
pages/scene/scene.js

@@ -299,8 +299,7 @@ Page({
 						groupId: Idindex,
 						deviceSn: SN,
 						deviceId: ID,
-						module: 3,
-            circuitNum:2,
+						module: 1,
 						deviceName: SN
 					}).then(add => {
 						if (add.data.code == 0) {

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1999 - 1907
pages/system/system.js


+ 2 - 1
project.config.json

@@ -44,7 +44,8 @@
     },
     "disableUseStrict": false,
     "useCompilerPlugins": false,
-    "checkSiteMap": false
+    "checkSiteMap": false,
+    "condition": false
   },
   "compileType": "miniprogram",
   "libVersion": "2.19.6",

+ 1 - 1
project.private.config.json

@@ -1,5 +1,5 @@
 {
-  "projectname": "weixin",
+  "projectname": "Wechat",
   "setting": {
     "compileHotReLoad": true,
     "bigPackageSizeSupport": true,