hwq 4 年之前
父节点
当前提交
6c17db023c
共有 2 个文件被更改,包括 68 次插入4 次删除
  1. 52 2
      pages/homework/setHomework.vue
  2. 16 2
      pages/user/user.vue

+ 52 - 2
pages/homework/setHomework.vue

@@ -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>

+ 16 - 2
pages/user/user.vue

@@ -17,7 +17,7 @@
 				<view class="centent">
 					<view class="title">待上课程</view>
 					<view class="text">待完成数</view>
-					<view class="number">394<text>个</text></view>
+					<view class="number">{{dai}}<text>个</text></view>
 				</view>
 			</view>
 			<view class="right"  @click="nav('/pages/course/courseWan')">
@@ -25,7 +25,7 @@
 				<view class="centent">
 					<view class="title">完成课程</view>
 					<view class="text">总完成数</view>
-					<view class="number">65<text>个</text></view>
+					<view class="number">{{wan}}<text>个</text></view>
 				</view>
 			</view>
 		</view>
@@ -50,6 +50,7 @@
 </template>
 
 <script>
+import { getCourse } from '@/api/course.js'
 import { mapState, mapMutations } from 'vuex';
 import { saveUrl, interceptor } from '@/utils/loginUtils.js';
 import { getUserInfo,} from '@/api/user.js';
@@ -57,6 +58,12 @@ export default {
 	computed: {
 		...mapState(['hasLogin', 'userInfo', 'baseURL', 'urlFile'])
 	},
+	data() {
+		return {
+			dai: '0',//待上课程
+			wan: '0',//完成课程
+		}
+	},
 	onShow() {
 		// 判断是否已经登录
 		if (this.hasLogin) {
@@ -78,6 +85,13 @@ export default {
 				.catch(e => {
 					console.log(e);
 				});
+			getCourse({})
+				.then(e => {
+					this.dai = e.data.count;
+				})
+				.catch(e => {
+					console.log(e);
+				});
 		},
 		navT(){
 			if (!this.hasLogin) {