Browse Source

Merge remote-tracking branch 'remotes/origin/3.3.4-kdyh' into xcx-v2

heyang 2 years ago
parent
commit
1a7244419c

+ 9 - 0
App.vue

@@ -1,8 +1,13 @@
 <script>
+	import {systemInfo} from '@/component/system-info.js'
     import $mqtt from '@/utils/mqtt.min.js';
     import { config } from '@/api/request/config.js'
 	export default {
 		onLaunch: function() {
+			/* 获取设备信息 */
+			const SystemInfomations = systemInfo()
+			this.navHeight = SystemInfomations.navHeight + SystemInfomations.statusBarHeight //头部导航栏总高度
+			uni.setStorageSync('navHeight', this.navHeight)
 			//获取openid
 			uni.login({
 				success(loginRes) {
@@ -70,6 +75,10 @@
 			mqttOnlineData:{},//设备是否在线
 			mqttPerformData:{},//是否正在执行灭火操作
         },
+		created() {
+			
+			
+		},
         methods: {
 			//删除报警监听
 			delWarnData(){

+ 126 - 0
component/navbar.vue

@@ -0,0 +1,126 @@
+<template>
+	<view>
+		<view class="wx-head-mod" :style="{height:navHeight+'rpx'}">
+			<view class="wx-head-mod-nav" :style="{height:navigationBarHeight+'rpx',top:statusBarHeight+'rpx'}">
+				<view class="wx-head-mod-nav-content"
+					:style="{height:customHeight+'rpx',justifyContent:'left'}">
+					<!-- 文本区 -->
+					<view class="wx-head-mod-nav-content-mian"
+						:style="{lineHeight:customHeight + 'rpx'}">
+						{{title}}
+					</view>
+				</view>
+			</view>
+		</view>
+
+	
+	</view>
+</template>
+ 
+<script>
+	import {systemInfo} from '@/component/system-info.js'
+	export default {
+		name: "HeadView",
+		props: {
+			// 文本区内容
+			title:'',
+		},
+		data() {
+			return {
+				statusBarHeight: 0, //状态栏高度
+				navHeight: 0, //头部导航栏总体高度
+				navigationBarHeight:0, //导航栏高度
+				customHeight: 0, //胶囊高度
+				scaleFactor: 0, //比例系数
+				menubarLeft:0, //胶囊定位的左边left
+				windowWidth: 0
+			};
+		},
+		methods: {
+
+		},
+		created() {
+			/* 获取设备信息 */
+			const SystemInfomations = systemInfo()
+			/* 通用平台 */
+			this.statusBarHeight = SystemInfomations.statusBarHeight //状态栏高度
+			this.scaleFactor = SystemInfomations.scaleFactor //比例系数
+			this.windowWidth = SystemInfomations.windowWidth //当前设备的屏幕宽度
+			/* 微信小程序平台 */
+			// #ifdef MP-WEIXIN
+			this.navHeight = SystemInfomations.navHeight + SystemInfomations.statusBarHeight //头部导航栏总高度
+			this.navigationBarHeight = SystemInfomations.navHeight //头部导航栏高度
+			this.customHeight = SystemInfomations.menuButtonHeight //胶囊高度
+			this.menubarLeft = SystemInfomations.menuButtonLeft //胶囊左边界距离左上角的距离
+			// #endif
+		}
+	}
+</script>
+ 
+<style>
+
+	.wx-head-mod {
+		box-sizing: border-box;
+		width: 100%;
+		position: fixed;
+		top: 0;
+		left: 0;
+		background: #0183FA;
+		/* background: linear-gradient(-35deg, #613A19 0%, #6F4E2B 100%); */
+	}
+ 
+	.wx-head-mod-nav {
+		box-sizing: border-box;
+		width: 100%;
+		position: absolute;
+		left: 0;
+		display: flex;
+		justify-content: center;
+		align-items: center;
+ 
+	}
+ 
+	.wx-head-mod-nav-content {
+		box-sizing: border-box;
+		width: 100%;
+		display: flex;
+		justify-content: left;
+		align-items: center;
+		position: relative;
+		padding-left: 30rpx;
+		box-sizing: border-box;
+		
+	}
+ 
+	/* 文本区 */
+	.wx-head-mod-nav-content-mian {
+		box-sizing: border-box;
+		height: 100%;
+		text-align: center;
+		white-space: nowrap;
+		text-overflow: ellipsis;
+		overflow: hidden;
+		color:#fff;
+		font-size:36rpx;
+	}
+ 
+	/* 返回按钮 */
+	.wx-head-mod-nav-content-back {
+		box-sizing: border-box;
+		width: 60rpx;
+		height: 100%;
+		/* background-color: aqua; */
+		position: absolute;
+		top: 0;
+		left: 32rpx;
+		display: flex;
+		align-items: center;
+		justify-content: left;
+	}
+ 
+	.wx-head-mod-nav-content-back-img {
+		box-sizing: border-box;
+	}
+ 
+	
+ </style>

+ 70 - 0
component/system-info.js

@@ -0,0 +1,70 @@
+/**
+ * 此js文件管理关于当前设备的机型系统信息
+ */
+const systemInfo = function() {
+	/****************** 所有平台共有的系统信息 ********************/
+	// 设备系统信息
+	let systemInfomations = uni.getSystemInfoSync()
+	// 机型适配比例系数
+	let scaleFactor = 750 / systemInfomations.windowWidth
+	// 当前机型-屏幕高度
+	let windowHeight = systemInfomations.windowHeight * scaleFactor //rpx
+	// 当前机型-屏幕宽度
+	let windowWidth = systemInfomations.windowWidth * scaleFactor //rpx
+	// 状态栏高度
+	let statusBarHeight = (systemInfomations.statusBarHeight) * scaleFactor //rpx
+ 
+	// 导航栏高度  注意:此导航栏高度只针对微信小程序有效 其他平台如自定义导航栏请使用:状态栏高度+自定义文本高度
+	let navHeight = 0 //rpx
+	// console.log(windowHeight,'哈哈哈哈哈');
+	
+	/****************** 微信小程序头部胶囊信息 ********************/
+	// #ifdef MP-WEIXIN
+	const menuButtonInfo = wx.getMenuButtonBoundingClientRect()
+	// 胶囊高度
+	let menuButtonHeight = menuButtonInfo.height * scaleFactor //rpx
+	// 胶囊宽度
+	let menuButtonWidth = menuButtonInfo.width * scaleFactor //rpx
+	// 胶囊上边界的坐标
+	let menuButtonTop = menuButtonInfo.top * scaleFactor //rpx
+	// 胶囊右边界的坐标
+	let menuButtonRight = menuButtonInfo.right * scaleFactor //rpx
+	// 胶囊下边界的坐标
+	let menuButtonBottom = menuButtonInfo.bottom * scaleFactor //rpx
+	// 胶囊左边界的坐标
+	let menuButtonLeft = menuButtonInfo.left * scaleFactor //rpx
+ 
+	// 微信小程序中导航栏高度 = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
+	navHeight = menuButtonHeight + (menuButtonTop - statusBarHeight) * 2
+	// #endif
+ 
+ 
+	// #ifdef MP-WEIXIN
+	return {
+		scaleFactor,
+		windowHeight,
+		windowWidth,
+		statusBarHeight,
+		menuButtonHeight,
+		menuButtonWidth,
+		menuButtonTop,
+		menuButtonRight,
+		menuButtonBottom,
+		menuButtonLeft,
+		navHeight
+	}
+	// #endif
+ 
+	// #ifndef MP-WEIXIN
+	return {
+		scaleFactor,
+		windowHeight,
+		windowWidth,
+		statusBarHeight
+	}
+	// #endif
+}
+ 
+export {
+	systemInfo
+}

+ 2 - 10
pages.json

@@ -6,13 +6,11 @@
 			"style": {
 				"navigationBarTitleText": "实验室安全智能监测与控制系统",
 				"navigationBarTextStyle": "white", //导航文字颜色
-				"navigationBarBackgroundColor": "#0183FA" //导航背景色
+				"navigationBarBackgroundColor": "#0183FA" ,//导航背景色
+				"navigationStyle": "custom"
 			}
 		},
 
-
-
-
 		{
 			"path": "pages/supplierWorkbench",
 			"style": {
@@ -327,12 +325,6 @@
 					}
 				},
 				{
-					"path": "mine/upStudentCard",//学生卡上传
-					"style": {
-						"navigationBarTitleText": "学生卡上传"
-					}
-				},
-				{
 					"path": "mine/pointsRecord",//积分记录
 					"style": {
 						"navigationBarTitleText": "积分记录"

+ 8 - 2
pages/manageWorkbench.vue

@@ -1,6 +1,7 @@
 <!-- 管理端工作台 -->
 <template>
-  <view class="manage-workbench">
+  <view class="manage-workbench" :style="{paddingTop:navHeight+'rpx'}">
+	<nav-bar :title="title"></nav-bar>
     <img class="top-big-img" :src="homepageBanner">
     <top-warn></top-warn>
     <view class="min-icon-button-box" style="margin-bottom: 0;">
@@ -114,13 +115,17 @@ import { config } from '@/api/request/config.js'
 import { appReceivePhotoNote,getApprovalCount,subject_class,getSafeWarnList,laboratoryInfo,laboratoryList,getLoginUserInfo,outSubjectPhoto,gradingControl,listData} from '@/api/index.js'
 import { tabBar } from '@/component/tabBar.vue'
 import { topWarn } from '@/component/topWarn.vue'
+import { navBar } from '@/component/navbar.vue'
 export default {
   components: {
     tabBar,
-    topWarn
+    topWarn,
+	navBar
   },
   data() {
     return {
+	  navHeight: uni.getStorageSync('navHeight'),		
+	  title:'实验室安全智能监测与控制系统',
       //随手拍数量
       appReceivePhotoNoteNum:0,
       //准入数量
@@ -505,6 +510,7 @@ export default {
   height:100%;
   width:100%;
   overflow-y:scroll;
+  box-sizing: border-box;
   .top-big-img{
     height:342rpx;
     width:750rpx;

+ 1 - 15
pages/mine.vue

@@ -88,14 +88,6 @@
           <view class="view-three-type" :class="!isUpload?'colorA':'marginType'">{{!isUpload?'未上传':'已上传'}}</view>
           <img class="right-img" src="@/images/icon_04.png">
         </view>
-        <view class="button-max-box" @click="goPage('upStudentCard')" v-if="userType==2&&certification.auditStatus">
-          <img class="left-img" src="@/images/icon_03.png">
-          <view>学生卡绑定</view>
-          <view class="view-three-type" :class="certification.auditStatus.code == 2 || certification.auditStatus.code == 3?'colorA':'marginType'">
-            {{certification.auditStatus.code == 0?'待审核':(certification.auditStatus.code == 1?'已绑定':(certification.auditStatus.code == 2?'未通过':(certification.auditStatus.code == 3?'去绑定':'')))}}
-          </view>
-          <img class="right-img" v-if="certification.auditStatus.code == 2 || certification.auditStatus.code == 3" src="@/images/icon_04.png">
-        </view>
         <view class="button-max-box" @click="fingerprintClick()">
           <img class="left-img" src="@/images/icon_wd_zw.png">
           <view>指纹</view>
@@ -310,13 +302,7 @@ export default {
     },
     //页面跳转
     goPage(type){
-      if(type == 'upStudentCard'){//学生卡上传
-        // if(this.certification.auditStatus.code  == 2||this.certification.auditStatus.code  == 3){
-        uni.navigateTo({
-          url: '/pages_student/mine/upStudentCard',
-        });
-        // }
-      }else if(type == 'pointsRecord'){//积分记录
+      if(type == 'pointsRecord'){//积分记录
         uni.navigateTo({
           url: '/pages_student/mine/pointsRecord',
         });

+ 13 - 7
pages/studentWorkbench.vue

@@ -1,6 +1,7 @@
 <!-- 学生端工作台 -->
 <template>
-  <view class="user-workbench">
+  <view class="user-workbench" :style="{paddingTop:navHeight+'rpx'}">
+	<nav-bar :title="title"></nav-bar>  
     <img class="top-big-img" :src="homepageBanner">
     <view class="min-icon-button-box">
       <view @click="goPage('casuallyPat')">
@@ -72,17 +73,21 @@
 <script>
 import { myViolationCount,queryMyCert,outSubjectPhoto,gradingControl} from '@/api/index.js'
 import { tabBar } from '@/component/tabBar.vue'
+import { navBar } from '@/component/navbar.vue'
 export default {
   components: {
-    tabBar
+    tabBar,
+	navBar
   },
   data() {
     return {
-      hintType:false,
-      dataList:[],
-      violationData:{},
-      gradingCount:0,
-      homepageBanner:uni.getStorageSync('homepageBanner'),
+		navHeight: uni.getStorageSync('navHeight'),
+	    title:'实验室安全智能监测与控制系统',		
+		hintType:false,
+		dataList:[],
+		violationData:{},
+		gradingCount:0,
+		homepageBanner:uni.getStorageSync('homepageBanner'),
     }
   },
   created() {
@@ -257,6 +262,7 @@ export default {
 .user-workbench{
   height:100%;
   flex:1;
+  box-sizing: border-box;
   .top-big-img{
     height:342rpx;
     width:750rpx;

+ 175 - 0
pages_student/component/compress.vue

@@ -0,0 +1,175 @@
+<template>
+	<view class="compress">
+		<canvas :style="{ width: canvasSize.width,height: canvasSize.height}" canvas-id="myCanvas"></canvas>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				pic:'',
+				canvasSize: {
+					width: 0,
+					height: 0
+				}
+			}
+		},
+		methods: {
+			// 压缩
+			compress(params) {
+				return new Promise(async (resolve, reject) => {
+					// 等待图片信息
+					let info = await this.getImageInfo(params.src).then(info=>info).catch(err=>err);
+					
+					if(!info){
+						reject('获取图片信息异常');
+						return;
+					}
+					
+					// 设置最大 & 最小 尺寸
+					const maxSize = params.maxSize || 1080;
+					const minSize = params.minSize || 640;
+					
+					// 当前图片尺寸
+					let {width,height} = info;
+					
+					// 非 H5 平台进行最小尺寸校验
+					// #ifndef H5
+					if(width <= minSize && height <= minSize){
+						resolve(params.src);
+						return;
+					}
+					// #endif
+					
+					// 最大尺寸计算
+					if (width > maxSize || height > maxSize) {
+						if (width > height) {
+							height = Math.floor(height / (width / maxSize));
+							width = maxSize;
+						} else {
+							width = Math.floor(width / (height / maxSize));
+							height = maxSize;
+						}
+					}
+
+					// 设置画布尺寸
+					this.$set(this,"canvasSize",{
+						width: `${width}rpx`,
+						height: `${height}rpx`
+					});
+					
+					// Vue.nextTick 回调在 App 有异常,则使用 setTimeout 等待DOM更新
+					setTimeout(() => {
+						const ctx = uni.createCanvasContext('myCanvas', this);
+						ctx.clearRect(0,0,width, height)
+						ctx.drawImage(info.path, 0, 0, uni.upx2px(width), uni.upx2px(height));
+						ctx.draw(false, () => {
+							uni.canvasToTempFilePath({
+								x: 0,
+								y: 0,
+								width: uni.upx2px(width),
+								height: uni.upx2px(height),
+								destWidth: width,
+								destHeight: height,
+								canvasId: 'myCanvas',
+								fileType: params.fileType || 'png',
+								quality: params.quality || 0.9,
+								success: (res) => {
+									// 在H5平台下,tempFilePath 为 base64
+									resolve(res.tempFilePath);
+								},
+								fail:(err)=>{
+									reject(null);
+								}
+							},this);
+						});
+					}, 300);
+				});
+			},
+			// 获取图片信息
+			getImageInfo(src){
+				return new Promise((resolve, reject)=>{
+					uni.getImageInfo({
+						src,
+						success: (info)=> {
+							resolve(info);
+						},
+						fail: () => {
+							reject(null);
+						}
+					});
+				});
+			},
+			// 批量压缩
+			batchCompress(params){
+				// index:进度,done:成功,fail:失败
+				let [index,done,fail] = [0,0,0];
+				// 压缩完成的路径集合
+				let paths = [];
+				// 批量压缩方法
+				let batch = ()=>{
+					return new Promise((resolve, reject)=>{
+						// 开始
+						let start = async ()=>{
+							params.progress && params.progress({
+								done,
+								fail,
+								count:params.batchSrc.length
+							});
+							// 等待图片压缩方法返回
+							let path = await next();
+							if(path){
+								done++;
+								paths.push(path);
+							}else{
+								fail++;
+							}
+							
+							index++;
+							// 压缩完成
+							if(index >= params.batchSrc.length){
+								resolve(true);
+							}else{
+								start();
+							}
+						}
+						start();
+					});
+				}
+				// 依次调用压缩方法
+				let next = ()=>{
+					return this.compress({
+						src:params.batchSrc[index],
+						maxSize:params.maxSize,
+						fileType:params.fileType,
+						quality:params.quality,
+						minSize:params.minSize
+					})
+				}
+				
+				// 全部压缩完成后调用
+				return new Promise(async (resolve, reject)=>{
+					// 批量压缩方法回调
+					let res = await batch();
+					if(res){
+						resolve(paths);
+					}else{
+						reject(null);
+					}
+				});
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	.compress{
+		position: fixed;
+		width: 12px;
+		height: 12px;
+		overflow: hidden;
+		top: -99999px;
+		left: 0;
+	}
+</style>

+ 0 - 177
pages_student/mine/upStudentCard.vue

@@ -1,177 +0,0 @@
-<!-- 学生卡上传 -->
-<template>
-    <view id="upStudentCard">
-        <view class="max-box">
-            <view>添加照片</view>
-            <img src="@/pages_student/images/icon_05.png" v-if="!imgUrl" @click="selectImage">
-            <img :src="imgUrl" v-else @click="selectImage">
-        </view>
-        <view class="up-data-button" @click="upDataButton">上传</view>
-    </view>
-</template>
-
-<script>
-    import { config } from '@/api/request/config.js'
-    export default {
-        data() {
-            return {
-                imgUrl:"",
-                imgData:{},
-            }
-        },
-        onLoad() {
-
-        },
-        methods: {
-            // 图片上传
-            selectImage() {
-                let self = this;
-                wx.chooseImage({
-                    count: 1,
-                    sizeType: ["original", "compressed"],
-                    sourceType: ["album", "camera"],
-                    success: function(res) {
-                        let tempFilePaths = res.tempFilePaths[0];
-                        self.imgData = res.tempFilePaths[0];
-                        self.uploadImg(tempFilePaths);
-                    }
-                });
-            },
-            async uploadImg(tempFilePaths){
-                var self = this;
-                uni.showLoading({
-                    title: '上传中',
-                    mask: true
-                });
-                uni.uploadFile({
-                    url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
-                    header:{'Authorization':uni.getStorageSync('token')},
-                    filePath: tempFilePaths,
-                    name: 'file',
-                    formData: {
-                        'user': 'test'
-                    },
-                    success: (uploadFileRes) => {
-                        let res = JSON.parse(uploadFileRes.data);
-						if(res.code == 200){
-							self.imgUrl = config.base_url+res.data.url;
-                            self.realImgUrl = res.data.url;
-						}else{
-							uni.showToast({
-								title: res.msg,
-								icon:"none",
-								mask:true,
-								duration: 2000
-							});
-						}
-                    },
-                    fail: err => {},
-                    complete: () => {
-                        uni.hideLoading()
-                    }
-                });
-            },
-            upDataButton(){
-                let self = this;
-				if(!this.imgUrl){
-					uni.showToast({
-						title: "请选择上传图片",
-						icon:"none",
-						mask:true,
-						duration: 2000
-					});
-					return
-				}
-                uni.showModal({
-                    // title: '确认要退出吗?',
-                    content: '确认上传吗?',
-                    cancelColor:"#999",
-                    confirmColor:"#0183FA",
-                    success: function (res) {
-                        if (res.confirm) {
-                            self.commitCrad();
-                            console.log('用户点击确定');
-                        } else if (res.cancel) {
-                            console.log('用户点击取消');
-                        }
-                    }
-                });
-            },
-            async commitCrad(){
-                var self = this;
-                uni.showLoading({
-                    title: '上传中',
-                    mask: true
-                });
-                uni.uploadFile({
-                    url: config.base_url+'/base/app/lab/api/commit/crad', //仅为示例,非真实的接口地址
-                    header:{'Authorization':uni.getStorageSync('token')},
-                    filePath: self.realImgUrl,
-                    name: 'file',
-                    formData: {
-                        'file': 'test'
-                    },
-                    success: (uploadFileRes) => {
-                        let res = JSON.parse(uploadFileRes.data);
-                        if(res.code == 200){
-                            uni.showToast({
-                                title: "提交成功",
-                                icon:"none",
-                                mask:true,
-                                duration: 2000
-                            });
-                            setTimeout(function(){
-                                uni.navigateBack();
-                            },2000);
-                        }else{
-                            uni.showToast({
-                                title: res.msg,
-                                icon:"none",
-                                mask:true,
-                                duration: 2000
-                            });
-                        }
-                    },
-                    fail: err => {},
-                    complete: () => {
-                        uni.hideLoading()
-                    }
-                });
-            },
-        }
-    }
-</script>
-
-<style lang="stylus" scoped>
-    #upStudentCard{
-        height:100%;
-        width:100%;
-        .max-box{
-            height:350rpx;
-            background #fff
-            view{
-                line-height :95rpx;
-                font-size:28rpx;
-                color:#333333;
-                margin-left:20rpx;
-            }
-            img{
-                height:180rpx;
-                width:180rpx;
-                margin:5rpx 0 0 30rpx;
-            }
-        }
-        .up-data-button{
-            position absolute
-            bottom:0;
-            left:0;
-            width: 750rpx;
-            height: 120rpx;
-            background: #0183FA;
-            line-height:120rpx;
-            text-align center
-            color:#fff;
-            font-size: 30rpx;
-        }
-    }
-</style>

+ 43 - 6
pages_student/workbench/photoInspection.vue

@@ -37,19 +37,32 @@
 			</view>
 		</view>
 		<view class="up-data-button" @click="upButton">提交</view>
+		<helang-compress ref="helangCompress"></helang-compress>
     </view>
+	
 </template>
 
 <script>
+	import helangCompress from '../component/compress.vue';
     import { config } from '@/api/request/config.js'
     import { addPhotoInspection,outSubjectList } from '@/api/index.js'
     export default {
+		components: {
+			helangCompress
+		},
         data() {
             return {
 				baseUrl:config.base_url,
                 newData:{},
 				buttonArray:[],
 				buttonArrayIndex:"",
+				
+				params: {
+					maxSize: 400,
+					fileType: 'png',
+					quality: 0.85,
+					minSize: 320
+				}
 
             }
         },
@@ -72,8 +85,6 @@
 				}
 			},
             upButton(){
-				console.log(111)
-				console.log(this.newData)
                 let self = this;
 				if(!this.buttonArrayIndex){
 					uni.showToast({
@@ -119,8 +130,6 @@
             },
             //拍照检查提交
             async addPhotoInspection(){
-				console.log(222)
-				console.log()
 				let obj = {
 					subjectId:this.buttonArray[this.buttonArrayIndex].subjectId,
 					subUrl:this.newData.subUrl,
@@ -151,11 +160,39 @@
                     sizeType: ["original", "compressed"],
                     sourceType: ["album", "camera"],
                     success: function(res) {
-                        let tempFilePaths = res.tempFilePaths[0];
-                        self.uploadImg(tempFilePaths,name);
+                        //let tempFilePaths = res.tempFilePaths[0];
+                        //self.uploadImg(tempFilePaths,name);
+						self.compress(res.tempFilePaths,name);
                     }
                 });
             },
+			//图片压缩
+			compress(tempFilePaths,name) {
+				 let self = this;
+				uni.showLoading({
+					title: '压缩中',
+					mask: true
+				});
+			
+				this.$refs.helangCompress.compress({
+					src: tempFilePaths[0],
+					maxSize: this.params.maxSize,
+					fileType: this.params.fileType,
+					quality: this.params.quality,
+					minSize: this.params.minSize
+				}).then((res) => {
+					uni.hideLoading();
+					console.log('压缩成功')
+					self.uploadImg(res,name);
+					
+				}).catch((err) => {
+					uni.hideLoading();
+					uni.showToast({
+						title: "压缩失败,请重新上传",
+						icon: "none"
+					})
+				})
+			},
             async uploadImg(tempFilePaths,name){
                 var self = this;
                 uni.showLoading({