日志控制
This commit is contained in:
@@ -5,6 +5,7 @@ import SubManager from "../../Sub/SubManager"
|
||||
import Utils from "../Common/Utils"
|
||||
import { InnerMsgCode } from "../Config/InnerMsgCode"
|
||||
import HttpUnit from "../Common/HttpUnit"
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
|
||||
//广告ID
|
||||
const AD_AWARD = "1ntrdiqhmdket7v5fe"
|
||||
@@ -47,7 +48,7 @@ export class ByteDanceSDK{
|
||||
window['tt'].checkScene({
|
||||
scene: "sidebar",
|
||||
success: (res) => {
|
||||
console.log("抖音 检测侧边栏功能->", res)
|
||||
logger.log("抖音 检测侧边栏功能->", res)
|
||||
if (res.isExist == true) {
|
||||
if (ByteDanceSDK._SidebarState == 0) {
|
||||
ByteDanceSDK._SidebarState = 1
|
||||
@@ -56,22 +57,22 @@ export class ByteDanceSDK{
|
||||
cb && cb(res.isExist == true);
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("抖音 检测侧边栏功能失败->", res)
|
||||
logger.log("抖音 检测侧边栏功能失败->", res)
|
||||
cb && cb(false);
|
||||
}
|
||||
})
|
||||
}
|
||||
/**前往侧边栏 */
|
||||
public static GotoSidebar(cb:Function = null){
|
||||
console.log("抖音 正在前往侧边栏...")
|
||||
logger.log("抖音 正在前往侧边栏...")
|
||||
window["tt"].navigateToScene({
|
||||
scene: "sidebar",
|
||||
success(res) {
|
||||
console.log("抖音 前往侧边栏 成功")
|
||||
logger.log("抖音 前往侧边栏 成功")
|
||||
cb && cb(true);
|
||||
},
|
||||
fail(res) {
|
||||
console.log("抖音 前往侧边栏 失败", res)
|
||||
logger.log("抖音 前往侧边栏 失败", res)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -79,7 +80,7 @@ export class ByteDanceSDK{
|
||||
|
||||
//初始化
|
||||
init(cb: Function = null) {
|
||||
console.log("init 抖音 初始化...")
|
||||
logger.log("init 抖音 初始化...")
|
||||
// 保持屏幕常亮
|
||||
window["tt"].setKeepScreenOn({
|
||||
keepScreenOn: true,
|
||||
@@ -92,14 +93,14 @@ export class ByteDanceSDK{
|
||||
|
||||
//小游戏回到前台
|
||||
window['tt'].onShow((res)=>{
|
||||
console.log("抖音 小游戏回到前台->", res)
|
||||
logger.log("抖音 小游戏回到前台->", res)
|
||||
if (!res) {
|
||||
return;
|
||||
}
|
||||
// console.log("启动参数:", res.query);
|
||||
// console.log("来源信息:", res.refererInfo);
|
||||
// console.log("场景值:", res.scene);
|
||||
// console.log("启动场景字段:", res.launch_from, ", ", res.location);
|
||||
// logger.log("启动参数:", res.query);
|
||||
// logger.log("来源信息:", res.refererInfo);
|
||||
// logger.log("场景值:", res.scene);
|
||||
// logger.log("启动场景字段:", res.launch_from, ", ", res.location);
|
||||
|
||||
//返回小游戏场景值
|
||||
if (res.query && res.query.ShareCode) {
|
||||
@@ -108,7 +109,7 @@ export class ByteDanceSDK{
|
||||
|
||||
//从侧边栏返回
|
||||
if (res.launch_from == "homepage" && res.location == "sidebar_card") {
|
||||
console.log("从侧边栏返回, SidebarState=", ByteDanceSDK._SidebarState)
|
||||
logger.log("从侧边栏返回, SidebarState=", ByteDanceSDK._SidebarState)
|
||||
if (ByteDanceSDK._SidebarState == 1) {
|
||||
ByteDanceSDK._SidebarState = 2
|
||||
Utils.sendInnerMsg(InnerMsgCode.UI_BD_Sidebar, {})
|
||||
@@ -129,7 +130,7 @@ export class ByteDanceSDK{
|
||||
if (this.ShareCb) {
|
||||
if (this.ShareSTime) {
|
||||
let nT = new Date().getTime();
|
||||
console.log("分享时间差 计算:",nT, this.ShareSTime);
|
||||
logger.log("分享时间差 计算:",nT, this.ShareSTime);
|
||||
if (nT - this.ShareSTime > 1500) {
|
||||
let cb = this.ShareCb.succ
|
||||
cb && cb()
|
||||
@@ -144,7 +145,7 @@ export class ByteDanceSDK{
|
||||
window['tt'].onHide(() => {
|
||||
if (this.ShareCb) {
|
||||
this.ShareSTime = new Date().getTime();
|
||||
console.log("分享时间差 记录:", this.ShareSTime);
|
||||
logger.log("分享时间差 记录:", this.ShareSTime);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -175,7 +176,7 @@ export class ByteDanceSDK{
|
||||
window['tt'].authorize({
|
||||
scope: autoKey,
|
||||
success(res:any) {
|
||||
console.log("抖音 - 检测权限状态 succ:", JSON.stringify(res))
|
||||
logger.log("抖音 - 检测权限状态 succ:", JSON.stringify(res))
|
||||
if (autoKey == "scope.userInfo" && res.data['scope.userInfo']) {
|
||||
cb && cb(true)
|
||||
} else {
|
||||
@@ -183,7 +184,7 @@ export class ByteDanceSDK{
|
||||
}
|
||||
},
|
||||
fail(res:any) {
|
||||
console.log("抖音 - 检测权限状态 fail:",JSON.stringify(res))
|
||||
logger.log("抖音 - 检测权限状态 fail:",JSON.stringify(res))
|
||||
cb && cb(false)
|
||||
}
|
||||
})
|
||||
@@ -196,11 +197,11 @@ export class ByteDanceSDK{
|
||||
window["tt"].getUserInfo({
|
||||
force: false, //当宿主未登录时,是否强制拉起登录框
|
||||
success(res) {
|
||||
console.log("抖音 - 获取用户信息成功:", res);
|
||||
logger.log("抖音 - 获取用户信息成功:", res);
|
||||
cb && cb({avatarUrl:res.userInfo.avatarUrl, nickName:res.userInfo.nickName}) //encryptedData
|
||||
},
|
||||
fail(res) {
|
||||
console.log("抖音 - 获取用户信息失败", res);
|
||||
logger.log("抖音 - 获取用户信息失败", res);
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -211,11 +212,11 @@ export class ByteDanceSDK{
|
||||
window["tt"].login({
|
||||
force: false, //未登录时, 是否强制调起登录框
|
||||
success(res) {
|
||||
console.log(`抖音 - 登录成功 code=${res.code}, anonymousCode=${res.anonymousCode}`);
|
||||
logger.log(`抖音 - 登录成功 code=${res.code}, anonymousCode=${res.anonymousCode}`);
|
||||
cb && cb({ platform:2, code: res.code });
|
||||
},
|
||||
fail(res) {
|
||||
console.log(`抖音 - 登录失败`, res);
|
||||
logger.log(`抖音 - 登录失败`, res);
|
||||
cb && cb({ platform:2, code: null });
|
||||
},
|
||||
})
|
||||
@@ -223,7 +224,7 @@ export class ByteDanceSDK{
|
||||
|
||||
private init_banner() {
|
||||
if (AD_BANNER as any == "test") {
|
||||
console.log("抖音 横幅广告id未配置,跳过此类型初始化")
|
||||
logger.log("抖音 横幅广告id未配置,跳过此类型初始化")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -260,10 +261,10 @@ export class ByteDanceSDK{
|
||||
// bd_banner
|
||||
// .show()
|
||||
// .then(() => {
|
||||
// console.log("init_banner 广告显示成功");
|
||||
// logger.log("init_banner 广告显示成功");
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log("init_banner 广告组件出现问题", err);
|
||||
// logger.log("init_banner 广告组件出现问题", err);
|
||||
// });
|
||||
// })
|
||||
}
|
||||
@@ -275,7 +276,7 @@ export class ByteDanceSDK{
|
||||
|
||||
private preload_splash() {
|
||||
if (AD_SPLASH as any == "test") {
|
||||
console.log("抖音 插屏广告id未配置,跳过此类型初始化")
|
||||
logger.log("抖音 插屏广告id未配置,跳过此类型初始化")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -290,7 +291,7 @@ export class ByteDanceSDK{
|
||||
this.bd_splash
|
||||
.load()
|
||||
.catch(err => {
|
||||
console.log("preload_splash err:",err);
|
||||
logger.log("preload_splash err:",err);
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -312,14 +313,14 @@ export class ByteDanceSDK{
|
||||
this.preload_splash()
|
||||
})
|
||||
this.bd_splash.onError(function(err){
|
||||
console.log("bd_splash err:",err)
|
||||
logger.log("bd_splash err:",err)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
private init_video() {
|
||||
if (AD_AWARD as any == "test") {
|
||||
console.log("抖音 激励广告id未配置,跳过此类型初始化")
|
||||
logger.log("抖音 激励广告id未配置,跳过此类型初始化")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -346,7 +347,7 @@ export class ByteDanceSDK{
|
||||
//显示视频广告
|
||||
show_video(callback:Function, tag:number) {
|
||||
if (AD_AWARD as any == 'test') {
|
||||
console.log('未接入广告ID,视频广告请求直接返回');
|
||||
logger.log('未接入广告ID,视频广告请求直接返回');
|
||||
callback && callback();
|
||||
SDKManager.video_ad_back();
|
||||
return;
|
||||
@@ -374,10 +375,10 @@ export class ByteDanceSDK{
|
||||
if (this.bd_splash && this.bd_splash['custom_load_stautus'] && !this.bd_splash['custom_show_stautus']) {
|
||||
this.bd_splash.show().then(() => {
|
||||
this.bd_splash['custom_show_stautus'] = true
|
||||
console.log("插屏广告展示成功");
|
||||
logger.log("插屏广告展示成功");
|
||||
})
|
||||
} else {
|
||||
console.log("插屏广告展示失败");
|
||||
logger.log("插屏广告展示失败");
|
||||
this.preload_splash()
|
||||
}
|
||||
|
||||
@@ -416,18 +417,18 @@ export class ByteDanceSDK{
|
||||
//主动拉起分享
|
||||
show_share(rewardCB?:Function) {
|
||||
// rewardCB && rewardCB()
|
||||
console.log("主动拉起分享");
|
||||
logger.log("主动拉起分享");
|
||||
let info:any = this.shareInfo();
|
||||
info.succ = rewardCB;
|
||||
|
||||
info.success = (res) => {
|
||||
console.log("抖音 主动拉起分享成功", res);
|
||||
logger.log("抖音 主动拉起分享成功", res);
|
||||
}
|
||||
info.fail = (err) => {
|
||||
console.log("抖音 主动拉起分享失败", err);
|
||||
logger.log("抖音 主动拉起分享失败", err);
|
||||
}
|
||||
// info.complete = (res) => {
|
||||
// console.log("抖音 主动拉起分享完成", res);
|
||||
// logger.log("抖音 主动拉起分享完成", res);
|
||||
// }
|
||||
|
||||
this.ShareCb = info;
|
||||
@@ -471,23 +472,23 @@ export class ByteDanceSDK{
|
||||
const fs = window['tt'].getFileSystemManager();
|
||||
//1.删除上一个音频
|
||||
const lastPath = window['tt'].env.USER_DATA_PATH + `/ordernew${self._iacIdx}.mp3`
|
||||
console.log("抖音 正在删除上一个音频 ->", lastPath);
|
||||
logger.log("抖音 正在删除上一个音频 ->", lastPath);
|
||||
fs.removeSavedFile({
|
||||
filePath: lastPath,
|
||||
success(res) {
|
||||
console.log("抖音 删除上一个音频成功", res);
|
||||
logger.log("抖音 删除上一个音频成功", res);
|
||||
},
|
||||
fail(err) {
|
||||
console.log("抖音 删除上一个音频失败", err);
|
||||
logger.log("抖音 删除上一个音频失败", err);
|
||||
},
|
||||
complete(res) {
|
||||
console.log("抖音 删除上一个音频完成", res);
|
||||
logger.log("抖音 删除上一个音频完成", res);
|
||||
|
||||
//2.保存当前音频
|
||||
//这里需要每次保存时换一下名字的原因是:innerAudioContext设置路径时如果路径相同,会认为还是同一个音频,不会重新加载,所以需要每次保存时换一下名字
|
||||
self._iacIdx++;
|
||||
const audioPath = window['tt'].env.USER_DATA_PATH + `/ordernew${self._iacIdx}.mp3`
|
||||
console.log("抖音 正在保存本次音频 ->", audioPath);
|
||||
logger.log("抖音 正在保存本次音频 ->", audioPath);
|
||||
fs.writeFile({
|
||||
filePath: audioPath,
|
||||
data: substring,
|
||||
@@ -497,18 +498,18 @@ export class ByteDanceSDK{
|
||||
self._innerAudioContext = window['tt'].createInnerAudioContext();
|
||||
// 添加播放结束的回调
|
||||
self._innerAudioContext.onEnded(() => {
|
||||
console.log("抖音 AI语音播放结束")
|
||||
logger.log("抖音 AI语音播放结束")
|
||||
self._innerAudioContext.stop(); // 使用 stop 方法停止音频并重置播放状态
|
||||
self._innerAudioContext.destroy(); // 销毁音频实例
|
||||
self._innerAudioContext = null;
|
||||
});
|
||||
}
|
||||
console.log("抖音 播放base64音频", audioPath)
|
||||
logger.log("抖音 播放base64音频", audioPath)
|
||||
self._innerAudioContext.src = audioPath;
|
||||
self._innerAudioContext.play(); // 开始播放音频
|
||||
},
|
||||
fail(err) {
|
||||
console.log("抖音 保存本次音频失败", err);
|
||||
logger.log("抖音 保存本次音频失败", err);
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -520,7 +521,7 @@ export class ByteDanceSDK{
|
||||
//微信开发者工具上可以通过「编译模式」下的「下次编译模拟更新」开关来调试
|
||||
qiangzhiUpdata() {
|
||||
if (window['tt'].getUpdateManager == null) {
|
||||
console.log("抖音 没有更新管理器", window['tt'].getUpdateManager)
|
||||
logger.log("抖音 没有更新管理器", window['tt'].getUpdateManager)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -529,7 +530,7 @@ export class ByteDanceSDK{
|
||||
//监听向微信后台请求检查更新结果事件。微信在小程序每次启动(包括热启动)时自动检查更新,不需由开发者主动触发。
|
||||
updateManager.onCheckForUpdate((res) => {
|
||||
// 请求完新版本信息的回调
|
||||
console.log("抖音 检查是否有新版本:", res.hasUpdate)
|
||||
logger.log("抖音 检查是否有新版本:", res.hasUpdate)
|
||||
});
|
||||
|
||||
//监听小程序有版本更新事件。客户端主动触发下载(无需开发者触发),下载成功后回调
|
||||
@@ -548,19 +549,19 @@ export class ByteDanceSDK{
|
||||
|
||||
//监听小程序更新失败事件。小程序有新版本,客户端主动触发下载(无需开发者触发),下载失败(可能是网络原因等)时回调
|
||||
updateManager.onUpdateFailed(function (err) {
|
||||
console.log("抖音 新版本下载失败", err)
|
||||
logger.log("抖音 新版本下载失败", err)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//客服功能是否支持
|
||||
kefuSupport() {
|
||||
console.log("抖音 不支持联系客服")
|
||||
logger.log("抖音 不支持联系客服")
|
||||
return false;
|
||||
}
|
||||
//进入联系客服
|
||||
openKefu() {
|
||||
console.log("抖音 进入联系客服")
|
||||
logger.log("抖音 进入联系客服")
|
||||
}
|
||||
|
||||
|
||||
@@ -573,15 +574,15 @@ export class ByteDanceSDK{
|
||||
//region 复制到剪贴板
|
||||
/**复制文本到剪贴板 */
|
||||
copyToClipboard(text: string, cb?: Function) {
|
||||
console.log("抖音 复制到剪贴板:", text);
|
||||
logger.log("抖音 复制到剪贴板:", text);
|
||||
window['tt'].setClipboardData({
|
||||
data: text,
|
||||
success: () => {
|
||||
console.log("抖音 复制成功");
|
||||
logger.log("抖音 复制成功");
|
||||
cb && cb(true);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log("抖音 复制失败:", err);
|
||||
logger.log("抖音 复制失败:", err);
|
||||
cb && cb(false);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user