coys 2 жил өмнө
parent
commit
feae818545

+ 1 - 1
src/api/evaluateTask.js

@@ -5,7 +5,7 @@ import request from '@/utils/request'
 // 分页
 export function getEvaluatePage(query) {
   return request({
-    url: '/core/task/list',
+    url: '/core/task/appList',
     
     method: 'get',
     params:query

+ 28 - 48
src/components/nfcPopup/alone.vue

@@ -19,7 +19,7 @@
           </div>
         </div>
       </div>
-      <input v-show="false" ref="upload" type="file" accept="image/*" @change="fileChange" />
+      <!-- <input v-show="false" ref="upload" type="file" accept="image/*" @change="fileChange" /> -->
       <!--    <uploader v-show="false" ref="imageUpload" v-model="nfcImage" multiple :maxCount="1" :deletable="false"/>-->
     </van-popup>
   </div>
@@ -27,13 +27,14 @@
 
 <script>
 import { baseImg } from '@/views/menu/LZRegister/api'
-import { upload } from '@/api/public'
+import { upload, uploadBase64 } from '@/api/public'
 import ImageCompressor from 'js-image-compressor'
 import { Toast } from 'vant'
 export default {
   name: 'index',
   data() {
     return {
+      imageList:[],
       //nfc弹窗
       visible: false,
       //nfc图片(base64)
@@ -52,64 +53,43 @@ export default {
   },
   mounted() {
     window.openNFCScanCallBack = this.openNFCScanCallBack
+    window.openCameraCallBack = this.openCameraCallBack
   },
   methods: {
-    //上传前
-    async fileChange(e) {
-      let file = e.target.files[0]
-      let fileName = e.target.files[0].name
-      let imgFile = await this.imageCompress(file)
-      console.log(imgFile, 'imgFile')
-      let formData = new FormData()
-      formData.append('file', imgFile)
-      upload(formData, 'image').then(res => {
-        console.log(res, 'resssss')
-        // this.nfcImage = baseImg.base;
-        this.$emit('change', baseImg)
-        this.visible = false
-
-        // this.showBottomBox = false;
-      })
-    },
-    //压缩图片
-    imageCompress(file) {
-      let imageCom = new Promise((resolve, reject) => {
-        new ImageCompressor({
-          file,
-          quality: 0.6,
-          success: result => {
-            console.log(result, '图片压缩后')
-            let img = new File([result], result.name, {
-              width: result.width,
-              height: result.height,
-              type: result.type
-            })
-            resolve(img)
-          },
-          error: e => {
-            console.log('imageError:' + e)
-            this.$toast('图片压缩失败')
-            reject(e)
-          }
-        })
-      })
-      return imageCom
-    },
     nfcTakePhotos() {
-      this.$refs.upload.click()
+      this.useCamera(1)
     },
     submitNFC() {
       this.useNFC()
-      // Toast.success(this.openNFCScanCallBack())
-
-      // alert(this.objNfc)
+    },
+    openCameraCallBack(data) {
+      let img = JSON.parse(data)
+      this.content = data
+      let params = {
+        extension: img.extension,
+        content: img.content
+      }
+      uploadBase64(params)
+        .then(res => {
+          /*上传成功*/
+          this.$toast.success('上传成功')
+          this.visible=false
+          this.imageList.push({ name: res.data.name, url: imgUrl(res.data.url), imgPath: res.data.url })
+          this.$emit('input', this.imageList)
+        })
+        .catch(err => {
+          /*上传失败*/
+          
+          this.$toast.fail('上传失败')
+          this.fileList.splice(this.fileList.length - 1, 1)
+        })
     },
     openNFCScanCallBack(data) {
       this.objNfc = JSON.parse(data)
       if (this.objNfc.errorCode == 0) {
         this.$emit('changeNFC', this.objNfc.content)
         Toast.success('扫描成功')
-        
+
         this.visible = false
       } else {
         Toast.error(this.objNfc.errorString)

+ 31 - 2
src/utils/globalMixins.js

@@ -4,7 +4,6 @@ import Dicts from '../utils/dicts'
 import { mapActions } from 'vuex'
 import { imgUrl } from '@/utils/index'
 
-
 export default {
   data() {
     return {}
@@ -121,10 +120,40 @@ export default {
         }
       }
     },
+    //调用相机和相册
+    useCamera(actionType) {
+      let parms = {}
+      if (actionType) {
+        parms.actionType = actionType
+      }
+      let system = this.isAndroidOrIos()
+      if (system === 1) {
+        //android
+        // 判断当前环境是是否存在 js桥 'sap'
+        const hasSap = window.hasOwnProperty('sap')
+        if (hasSap) {
+          // 判断是否存在方法 ?preview
+          const fun = sap.hasOwnProperty('openCamera')
+          if (fun) {
+            sap.openCamera(JSON.stringify(parms))
+          }
+        }
+      }
+
+      if (system === 2) {
+        //ios
+        // 判断 ios是否存在方法 preview
+        const preview = window.webkit.messageHandlers.hasOwnProperty('openCamera')
+        if (preview) {
+          window.webkit.messageHandlers.openCamera.postMessage(JSON.stringify(parms))
+        }
+      }
+    },
+    
 
     isAndroidOrIos() {
       const urls = navigator.userAgent
-      console.log(urls,'urls')
+      console.log(urls, 'urls')
       let isAndroid = urls.indexOf('Android') > -1 || urls.indexOf('Linux') > -1
       let isIos = !!urls.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
       if (isAndroid) {

+ 1 - 0
src/utils/request.js

@@ -7,6 +7,7 @@ import { baseApi } from '@/config'
 // create an axios instance
 const service = axios.create({
   baseURL: baseApi, // url = base api url + request url
+  // baseURL: '/dev', // url = base api url + request url
   withCredentials: false, // send cookies when cross-domain requests
   timeout: 15000 // request timeout
 })

+ 8 - 21
src/views/menu/monitoringCall/index.vue

@@ -84,7 +84,7 @@
     </div>
 
     <!-- 扫描弹框 -->
-    <scandialog ref="scandialog" @change="resultImg" @changeNFC="getNFC"></scandialog>
+    <scandialog ref="scandialog" @input="resultImg" @changeNFC="getNFC"></scandialog>
   </div>
 </template>
 <script>
@@ -171,10 +171,10 @@ export default {
   methods: {
     //单元格点击事件
     linkHandler(status, id, item) {
-      if (item.isExist == 0&&status ==0) {
+      if (item.isExist == 0 && status == 0) {
         Dialog.alert({
           message: '机构下没有主机摄像头,不能开启调阅任务!',
-          confirmButtonText:'关闭'
+          confirmButtonText: '关闭'
         })
         return
       }
@@ -276,9 +276,9 @@ export default {
             this.finished = false
             this.taskList = rows
           }
-        }else{
+        } else {
           this.finished = true
-          this.taskList =[]
+          this.taskList = []
         }
       })
     },
@@ -316,22 +316,9 @@ export default {
       })
     },
     //文件上传
-    resultImg(img) {
-      let obj = base64ToBlob(img.base)
-      let formData = new FormData()
-      obj.name = '调阅.jpg'
-      formData.append('file', base64ToBlob(img.base))
-      upload(formData, 'image')
-        .then(res => {
-          /*上传成功*/
-          let imgUrl = process.env.NODE_ENV === 'development' ? res.data.url : window.origin + res.data.url
-          this.photoHandler(imgUrl)
-
-          // this.$emit("imgUrl", res.data.url);
-        })
-        .catch(err => {
-          /*上传失败*/
-        })
+    input(img) {
+      
+      this.photoHandler(img[0].url)
     },
     //上传NFC
     getNFC(nfc) {

+ 2 - 2
vue.config.js

@@ -110,8 +110,8 @@ module.exports = defineConfig({
         }
       },
       '/dev': {
-        // target: "http://10.87.10.55:8080",
-        target: "http://10.87.10.91:8080",
+        target: "http://10.87.10.55:8080",
+        // target: "http://10.87.10.91:8080",
         // target: "http://10.87.10.47:8080",
         // ws:true,
         changOrigin:true,