lilei 3 lat temu
rodzic
commit
f7dc9be28f
1 zmienionych plików z 32 dodań i 18 usunięć
  1. 32 18
      pages/scan-frame/scan-frame.vue

+ 32 - 18
pages/scan-frame/scan-frame.vue

@@ -3,8 +3,11 @@
 	<!-- position: absolute;left: 100000px; 隐藏canvas画布 -->
 	<canvas style="width: 100%; height: 100vh;position: absolute;left: 100000px;" canvas-id="canvas" id="canvas"></canvas>
 	<!-- 相机组件 -->
-    <camera device-position="back" flash="auto" style="width: 100%; height: 100vh">
+    <camera device-position="back" @initdone="cameraInit" flash="auto" style="width: 100%; height: 100vh">
       <cover-image src="@/static/scan-frame/cameraBg.png" class="cover-img"> </cover-image>
+	  <cover-view class="noAuth" v-if="showAuth" @click="openAuth">
+		  您未开启摄像机权限,<cover-view class="btns">请点击开启权限</cover-view>
+	  </cover-view>
       <cover-view class="scanBtn" v-if="scanShow">
         <cover-view class="beat" @click="scan">
           <cover-image class="beatImg" src="@/static/scan-frame/album.png"></cover-image>
@@ -30,36 +33,36 @@ export default {
     return {
       scanShow: true, // 显示操作按钮
 	  sysinfo: null, // 设备信息
-	  imageInfo: null // 拍照图片信息
+	  imageInfo: null ,// 拍照图片信息
+	  showAuth: false
     }
   },
   onReady() {
   	const sysinfo = uni.getSystemInfoSync()
 	this.sysinfo = sysinfo
   },
-  onLoad() {
+  onShow() {
+	const _this = this
   	uni.getSetting({
   	   success(res) {
   	      console.log(res.authSetting['scope.camera'])
-  		  if(!res.authSetting['scope.camera']){
-			  uni.showModal({
-			  	title: '您未开启摄像机权限',
-			  	content: '请点击右上角,然后在设置里面开启。',
-			  	success: (ret) => {
-			  	  if(ret.confirm){
-					  uni.openSetting({
-					    success(res) {
-					      console.log(res.authSetting)
-					    }
-					  })
-			  	  }
-			  	}
-			  })
-  		  }
+  		  _this.showAuth = !res.authSetting['scope.camera']
   	   }
   	})
   },
   methods: {
+	cameraInit(e){
+		this.showAuth = false
+	},
+	openAuth(){
+		uni.openSetting({
+		  success(res) {
+			if(res.authSetting['scope.camera']){
+				uni.navigateBack()
+			}
+		  }
+		})
+	},
 	// 手动输入
 	inputs(){
 		uni.redirectTo({
@@ -223,6 +226,17 @@ export default {
     height: 100vh;
     z-index: 1;
   }
+  .noAuth{
+	  width: 100%;
+	  z-index: 999998;
+	  position: fixed;
+	  bottom: 55vh;
+	  text-align: center;
+	  color: #999;
+	  .btns{
+		  color: dodgerblue;
+	  }
+  }
   .scanBtn {
     width: 100%;
     z-index: 99999;