瀏覽代碼

Merge branch 'new' of http://192.168.2.236:10080/zhouna/preliminary into new

luolei 5 年之前
父節點
當前提交
bacadfb391
共有 2 個文件被更改,包括 29 次插入5 次删除
  1. 16 4
      src/common/UploadImg.vue
  2. 13 1
      src/utils/tools.js

+ 16 - 4
src/common/UploadImg.vue

@@ -1,11 +1,11 @@
 <template>
   <div class="img-wrap">
     <div class="box">
+      
       <ul class="upload-imgs">
         <li
           v-show="imgLen<6"
           class="uploadBox"
-          @click="handleUpload"
         >
           <input
             type="file"
@@ -13,7 +13,6 @@
             @change="addImg"
             accept="image/*"
             ref="inp"
-            style="display:none"
           />
           <img src="../images/upload.png">
           <p>点击上传</p>
@@ -37,7 +36,7 @@
   </div>
 </template>
 <script type="text/javascript">
-import {isIos,isWX} from '@utils/tools';
+import {isIos,isWX,isQQ} from '@utils/tools';
 import $ from 'jquery';
 export default {
   name: 'UploadImg',
@@ -54,12 +53,17 @@ export default {
     this.imgs = this.imgList; //回读
     this.imgLen = Object.keys(this.imgList).length;
     this.$previewRefresh();//预览刷新
-    if(isIos()){
+    /*if(isIos()){
       $('.upload').removeAttr("capture")
     }else if(!isWX()){ 
     // 微信端添加这个属性直接调拍照
     //安卓手机且非微信端添加相机属性,否则QQ浏览器打不开相机
       $('.upload').attr("capture","camera")
+    }*/
+    if(isQQ() && !isIos()){
+      $('.upload').attr("capture","camera")
+    }else{
+      $('.upload').removeAttr("capture")
     }
   },
   methods: {
@@ -188,6 +192,14 @@ export default {
   font-size: 0.3rem;
   .upload-imgs {
     margin-bottom: 0.2rem;
+    .upload{
+      width: 1.86rem;
+      height: 100%;
+      position: absolute;
+      left: 0;
+      z-index: 66;
+      opacity: 0;
+    }
     .uploadBox {
       border: 1px solid #dfe0e4;
       box-sizing: border-box;

+ 13 - 1
src/utils/tools.js

@@ -210,6 +210,17 @@ function isWX(){
   }
 }
 
+// 是否QQ浏览器
+function isQQ(){
+  let us = navigator.userAgent.toLowerCase();
+  // if(us.indexOf(' qq')>-1 && us.indexOf('mqqbrowser') <0){
+  if(us.indexOf(' qq')>-1){
+    return true;
+  }else{
+    return false;
+  }
+}
+
 // 监听键盘是否弹起
 function fixedKeyboard() {
   var win_h = $(window).height();
@@ -361,7 +372,8 @@ module.exports =  {
   jgpattern,
   compare,
   dateParser,
-  name
+  name,
+  isQQ
 }