Commit df7ff131 authored by Tt's avatar Tt

修改通用异常

parent 407525e5
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output, NgZone, OnChanges} from '@angular/core'; import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, NgZone, OnChanges } from '@angular/core';
import {NzMessageService, NzNotificationService, UploadFile} from 'ng-zorro-antd'; import { NzMessageService, NzNotificationService, UploadFile } from 'ng-zorro-antd';
import {HttpClient, HttpEvent, HttpEventType, HttpRequest} from '@angular/common/http'; import { HttpClient, HttpEvent, HttpEventType, HttpRequest } from '@angular/common/http';
import {environment} from '../../../environments/environment'; import { environment } from '../../../environments/environment';
declare var Recorder; declare var Recorder;
...@@ -9,7 +9,7 @@ declare var Recorder; ...@@ -9,7 +9,7 @@ declare var Recorder;
selector: 'app-audio-recorder', selector: 'app-audio-recorder',
templateUrl: './audio-recorder.component.html', templateUrl: './audio-recorder.component.html',
styleUrls: ['./audio-recorder.component.scss'] styleUrls: ['./audio-recorder.component.scss']
}) })
export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
_audioUrl: string; _audioUrl: string;
audio = new Audio(); audio = new Audio();
...@@ -52,8 +52,15 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -52,8 +52,15 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
recorder: any; recorder: any;
audioBlob: any; audioBlob: any;
constructor( private nzMessageService: NzMessageService ) { constructor(private nzMessageService: NzMessageService) {
this.uploadUrl = (<any>window).courseware.uploadUrl();
this.uploadData = (<any>window).courseware.uploadData();
window['air'].getUploadCallback = (url, data) => {
this.uploadUrl = url;
this.uploadData = data;
};
} }
...@@ -137,11 +144,11 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -137,11 +144,11 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
} }
// 开始录音 // 开始录音
onBtnRecord = () => { onBtnRecord = () => {
} }
// 切换模式 // 切换模式
onBtnSwitchType() { onBtnSwitchType() {
} }
onBtnClearAudio() { onBtnClearAudio() {
this.audioRemoved.emit(); this.audioRemoved.emit();
...@@ -152,7 +159,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -152,7 +159,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
this.audioRemoved.emit(); this.audioRemoved.emit();
} }
handleChange(info: { type: string, file: UploadFile, event: any }): void { handleChange(info: { type: string, file: UploadFile, event: any }): void {
switch (info.type) { switch (info.type) {
case 'start': case 'start':
this.isUploading = true; this.isUploading = true;
...@@ -177,7 +184,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -177,7 +184,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
this.nzMessageService.error('You can only upload Audio file ( mp3 | wav |ogg)'); this.nzMessageService.error('You can only upload Audio file ( mp3 | wav |ogg)');
return; return;
} }
const delta = 25; const delta = 25;
const isOverSize = (file.size / 1024 / 1024) < delta; const isOverSize = (file.size / 1024 / 1024) < delta;
if (!isOverSize) { if (!isOverSize) {
this.nzMessageService.error(`audio file must smaller than ${delta}MB!`); this.nzMessageService.error(`audio file must smaller than ${delta}MB!`);
...@@ -185,21 +192,21 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -185,21 +192,21 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
} }
return true; return true;
} }
beforeUpload = (file: File) => { beforeUpload = (file: File) => {
this.audioUrl = null; this.audioUrl = null;
if (!this.checkSelectFile(file)) { if (!this.checkSelectFile(file)) {
return false; return false;
} }
this.isUploading = true; this.isUploading = true;
this.progress = 0; this.progress = 0;
} }
uploadSuccess = (url) => { uploadSuccess = (url) => {
this.nzMessageService.info('Upload Success'); this.nzMessageService.info('Upload Success');
this.isUploading = false; this.isUploading = false;
if(typeof url == "string"){ if (typeof url == "string") {
this.audioUrl = url this.audioUrl = url
}else{ } else {
this.audioUrl = url.url this.audioUrl = url.url
} }
} }
uploadFailure = (err, file) => { uploadFailure = (err, file) => {
...@@ -219,7 +226,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -219,7 +226,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
p = 0; p = 0;
} }
// console.log(Math.floor(p * 100)); // console.log(Math.floor(p * 100));
this.progress = Math.floor(p * 100); this.progress = Math.floor(p * 100);
} }
} }
......
...@@ -120,7 +120,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -120,7 +120,7 @@ export class PlayComponent implements OnInit, OnDestroy {
g_clickY; // 点击坐标 Y g_clickY; // 点击坐标 Y
g_ctx; // canvas 实例 g_ctx; // canvas 实例
g_data; // 数据 g_data; // 数据
g_formData: FormData; // 表单转换之后的数据 g_formData: any; // 表单转换之后的数据
g_teacherFlag = false; // 默认角色 g_teacherFlag = false; // 默认角色
g_currentUser; g_currentUser;
...@@ -2154,7 +2154,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2154,7 +2154,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// 创建倒计时数字元素 // 创建倒计时数字元素
const countdownElements = ['dao_ji_shi_3', 'dao_ji_shi_2', 'dao_ji_shi_1']; const countdownElements = ['dao_ji_shi_3', 'dao_ji_shi_2', 'dao_ji_shi_1'];
// 根据type计算x坐标的偏移量 // 根据type计算x坐标的偏移量
const xOffset = type === 'left' ? 140 : -190; const xOffset = type === 'left' ? 140 : -190;
countdownElements.forEach(elementName => { countdownElements.forEach(elementName => {
...@@ -2516,24 +2516,12 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2516,24 +2516,12 @@ export class PlayComponent implements OnInit, OnDestroy {
// this.g_currentUser = window['air'].airClassInfo.user; // this.g_currentUser = window['air'].airClassInfo.user;
if (data && typeof data == "object") { if (data && typeof data == "object") {
this.g_data = data; this.g_data = data;
this.g_formData = data.contentObj; this.g_formData = data;
} else { } else {
this.g_data = {}; this.g_data = {};
this.g_formData = {};
} }
if (!this.g_data.contentObj) {
this.g_data.contentObj = {};
this.g_formData = {
score: 0,
title: '',
doubleModal: false,
questionText: '',
questionType: '',
questionTextAudio: '',
bgAudio: '',
questions: []
};
}
this.initDefaultData(); this.initDefaultData();
this.initAudio(); this.initAudio();
...@@ -2562,9 +2550,13 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2562,9 +2550,13 @@ export class PlayComponent implements OnInit, OnDestroy {
// 初始化默认数据 // 初始化默认数据
// ---------------------------------- // ----------------------------------
initDefaultData() { initDefaultData() {
console.log("Init default form data") if (Object.keys(this.g_formData).length === 0) {
this.g_formData = defaultFormData; this.g_formData = defaultFormData;
console.log("this.g_formData", this.g_formData) console.log("this.g_formData", this.g_formData)
} else {
this.g_formData = this.g_data;
console.log("this.g_formData", this.g_formData);
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment