<form>
<view class="cu-bar bg-white flex ">
<view class="cu-bar bg-white">
<view class="action ">
面试视频
</view>
</view>
<view class="grid col-4 grid-square flex-sub padding-xs radius">
<view class="bg-img" v-show="stu.mssp!=null">
<image :src="$config.apiUrl+stu.mssp" mode="aspectFill"></image>
<view class="cu-tag bg-red" @tap.stop="DelImg">
<text class='cuIcon-close'></text>
</view>
<view class="cu-tag bg-red" v-if="stu.msspsh == '审核通过'">
<text class='cuIcon-close'></text>
</view>
</view>
<view class="solids" @tap="uploadVideo" v-show="stu.mssp ==''||stu.mssp==null">
<text class='cuIcon-cameraadd'></text>
</view>
<button class='cu-btn bg-blue shadow margin' v-show="stu.mssp!=null" @tap="showModal"
data-target="mssp">面试视频预览</button>
</view>
</view>
</form>
uploadVideo() {
var other = this;
uni.chooseVideo({
sourceType: ['album', 'camera'],
success: (res) => {
var fileName = res.tempFile.name.split('.');
var fileSize = res.size;
var fileDuration = res.duration;
if (fileName[fileName.length - 1].toLowerCase() != 'mp4' && fileName[fileName.length -
1].toLowerCase() != 'mov') {
// alert(111)
// other.$tip.alert(res.duration);
other.$tip.alert("上传视频格式必须为mp4或mov尾缀");
} else if (fileSize > 120 * 1000 * 1000) {
other.$tip.alert("上传视频大小不能超过120M");
} else if (fileDuration < 120 && fileDuration != 0) {
other.$tip.alert("上传视频大小不能小于2分钟");
} else if (fileDuration == 0) {
var ua = window.navigator.userAgent
.toLowerCase(); // 不加window部分Android机会显示不了提示图,即判断不了是否是微信
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
other.$http
.upload('/common/uploadWeixin', {
name: 'file',
filePath: res.tempFilePath
})
.then(res => {
other.img = res.data.fileName
other.stu.mssp = res.data.fileName
if (res.data.code == 500) {
other.$tip.alert(res.data.msg);
}
})
} else {
var fileurl = URL.createObjectURL(res.tempFile);
var audioElement = new Audio(fileurl);
var duration;
audioElement.addEventListener("loadedmetadata", function(_event) {
duration = audioElement.duration;
if (duration >= 120) {
other.$http
.upload('/common/upload', {
name: 'file',
filePath: res.tempFilePath
})
.then(res => {
other.img = res.data.fileName
other.stu.mssp = res.data.fileName
if (res.data.code == 500) {
other.$tip.alert(res.data.msg);
}
})
} else if (duration == 0) {
other.$tip.alert("当前浏览器不支持视频上传,请更换浏览器后重试");
} else {
other.$tip.alert("上传视频大小不能小于2分钟");
}
})
}
} else {
other.$http
.upload('/common/upload', {
name: 'file',
filePath: res.tempFilePath
})
.then(result => {
other.img = result.data.fileName
other.stu.mssp = result.data.fileName
var fileurl = URL.createObjectURL(res.tempFile);
var audioElement = new Audio(fileurl);
/* other.$tip.alert("***"+res.size+"***"+res.duration); */
if (result.data.code == 500) {
other.$tip.alert(result.data.msg);
}
})
}
}
});
},
DelImg(e) {
uni.showModal({
content: '确定要删除吗?',
success: res => {
if (res.confirm) {
this.stu.mssp = null;
}
}
})
},