Explorar o código

修复camera功能bug

oyq28 hai 3 días
pai
achega
6b7480043f

+ 6 - 0
pages.json

@@ -31,6 +31,12 @@
                 "navigationBarTitleText" : "拍照点"
             }
         },
+		{
+		    "path" : "pages/work/record/camera-scan-code",
+		    "style" : {
+		        "navigationBarTitleText" : "相册"
+		    }
+		},
 		{
 		    "path" : "pages/work/record/InfoList",
 		    "style" : {

+ 1 - 1
pages/work/download/DownloadDetail.uvue

@@ -89,7 +89,7 @@
 		progress: "1/3"
 	}
 	
-	const taskProcessList : Array<TaskProcess> = [
+	 taskProcessList.value = [
 		{ id: 1, name: "前底-外侧", num: 5, step: 5, status: 3 },
 		{ id: 2, name: "后底-外侧", num: 3, step: 3, status: 4 },
 		{ id: 3, name: "简段-外侧", num: 12, step: 2, status: 2 },

+ 1 - 1
pages/work/download/DownloadList.uvue

@@ -86,7 +86,7 @@
 	// #endif
 		
 		// #ifdef H5
-		const downloads = [{
+		downloads = [{
 			pdid: 1,
 			workorder: "632-P-01",
 			invname: "箱间段",

+ 24 - 36
pages/work/record/Camera.uvue

@@ -1,14 +1,8 @@
 <template>
 	<view class="camera-container">
 		<!-- 全屏相机预览 -->
-		<camera class="camera-preview" 
-			:resolution="'medium'" 
-			:device-position="devicePosition"
-			:flash="flash" 
-			:frame-size="frameSize" 
-			@stop="handleStop" 
-			@error="handleError" 
-			@initdone="handleInitDone">
+		<camera class="camera-preview" :resolution="'medium'" :device-position="devicePosition" :flash="flash"
+			:frame-size="frameSize" @stop="handleStop" @error="handleError" @initdone="handleInitDone">
 		</camera>
 
 		<!-- 左上角:闪光灯图标按钮 -->
@@ -41,7 +35,7 @@
 		<view class="bottom-left">
 			<view class="album-preview" @click="handleScanCode">
 				<image class="preview-img" v-if="imageSrc" :src="imageSrc"></image>
-				<text class="preview-tip" v-else>相册</text>
+				<text class="preview-tip" v-else>浏览相册</text>
 			</view>
 		</view>
 
@@ -49,13 +43,8 @@
 		<view class="zoom-control">
 			<text class="setting-label">预览缩放</text>
 			<view class="zoom-container">
-				<slider class="zoom-slider" 
-					:disabled="maxZoom <= 1" 
-					:show-value="true" 
-					:min="1"
-					:max="maxZoom" 
-					:value="1" 
-					@change="zoomSliderChange" />
+				<slider class="zoom-slider" :disabled="maxZoom <= 1" :show-value="true" :min="1" :max="maxZoom"
+					:value="1" @change="zoomSliderChange" />
 			</view>
 		</view>
 	</view>
@@ -88,7 +77,7 @@
 		methods: {
 			handleScanCode() {
 				uni.navigateTo({
-					url: "/pages/component/camera/camera-scan-code"
+					url: "/pages/work/record/camera-scan-code?path="+this.imageSrc
 				})
 			},
 			switchDevicePosition() {
@@ -219,25 +208,20 @@
 			},
 			getTimeout() : number {
 				let value = parseInt(this.timeoutStr)
-				// #ifdef APP-ANDROID
-				if (value == NaN) {
-					// #endif
-					// #ifndef APP-ANDROID
-					if (value !== value) {
-						// #endif
-						return 30
+				if (isNaN(value)) {
+					return 30
+				} else {
+					if (value < 1) {
+						return 1
+					} else if (value > 60 * 5) {
+						return 60 * 5
 					} else {
-						if (value < 1) {
-							return 1
-						} else if (value > 60 * 5) {
-							return 60 * 5
-						} else {
-							return value
-						}
+						return value
 					}
 				}
 			}
 		}
+	}
 </script>
 
 <style scope>
@@ -281,7 +265,8 @@
 
 	.icon {
 		font-size: 48rpx;
-		color: #e0e0e0; /* 银色 */
+		color: #e0e0e0;
+		/* 银色 */
 	}
 
 	/* 右上角:图像质量设置 */
@@ -351,7 +336,8 @@
 	}
 
 	.preview-tip {
-		color: #e0e0e0; /* 银色 */
+		color: #e0e0e0;
+		/* 银色 */
 		font-size: 26rpx;
 	}
 
@@ -368,7 +354,8 @@
 
 	.setting-label {
 		display: block;
-		color: #e0e0e0; /* 银色 */
+		color: #e0e0e0;
+		/* 银色 */
 		font-size: 28rpx;
 		margin-bottom: 16rpx;
 		font-weight: 500;
@@ -381,7 +368,8 @@
 	}
 
 	.quality-radio {
-		color: #e0e0e0; /* 银色 */
+		color: #e0e0e0;
+		/* 银色 */
 		font-size: 26rpx;
 		display: flex;
 		align-items: center;
@@ -398,4 +386,4 @@
 		width: 100%;
 		height: 4px;
 	}
-</style>
+</style>

+ 5 - 5
pages/work/record/InfoDetail.uvue

@@ -22,7 +22,7 @@
 					<uni-td class="grid-text">{{item.title3}}</uni-td>
 				</uni-tr>
 				<uni-tr class="section-title" v-for="(taskProcess : TaskProcess,index2 : number) in taskProcessList"
-					:key="index2" @click="enterProcess(taskProcess.id)">
+					:key="index2" @click="enterProcess(taskProcess.id, taskProcess.num)">
 					<uni-td class="grid-text">{{taskProcess.name}}</uni-td>
 					<uni-td class="grid-text">
 						<text :class="{
@@ -77,7 +77,7 @@
 	})
 
 // #ifdef H5
-	const download = {
+	download = {
 		pdid: 1,
 		workorder: "632-P-01",
 		invname: "箱间段",
@@ -90,7 +90,7 @@
 		progress: "1/3"
 	}
 
-	const taskProcessList : Array<TaskProcess> = [
+	taskProcessList.value = [
 		{ id: 1, name: "前底-外侧", num: 5, step: 5, state: "done" },
 		{ id: 2, name: "后底-外侧", num: 3, step: 3, state: "error" },
 		{ id: 3, name: "简段-外侧", num: 12, step: 2, state: "doing" },
@@ -146,10 +146,10 @@
 		uni.navigateBack()
 	}
 
-	const enterProcess = (id : number) => {
+	const enterProcess = (id : number, num: number) => {
 		console.log(id);
 		uni.navigateTo({
-			url: `/pages/work/record/RecordList?id=${id}`
+			url: `/pages/work/record/RecordList?id=${id}&num=${num}`
 		});
 	}
 </script>

+ 1 - 1
pages/work/record/InfoList.uvue

@@ -90,7 +90,7 @@
 	// #endif
 
    // #ifdef H5
-	const downloads = [{
+	downloads = [{
 		pdid: 1,
 		workorder: "632-P-01",
 		invname: "箱间段",

+ 11 - 8
pages/work/record/RecordList.uvue

@@ -52,7 +52,7 @@
 				<text class="value">{{ item.num }}</text>
 			</view>
 
-			<button class="cancel-btn" v-if="item.status === '未执行'" @click="cancel(item.sxid)">
+			<button class="cancel-btn" v-if="item.status == '未执行'" @click="cancel(item.sxid)">
 				拍照
 			</button>
 
@@ -110,9 +110,11 @@
 	var initRecords = [] as Record[]
 	
 	onLoad((options) => {	
-	   const pid = options?.id ?? ""	
+	   const tid = options?.id ?? ""
+	   const num = options?.num ?? "1"
+	   maxcount = parseInt(num)		  
 	// #ifdef APP-ANDROID
-	   getList('app_media_record', 'pid', pid, null).then((res:UTSJSONObject) => {
+	   getList('app_media_record', 'sxid', tid, null).then((res:UTSJSONObject) => {
 	    		let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
 	   			if(dataList!=null && dataList.length>0){
 	   				dataList.forEach(item =>{
@@ -129,18 +131,19 @@
 	   						}
 	   					}
 	   				});
-	   			}
-	   		console.log(initRecords)
+	   			}	   		
 			if(initRecords.length>0){
 				current.value = initRecords[0].senum
 				records.value = [initRecords[0]]
-			} 
+				console.log(records)	
+			}
 	    });
+		// #endif
 	});
-	// #endif
+	
 	
 	// #ifdef H5
-	const initRecords = [{
+	initRecords = [{
 		sxid: 1,
 		senum: 1,
 		photoitem: '前底-外侧',

+ 165 - 0
pages/work/record/camera-scan-code.uvue

@@ -0,0 +1,165 @@
+<template>
+  <view style="flex:1">
+	<!--
+    <camera style="width: 100%; height: 300px;" :resolution="'high'" :mode="'scanCode'" @scancode="handleScanCode">
+    </camera> -->
+	<swiper class="swiper-box my-swiper" :current="swiperDotIndex" :indicator-dots="true" >
+	  <swiper-item v-for="item in data"  >
+	    <view class="swiper-item" @tap="previewSingleImage(item.image)">
+	      <image class="my-image" :src="item.image" mode="aspectFill"   />
+	    </view>
+	  </swiper-item>
+	</swiper>
+	    
+    <view class="camera-scan-code-back-wrap">
+      <button class="btn block bg-blue lg round" @click="chooseImage">
+      	浏览相册
+      </button>
+    </view>
+			
+	  <view class="camera-scan-code-back-wrap">
+		  <button class="btn block bg-blue lg round" @click="saveImage">
+			 保存图片
+		  </button>
+	  </view>
+    	  
+	  <view class="camera-scan-code-back-wrap">
+	    <button type="default" class="btn bg-blue round" @click="navigateBack">返回拍照</button>
+	  </view>
+    
+  </view>
+</template>
+
+<script>
+  type CameraScanCodeResult = {
+    type : string | null;
+    result : string | null;
+  }
+  type ImageItem={
+  	 image:string,
+	 name:string
+  }
+  export default {
+    data() {
+      return {
+        result: null as CameraScanCodeResult | null,
+		swiperDotIndex: 0 as number,
+		data: [{
+		    image: '/static/images/banner/banner01.png',
+			name: 'banner01.png'
+		  },
+		] as ImageItem[] 	
+      }
+    },
+	onLoad(options) {
+		let path = options?.['path'] ?? ''
+		console.log(path)
+		if(path!=''){
+			this.data = []
+			this.data.push({image:path, name:''})
+		}
+	},
+    methods: {
+      navigateBack() {
+        uni.navigateBack()
+      },
+	  chooseImage() {
+	  	uni.chooseImage({
+	  		success: (res) => {
+	  			//this.data = res.tempFilePaths; // 获取选中的图片路径
+				this.data = []
+				for(let i=0; i<res.tempFilePaths.length; i++){
+					this.data.push({image: res.tempFilePaths[i], name:''})
+				}
+	  		},
+	  		fail: (err) => {
+	  			console.error('选择图片失败', err);
+	  		}
+	  	});
+	  },
+	  saveImage() {
+		 uni.chooseImage({
+		     count: 1, // 默认9
+		     sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图
+		     sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机
+		     success: (chooseImageRes) => {
+		       const tempFilePaths = chooseImageRes.tempFilePaths; // 临时文件路径
+		       const tempFiles = chooseImageRes.tempFiles; // 临时文件信息
+		       
+			   //保存图片信息到数据库
+		       
+		     }
+		   });
+	  },
+	  previewSingleImage(imageUrl:string) {		 
+	    uni.previewImage({
+	      urls: [imageUrl], // 需要预览的图片链接列表
+	      current: 0, // 当前显示图片的索引
+	      indicator: 'number', // 图片指示器样式
+	      loop: false // 是否可循环预览
+	    });
+	  },  	
+      handleScanCode(ev : UniCameraScanCodeEvent) {
+        const deatil = ev.detail;
+        this.result = {
+          type: deatil.type,
+          result: deatil.result
+        } as CameraScanCodeResult
+      }
+    }
+  }
+</script>
+
+<style>
+  .camera-scan-code-back-wrap {
+    display: flex;
+    justify-content: center;
+    align-items: center;	
+  }
+  .camera-scan-code-table {
+    background-color: white;
+    margin-top: 20rpx;
+  }
+  .camera-scan-code-table-pair {
+    height: 60rpx;
+    flex-direction: row;
+    justify-content: space-between;
+    align-items: center;
+  }
+  .camera-scan-code-table-pair-label {
+    flex-grow: 1;
+    margin-left: 15px;
+
+  }
+  .camera-scan-code-table-pair-value{
+    flex-grow: 2;
+
+  }
+  .camera-scan-code-table-top-line {
+    border-top: 1px solid #eee;
+  }
+  
+  .swiper {
+    height: 300rpx;
+  }
+  
+  .swiper-box {
+    height: 150px;
+  }
+  
+  .swiper-item {
+    /* #ifndef APP-NVUE */
+    display: flex;
+    /* #endif */
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+    color: #fff;
+    height: 300rpx;
+    line-height: 300rpx;
+  }
+  .btn {
+	margin-top: 30px;
+	height: 45px; 
+  }
+</style>

BIN=BIN
static/db/QT800.db