"use strict"; const common_vendor = require("../../common/vendor.js"); const recorderManager = common_vendor.index.getRecorderManager(); const _sfc_main = { name: "VoiceCheckModal", props: { visible: { type: Boolean, default: false } }, data() { return { isRecording: false, waveData: Array(20).fill(20), // 初始波形数据 waveTimer: null }; }, methods: { // 开始录音 startRecording() { this.isRecording = true; recorderManager.start({ duration: 1e4, sampleRate: 16e3, numberOfChannels: 1, encodeBitRate: 48e3, format: "wav" }); this.waveTimer = setInterval(() => { this.waveData = this.waveData.map(() => Math.random() * 40 + 20); }, 100); }, // 停止录音 stopRecording() { this.isRecording = false; recorderManager.stop(); clearInterval(this.waveTimer); this.waveData = Array(20).fill(20); }, // 处理确认按钮点击 handleConfirm() { if (!this.isRecording) { this.startRecording(); } else { this.stopRecording(); this.$emit("complete"); } } }, beforeDestroy() { clearInterval(this.waveTimer); } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: $props.visible }, $props.visible ? common_vendor.e({ b: $data.isRecording }, $data.isRecording ? { c: common_vendor.f($data.waveData, (item, index, i0) => { return { a: index, b: item + "rpx" }; }) } : {}, { d: common_vendor.t($data.isRecording ? "读完了" : "开始"), e: common_vendor.o((...args) => $options.handleConfirm && $options.handleConfirm(...args)) }) : {}); } const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-ce199c44"]]); wx.createComponent(Component);