|
|
@ -17,8 +17,11 @@ Component({ |
|
|
|
* 组件的初始数据 |
|
|
|
* 组件的初始数据 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
|
|
|
|
record: false, |
|
|
|
startShow: false, |
|
|
|
startShow: false, |
|
|
|
show: false, |
|
|
|
show: false, |
|
|
|
|
|
|
|
audioObj: {} as any, |
|
|
|
|
|
|
|
|
|
|
|
recorderManager: null as null | WechatMiniprogram.RecorderManager, |
|
|
|
recorderManager: null as null | WechatMiniprogram.RecorderManager, |
|
|
|
time: 0, |
|
|
|
time: 0, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -47,6 +50,7 @@ Component({ |
|
|
|
const { recorderManager } = this.data; |
|
|
|
const { recorderManager } = this.data; |
|
|
|
this.setData({ |
|
|
|
this.setData({ |
|
|
|
show: true, |
|
|
|
show: true, |
|
|
|
|
|
|
|
record: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (this.data.startShow) { |
|
|
|
if (this.data.startShow) { |
|
|
|
recorderManager?.start({ |
|
|
|
recorderManager?.start({ |
|
|
@ -61,8 +65,8 @@ Component({ |
|
|
|
recorderManager?.stop(); |
|
|
|
recorderManager?.stop(); |
|
|
|
} |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
this.setData({ |
|
|
|
startShow: false, |
|
|
|
// startShow: false,
|
|
|
|
show: false, |
|
|
|
// show: false,
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
recorderManagerListen(recorderManager: WechatMiniprogram.RecorderManager) { |
|
|
|
recorderManagerListen(recorderManager: WechatMiniprogram.RecorderManager) { |
|
|
@ -79,18 +83,40 @@ Component({ |
|
|
|
title: "录音时间太短", |
|
|
|
title: "录音时间太短", |
|
|
|
icon: "none", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
|
|
|
|
startShow: false, |
|
|
|
|
|
|
|
show: false, |
|
|
|
|
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
this.uploadFile({ |
|
|
|
this.setData({ |
|
|
|
fileType: "audio", |
|
|
|
record: false, |
|
|
|
tempFilePath: res.tempFilePath, |
|
|
|
audioObj: { |
|
|
|
size: res.fileSize, |
|
|
|
...res, |
|
|
|
duration: res.duration, |
|
|
|
duration: Number.parseInt(String(res.duration / 1000)), |
|
|
|
}).then((res) => { |
|
|
|
}, |
|
|
|
this.triggerEvent("file", res as object); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
handleCancel() { |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
|
|
|
|
startShow: false, |
|
|
|
|
|
|
|
show: false, |
|
|
|
|
|
|
|
record: false, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
handleConform() { |
|
|
|
|
|
|
|
const { audioObj } = this.data; |
|
|
|
|
|
|
|
this.handleCancel(); |
|
|
|
|
|
|
|
this.uploadFile({ |
|
|
|
|
|
|
|
fileType: "audio", |
|
|
|
|
|
|
|
tempFilePath: audioObj.tempFilePath, |
|
|
|
|
|
|
|
size: audioObj.fileSize, |
|
|
|
|
|
|
|
duration: audioObj.duration, |
|
|
|
|
|
|
|
}).then((res) => { |
|
|
|
|
|
|
|
this.triggerEvent("file", res as object); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
checkRecordPermission(callback: () => void) { |
|
|
|
checkRecordPermission(callback: () => void) { |
|
|
|
wx.getSetting({ |
|
|
|
wx.getSetting({ |
|
|
|
success(res) { |
|
|
|
success(res) { |
|
|
@ -185,7 +211,7 @@ Component({ |
|
|
|
expandJson.imgUrl = data.data.SnapshotUrl; |
|
|
|
expandJson.imgUrl = data.data.SnapshotUrl; |
|
|
|
} |
|
|
|
} |
|
|
|
if (item.fileType === "audio") { |
|
|
|
if (item.fileType === "audio") { |
|
|
|
expandJson.duration = Number.parseInt(String(item.duration / 1000)); |
|
|
|
expandJson.duration = item.duration; |
|
|
|
} |
|
|
|
} |
|
|
|
resolve(expandJson); |
|
|
|
resolve(expandJson); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -204,6 +230,7 @@ Component({ |
|
|
|
const arr2 = lastString.split("."); // 再以"."作为分隔符
|
|
|
|
const arr2 = lastString.split("."); // 再以"."作为分隔符
|
|
|
|
return arr2[arr2.length - 1]; //将后缀名返回出来
|
|
|
|
return arr2[arr2.length - 1]; //将后缀名返回出来
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
noneEnoughPeople() {}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|