diff --git a/src/components/customAudioBar/index.ts b/src/components/customAudioBar/index.ts index 40a50b9..b53b352 100644 --- a/src/components/customAudioBar/index.ts +++ b/src/components/customAudioBar/index.ts @@ -1,4 +1,4 @@ -const _app = getApp() +const _app = getApp(); // pages/story/a.ts Component({ @@ -8,12 +8,12 @@ Component({ properties: { url: { type: String, - value: - 'https://circlehbsaas.oss-cn-beijing.aliyuncs.com/audio/20240907757_tmp_acf4f18c59553a8d2d9f74e173a16328.m4a.mp3', + value: "", + // 'https://circlehbsaas.oss-cn-beijing.aliyuncs.com/audio/20240907757_tmp_acf4f18c59553a8d2d9f74e173a16328.m4a.mp3', }, time: { type: String, - value: '', + value: "", }, }, @@ -29,7 +29,7 @@ Component({ attached() { this.setData({ innerAudioContext: wx.createInnerAudioContext(), - }) + }); }, }, @@ -38,33 +38,35 @@ Component({ */ methods: { handlePlay() { - const { url, play, innerAudioContext } = this.data + const { url, play, innerAudioContext } = this.data; if (innerAudioContext) { if (play) { - innerAudioContext.stop() - return + innerAudioContext.stop(); + return; } - innerAudioContext.stop() - innerAudioContext.src = url - innerAudioContext.play() + innerAudioContext.stop(); + innerAudioContext.src = url; + innerAudioContext.play(); this.setData({ play: true, - }) + }); innerAudioContext.onEnded(() => { this.setData({ play: false, - }) - }) + }); + }); } }, handlePause() { - const { innerAudioContext } = this.data + const { innerAudioContext } = this.data; if (innerAudioContext) { - innerAudioContext.pause() + innerAudioContext.pause(); this.setData({ play: false, - }) + }); } }, }, -}) +}); + +export {}; diff --git a/src/components/customRecord/index.ts b/src/components/customRecord/index.ts index b105846..0f6e9c8 100644 --- a/src/components/customRecord/index.ts +++ b/src/components/customRecord/index.ts @@ -55,13 +55,10 @@ Component({ }); }, recorderManagerListen(recorderManager: WechatMiniprogram.RecorderManager) { - recorderManager.onError(() => { - wx.showToast({ - title: "录音失败", - icon: "none", - }); - }); recorderManager.onStart(() => { + this.setData({ + time: 0, + }); this.handleTiem(); }); recorderManager.onStop((res) => { @@ -155,7 +152,7 @@ Component({ suffix: this.GetExtensionFileName(data.data.Url), type: item.fileType, imgUrl: "", - duration: "", + duration: 0, }; if (item.fileType === "image") { expandJson.imgUrl = data.data.Url; @@ -164,7 +161,7 @@ Component({ expandJson.imgUrl = data.data.SnapshotUrl; } if (item.fileType === "audio") { - expandJson.duration = item.duration; + expandJson.duration = Number.parseInt(String(item.duration / 1000)); } resolve(expandJson); }, @@ -185,3 +182,5 @@ Component({ }, }, }); + +export {}; diff --git a/src/components/uploadFile/index.ts b/src/components/uploadFile/index.ts index befd2b3..b5fbdd1 100644 --- a/src/components/uploadFile/index.ts +++ b/src/components/uploadFile/index.ts @@ -10,6 +10,10 @@ Component({ type: Boolean, value: false, }, + chooseMessage: { + type: Boolean, + value: false, + }, accept: { type: String, value: "image", @@ -23,7 +27,16 @@ Component({ /** * 组件的初始数据 */ - data: {}, + data: { + fileTypeList: { + doc: 5, + docx: 5, + pdf: 4, + xls: 6, + xlsx: 6, + ppt: 7, + }, + }, /** * 组件的方法列表 @@ -41,8 +54,11 @@ Component({ if (this.data.obscure) { wx.editImage({ src: e.detail.file.url || e.detail.file.tempFilePath, - success: (res:any) => { - this.uploadFile(res.detail.file).then((res) => { + success: (res: any) => { + this.uploadFile({ + ...e.detail.file, + tempFilePath: res.tempFilePath, + }).then((res) => { this.triggerEvent("file", res as object); }); }, @@ -62,6 +78,27 @@ Component({ this.triggerEvent("file", res as object); }); }, + handleChooseFile() { + wx.chooseMessageFile({ + type: "file", + count: 1, + success: (res) => { + this.uploadFile({ + ...res.tempFiles[0], + fileType: res.tempFiles[0].type, + tempFilePath: res.tempFiles[0].path, + }).then((res) => { + this.triggerEvent("file", res as object); + }); + }, + fail() { + wx.showToast({ + icon: "none", + title: "取消选择", + }); + }, + }); + }, uploadFile(item) { wx.showLoading({ title: "正在上传", diff --git a/src/components/uploadFile/index.wxml b/src/components/uploadFile/index.wxml index f3ac8b0..4fcc942 100644 --- a/src/components/uploadFile/index.wxml +++ b/src/components/uploadFile/index.wxml @@ -1,6 +1,9 @@ + diff --git a/src/images/icon-file.png b/src/images/icon-file.png index 6b4a6c3..421d7e4 100644 Binary files a/src/images/icon-file.png and b/src/images/icon-file.png differ diff --git a/src/images/icon-file1.png b/src/images/icon-file1.png new file mode 100644 index 0000000..b092f87 Binary files /dev/null and b/src/images/icon-file1.png differ diff --git a/src/images/icon-file2.png b/src/images/icon-file2.png new file mode 100644 index 0000000..802cec7 Binary files /dev/null and b/src/images/icon-file2.png differ diff --git a/src/images/icon-file3.png b/src/images/icon-file3.png new file mode 100644 index 0000000..ec85fbb Binary files /dev/null and b/src/images/icon-file3.png differ diff --git a/src/images/icon-file4.png b/src/images/icon-file4.png new file mode 100644 index 0000000..0511511 Binary files /dev/null and b/src/images/icon-file4.png differ diff --git a/src/module1/pages/entryCases/index.scss b/src/module1/pages/entryCases/index.scss index 4861dad..9774595 100644 --- a/src/module1/pages/entryCases/index.scss +++ b/src/module1/pages/entryCases/index.scss @@ -15,8 +15,10 @@ page { .limit { color: rgba(153, 153, 153, 1); } - .message-select { + .message-select-wrap { float: right; + } + .message-select { padding: 8rpx 24rpx; font-size: 28rpx; color: rgba(255, 255, 255, 1); @@ -27,7 +29,7 @@ page { &.required { &::before { display: inline; - content: '*'; + content: "*"; color: rgba(255, 87, 51, 1); } } @@ -118,6 +120,7 @@ page { .audio-list { margin-top: 32rpx; .row { + margin-bottom: 24rpx; display: flex; gap: 28rpx; align-items: center; @@ -131,7 +134,7 @@ page { gap: 20rpx; display: flex; align-items: center; - .del{ + .del { width: 36rpx; height: 36rpx; } @@ -192,13 +195,19 @@ page { display: flex; align-items: center; .icon { + flex-shrink: 0; width: 56rpx; height: 56rpx; } .name { + flex: 1; margin-left: 30rpx; font-size: 32rpx; color: rgba(128, 128, 128, 1); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 10em; } } .option { @@ -389,17 +398,16 @@ page { } } - .popup3 { position: relative; width: 580rpx; height: 590rpx; box-sizing: border-box; - .bg{ + .bg { width: 100%; height: 100%; } - .sure{ + .sure { position: absolute; width: 100%; bottom: 40rpx; diff --git a/src/module1/pages/entryCases/index.ts b/src/module1/pages/entryCases/index.ts index 28df187..0ea6a64 100644 --- a/src/module1/pages/entryCases/index.ts +++ b/src/module1/pages/entryCases/index.ts @@ -9,22 +9,9 @@ Page({ images: [] as any, description: "", audios: [] as any, + files: [] as any, }, onLoad() {}, - handleChooseFile() { - wx.chooseMessageFile({ - count: 1, - success(res) { - console.log(res); - }, - fail() { - wx.showToast({ - icon: "none", - title: "取消选择", - }); - }, - }); - }, handleSubmit() { wx.navigateTo({ url: "/module1/pages/entryCasesResult/index", @@ -63,4 +50,26 @@ Page({ ], }); }, + handleDelAudio(e) { + const { index } = e.currentTarget.dataset; + this.setData({ + audios: this.data.audios.filter((_, i) => i !== Number(index)), + }); + }, + handleFile(e) { + this.setData({ + files: [ + ...this.data.files, + { + fileType: 99, + name: e.detail.name, + url: e.detail.fileUrl, + size: e.detail.size, + isRepeat: 2, + }, + ], + }); + }, }); + +export {}; diff --git a/src/module1/pages/entryCases/index.wxml b/src/module1/pages/entryCases/index.wxml index 481935e..ee0b10e 100644 --- a/src/module1/pages/entryCases/index.wxml +++ b/src/module1/pages/entryCases/index.wxml @@ -39,7 +39,12 @@ - + 转文字 @@ -52,17 +57,15 @@ 病历相关文件 - 从聊天记录选择文件 - - - - 还没有文件哦! + + 从聊天记录选择文件 + - - + + - 基因检测报告.pdf + {{item.name}} @@ -71,6 +74,10 @@ + + + 还没有文件哦! + 标签