ming 2 lat temu
rodzic
commit
7ddf0e6405
2 zmienionych plików z 69 dodań i 108 usunięć
  1. 68 107
      pages/index/index.vue
  2. 1 1
      pages/login/login.vue

+ 68 - 107
pages/index/index.vue

@@ -99,9 +99,9 @@
 
 		data() {
 			return {
-				staticData: '',
-				indicator:[],
-				datavalue:[],
+				staticData: '',
+				indicator:[],
+				datavalue:[],
 				dataname:[],
 				alarmCount: json.staticData.data[0].alarmCount,
 				cuIconList: json.cuIconList,
@@ -113,7 +113,7 @@
 				searchInput: '',
 				selectedCode: 10012,
 				getData: [],
-				codeResult: '',
+				codeResult: '',
 				status:false
 
 			};
@@ -123,8 +123,8 @@
 		onNavigationBarButtonTap(e) {
 			if (e.float == 'right') {
 				// alert("你点击了扫一扫");
-				this.scanQRCode();
-				
+				this.scanQRCode();
+				
 				
 			} else {
 				// alert("你点击了获取位置");
@@ -134,54 +134,9 @@
 		},
 
 		onLoad(option) {
-			// uni.showToast({
-			// 	title: '扫码成功',
-			// 	icon: "none"
-			// })
-			
-			//this.init()
-			
-			// start
-			
-			// if (window.location.host.indexOf('localhost') != -1  ||  (window.location.host.indexOf('localhost') == -1 && option.op)) {
-			// 	this.getSearchList();
-			// 	this.getHomeData({
-			// 		'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
-			// 			.defaultSite
-			// 	});
-			// 	this.getHandleData({
-			// 		'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
-			// 			.defaultSite
-			// 	});
-			// } else {
-			// 	console.log(2)
-			// 	this.init()
-			// }
-			// end
-
-			// if (option.op) {
-			// 	// alert('op')
-			// 	// 首页数据渲染
-			// 	this.getSearchList();
-			// 	this.getHomeData({
-			// 		'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
-			// 			.defaultSite
-			// 	});
-			// 	this.getHandleData({
-			// 		'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
-			// 			.defaultSite
-			// 	});
-
-			// } else {
-			// 	this.init()
-			// }
-
-			
-			this.indicator=[] 
-			
 			
 			// 首页数据渲染
-			// if(uni.getStorageSync('token')){
+			if(uni.getStorageSync('token')){
 				this.getSearchList();
 				this.getHomeData({
 					'company_code': uni.getStorageSync('selectedCode') ? uni.getStorageSync('selectedCode') : this
@@ -195,13 +150,7 @@
 				
 				
 				
-				var res = uni.getStorageSync('selectedCode');
-				var res2 = uni.getStorageSync('selectedName');
-				if (res) {
-					uni.setNavigationBarTitle({
-						title: res2
-					});
-				}
+				
 				
 				// 图表切换渲染
 				this.hackReset = false;
@@ -209,21 +158,21 @@
 					this.hackReset = true;
 				})
 				this.status = true
-			// }else{
-			
-			// }
-			this.status = true
-			
+			}else{
+				uni.navigateTo({
+					url: '/pages/login/login'
+				})
+			}
+			this.status = true
+			
+			
+		},
+		onShow:function(){
 			
-		},
-		onShow:function(){
-		
-			// this.indicator=[] 
-			
 		},
 		methods: {
-			async init() {
-				//window.location.href = this.$BASE_URL + "Com/getPageAuthorization1"
+			async init() { 
+				//window.location.href = this.$BASE_URL + "Com/getPageAuthorization1"
 				//plus.runtime.openURL('https://baidu.com');
 			},
 			//扫码
@@ -351,10 +300,22 @@
 				})
 				this.getData = res.data.data
 				this.defaultSite = this.getData[0].owner_code;
-				if (!uni.getStorageSync('selectedCode')) {
+				if (!uni.getStorageSync('selectedCode')) {
+				
 					uni.setStorageSync('selectedCode', this.getData[0].owner_code);
 					uni.setStorageSync('selectedName', this.getData[0].owner_name);
 				}
+				
+				var aaa = uni.getStorageSync('selectedCode');
+				var bbb = uni.getStorageSync('selectedName');
+				if (aaa) {
+					uni.setNavigationBarTitle({
+						title: bbb
+					});
+				}
+				
+				
+				
 				this.searchList = []
 				res.data.data.forEach(item => {
 					this.searchList.push(item)
@@ -366,7 +327,7 @@
 			},
 			// 下拉选择
 			clickSelectItem(item, index) {
-				this.indicator=[] 
+				
 				this.staticData = '';
 				this.selectedCode = item.owner_code;
 				uni.setStorageSync('selectedCode', item.owner_code);
@@ -406,35 +367,35 @@
 				})
 				// console.log('首页请求staticData')
 				// console.log(res.data.data[0])
-				this.staticData = res.data.data[0];
-				
-				// var data = res.data.data[0]
-				
-				var datavalue = [this.staticData.fire_water_count, this.staticData.alarm_host_count, this.staticData.electrical_fire_count, this.staticData.other_count, this.staticData.video_monitoring_count
-				]
-				var dataname = ['消防水系统', '报警主机', '电气火灾', '其他', '监控视频']
-				var color = ['#3C8BF0', '#06CDF8', '#0ECB70', '#6744EF', '#FFD803'];
-				
-				var aa = [this.staticData.fire_water_count, this.staticData.alarm_host_count, this.staticData
-					.electrical_fire_count, this.staticData.other_count, this.staticData.video_monitoring_count
-				]
-				aa.sort(function(a, b) {
-					return a - b;
-				});
-				aa = aa.pop();
-				var datamax = [aa, aa, aa, aa, aa];
-				
-				this.datavalue = datavalue;
-				this.dataname=dataname;
-				
-				dataname.map((val, ind) => {
-					this.indicator.push({
-						name: val,
-						max: datamax[ind],
-						color: color[ind]
-					})
-				})
-				// this.indicator=this.indicator.slice(-5)
+				this.staticData = res.data.data[0];
+				
+				// var data = res.data.data[0]
+				
+				var datavalue = [this.staticData.fire_water_count, this.staticData.alarm_host_count, this.staticData.electrical_fire_count, this.staticData.other_count, this.staticData.video_monitoring_count
+				]
+				var dataname = ['消防水系统', '报警主机', '电气火灾', '其他', '监控视频']
+				var color = ['#3C8BF0', '#06CDF8', '#0ECB70', '#6744EF', '#FFD803'];
+				
+				var aa = [this.staticData.fire_water_count, this.staticData.alarm_host_count, this.staticData
+					.electrical_fire_count, this.staticData.other_count, this.staticData.video_monitoring_count
+				]
+				aa.sort(function(a, b) {
+					return a - b;
+				});
+				aa = aa.pop();
+				var datamax = [aa, aa, aa, aa, aa];
+				
+				this.datavalue = datavalue;
+				this.dataname=dataname;
+				
+				dataname.map((val, ind) => {
+					this.indicator.push({
+						name: val,
+						max: datamax[ind],
+						color: color[ind]
+					})
+				})
+				this.indicator=this.indicator.slice(-5)
 			},
 			// 未处理告警请求
 			async getHandleData(param = {}) {
@@ -523,13 +484,13 @@
 		padding: 0;
 		margin: 0;
 		list-style: none
-	}
-	
-	.shadow {
-		box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
+	}
+	
+	.shadow {
+		box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
 	}
 </style>
 
 <style>
 	
-</style>
+</style>

+ 1 - 1
pages/login/login.vue

@@ -150,7 +150,7 @@
 				})
 				uni.setStorageSync("token", res.data.data);
 				if (res.data.flag == true) {
-					uni.switchTab({
+					uni.reLaunch({
 						url: '/pages/index/index'
 					});
 				} else {