Ver Fonte

1、单点登录修改
2、顶部状态栏背景修改

msx há 3 meses atrás
pai
commit
ecab6a1587

+ 26 - 12
api/api.js

@@ -17,19 +17,33 @@ const apiService = {
   /**
    * 单点登录
    */
-  validateCasLogin(params) {
-	  var index = 0;
-	  var url = "/sys/cas/client/validateLogin";
-	  for(var w in params){
-		  if(index == 0)
-		  url = url+"?"+w+"="+params[w];
-		  else
-		  url = url+"&"+w+"="+params[w];
-		  index++;
-	  }
-    return http.get(url);
-  },
+  // validateCasLogin(params) {
+	 //  var index = 0;
+	 //  var url = "/sys/cas/client/validateLogin";
+	 //  for(var w in params){
+		//   if(index == 0)
+		//   url = url+"?"+w+"="+params[w];
+		//   else
+		//   url = url+"&"+w+"="+params[w];
+		//   index++;
+	 //  }
+  //   return http.get(url);
+  // },
 
+  validateCasLogin(to,params) {
+	  var url = to+"/sys/cas/client/validateLogin"+params;
+	  // var index = 0;
+	  // var url = "/sys/cas/client/validateLogin";
+	  // for(var w in params){
+		 //  if(index == 0)
+		 //  url = url+"?"+w+"="+params[w];
+		 //  else
+		 //  url = url+"&"+w+"="+params[w];
+		 //  index++;
+	  // }
+	  console.log("validateCasLogin url============"+url)
+    return http.get(url,{});
+  },
   /**
    * 手机号码登录
    */

+ 4 - 0
main.js

@@ -37,6 +37,10 @@ import history from "./pages/history/history.vue";
 Vue.component("history", history);
 import warndata from "./pages/warndata/warndata.vue";
 Vue.component("warndata", warndata);
+import detail from "./pages/warndata/components/device-detail.vue";
+Vue.component("detail", detail);
+import user from "./pages/user/people.vue";
+Vue.component("user", user);
 import filecenter from "./pages/filecenter/filecenter.vue";
 Vue.component("filecenter", filecenter);
 import gasreport from "./pages/gasreport/gasreport.vue";

+ 4 - 0
pages.json

@@ -130,6 +130,10 @@
       "style": {}
     },
     {
+      "path": "pages/user/user",
+      "style": {}
+    },
+    {
       "path": "pages/camera/camera",
       "style": {}
     },

+ 5 - 1
pages/device/index.vue

@@ -2,7 +2,9 @@
   <view>
 	  <!-- 建议放在外层 -->
 	  <u-navbar
-		title="设备中心"
+		title="设备中心" 
+		:bgImage="backPic"
+		 :bgStatusImage="backPic0" 
 		@leftClick="devicemenuShow"
 		:safeAreaInsetTop="true"
 	  >
