添加图标和页面
This commit is contained in:
@@ -8,7 +8,7 @@ export const defaultAvatarUrl =
|
||||
"https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0";
|
||||
|
||||
export const base = {
|
||||
appletName: "易宝赞数据化管理系统",
|
||||
appletName: "易宝赞管理系统普惠版",
|
||||
apiHost:
|
||||
wx.getAccountInfoSync().miniProgram.envVersion == "release"
|
||||
? "https://ebaozan.com/api/"
|
||||
|
||||
75
miniprogram/utils/voiceUtil.js
Normal file
75
miniprogram/utils/voiceUtil.js
Normal file
@@ -0,0 +1,75 @@
|
||||
import { post, urlAddBaseUrl } from "./https";
|
||||
|
||||
const playVoice = (src, text) => {
|
||||
const innerAudioContext = wx.createInnerAudioContext({
|
||||
useWebAudioImplement: true,
|
||||
});
|
||||
innerAudioContext.src = src;
|
||||
innerAudioContext.play();
|
||||
innerAudioContext.onError(() => {
|
||||
innerAudioContext.destroy();
|
||||
console.log("Audio Error");
|
||||
// wx.removeStorageSync(text);
|
||||
});
|
||||
innerAudioContext.onEnded(() => {
|
||||
innerAudioContext.destroy();
|
||||
console.log("Audio End");
|
||||
});
|
||||
};
|
||||
|
||||
export const voiceRequest = (text, cacheVoice) => {
|
||||
// if (cacheVoice) {
|
||||
// const data = wx.getStorageSync(text);
|
||||
// console.log(data);
|
||||
// if (data) {
|
||||
// console.log("有 base64");
|
||||
// const fs = wx.getFileSystemManager();
|
||||
// //随机定义路径名称
|
||||
// var times = new Date().getTime();
|
||||
// var codeimg = wx.env.USER_DATA_PATH + "/" + times + ".mp3";
|
||||
// //将base64图片写入
|
||||
// fs.writeFile({
|
||||
// filePath: codeimg,
|
||||
// data: data,
|
||||
// encoding: "base64",
|
||||
// success: (res) => {
|
||||
// console.log(res);
|
||||
// playVoice(codeimg, text);
|
||||
// },
|
||||
// fail: (res) => {
|
||||
// console.log(res);
|
||||
// },
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
post(
|
||||
"/Tools/voice",
|
||||
{
|
||||
txt: text,
|
||||
per: 3,
|
||||
spd: 5,
|
||||
pit: 5,
|
||||
vol: 9,
|
||||
},
|
||||
{ showLoading: false }
|
||||
).then((res) => {
|
||||
if (res.err_code == 0) {
|
||||
playVoice(urlAddBaseUrl(res.data), text);
|
||||
// if (cacheVoice) {
|
||||
// wx.request({
|
||||
// url: urlAddBaseUrl(res.data),
|
||||
// responseType: "arraybuffer",
|
||||
// success(res) {
|
||||
// const base64 = base64js.fromByteArray(new Uint8Array(res.data));
|
||||
// try {
|
||||
// wx.setStorageSync(text, base64);
|
||||
// } catch (_) {
|
||||
// console.log("缓存错误");
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user