|
|
@@ -1,8 +1,16 @@
|
|
|
<template>
|
|
|
<div class="questionNamep">
|
|
|
- <div class="cameraDiv" @click="uploadImg">
|
|
|
+ <!-- 0=企业微信,1=H5相机 -->
|
|
|
+ <!-- 企业微信拍照 -->
|
|
|
+ <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"
|
|
|
+ ref="H5Camera"
|
|
|
+ :capture="pictureSource == '1' ? '' : 'camera'"
|
|
|
+ v-else />
|
|
|
<div id="allmap"></div>
|
|
|
<div class="mask" v-if="progressFlag">
|
|
|
<el-progress
|
|
|
@@ -18,7 +26,7 @@
|
|
|
:imageAIVerifyFlag="imageAIVerifyFlag"
|
|
|
:imageAIVerifyData="imageAIVerifyData"
|
|
|
@confirmUpload="confirmUpload"
|
|
|
- @uploadImgFun="uploadImg"
|
|
|
+ @uploadImgFun="uploadImgFun"
|
|
|
:source="'visit'"
|
|
|
@normalFlow="normalFlow"
|
|
|
@close="close"></imageAIVerifyErr>
|
|
|
@@ -28,11 +36,15 @@
|
|
|
<script>
|
|
|
import { addstorePhoto, addVisitsPosition, addPhotoToDB } from '@/api/index';
|
|
|
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',
|
|
|
- components: { imageAIVerifyErr },
|
|
|
+ components: { imageAIVerifyErr, H5Camera },
|
|
|
props: {
|
|
|
uploadid: {
|
|
|
type: String,
|
|
|
@@ -111,6 +123,11 @@ export default {
|
|
|
default: '',
|
|
|
},
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ ...mapState({
|
|
|
+ userInfo: (state) => state.user.userInfo,
|
|
|
+ }),
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
shows: false,
|
|
|
@@ -120,12 +137,76 @@ export default {
|
|
|
timeFlag: null,
|
|
|
imageAIVerifyFlag: false,
|
|
|
imageAIVerifyData: null, //图匠校验返回的数据
|
|
|
- meidaId: '', //当前上传图片id
|
|
|
+ mediaId: '', //当前上传图片id
|
|
|
addressesRemark: '', //当前位置信息
|
|
|
controller: null, //取消请求状态
|
|
|
+ fileUrl: '',
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 原生H5拍照图片
|
|
|
+ // url: base64
|
|
|
+ getImg(base64) {
|
|
|
+ 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) {
|
|
|
+ this.fileUrl = res.url;
|
|
|
+ this.uploadImagev();
|
|
|
+ // 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);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ uploadImgFun() {
|
|
|
+ // 0=企业微信,1=H5相机
|
|
|
+ if (this.userInfo.photoMethod == '0') {
|
|
|
+ this.uploadImg();
|
|
|
+ } else {
|
|
|
+ this.$refs.H5Camera.camera();
|
|
|
+ }
|
|
|
+ },
|
|
|
uploadImg() {
|
|
|
var map = new TMap.Map('allmap', {
|
|
|
zoom: 14,
|
|
|
@@ -215,7 +296,8 @@ export default {
|
|
|
localId: localIds, // 需要上传的图片的本地ID,由chooseImage接口获得
|
|
|
isShowProgressTips: 1, // 默认为1,显示进度提示
|
|
|
success: function (res) {
|
|
|
- that.uploadImagev(res.serverId, addressesRemark);
|
|
|
+ that.mediaId = res.serverId;
|
|
|
+ that.uploadImagev(addressesRemark);
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
@@ -224,7 +306,7 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- uploadImagev(meidaId, addressesRemark) {
|
|
|
+ uploadImagev(addressesRemark = '') {
|
|
|
// 初始化重置 图匠校验
|
|
|
this.resetProgress();
|
|
|
this.close();
|
|
|
@@ -249,10 +331,10 @@ export default {
|
|
|
if (that.thirdCollectionId != null && that.thirdCollectionId != 'null') {
|
|
|
thirdCollectionId = that.thirdCollectionId;
|
|
|
}
|
|
|
- this.meidaId = meidaId;
|
|
|
this.addressesRemark = addressesRemark;
|
|
|
var form = {
|
|
|
- mediaId: meidaId,
|
|
|
+ mediaId: '',
|
|
|
+ fileUrl: '',
|
|
|
collectionItemId: that.collectionId,
|
|
|
objectType: that.objectType,
|
|
|
storeGroupId: that.storeGroupId,
|
|
|
@@ -269,6 +351,12 @@ export default {
|
|
|
deviceCode: that.deviceCode, //设备编号
|
|
|
putInCode: that.putInCode, //投放编号
|
|
|
};
|
|
|
+ // 0=企业微信,1=H5相机
|
|
|
+ if (this.userInfo.photoMethod == '0') {
|
|
|
+ form.mediaId = this.mediaId; // string 图片素材id
|
|
|
+ } else {
|
|
|
+ form.fileUrl = this.fileUrl; // string 图片素材id
|
|
|
+ }
|
|
|
this.controller = null;
|
|
|
// 需要图匠校验的添加参数和loading
|
|
|
if (this.photoIdentifyType) {
|
|
|
@@ -280,34 +368,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('上传成功!');
|
|
|
@@ -342,7 +438,8 @@ export default {
|
|
|
confirmUpload(res) {
|
|
|
if (this.photoIdentifyType) {
|
|
|
var form = {
|
|
|
- mediaId: this.meidaId, // string 图片素材id
|
|
|
+ mediaId: '',
|
|
|
+ fileUrl: '',
|
|
|
visitSource: '1', // Long 拜访模式
|
|
|
storeGroupId: this.storeGroupId, // string 门店任务组,多个用逗号隔开
|
|
|
visitsId: localStorage.getItem('visitId'), // string 拜访id
|
|
|
@@ -358,6 +455,12 @@ export default {
|
|
|
businessId: res.data.businessId, // 当前拍摄图片id
|
|
|
feedbackMessage: res.feedbackMessage,
|
|
|
};
|
|
|
+ // 0=企业微信,1=H5相机
|
|
|
+ if (this.userInfo.photoMethod == '0') {
|
|
|
+ form.mediaId = this.mediaId; // string 图片素材id
|
|
|
+ } else {
|
|
|
+ form.fileUrl = this.fileUrl; // string 图片素材id
|
|
|
+ }
|
|
|
if (res.isUpdate) {
|
|
|
form.isUpdate = 'true';
|
|
|
}
|