@@ -39,6 +41,8 @@ export default {
 	},
   data() {
     return {
+      backPic0: "url(/static/topnavbar0.png)",
+      backPic: "url(/static/topnavbar.png)",
       PageCur: "0",
 	  showColum: {},
 	  menushow: false,

+ 8 - 3
pages/filecenter/filecenter.vue

@@ -1,7 +1,9 @@
 <template name="filecenter">
+  <view >
+    <u-navbar title="文件中心" :bgStatusImage="backPic0" :bgImage="backPic" :safeAreaInsetTop="true" leftIcon=""> </u-navbar>
   <view class="container">
-    <u-navbar title="文件中心" :safeAreaInsetTop="true" leftIcon=""> </u-navbar>
     <view class="main">
+      <view class="u-page">
       <u-subsection
         :list="sectionList"
         mode="subsection"
@@ -205,6 +207,8 @@
         :duration="1000"
       ></u-notify>
     </view>
+    </view>
+    </view>
   </view>
 </template>
 
@@ -217,6 +221,8 @@ export default {
   watch: {},
   data() {
     return {
+      backPic0: "url(/static/topnavbar0.png)",
+      backPic: "url(../../static/topnavbar.png)",
       sectionList: [
         { name: "全部", code: 0 },
         { name: "待审批", code: 1 },
@@ -543,10 +549,9 @@ button {
 }
 .main {
   /* margin-top: 100rpx; */
-  margin-top: 80px;
+  /* margin-top: 80px; */
   display: flex;
   flex-direction: column;
-  margin-top: 80px; /* 内容区域顶部留出导航栏的高度 */
 }
 
 .itemback {

+ 3 - 1
pages/gasreport/gasreport.vue

@@ -1,6 +1,6 @@
 <template>
     <view class="gas-report" name="gasreport">
-        <u-navbar title="瓦斯日报" :safeAreaInsetTop="true" leftIcon=""> </u-navbar>
+        <u-navbar title="瓦斯日报" :bgImage="backPic" :bgStatusImage="backPic0" :safeAreaInsetTop="true" leftIcon=""> </u-navbar>
         <view class="gas-content">
             <!-- 瓦斯上报列表 -->
             <view v-if="!isShowAdd">
@@ -194,6 +194,8 @@ export default {
     watch: {},
     data() {
         return {
+      backPic0: "url(/static/topnavbar0.png)",
+            backPic: "url(/static/topnavbar.png)",
             isDisabled: false,
             isStatus: '',
             deviceId: '',

+ 1 - 16
pages/history/history.vue

@@ -114,22 +114,7 @@
                 </div>
               </u-col>
               <u-col span="2">
-                <div v-if="item.readData[warnFlag] == 0" class="success-tag">
-                  <image
-                    src="/static/model/alarmTrue.svg"
-                    alt=""
-                    class="icon-style"
-                  />
-                  <span style="float: right">{{ item.readData[warndes] }}</span>
-                </div>
-                <div v-else class="error-tag">
-                  <image
-                    src="/static/model/alarmFalse.svg"
-                    alt=""
-                    class="icon-style"
-                  />
-                  <span style="float: right">{{ item.readData[warndes] }}</span>
-                </div>
+              
               </u-col>
               <u-col span="3"> </u-col>
               <u-col span="5">

+ 3 - 2
pages/home/detail/autodoor/autodoor.vue

@@ -1,7 +1,7 @@
 <template>
   <view style="overflow: auto; height: 100%">
     <!-- 建议放在外层 -->
-    <u-navbar :title="name" @leftClick="backPage" :bgImage="backPic">
+    <u-navbar :title="name" @leftClick="backPage" :bgImage="backPic" :bgStatusImage="backPic0">
       <view class="u-nav-slot" slot="left">
         <u-icon name="arrow-left" size="20"> </u-icon>
       </view>
@@ -276,7 +276,8 @@ export default {
       deviceid: "", //初始化设备id
       TabCur: "",
       checked: [],
-      backPic: "url(../../../../static/topnavbar.png)",
+      backPic0: "url(/static/topnavbar0.png)",
+      backPic: "url(/static/topnavbar.png)",
       frontAngle: "", //风窗打开角度
       nwindownum: "", //风窗道数
       ndoorcount: "", //风门道数

+ 20 - 7
pages/index/index.vue

@@ -19,15 +19,16 @@
     <filecenter :cur="PageCur" v-if="PageCur == 'filecenter'"></filecenter>
     <warndata v-if="PageCur == 'warndata'" :cur="PageCur"></warndata>
     <gasreport :cur="PageCur" v-if="PageCur == 'gasreport'"></gasreport>
+    <user :cur="PageCur" v-if="PageCur == 'user'"></user>
     <u-tabbar :value="PageCur" @change="NavChange" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true">
-      <u-tabbar-item v-for="(item, index) in permission " :key="index" :text="item.name" :name="item.component"
+      <u-tabbar-item v-for="(item, index) in permission " :key="index" :text="item.meta.title" :name="item.component"
         :icon="index = 0 ? 'list-dot' : index == 1 ? 'calendar' : index == 2 ? 'plus-circle' : index == 3 ? 'file-text' : index == 4 ? 'bell' : 'list-dot'"></u-tabbar-item>
-      <u-tabbar-item
+    <!--  <u-tabbar-item
         text="通风系统图"
         name="tun2D"
         icon="list-dot"
-      ></u-tabbar-item>
-      <u-tabbar-item
+      ></u-tabbar-item> -->
+     <!-- <u-tabbar-item
         text="设备中心"
         name="device"
         icon="calendar"
@@ -46,7 +47,12 @@
         text="瓦斯日报"
         name="gasreport"
         icon="bell"
-      ></u-tabbar-item>
+      ></u-tabbar-item> -->
+      <u-tabbar-item
+        text="我的"
+        name="user"
+        icon="bell"
+      ></u-tabbar-item> -->
     </u-tabbar>
   </view>
 </template>
@@ -71,13 +77,20 @@ export default {
   },
   computed: {
     permission: function () {
-      return uni.getStorageSync('menuPermission')
+		var data = uni.getStorageSync('menuPermission');
+		console.log(JSON.stringify(data))
+		if(data==null ||data==""||data.length==0){
+			data = [{"redirect":null,"path":"/device","ver":null,"component":"device","route":"1","meta":{"keepAlive":false,"des":null,"internalOrExternal":false,"componentName":"device","title":"设备中心"},"name":"device","id":"1862300062379954178"},{"redirect":null,"path":"/warndata","ver":null,"component":"warndata","route":"1","meta":{"keepAlive":false,"des":null,"internalOrExternal":false,"componentName":"warndata","title":"预警分析"},"name":"warndata","id":"1862301272310829057"},{"redirect":null,"path":"/filecenter","ver":null,"component":"filecenter","route":"1","meta":{"keepAlive":false,"des":null,"internalOrExternal":false,"componentName":"filecenter","title":"文件共享中心"},"name":"filecenter","id":"1862301712700166146"},{"redirect":null,"path":"/gasreport","ver":null,"component":"gasreport","route":"1","meta":{"keepAlive":false,"des":null,"internalOrExternal":false,"componentName":"gasreport","title":"瓦斯上报"},"name":"gasreport","id":"1862302433877184513"}]
+		}
+      return data
     }
   },
   watch: {
     permission: {
       handler(newV, oldV) {
-        this.PageCur=newV[0].component
+		  debugger
+		if(newV!=null && newV != "")
+          this.PageCur=newV[0].component
       },
       immediate: true,
     }

+ 5 - 5
pages/user/people.vue

@@ -19,7 +19,7 @@
 		  </view>
 		  <!-- 列表list-->
 		  <view class="cu-list menu card-menu margin-top-xl margin-bottom-xl shadow-lg radius">
-		    <view class="cu-item arrow animation-slide-bottom" :style="[{animationDelay: '0.1s'}]">
+		   <!-- <view class="cu-item arrow animation-slide-bottom" :style="[{animationDelay: '0.1s'}]">
 		      <view class="content" >
 		        <text class="cuIcon-favorfill text-yellow"></text>
 		        <text class="text-grey">收藏</text>
@@ -30,19 +30,19 @@
 		        <text class="cuIcon-redpacket_fill text-red"></text>
 		        <text class="text-grey">红包</text>
 		      </view>
-		    </view>
+		    </view> -->
 			<view class="cu-item arrow animation-slide-bottom" :style="[{animationDelay: '0.3s'}]" @tap="scan">
 			  <view class="content">
 			    <text class="cuIcon-scan text-red"></text>
 			    <text class="text-grey">扫码</text>
 			  </view>
 			</view>
-			<navigator class="cu-item arrow animation-slide-bottom" :style="[{animationDelay: '0.4s'}]" url="/pages/user/location" hover-class="none">
+			<!-- <navigator class="cu-item arrow animation-slide-bottom" :style="[{animationDelay: '0.4s'}]" url="/pages/user/location" hover-class="none">
 				<view class="content" >
 				    <text class="cuIcon-location text-cyan"></text>
 					<text class="text-grey">定位</text>
 				</view>
-			</navigator>
+			</navigator> -->
 			<navigator class="cu-item arrow animation-slide-bottom" url="/pages/user/userdetail" :style="[{animationDelay: '0.6s'}]">
 			     <view class="content">
 				    <text class="cuIcon-settingsfill text-cyan"></text>
@@ -151,7 +151,7 @@
 <style>
 .UCenter-bg {
 	/* #ifdef MP-WEIXIN */
-	background-image: url('https://static.jeecg.com/upload/test/blue_1595818030310.png');
+	background-image: url('/static/topnavbar.png');
 	/* #endif */
 	/* #ifndef MP-WEIXIN */
 	background-image: url('/static/blue.png');

+ 211 - 65
pages/webview/webview.vue

@@ -1,71 +1,217 @@
 <!-- /pages/webview/webview.vue -->
 <template>
-  <web-view :src="src" @message="onMessage"></web-view>
+	<view>
+		<web-view style="height:calc(100% - 30px);margin-top:30px" :src="src" ref="webview"></web-view>
+		<view class="zai-title text-shadow " style="position: fixed;top:5px;z-index:3">返回</view>
+	</view>
 </template>
- 
+
 <script>
-import configService from "@/common/service/config.service.js";
-import api from "@/api/api";
-export default {
-  data() {
-    return {
-      src: ''
-    };
-  },
-  methods:{
-	  onMessage(event) {
-	                  uni.showModal({
-	                      content: JSON.stringify(event.detail),
-	                      showCancel: false
-	                  });
-	              },
-	  // onMessage(e) {
-	  //     // 通过 e.detail.data 可以获取到网页发送过来的数据
-	  //     // 如果要监听URL变化,可以在这里处理
-	  //     console.log('网页发送的数据:', e.detail.data);
-	  //   }
-  },
-  watch:{
-	  src(value){
-		if(value.indexOf("ticket") !=-1) {	   
-		     this.$destroy();
-            var tourl = configService.apiUrl;
-			 try {
-			 	new Promise((resolve, reject) => {
-			 		api
-			 			.validateCasLogin({
-			 				ticket: value.substring(value.indexOf("ticket")+7,value.length),
-			 				service: tourl,
-			 			})
-			 			.then((response) => {
-			 				if (response.data.code == 200) {
-			 					uni.setStorageSync(ACCESS_TOKEN, response.data.result.token);
-			 				} else {
-			 					reject(response);
-			 				}
-							
-							uni.navigateTo({
-							  url: "/pages/home/home",
-							});
-			 			})
-			 			.catch((error) => {
-			 				console.log("catch===>response", response);
-			 				reject(error);
-			 			});
-			 	});
-			 
-			 } catch (e) {
-			 }
+	import configService from "@/common/service/config.service.js";
+	import {
+		ACCESS_TOKEN,
+		USER_NAME,
+		USER_INFO
+	} from "@/common/util/constants";
+	import api from "@/api/api";
+	export default {
+		data() {
+			return {
+				timer: '',
+				src: ''
+			};
+		},
+		methods: {
+			onLoaded() {
+				this.$tip.toast("onLoaded");
+				// 在webview加载完成后,注入JavaScript代码
+				this.$refs.webview.evalJs(`
+	        (function() {
+	          // 监听URL变化事件
+	          window.addEventListener('hashchange', function() {
+	            // 将URL变化通过postMessage传递给uniapp
+	            window.postMessage(JSON.stringify({
+	              type: 'urlChange',
+	              url: window.location.href
+	            }));
+	          });
+	
+	          // 监听popstate事件(用于处理浏览器历史记录的变化)
+	          window.addEventListener('popstate', function() {
+	            window.postMessage(JSON.stringify({
+	              type: 'urlChange',
+	              url: window.location.href
+	            }));
+	          });
+	
+	          // 初始化时发送一次当前URL
+	          window.postMessage(JSON.stringify({
+	            type: 'initUrl',
+	            url: window.location.href
+	          }));
+	        })();
+	      `);
+
+				// 监听来自webview的消息
+				window.addEventListener('message', (event) => {
+					const data = JSON.parse(event.data);
+					if (data.type === 'urlChange') {
+						console.log('Webview URL changed:', data.url);
+						// 在这里处理URL变化逻辑
+					} else if (data.type === 'initUrl') {
+						console.log('Initial Webview URL:', data.url);
+						// 处理初始化时的URL
+					}
+				});
+			},
+			startListening() {
+				this.timer = setInterval(() => {
+					var pages = getCurrentPages();
+					var page = pages[pages.length - 1];
+					var currentWebview = page.$getAppWebview();
+					var urls = currentWebview.children()[0].getURL();
+					console.log("=======当前地址======", urls);
+
+					console.log(
+						'WebView加载新页面------------------------------------------------------------------------' +
+						this.src);
+					if (urls.indexOf("ticket") != -1) {
+						this.stopListening();
+						var tourl = urls;
+						tourl = tourl.substring(tourl.indexOf("ticket") + 7, tourl.length)
+						var pos = tourl.indexOf("&");
+						if (pos != -1)
+							tourl = tourl.substring(0, pos)
+						// uni.navigateTo({
+						//   url: "/pages/login/login",
+						// });
+						this.loginCas(tourl)
+					}
+				}, 1000); // 间隔3秒检查一次
+			},
+			stopListening() {
+				if (this.timer) {
+					clearInterval(this.timer);
+					this.timer = null;
+				}
+			},
+
+			loginCas(value) {
+				var than = this
+				var ser = this.src;
+				new Promise((resolve, reject) => {
+					api
+						.validateCasLogin('', "?ticket=" + value + "&service=" + ser)
+						.then((response) => {
+							debugger
+							// console.log("response===>response", JSON.stringify(response));
+							// if (response.data.code == 200) {
+							// 	uni.setStorageSync(ACCESS_TOKEN, response.data.result.token);
+							// } else {
+							// }
+							const result = response.data.result
+							const userInfo = result.userInfo
+							uni.setStorageSync(ACCESS_TOKEN, result.token);
+							uni.setStorageSync(USER_INFO, userInfo);
+							console.log("userInfo=" + userInfo)
+							this.$store.commit('SET_TOKEN', result.token)
+							console.log("result.token=" + result.token)
+							this.$store.commit('SET_DICT', result.sysAllDictItems)
+							this.$store.commit('SET_AVATAR', userInfo.avatar)
+							this.$store.commit('SET_NAME', {
+								username: userInfo.username,
+								realname: userInfo.realname
+							})
+
+							console.log("getPermissionList-----------")
+							than.getPermissionList()
+						})
+						.catch((error) => {
+							debugger
+							// console.log("catch===>response", error);
+							// uni.navigateTo({
+							//   url: "/pages/home/home",
+							// });
+						});
+				});
+
+			},
+
+			//获取权限菜单
+			getPermissionList() {
+				console.log("getPermissionList=========================")
+				new Promise((resolve, reject) => {
+					api
+						.getPermission({})
+						.then((response) => {
+							console.log(response, '权限菜单----------------')
+							if (response.statusCode == 200) {
+								let data = response.data.result.menuApp
+								let dataBtn = response.data.result.appauth
+								uni.setStorageSync('menuPermission', data);
+								uni.setStorageSync('btnPermission', dataBtn);
+								this.$tip.success("登录成功!");
+								uni.navigateTo({
+									url: "/pages/index/index",
+								});
+							} else {
+								reject(response);
+							}
+						})
+						.catch((error) => {
+							console.log("catch===>response", response);
+							reject(error);
+						});
+				});
+			},
+			saveClientId() {
+				console.log("saveClientId=========================")
+				var info = plus.push.getClientInfo();
+				var cid = info.clientid;
+				this.$http
+					.get("/sys/user/saveClientId", {
+						params: {
+							clientId: cid
+						}
+					})
+					.then((res) => {
+						console.log("res::saveClientId>", res);
+						//获取权限菜单
+						this.getPermissionList()
+					});
+			},
+		},
+		onShow() {
+			this.startListening();
+		},
+		onHide() {
+			this.stopListening();
+		},
+		watch: {},
+		onUnload() {
+			plus.runtime.quit();
+		},
+		onLoad(option) {
+			// 获取传递过来的url参数
+			let optionurl = option.url;
+			console.log('onLoad  当前URL:', option.url);
+			// setTimeout(()=>{
+
+			// 	console.log('onLoad  setNavigationBarTitle', option.url);
+			// uni.setNavigationBarTitle({
+			//         title: '单点登录'
+			//       });
+			// },2000)
+			console.log("option.url======" + option.url)
+			this.src = decodeURIComponent(optionurl);
 		}
-	  }
-  },
-  onLoad(option) {
-    // 获取传递过来的url参数
-	let optionurl = option.url;
-	if(option.url.indexOf("ticket") !=-1){
-			console.log("option.url======"+option.url)
-    this.src = decodeURIComponent(optionurl);
+	};
+</script>
+<style scoped>
+	.zai-title {
+		margin-top: 20upx;
+		font-size: 58upx;
+		color: #000000;
+		text-align: center;
 	}
-  }
-};
-</script>
+</style>

BIN
static/topnavbar.png


+ 8 - 0
uni_modules/uview-ui/components/u-navbar/props.js

@@ -50,6 +50,14 @@ export default {
 			type: String,
 			default: uni.$u.props.navbar.bgColor
 		},
+		bgImage: {
+			type: String,
+			default: uni.$u.props.navbar.bgImage
+		},
+		bgStatusImage: {
+			type: String,
+			default: uni.$u.props.navbar.bgStatusImage
+		},
 		// 标题的宽度
 		titleWidth: {
 			type: [String, Number],

+ 4 - 0
uni_modules/uview-ui/components/u-navbar/u-navbar.vue

@@ -11,6 +11,7 @@
 			<u-status-bar
 				v-if="safeAreaInsetTop"
 				:bgColor="bgColor"
+				:bgStatusImage="bgStatusImage"
 			></u-status-bar>
 			<view
 				class="u-navbar__content"
@@ -18,7 +19,9 @@
 				:style="{
 					height: $u.addUnit(height),
 					backgroundColor: bgColor,
+					backgroundImage: bgImage
 				}"
+		        style="background-size: 100% 100%;"
 			>
 				<view
 					class="u-navbar__content__left"
@@ -88,6 +91,7 @@
 	 * @property {String}			rightIcon			右边返回图标的名称,只能为uView自带的图标
 	 * @property {String}			title				导航栏标题,如设置为空字符,将会隐藏标题占位区域
 	 * @property {String}			bgColor				导航栏背景设置 (默认 '#ffffff' )
+	 * @property {String}			bgImage				导航栏背景
 	 * @property {String | Number}	titleWidth			导航栏标题的最大宽度,内容超出会以省略号隐藏 (默认 '400rpx' )
 	 * @property {String | Number}	height				导航栏高度(不包括状态栏高度在内,内部自动加上)(默认 '44px' )
 	 * @property {String | Number}	leftIconSize		左侧返回图标的大小(默认 20px )

+ 5 - 1
uni_modules/uview-ui/components/u-status-bar/props.js

@@ -3,6 +3,10 @@ export default {
         bgColor: {
             type: String,
             default: uni.$u.props.statusBar.bgColor
-        }
+        },
+		bgStatusImage: {
+            type: String,
+            default: uni.$u.props.statusBar.c
+        },
     }
 }

+ 2 - 0
uni_modules/uview-ui/components/u-status-bar/u-status-bar.vue

@@ -1,6 +1,7 @@
 <template>
 	<view
 	    :style="[style]"
+		style="background-size: 100% 100%;"
 	    class="u-status-bar"
 	>
 		<slot />
@@ -30,6 +31,7 @@
 				// 状态栏高度,由于某些安卓和微信开发工具无法识别css的顶部状态栏变量,所以使用js获取的方式
 				style.height = uni.$u.addUnit(uni.$u.sys().statusBarHeight, 'px')
 				style.backgroundColor = this.bgColor
+				style.backgroundImage = this.bgStatusImage
 				return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle))
 			}
 		},