| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <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>
- <script>
- import { sethomework } from '@/api/homework.js'
- export default {
- data(){
- return{
- id: '',
- showVideo: false,
- addVideo: false,
- src:''
- }
- },
- onLoad(option) {
- this.id = option.id
- },
- methods:{
- submit(){
- sethomework({
- 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>
- <style>
- </style>
|