xuqiaoying 2 жил өмнө
parent
commit
fe9b3db982
1 өөрчлөгдсөн 43 нэмэгдсэн , 40 устгасан
  1. 43 40
      pages3/polyv/detail.vue

+ 43 - 40
pages3/polyv/detail.vue

@@ -538,7 +538,8 @@
               </camera>
               <!-- #endif -->
               <!-- #ifdef H5 -->
-              <video id="video" :src="stream" class="photo_v"></video>
+              <!-- :src="stream" -->
+              <video id="video" width="400" height="300" class="photo_v"></video>
               <!-- #endif -->
             </view>
             <view class="custom" v-if="!isTaking">
@@ -849,42 +850,42 @@ export default {
     
   },
   onShow() {
-    // this.photoPopup = true;
-    // this.isTaking = true;
-    // console.log('photoPopup:', this.photoPopup, 'isTaking:', this.isTaking, 'window:', window, 'navigator:', navigator);
-    // console.log('window.navigator.mediaDevices', window.navigator.mediaDevices, '1:', window.navigator.mediaDevices.getUserMedia, '2:',window.navigator.getUserMedia,
-    //   '3:', window.navigator.webkitGetUserMedia, '4:', window.navigator.mozGetUserMedia);
-    // if (
-    //       (window.navigator.mediaDevices &&
-    //         window.navigator.mediaDevices.getUserMedia) ||
-    //       window.navigator.getUserMedia ||
-    //       window.navigator.webkitGetUserMedia ||
-    //       window.navigator.mozGetUserMedia
-    //     ) {
-    //       console.log( "getUserMedia----");
-    //       // 调用用户媒体设备, 访问摄像头
-    //       this.getUserMedia(
-    //         {
-    //           video: {
-    //             width: 400,
-    //             height: 300,
-    //           },
-    //         },
-    //         this.photographSuccess,
-    //         this.photographError
-    //       );
-    //     } else {
-    //       console.log('1111没有摄像');
-    //       this.photographError();
-    //     }
-    console.log('this.option:', this.option);
-    if (this.$method.isGoLogin()) { // 从公众号消息进来的没登录需要跳到登录页,登录后返回
-      return;
-    }
-    console.log('onshow返回之后');
-    this.courseCourseList();
-    this.informId && this.clickOfficial() // 从公众号消息点击进来上报一次
-    this.$store.getters.dictObj;
+    this.photoPopup = true;
+    this.isTaking = true;
+    console.log('photoPopup:', this.photoPopup, 'isTaking:', this.isTaking, 'window:', window, 'navigator:', navigator);
+    console.log('window.navigator.mediaDevices', window.navigator.mediaDevices, '1:', window.navigator.mediaDevices.getUserMedia, '2:',window.navigator.getUserMedia,
+      '3:', window.navigator.webkitGetUserMedia, '4:', window.navigator.mozGetUserMedia);
+    if (
+          (window.navigator.mediaDevices &&
+            window.navigator.mediaDevices.getUserMedia) ||
+          window.navigator.getUserMedia ||
+          window.navigator.webkitGetUserMedia ||
+          window.navigator.mozGetUserMedia
+        ) {
+          console.log( "getUserMedia----");
+          // 调用用户媒体设备, 访问摄像头
+          this.getUserMedia(
+            {
+              video: {
+                width: 400,
+                height: 300,
+              },
+            },
+            this.photographSuccess,
+            this.photographError
+          );
+        } else {
+          console.log('1111没有摄像');
+          this.photographError();
+        }
+    // console.log('this.option:', this.option);
+    // if (this.$method.isGoLogin()) { // 从公众号消息进来的没登录需要跳到登录页,登录后返回
+    //   return;
+    // }
+    // console.log('onshow返回之后');
+    // this.courseCourseList();
+    // this.informId && this.clickOfficial() // 从公众号消息点击进来上报一次
+    // this.$store.getters.dictObj;
   },
   onUnload() {
     console.log('onUnloadonUnloadonUnloadonUnload');
@@ -3597,17 +3598,19 @@ export default {
     photographSuccess(stream) {
       console.log('有摄像头---');
       // 兼容webkit核心浏览器
-      this.isTaking = true
-      this.photoPopup = true
+      // this.isTaking = true
+      // this.photoPopup = true
       this.$nextTick(() => {
         console.log('video:', document);
         const video = document.getElementById("video");
         // 将视频流设置为video元素的源
         console.log('video1:',video, 'stream:',stream);
         video.srcObject = stream;
+        video.play();
         this.mediaStreamTrack =
           typeof stream.stop === "function" ? stream : stream.getTracks()[0];
-        video.play();
+        console.log('mediaStreamTrack:', mediaStreamTrack);
+        // video.play();
       });
     },
     photographError(err) {