提交 3541c36e authored 作者: 杨斌基's avatar 杨斌基

feat(#2750): 城市不文明举报中,图片是必需上传3张的,视频可不上传

上级 9d635c43
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
<image @click.native.stop="cancel(item, index)" mode="aspectFill" class="upload_del" src="/static/icon/ic_zp_del@2x.png" /> <image @click.native.stop="cancel(item, index)" mode="aspectFill" class="upload_del" src="/static/icon/ic_zp_del@2x.png" />
</view> </view>
</view> </view>
<view v-if="isAllowUpload" class="photo_upload" @click="upload"> <view v-if="uploadVisible" class="photo_upload" @click="upload">
<image mode="aspectFill" class="upload_icon" src="/static/icon/upload_icon@2x.png" /> <image mode="aspectFill" class="upload_icon" src="/static/icon/upload_icon@2x.png" />
</view> </view>
</view> </view>
...@@ -282,7 +282,7 @@ ...@@ -282,7 +282,7 @@
<image @click.native.stop="cancel(item, index)" mode="aspectFill" class="upload_del" src="/static/icon/ic_zp_del@2x.png" /> <image @click.native.stop="cancel(item, index)" mode="aspectFill" class="upload_del" src="/static/icon/ic_zp_del@2x.png" />
</view> </view>
</view> </view>
<view v-if="isAllowUpload" class="photo_upload" @click="upload"> <view v-if="uploadVisible" class="photo_upload" @click="upload">
<image mode="aspectFill" class="upload_icon" src="/static/icon/upload_icon@2x.png" /> <image mode="aspectFill" class="upload_icon" src="/static/icon/upload_icon@2x.png" />
</view> </view>
</view> </view>
...@@ -535,6 +535,9 @@ export default { ...@@ -535,6 +535,9 @@ export default {
activeMap() { activeMap() {
return this.map[this.activeParent?.name] || {} return this.map[this.activeParent?.name] || {}
}, },
uploadedImages() {
return this.photoList.filter(({ type }) => type === 'image')
},
isIllegality() { isIllegality() {
return this.activeParent?.name === typeMap.illegality return this.activeParent?.name === typeMap.illegality
}, },
...@@ -576,10 +579,16 @@ export default { ...@@ -576,10 +579,16 @@ export default {
const { isOnlyAllowUploadOneType, uploadActionsOptions: options } = this const { isOnlyAllowUploadOneType, uploadActionsOptions: options } = this
return isOnlyAllowUploadOneType && options[0].type === 'image' return isOnlyAllowUploadOneType && options[0].type === 'image'
}, },
isAllowUploadImagesAndVideos() {
return this.uploadActionsOptions.length === 2
},
isAllowUploadImages() {
return this.isOnlyAllowUploadImages || this.isAllowUploadImagesAndVideos
},
uploadTitle() { uploadTitle() {
return `上传${this.uploadActionsOptions.map(v => v.name).join('/')}` return `上传${this.uploadActionsOptions.map(v => v.name).join('/')}`
}, },
isAllowUpload() { uploadVisible() {
return !this.isOnlyAllowUploadImages || this.photoList.length < mustUploadImageCount return !this.isOnlyAllowUploadImages || this.photoList.length < mustUploadImageCount
} }
}, },
...@@ -752,6 +761,9 @@ export default { ...@@ -752,6 +761,9 @@ export default {
switch (item.type) { switch (item.type) {
case 'image': case 'image':
if (this.isAllowUploadImages && this.uploadedImages.length === mustUploadImageCount) {
return uni.$u.toast(`照片只能上传 ${mustUploadImageCount} 张`)
}
uni.chooseImage({ uni.chooseImage({
success: (result) => { success: (result) => {
result.tempFiles.forEach((value, index) => { result.tempFiles.forEach((value, index) => {
...@@ -804,7 +816,7 @@ export default { ...@@ -804,7 +816,7 @@ export default {
if (!this.IllegalForm.content) return t('请输入违法行为描述'); if (!this.IllegalForm.content) return t('请输入违法行为描述');
// if (!this.IllegalForm.number_plate) return t('请输入号牌种类'); // if (!this.IllegalForm.number_plate) return t('请输入号牌种类');
if (!this.IllegalForm.license_plate) return t('请输入车牌号码'); if (!this.IllegalForm.license_plate) return t('请输入车牌号码');
if (!this.photoList.length) return t('请上传图片/视频'); if (!this.photoList.length) return t(`请${this.uploadTitle}`);
if (!this.realForm.name) return t('请输入真实姓名'); if (!this.realForm.name) return t('请输入真实姓名');
if (!this.realForm.phone) return t('请输入电话号码'); if (!this.realForm.phone) return t('请输入电话号码');
if (!this.realForm.certificateType) return t('请选择证件类型'); if (!this.realForm.certificateType) return t('请选择证件类型');
...@@ -812,7 +824,7 @@ export default { ...@@ -812,7 +824,7 @@ export default {
} else { } else {
if (!this.id) return t('请选择上报类型'); if (!this.id) return t('请选择上报类型');
if (!this.longitude) return t('请选择位置'); if (!this.longitude) return t('请选择位置');
if (!this.photoList.length) return t('请上传图片/视频'); if (!this.photoList.length) return t(`请${this.uploadTitle}`);
if (!this.IllegalForm.illegal_time) return t(`请输入${activeMap.time}`); if (!this.IllegalForm.illegal_time) return t(`请输入${activeMap.time}`);
if (isIncivility) { if (isIncivility) {
// if (!this.IllegalForm.IllegalType) return t('请输入违法类型'); // if (!this.IllegalForm.IllegalType) return t('请输入违法类型');
...@@ -832,7 +844,7 @@ export default { ...@@ -832,7 +844,7 @@ export default {
try { try {
const images = this.photoList.filter(({ type }) => type === 'image') const images = this.photoList.filter(({ type }) => type === 'image')
if (this.isOnlyAllowUploadImages) { if (this.isAllowUploadImages) {
if (images.length !== mustUploadImageCount) { if (images.length !== mustUploadImageCount) {
return t(`请上传 ${mustUploadImageCount} 张照片`) return t(`请上传 ${mustUploadImageCount} 张照片`)
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论