Commit df7ff131 authored by Tt's avatar Tt

修改通用异常

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