浏览代码

加入了状态显示

Administrator 2 年之前
父节点
当前提交
2bc5f16e3b
共有 5 个文件被更改,包括 128 次插入56 次删除
  1. 二进制
      node_modules.zip
  2. 7 7
      pages.json
  3. 121 49
      pages/lampControls/lampControls.vue
  4. 二进制
      uni_modules.zip
  5. 二进制
      unpackage.zip

二进制
node_modules.zip


+ 7 - 7
pages.json

@@ -3,6 +3,13 @@
 		"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
 	},
 	"pages": [
+		{
+			"path": "pages/login/login",
+			"style": {
+				"navigationBarTitleText" : "登录",
+				"navigationBarTextStyle": "#ffffff"
+			}
+		},
 		{
 			"path": "pages/Supervisory/Supervisory",
 			"style": {
@@ -28,13 +35,6 @@
 				}//横屏
 			}
 		},
-		{
-			"path": "pages/login/login",
-			"style": {
-				"navigationBarTitleText" : "登录",
-				"navigationBarTextStyle": "#ffffff"
-			}
-		},
 		{
 			"path": "pages/Supervisory_keep/Supervisory_keep",
 			"style": {

+ 121 - 49
pages/lampControls/lampControls.vue

@@ -22,12 +22,15 @@
 		</view>
 		<view class="list">
 			<view v-for="(item2,index2) in tworacords" :key="item2.id" class="list_data">
+				<image :src="item2.lightControlState == '2' ? imageAddress + '/lamp.png' : imageAddress + '/lamp1.png'">
+				</image>
 				<text>{{item2.publicName}}</text>
 				<button type="default" @click="allTactics(item2.publicName,item2.publicId,1,item2.lightName)"
 					style="right: 220rpx; width: 120rpx;">策略</button>
-				<button type="primary" @click="open(1,item2.publicId,item2.publicName)"
+				<button type="primary" @click="open(1,item2.publicId,item2.publicName,index2)"
 					style="right: 120rpx;">开</button>
-				<button type="warn" @click="shut(1,item2.publicId,item2.publicName)" style="right: 20rpx;">关</button>
+				<button type="warn" @click="shut(1,item2.publicId,item2.publicName,index2)"
+					style="right: 20rpx;">关</button>
 			</view>
 			<!-- 开启控制 -->
 			<u-popup :show="openShow" mode="center" duration="0">
@@ -93,7 +96,12 @@
 </template>
 
 <script>
-	import { grouplist, list, Control, light } from '@/pages/api/lighting/lighting.js'
+	import {
+		grouplist,
+		list,
+		Control,
+		light
+	} from '@/pages/api/lighting/lighting.js'
 	export default {
 		data() {
 			return {
@@ -101,7 +109,7 @@
 					total: 80, //数据总量
 					pageSize: 15, //每页的数据量
 					current: 1, //当前页数
-					thrifty: false //节流阀
+					thrifty: false ,//节流阀
 				},
 				openShow: false,
 				shutShow: false,
@@ -214,25 +222,28 @@
 				//分组信息
 				divide: {
 					publicId: 0,
-					publicName: ''
+					publicName: '',
+					groupIndex:0,//当前的分组下标
 				},
 				//设备信息
 				device: {
 					publicId: '',
-					publicName: ''
+					publicName: '',
+					index2: 0
 				},
 				//区分单个和多个开关控制
 				distinguish: {
 					opensh: 1,
 					shutsh: 1,
-				}
+				},
+				imageAddress: 'https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image',
 			}
 		},
 		onLoad() {
 			this.load()
 		},
 		onShow() {
-			
+
 		},
 		methods: {
 			load() {
@@ -240,10 +251,10 @@
 				const pageSize = this.page.pageSize
 				var records = []
 				grouplist().then(get => {
-					if(get.code == 200){
+					if (get.code == 200) {
 						this.records = get.data
 						records = get.data
-						list(records[0].id,current, pageSize).then(res => {
+						list(records[0].id, current, pageSize).then(res => {
 							if (res.code == 200) {
 								let children = res.data.records[0].children
 								this.page.total = res.data.total
@@ -257,46 +268,57 @@
 			},
 			//上拉加载
 			twoload() {
-				const current = this.page.current
-				const pageSize = this.page.pageSize
-				const groupId = this.divide.publicId
-				this.page.thrifty = true
-				list(groupId,current,pageSize).then(res => {
+				var that = this
+				const current = that.page.current
+				const pageSize = that.page.pageSize
+				const groupId = that.divide.publicId
+				that.page.thrifty = true
+				list(groupId, current, pageSize).then(res => {
 					if (res.code == 200) {
 						let records = res.data.records
 						let children = records[0].children
-						this.tworacords = [...this.tworacords, ...children]
+						uni.showToast({
+							title:'数据加载中',
+							duration:1000,
+							icon:'loading'
+						})
+						setTimeout(function(){
+							that.tworacords = [...that.tworacords, ...children]
+						},1000)
 					}
 				})
-				this.page.thrifty = false
+				that.page.thrifty = false
 			},
 			//切换分组
 			selectItem(index) {
 				var records = this.records
 				let pageSize = this.page.pageSize
 				let current = 1
+				this.divide.groupIndex = index
 				this.divide.publicId = records[index].id
 				this.divide.publicName = records[index].poleGroupName
-				list(records[index].id,current,pageSize).then(res => {
-					if(res.code == 200){
+				list(records[index].id, current, pageSize).then(res => {
+					if (res.code == 200) {
 						this.tworacords = res.data.records[0].children
 						this.page.current = 1
 					}
 				})
 			},
-			open(ever, publicId, publicName) {
+			open(ever, publicId, publicName, index2) {
 				this.distinguish.opensh = ever
 				if (ever == 1) {
 					this.device.publicId = publicId
 					this.device.publicName = publicName
+					this.device.index2 = index2
 				}
 				this.openShow = true
 			},
-			shut(ever,publicId,publicName) {
+			shut(ever, publicId, publicName,index2) {
 				this.distinguish.shutsh = ever
-				if(ever == 1){
+				if (ever == 1) {
 					this.device.publicId = publicId
 					this.device.publicName = publicName
+					this.device.index2 = index2
 				}
 				this.shutShow = true
 			},
@@ -328,21 +350,36 @@
 					fontSize: 15,
 				})
 			},
+			//延时请求(全开)
+			delayedOpen(publicId,records){
+				var that = this
+				var index = that.divide.groupIndex
+				list(publicId,1,15).then(res => {
+					if(res.code == 200){
+						that.page.current = 1
+						let children = records[index].children
+					}
+				})
+			},
 			openControl(handSwitch, handType) {
-				const openTime = this.openTime
-				const duration = this.duration
-				const openRemarks = this.openRemarks
+				var that = this
+				const openTime = that.openTime
+				const duration = that.duration
+				const openRemarks = that.openRemarks
+				var opensh = that.distinguish.opensh
+				var tworacords = that.tworacords
+				var index2 = that.device.index2
 				if (openTime == '') {
-					this.exError()
+					that.exError()
 				} else {
 					var publicId = 0
 					var publicName = ''
-					if (this.distinguish.opensh == 1) {
-						publicId = this.device.publicId
-						publicName = this.device.publicName
+					if (opensh == 1) {
+						publicId = that.device.publicId
+						publicName = that.device.publicName
 					} else {
-						publicId = this.divide.publicId
-						publicName = this.divide.publicName
+						publicId = that.divide.publicId
+						publicName = that.divide.publicName
 					}
 					//handSwitch(开启:1,关闭:2)
 					//handType(开/关:1,全开/全关:2)
@@ -353,7 +390,20 @@
 					//publicName(分组/设备名称)
 					Control(handSwitch, handType, publicId, openTime, duration, openRemarks, publicName).then(res => {
 						if (res.code == 200) {
-							this.Success('开灯成功')
+							if(opensh == 1){
+								tworacords[index2].lightControlState = "1"
+								that.tworacords = tworacords
+								that.Success('开灯成功')
+							}else{
+								uni.showToast({
+									title:'发送指令中',
+									duration:10000,
+									icon:'loading',
+								})
+								setTimeout(function(){
+									that.load()
+								},10000)
+							}
 						}
 					})
 				}
@@ -362,23 +412,40 @@
 				this.shutTime = index >= 0 ? item.value : ''
 			},
 			shutControl(handSwitch, handType) {
-				const shutTime = this.shutTime
-				const shutRemarks = this.shutRemarks
+				var that = this
+				const shutTime = that.shutTime
+				const shutRemarks = that.shutRemarks
+				var tworacords = that.tworacords
+				var index2 = that.device.index2
+				var opensh = that.distinguish.opensh
 				if (shutTime == '') {
-					this.exError()
+					that.exError()
 				} else {
 					var publicId = 0
 					var publicName = ''
-					if(this.distinguish.opensh == 1){
-						publicId = this.device.publicId
-						publicName = this.device.publicName
-					}else{
-						publicId = this.divide.publicId
-						publicName = this.divide.publicName
+					if (opensh == 1) {
+						publicId = that.device.publicId
+						publicName = that.device.publicName
+						
+					} else {
+						publicId = that.divide.publicId
+						publicName = that.divide.publicName
 					}
 					Control(handSwitch, handType, publicId, shutTime, 0, shutRemarks, publicName).then(res => {
 						if (res.code == 200) {
-							this.Success('关灯成功')
+							if(opensh == 1){
+								tworacords[index2].lightControlState = '2'
+								that.tworacords = tworacords
+							}else{
+								uni.showToast({
+									title:'发送指令中',
+									duration:10000,
+									icon:'loading',
+								})
+								setTimeout(function(){
+									that.delayedOpen(publicId,that.records,)
+								},10000)
+							}
 						}
 					})
 				}
@@ -417,8 +484,8 @@
 			}
 		},
 		//触底事件(如果节流阀打开则不执行加载)
-		onReachBottom(){
-			if(this.page.current * this.page.pageSize >= this.page.total){
+		onReachBottom() {
+			if (this.page.current * this.page.pageSize >= this.page.total) {
 				this.$refs.uToast.show({
 					type: 'default',
 					message: '数据加载完毕',
@@ -426,12 +493,11 @@
 				})
 				return
 			}
-			if(this.page.thrifty == true) return
+			if (this.page.thrifty == true) return
 			this.page.current = this.page.current + 1
 			this.twoload()
 		}
 	}
-
 </script>
 
 <style scoped lang="scss">
@@ -481,6 +547,14 @@
 			font-size: 32rpx;
 			position: absolute;
 			top: 34rpx;
+			left: 110rpx;
+		}
+
+		image {
+			width: 70rpx;
+			height: 70rpx;
+			position: absolute;
+			top: 15rpx;
 			left: 20rpx;
 		}
 
@@ -602,6 +676,4 @@
 			font-size: 36rpx;
 		}
 	}
-
-</style>
-
+</style>

二进制
uni_modules.zip


二进制
unpackage.zip