|
|
@@ -1,5 +1,12 @@
|
|
|
<template>
|
|
|
<view class="center">
|
|
|
+ <view class="" v-if="showVideo" >
|
|
|
+ <video :src="src" ></video>
|
|
|
+ <view @click="DelImg">x</view>
|
|
|
+ </view>
|
|
|
+ <view v-else class="add_picture">
|
|
|
+ <image src="https://zhibo.liuniu946.com/img/phone.png" @click="test"></image>
|
|
|
+ </view>
|
|
|
<view class="buttom" @click="submit()">上传作业</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
@@ -10,6 +17,9 @@ export default {
|
|
|
data(){
|
|
|
return{
|
|
|
id: '',
|
|
|
+ showVideo: false,
|
|
|
+ addVideo: false,
|
|
|
+ src:''
|
|
|
}
|
|
|
},
|
|
|
onLoad(option) {
|
|
|
@@ -18,13 +28,53 @@ export default {
|
|
|
methods:{
|
|
|
submit(){
|
|
|
sethomework({
|
|
|
- timetable_id: this.id
|
|
|
+ timetable_id: this.id,
|
|
|
+ task_video: this.src
|
|
|
}).then(() =>{
|
|
|
|
|
|
}).catch(err =>{
|
|
|
console.log(err)
|
|
|
})
|
|
|
- }
|
|
|
+ },
|
|
|
+ test: function () {
|
|
|
+ var self = this;
|
|
|
+ uni.chooseVideo({
|
|
|
+ count: 1,
|
|
|
+ sourceType: ['camera', 'album'],
|
|
|
+ success: function (res) {
|
|
|
+ console.log("选择视频成功",res)
|
|
|
+ self.showVideo=true
|
|
|
+ self.addVideo=false
|
|
|
+ self.src = res.tempFilePath;
|
|
|
+ uni.uploadFile({
|
|
|
+ url: config.upload_img_url, //仅为示例,非真实的接口地址
|
|
|
+ filePath: res.tempFilePath,
|
|
|
+ name: 'files',
|
|
|
+ // formData: {
|
|
|
+ // 'user': 'test'
|
|
|
+ // },
|
|
|
+ header: {
|
|
|
+ Authorization: 'Bearer ' + uni.getStorageSync('access')
|
|
|
+ },
|
|
|
+ success: (uploadFileRes) => {
|
|
|
+ console.log('1张', uploadFileRes);
|
|
|
+ let bold = JSON.parse(uploadFileRes.data)
|
|
|
+ console.log(bold)
|
|
|
+ console.log(bold.result[0].filePath)
|
|
|
+ self.returnImage = bold.result[0].filePath + bold.result[0].fileName
|
|
|
+ console.log("this.returnImage", self.returnImage)
|
|
|
+ },
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //右上角删除视频
|
|
|
+ DelImg(){
|
|
|
+ this.src='',
|
|
|
+ this.showVideo=false,
|
|
|
+ this.addVideo=true
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
</script>
|