|
@@ -59,7 +59,9 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { sendAudioWarningMsg } from "@/api/invigilation";
|
|
|
|
|
|
+import MD5 from "js-md5";
|
|
|
|
+import { uploadFile } from "@/api/system-info";
|
|
|
|
+import { sendWarningMsg } from "@/api/invigilation";
|
|
import AudioRecord from "./audioRecord";
|
|
import AudioRecord from "./audioRecord";
|
|
|
|
|
|
function recordTimeToText(timeNumber) {
|
|
function recordTimeToText(timeNumber) {
|
|
@@ -204,11 +206,32 @@ export default {
|
|
if (this.isSubmit) return;
|
|
if (this.isSubmit) return;
|
|
this.isSubmit = true;
|
|
this.isSubmit = true;
|
|
|
|
|
|
- const fdata = new FormData();
|
|
|
|
- fdata.append("content", this.audioBlob);
|
|
|
|
- fdata.append("type", "audio");
|
|
|
|
- fdata.append("examRecordId", this.recordId);
|
|
|
|
- const result = await sendAudioWarningMsg(fdata).catch(() => {});
|
|
|
|
|
|
+ async function blobToArray(blob) {
|
|
|
|
+ return new Promise((resolve) => {
|
|
|
|
+ var reader = new FileReader();
|
|
|
|
+ reader.addEventListener("loadend", function () {
|
|
|
|
+ resolve(reader.result);
|
|
|
|
+ });
|
|
|
|
+ reader.readAsArrayBuffer(blob);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ const ab = await blobToArray(this.audioBlob);
|
|
|
|
+ const md5 = MD5(ab);
|
|
|
|
+ const res = await uploadFile({
|
|
|
|
+ file: this.audioBlob,
|
|
|
|
+ md5,
|
|
|
|
+ }).catch(() => {});
|
|
|
|
+
|
|
|
|
+ if (!res) {
|
|
|
|
+ this.isSubmit = false;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const result = await sendWarningMsg({
|
|
|
|
+ content: res.data.data.url,
|
|
|
|
+ type: "audio",
|
|
|
|
+ examRecordId: this.recordId,
|
|
|
|
+ }).catch(() => {});
|
|
|
|
|
|
this.isSubmit = false;
|
|
this.isSubmit = false;
|
|
if (!result) return;
|
|
if (!result) return;
|