fix: 课程名称校验调整
This commit is contained in:
@@ -157,6 +157,38 @@ export function downloadVoiceFile(url) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export function getAudioByText(data) {
|
||||
const token = getToken();
|
||||
const header = {
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
};
|
||||
if (token)
|
||||
header['summary'] = token
|
||||
let baseUrl = get_base_url();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: `${baseUrl}/trastudy/traStdyInfo/readContent`,
|
||||
header,
|
||||
method:"POST",
|
||||
data,
|
||||
responseType: "arraybuffer",
|
||||
success(result) {
|
||||
if(result.statusCode === 200){
|
||||
resolve(result.data)
|
||||
}else{
|
||||
reject(new Error(result))
|
||||
}
|
||||
},
|
||||
fail(error) {
|
||||
reject(new Error(error));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 对象存储预览 /traoss/tras3/show/{文件ID}
|
||||
export function previewFile(id, responseType = 'arraybuffer') {
|
||||
const token = getToken();
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
import { watch, unref, ref, toRefs, computed, nextTick,onMounted } from 'vue'
|
||||
import ImagePreview from '@/components/image-preview/image-preview.vue'
|
||||
import VideoPreview from '@/components/image-preview/video-preview.vue'
|
||||
import { downloadVoiceFile, uploadVoiceFile, } from "@/api/common.js"
|
||||
import { downloadVoiceFile, uploadVoiceFile, getAudioByText } from "@/api/common.js"
|
||||
import { studyParagraphOverApi, getAskAboutRawApi } from "@/api/study.js"
|
||||
import ChartFour from "./chartFour.vue"
|
||||
import ChartThree from "./chartThree.vue"
|
||||
@@ -373,6 +373,8 @@ const audioCacheObj = computed(() => storageStore.audioObj)
|
||||
teachNo: unref(teacherInfo)?.teacherNo, // 必填
|
||||
content: _content
|
||||
}
|
||||
|
||||
|
||||
let _url = '/trastudy/traStdyInfo/readContent?' + Object.keys(_params).map(t=>{
|
||||
return encodeURIComponent(t) + '=' + encodeURIComponent(_params[t])
|
||||
}).join('&')
|
||||
@@ -384,6 +386,19 @@ const audioCacheObj = computed(() => storageStore.audioObj)
|
||||
talkVoiceObj.value.src = url
|
||||
talkVoiceObj.value.play()
|
||||
}else{
|
||||
// getAudioByText(_params).then(res=>{
|
||||
// // uni.env.USER_DATA_PATH ||
|
||||
// let filePath = `${'/'}/${dataInfo.value.id}.mp3`
|
||||
// saveFile(res, filePath, () => {
|
||||
// voiceLoading.value = false
|
||||
// itemVoice.value = filePath
|
||||
// talkVoiceObj.value.src = filePath
|
||||
// talkVoiceObj.value.play()
|
||||
// storageStore.setStorage('audio', _url + _params.teachNo, itemVoice.value)
|
||||
// })
|
||||
// }).catch(err=>{
|
||||
// console.log(err)
|
||||
// })
|
||||
downloadVoiceFile(_url).then(res=>{
|
||||
if(res?.data){
|
||||
common.msg(res.data.message)
|
||||
@@ -401,6 +416,19 @@ const audioCacheObj = computed(() => storageStore.audioObj)
|
||||
})
|
||||
}
|
||||
}
|
||||
const saveFile = (buffer,filePath, cb = ()=>{}) => {
|
||||
let fileManager = uni.getFileSystemManager()
|
||||
fileManager.writeFile({
|
||||
filePath: filePath,
|
||||
data: buffer,
|
||||
encoding: 'binary',
|
||||
success: cb,
|
||||
file: ()=>{
|
||||
voiceLoading.value = false
|
||||
console.log('文件保存失败!')
|
||||
}
|
||||
})
|
||||
}
|
||||
const initVoice = (readType = 'qns', item, isplay=false) => {
|
||||
if(unref(dataInfo).talkingVoice){
|
||||
itemVoice.value = unref(dataInfo).talkingVoice
|
||||
|
||||
Reference in New Issue
Block a user