|
|
@@ -1,11 +1,12 @@
|
|
|
<template>
|
|
|
<div class="questionNamep">
|
|
|
+ <!-- 0=企业微信,1=H5相机 -->
|
|
|
<!-- 企业微信拍照 -->
|
|
|
- <div class="cameraDiv" @click="uploadImg">
|
|
|
+ <div class="cameraDiv" @click="uploadImg" v-if="userInfo.photoMethod == '0'">
|
|
|
<van-icon class="photo photos" name="photograph" size="22px" color="#969696" />
|
|
|
</div>
|
|
|
<!-- 原生自带拍照 -->
|
|
|
- <!-- <H5Camera @getImg="getImg" /> -->
|
|
|
+ <H5Camera @getImg="getImg" :capture="pictureSource == '1' ? '' : 'camera'" v-else />
|
|
|
<div id="allmap"></div>
|
|
|
<div class="mask" v-if="progressFlag">
|
|
|
<el-progress
|
|
|
@@ -34,6 +35,8 @@ import imageAIVerifyErr from './imageAIVerifyErr';
|
|
|
import H5Camera from '@/components/H5Camera';
|
|
|
import axios from 'axios';
|
|
|
import uploadAliOss from '@/utils/uploadAliOss';
|
|
|
+import { addH5Photo } from '@/api/H5Camera';
|
|
|
+import { mapState } from 'vuex';
|
|
|
|
|
|
export default {
|
|
|
name: 'uploadImg',
|
|
|
@@ -116,6 +119,11 @@ export default {
|
|
|
default: '',
|
|
|
},
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ ...mapState({
|
|
|
+ userInfo: (state) => state.user.userInfo,
|
|
|
+ }),
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
shows: false,
|
|
|
@@ -134,7 +142,55 @@ export default {
|
|
|
// 原生H5拍照图片
|
|
|
// url: base64
|
|
|
getImg(base64) {
|
|
|
- uploadAliOss(base64, '测试111');
|
|
|
+ if (this.objectType == '' || this.objectType == null) {
|
|
|
+ this.$toast('请选择类型!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 图片名称:用户名-时间戳
|
|
|
+ let username = localStorage.getItem('loginName');
|
|
|
+ let imgName = username + '-' + new Date().getTime();
|
|
|
+ uploadAliOss(base64, imgName)
|
|
|
+ .then((res) => {
|
|
|
+ if (res.url && res.url.indexOf('http') != -1) {
|
|
|
+ var form = {
|
|
|
+ fileUrl: res.url,
|
|
|
+ collectionItemId: this.collectionId,
|
|
|
+ objectType: this.objectType,
|
|
|
+ storeGroupId: this.storeGroupId,
|
|
|
+ taskId: this.taskId,
|
|
|
+ visitsId: localStorage.getItem('visitId'),
|
|
|
+ visitModel: this.visitModel,
|
|
|
+ visitSource: '1',
|
|
|
+ locationRemark: '',
|
|
|
+ parentCollectionId: this.parentCollectionId || '',
|
|
|
+ secondCollectionId: this.secondCollectionId || '',
|
|
|
+ firstCollectionId: this.firstCollectionId || '',
|
|
|
+ fourthCollectionId: this.fourthCollectionId || '',
|
|
|
+ thirdCollectionId: this.thirdCollectionId || '',
|
|
|
+ deviceCode: this.deviceCode, //设备编号
|
|
|
+ putInCode: this.putInCode, //投放编号
|
|
|
+ };
|
|
|
+ this.controller = null;
|
|
|
+ // 需要图匠校验的添加参数和loading
|
|
|
+ if (this.photoIdentifyType) {
|
|
|
+ form.photoIdentifyType = this.photoIdentifyType;
|
|
|
+ this.progress();
|
|
|
+ this.controller = new AbortController(); //取消请求
|
|
|
+ } else {
|
|
|
+ this.toastLoading(0, '上传中...', true);
|
|
|
+ }
|
|
|
+ addH5Photo(form, this.controller ? this.controller.signal : null)
|
|
|
+ .then((res) => {
|
|
|
+ this.requestThen(res);
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ this.requestCatch(error);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log('err:' + err);
|
|
|
+ });
|
|
|
},
|
|
|
uploadImg() {
|
|
|
var map = new TMap.Map('allmap', {
|
|
|
@@ -290,34 +346,42 @@ export default {
|
|
|
}
|
|
|
addstorePhoto(form, this.controller ? this.controller.signal : null)
|
|
|
.then((res) => {
|
|
|
- this.toastLoading().clear();
|
|
|
- if (res.code == -1) {
|
|
|
- // 图匠图片校验接口超时
|
|
|
- this.requestTimeOut(res);
|
|
|
- } else if (res.code == 200) {
|
|
|
- // 图匠校验结果返回
|
|
|
- if (this.photoIdentifyType) {
|
|
|
- // 重置loaidng状态
|
|
|
- this.resetProgress();
|
|
|
- this.imageAIVerifyFlag = true;
|
|
|
- this.imageAIVerifyData = res.data;
|
|
|
- } else {
|
|
|
- // 正常流程
|
|
|
- this.normalFlow(res);
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.resetProgress();
|
|
|
- that.$toast('上传失败!');
|
|
|
- }
|
|
|
+ this.requestThen(res);
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
- if (error.message === 'canceled') {
|
|
|
- this.$toast('取消上传');
|
|
|
- console.log('请求被取消:', error.message);
|
|
|
- }
|
|
|
- this.resetProgress();
|
|
|
+ this.requestCatch(error);
|
|
|
});
|
|
|
},
|
|
|
+ // 公用请求then
|
|
|
+ requestThen(res) {
|
|
|
+ this.toastLoading().clear();
|
|
|
+ if (res.code == -1) {
|
|
|
+ // 图匠图片校验接口超时
|
|
|
+ this.requestTimeOut(res);
|
|
|
+ } else if (res.code == 200) {
|
|
|
+ // 图匠校验结果返回
|
|
|
+ if (this.photoIdentifyType) {
|
|
|
+ // 重置loaidng状态
|
|
|
+ this.resetProgress();
|
|
|
+ this.imageAIVerifyFlag = true;
|
|
|
+ this.imageAIVerifyData = res.data;
|
|
|
+ } else {
|
|
|
+ // 正常流程
|
|
|
+ this.normalFlow(res);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.resetProgress();
|
|
|
+ that.$toast('上传失败!');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 公用请求catch
|
|
|
+ requestCatch(error) {
|
|
|
+ if (error.message === 'canceled') {
|
|
|
+ this.$toast('取消上传');
|
|
|
+ console.log('请求被取消:', error.message);
|
|
|
+ }
|
|
|
+ this.resetProgress();
|
|
|
+ },
|
|
|
// 正常流程
|
|
|
normalFlow(res) {
|
|
|
this.$toast('上传成功!');
|