|
@ -78,7 +78,7 @@ |
|
|
|
|
|
|
|
|
<!-- 8. 房屋视频 --> |
|
|
<!-- 8. 房屋视频 --> |
|
|
<uv-form-item label="房屋视频" labelWidth="250" prop="videos" labelPosition="top" required> |
|
|
<uv-form-item label="房屋视频" labelWidth="250" prop="videos" labelPosition="top" required> |
|
|
<view class="upload-tip">请上传房屋内部和外部视频(1分钟内)</view> |
|
|
|
|
|
|
|
|
<view class="upload-tip">请上传房屋内部和外部视频,时长不超过1分钟,最多上传2个视频</view> |
|
|
<uv-upload customStyle="margin-top:20rpx;" accept="video" :fileList="form.videos" @afterRead="afterVideoRead" @delete="deleteVideoPic" name="1" |
|
|
<uv-upload customStyle="margin-top:20rpx;" accept="video" :fileList="form.videos" @afterRead="afterVideoRead" @delete="deleteVideoPic" name="1" |
|
|
multiple :maxCount="2"></uv-upload> |
|
|
multiple :maxCount="2"></uv-upload> |
|
|
</uv-form-item> |
|
|
</uv-form-item> |
|
@ -359,12 +359,66 @@ |
|
|
// 视频上传 |
|
|
// 视频上传 |
|
|
async afterVideoRead(e) { |
|
|
async afterVideoRead(e) { |
|
|
let self = this |
|
|
let self = this |
|
|
e.file.forEach(file => { |
|
|
|
|
|
self.$Oss.ossUpload(file.url).then(url => { |
|
|
|
|
|
self.form.videos.push({ |
|
|
|
|
|
url |
|
|
|
|
|
|
|
|
for (let file of e.file) { |
|
|
|
|
|
try { |
|
|
|
|
|
// 检查视频时长 |
|
|
|
|
|
const duration = await this.getVideoDuration(file.url) |
|
|
|
|
|
if (duration > 60) { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '视频时长不能超过1分钟', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
|
|
|
continue // 跳过这个视频 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
self.$Oss.ossUpload(file.url).then(url => { |
|
|
|
|
|
self.form.videos.push({ |
|
|
|
|
|
url |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('视频处理失败:', error) |
|
|
|
|
|
// 如果获取时长失败,仍然允许上传 |
|
|
|
|
|
self.$Oss.ossUpload(file.url).then(url => { |
|
|
|
|
|
self.form.videos.push({ |
|
|
|
|
|
url |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 获取视频时长的辅助方法 |
|
|
|
|
|
getVideoDuration(videoUrl) { |
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
|
|
uni.getVideoInfo({ |
|
|
|
|
|
src: videoUrl, |
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
resolve(res.duration) |
|
|
|
|
|
}, |
|
|
|
|
|
fail: (err) => { |
|
|
|
|
|
reject(err) |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
// #endif |
|
|
|
|
|
|
|
|
|
|
|
// #ifdef APP-PLUS |
|
|
|
|
|
plus.io.getVideoInfo({ |
|
|
|
|
|
filePath: videoUrl, |
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
resolve(res.duration) |
|
|
|
|
|
}, |
|
|
|
|
|
fail: (err) => { |
|
|
|
|
|
reject(err) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
// #endif |
|
|
|
|
|
|
|
|
|
|
|
// #ifdef H5 |
|
|
|
|
|
// H5环境暂不支持视频时长检测,直接通过 |
|
|
|
|
|
resolve(0) |
|
|
|
|
|
// #endif |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -620,4 +674,4 @@ |
|
|
background: #ff4757; |
|
|
background: #ff4757; |
|
|
color: white; |
|
|
color: white; |
|
|
} |
|
|
} |
|
|
</style> |
|
|
|
|
|
|
|
|
</style> |