diff --git a/assets/Scripts/Main/Channel/SDKManager.ts b/assets/Scripts/Main/Channel/SDKManager.ts index e1ad9f55..8c203c01 100644 --- a/assets/Scripts/Main/Channel/SDKManager.ts +++ b/assets/Scripts/Main/Channel/SDKManager.ts @@ -7,6 +7,7 @@ import { KSSDK } from "./ksSDK"; import AudioManager from "../Manager/AudioManager"; import GlobalValue, { VideoRoleType } from "../Common/GlobalValue"; import { luffaSDK } from "./luffaSDK"; +import { logger } from "db://assets/Scripts/Main/Common/Logger"; const { ccclass, property } = _decorator; @@ -86,9 +87,9 @@ export class SDKManager { //extends Component this.video_reward_map = {} this.share_reward_map = {} - console.log("平台值 wx:",window["wx"], typeof window["wx"]) - console.log("平台值 ks:",window["ks"], typeof window["ks"]) - console.log("平台值 tt:",window["tt"], typeof window["tt"]) + logger.log("平台值 wx:",window["wx"], typeof window["wx"]) + logger.log("平台值 ks:",window["ks"], typeof window["ks"]) + logger.log("平台值 tt:",window["tt"], typeof window["tt"]) if (typeof window["ks"] !== 'undefined') { this.sdk_channel = E_SDK_Channel.KS @@ -104,7 +105,7 @@ export class SDKManager { //extends Component this.sdk = new WebSDK() } - console.log("当前平台:",sys.platform, this.sdk_channel) + logger.log("当前平台:",sys.platform, this.sdk_channel) if (GlobalValue.NpcVideoMod) { GlobalValue.NpcVideoMod = this.sdk_channel === E_SDK_Channel.WX || this.sdk_channel === E_SDK_Channel.WEB } @@ -192,12 +193,12 @@ export class SDKManager { //extends Component } //看视频广告前 static video_ad_pre() { - console.log("SDKManager 视频广告前") + logger.log("SDKManager 视频广告前") AudioManager.I.PauseMusic(); } //看视频广告后返回游戏 static video_ad_back() { - console.log("SDKManager 视频广告后") + logger.log("SDKManager 视频广告后") AudioManager.I.ResumeMusic(); } diff --git a/assets/Scripts/Main/Channel/bdSDK.ts b/assets/Scripts/Main/Channel/bdSDK.ts index d0b1ff4f..b3950ed7 100644 --- a/assets/Scripts/Main/Channel/bdSDK.ts +++ b/assets/Scripts/Main/Channel/bdSDK.ts @@ -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); } }); diff --git a/assets/Scripts/Main/Channel/ksSDK.ts b/assets/Scripts/Main/Channel/ksSDK.ts index 85df3766..b12c47f3 100644 --- a/assets/Scripts/Main/Channel/ksSDK.ts +++ b/assets/Scripts/Main/Channel/ksSDK.ts @@ -6,6 +6,7 @@ import Utils from "../Common/Utils"; import { InnerMsgCode } from "../Config/InnerMsgCode"; import { BgVideo } from "./BgVideo"; import { SceneBgVideoLayer } from "../../Sub/UI/SceneBgVideoLayer"; +import { logger } from "db://assets/Scripts/Main/Common/Logger"; //广告ID const wx_banner_ad_unit_id = 'test' @@ -35,7 +36,7 @@ export class KSSDK{ //获取小游戏冷启动时的参数 热启动参数通过 ks.onShow 接口获取。 let launchOption = window['ks'].getLaunchOptionsSync(); KSSDK.g_InGameScene = launchOption.from; - console.log('init 快手 - 进入游戏的场景值', launchOption); + logger.log('init 快手 - 进入游戏的场景值', launchOption); // //显示分享按钮 // window['ks'].showShareMenu({ @@ -53,10 +54,10 @@ export class KSSDK{ window['ks'].onShow(this.onWxShow.bind(this)); //小游戏被隐藏 记个时间 window['ks'].onHide(() => { - console.log("快手 onHide回调:") + logger.log("快手 onHide回调:") if (this.ShareCb) { this.ShareSTime = new Date().getTime(); - console.log("分享时间差 记录:", this.ShareSTime); + logger.log("分享时间差 记录:", this.ShareSTime); } }); @@ -70,7 +71,7 @@ export class KSSDK{ //小游戏回到前台 onWxShow(data: any) { - console.log("快手 onShow回调:", data) + logger.log("快手 onShow回调:", data) if (data) { //启动小游戏时传入的参数 object if (data.query) { @@ -85,7 +86,7 @@ export class KSSDK{ if (this.ShareCb) { if (this.ShareSTime) { let nT = new Date().getTime(); - console.log("分享时间差 计算:",nT, this.ShareSTime, nT - this.ShareSTime); + logger.log("分享时间差 计算:",nT, this.ShareSTime, nT - this.ShareSTime); if (nT - this.ShareSTime > 1) { //快手的onHide有问题,离onShow很近 let cb = this.ShareCb.succ cb && cb() @@ -113,7 +114,7 @@ export class KSSDK{ checkAutoSetting(autoKey:string, cb:Function = null) { window['ks'].getSetting({ success(res:any) { - console.log("快手 - 检测权限状态 succ:", res) + logger.log("快手 - 检测权限状态 succ:", res) if (autoKey == "userInfo" && res.authSetting['scope.userInfo']) { cb && cb(true) } else { @@ -121,7 +122,7 @@ export class KSSDK{ } }, fail(res:any) { - console.log("快手 - 检测权限状态 fail:", res) + logger.log("快手 - 检测权限状态 fail:", res) cb && cb(false) } }) @@ -134,16 +135,16 @@ export class KSSDK{ var self = this; window['ks'].getSetting({ success(res:any) { - console.log("快手 - 获取授权信息成功:", res); + logger.log("快手 - 获取授权信息成功:", res); let isScope = res.authSetting['scope.userInfo'] if (isScope) { window['ks'].getUserInfo({ success: (res2) => { - console.log("快手 - 获取用户信息成功:", res2); + logger.log("快手 - 获取用户信息成功:", res2); cb && cb({avatarUrl:res2.userInfo.avatarUrl, nickName:res2.userInfo.nickName}) }, fail: (error) => { - console.log("快手 - 获取用户信息失败:", error); + logger.log("快手 - 获取用户信息失败:", error); } }) } else { @@ -151,17 +152,17 @@ export class KSSDK{ window['ks'].authorize({ scope: 'scope.userInfo', success: (res) => { - console.log("快手 - 发起授权请求成功:", res); + logger.log("快手 - 发起授权请求成功:", res); self.getUserInfo(cb) }, fail: (error) => { - console.log("快手 - 发起授权请求失败: ", error); + logger.log("快手 - 发起授权请求失败: ", error); } }) } }, fail: (error) => { - console.log("快手 - 获取授权信息失败: ", error); + logger.log("快手 - 获取授权信息失败: ", error); // cb && cb({avatarUrl:"", nickName:""}) } }) @@ -172,11 +173,11 @@ export class KSSDK{ login(cb: Function = null) { window['ks'].login({ success: (res) => { - console.log('快手 - 登录成功', res.code); + logger.log('快手 - 登录成功', res.code); cb && cb({ platform:3, code: res.code }); }, fail(res: any) { - console.log(`快手 login 调用失败`, res); + logger.log(`快手 login 调用失败`, res); cb && cb({ platform:3, code: null }); }, }); @@ -185,7 +186,7 @@ export class KSSDK{ //初始化视频广告 private init_video() { if (wx_video_ad_unit_id as any == "test") { - console.log("快手 激励广告id未配置,跳过此类型初始化") + logger.log("快手 激励广告id未配置,跳过此类型初始化") return } @@ -193,10 +194,10 @@ export class KSSDK{ adUnitId: wx_video_ad_unit_id }); this.wx_video.onError((err) => { - console.log('onError event emit', err); + logger.log('onError event emit', err); }); this.wx_video.onClose(res => { - console.log('onClose event emit',res); + logger.log('onClose event emit',res); // 用户点击了【关闭广告】按钮 // 小于 2.1.0 的基础库版本,res 是一个 undefined if ((res && res.isEnded) || res === undefined) { @@ -217,7 +218,7 @@ export class KSSDK{ //初始化插屏广告 private init_splash() { if (wx_splash_ad_unit_id as any == "test") { - console.log("快手 插屏广告id未配置,跳过此类型初始化") + logger.log("快手 插屏广告id未配置,跳过此类型初始化") return } @@ -227,10 +228,10 @@ export class KSSDK{ adUnitId: wx_splash_ad_unit_id }); this.wx_splash.onError((err) => { - console.log('splash onError event emit', err); + logger.log('splash onError event emit', err); }); this.wx_splash.onClose(res => { - console.log('splash onClose event emit', res); + logger.log('splash onClose event emit', res); }); } } @@ -238,7 +239,7 @@ export class KSSDK{ //初始化Banner private init_banner() { if (wx_banner_ad_unit_id as any == "test") { - console.log("快手 横幅广告id未配置,跳过此类型初始化") + logger.log("快手 横幅广告id未配置,跳过此类型初始化") return } @@ -247,7 +248,7 @@ export class KSSDK{ //显示视频广告 show_video(callback:Function, tag:number) { if (wx_video_ad_unit_id == 'test') { - console.log('未接入广告ID,视频广告请求直接返回'); + logger.log('未接入广告ID,视频广告请求直接返回'); callback && callback(); SDKManager.video_ad_back(); return; @@ -258,10 +259,10 @@ export class KSSDK{ let p = this.wx_video.show() p.then(function(result){ // 激励视频展示成功 - console.log(`快手 show rewarded video ad success, result is ${result}`) + logger.log(`快手 show rewarded video ad success, result is ${result}`) }).catch(function(error){ // 激励视频展示失败 - console.log(`快手 show rewarded video ad failed, error is ${error}`) + logger.log(`快手 show rewarded video ad failed, error is ${error}`) }) // this.wx_video.load() @@ -282,10 +283,10 @@ export class KSSDK{ let p = this.wx_splash.show() p.then(function(result){ // 插屏广告展示成功 - console.log(`快手 show interstitial ad success, result is ${result}`) + logger.log(`快手 show interstitial ad success, result is ${result}`) }).catch(function(error){ // 插屏广告展示失败 - console.log(`快手 show interstitial ad failed, error is ${error}`) + logger.log(`快手 show interstitial ad failed, error is ${error}`) if (error.code === -10005) { // 表明当前app版本不支持插屏广告,可以提醒用户升级app版本 } @@ -319,7 +320,7 @@ export class KSSDK{ } //主动拉起分享 show_share(rewardCB?:Function) { - console.log("主动拉起分享"); + logger.log("主动拉起分享"); let info:any = this.shareInfo(); info.succ = rewardCB; info.success = null; @@ -337,13 +338,13 @@ export class KSSDK{ //显示游戏圈 show_gameClub(leftRatio, topRatio, widthRatio, heightRatio) { if (true) { - console.log("显示游戏圈,快手暂不支持"); + logger.log("显示游戏圈,快手暂不支持"); return } } //隐藏游戏圈 hide_gameClub() { - console.log("隐藏游戏圈"); + logger.log("隐藏游戏圈"); if (this.wx_gameClub) { this.wx_gameClub.hide(); } @@ -359,7 +360,7 @@ export class KSSDK{ private _iacIdx = 0 //音频播放索引 playBase64Audio(base64, loop) { if (!this.checkSupportBase64Audio()) { - console.log("当前平台不支持base64音频播放"); + logger.log("当前平台不支持base64音频播放"); return; } @@ -373,23 +374,23 @@ export class KSSDK{ const fs = window['ks'].getFileSystemManager(); //1.删除上一个音频 const lastPath = window['ks'].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['ks'].env.USER_DATA_PATH + `/ordernew${self._iacIdx}.mp3` - console.log("快手 正在保存本次音频 ->", audioPath); + logger.log("快手 正在保存本次音频 ->", audioPath); fs.writeFile({ filePath: audioPath, data: substring, @@ -399,18 +400,18 @@ export class KSSDK{ self._innerAudioContext = window['ks'].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); } }) } @@ -423,7 +424,7 @@ export class KSSDK{ //微信开发者工具上可以通过「编译模式」下的「下次编译模拟更新」开关来调试 qiangzhiUpdata() { if (window['ks'].getUpdateManager == null) { - console.log("快手 没有更新管理器", window['ks'].getUpdateManager) + logger.log("快手 没有更新管理器", window['ks'].getUpdateManager) return; } @@ -432,7 +433,7 @@ export class KSSDK{ //监听向微信后台请求检查更新结果事件。微信在小程序每次启动(包括热启动)时自动检查更新,不需由开发者主动触发。 updateManager.onCheckForUpdate((res) => { // 请求完新版本信息的回调 - console.log("快手 检查是否有新版本:", res.hasUpdate) + logger.log("快手 检查是否有新版本:", res.hasUpdate) }); //监听小程序有版本更新事件。客户端主动触发下载(无需开发者触发),下载成功后回调 @@ -449,19 +450,19 @@ export class KSSDK{ //监听小程序更新失败事件。小程序有新版本,客户端主动触发下载(无需开发者触发),下载失败(可能是网络原因等)时回调 updateManager.onUpdateFailed(function (err) { - console.log("快手 新版本下载失败", err) + logger.log("快手 新版本下载失败", err) }) } //客服功能是否支持 kefuSupport() { - console.log("快手 不支持联系客服") + logger.log("快手 不支持联系客服") return false; } //进入联系客服 openKefu() { - console.log("快手 进入联系客服") + logger.log("快手 进入联系客服") } @@ -471,7 +472,7 @@ export class KSSDK{ private curPlayType: VideoRoleType = VideoRoleType.None //当前播放的视频的类型 playBgAudio(remoteUrl:string, vtype:VideoRoleType, loop:boolean = false, extra:any = {}) { if (!window['ks'].createVideo) { - console.log("快手 不支持播放视频") + logger.log("快手 不支持播放视频") return } if (this._bgVideo && this._bgShow) { @@ -479,18 +480,18 @@ export class KSSDK{ return } let self = this; - console.log("微信 播放背景视频组件1", remoteUrl); + logger.log("微信 播放背景视频组件1", remoteUrl); this.curPlayType = vtype if (!this._bgVideo) { this._bgVideo = this.createVideoHandle(); // this._bgVideo.onPlay(() => { - // console.log("微信 背景视频播放开始"); + // logger.log("微信 背景视频播放开始"); // }) this._bgVideo.onTimeUpdate((_tinfo:any) =>{ - // console.log("微信 背景视频播放进度", self._bgShow, _tinfo); + // logger.log("微信 背景视频播放进度", self._bgShow, _tinfo); if (!self._bgShow) { if (_tinfo && _tinfo.position > 0.01) { - console.log("微信 背景视频1进入视野"); + logger.log("微信 背景视频1进入视野"); self.videoMoveIn(self._bgVideo) self._bgShow = true; self.removeBgAudioNext() @@ -521,19 +522,19 @@ export class KSSDK{ private _bgTempShow: boolean = false; playBgAudioNext(remoteUrl:string, vtype:VideoRoleType, loop:boolean = false, extra:any = {}) { this.removeBgAudioNext(); - console.log("微信 创建背景视频组件2--->", remoteUrl); + logger.log("微信 创建背景视频组件2--->", remoteUrl); this.curPlayType = vtype let self = this; if (!this._bgTempVideo) { this._bgTempVideo = this.createVideoHandle(); // this._bgTempVideo.onPlay(() => { - // console.log("微信 临时背景视频播放开始"); + // logger.log("微信 临时背景视频播放开始"); // }) this._bgTempVideo.onTimeUpdate((_tinfo:any) =>{ - // console.log("微信 临时背景视频播放进度", self._bgTempShow, _tinfo); + // logger.log("微信 临时背景视频播放进度", self._bgTempShow, _tinfo); if (!self._bgTempShow) { if (_tinfo && _tinfo.position > 0.01) { - console.log("微信 背景视频2进入视野"); + logger.log("微信 背景视频2进入视野"); self._bgTempShow = true; self.videoMoveIn(self._bgTempVideo) self.removeBgAudio() @@ -569,18 +570,18 @@ export class KSSDK{ return } let self = this; - console.log("微信 播放emo视频1", remoteUrl); + logger.log("微信 播放emo视频1", remoteUrl); this.curPlayType = vtype if (!this._emoVideo) { this._emoVideo = this.createVideoHandle(); // this._emoVideo.onPlay(() => { - // console.log("微信 背景视频播放开始"); + // logger.log("微信 背景视频播放开始"); // }) this._emoVideo.onTimeUpdate((_tinfo:any) =>{ - // console.log("微信 背景视频播放进度", self._emoShow, _tinfo); + // logger.log("微信 背景视频播放进度", self._emoShow, _tinfo); if (!self._emoShow) { if (_tinfo && _tinfo.position > 0.01) { - console.log("微信 emo视频1准备好了"); + logger.log("微信 emo视频1准备好了"); self._emoShow = true; self.removeEmoAudioNext() self.setEmoReadyAudio(self._emoVideo) @@ -610,19 +611,19 @@ export class KSSDK{ private _emoTempShow: boolean = false; playEmoAudioNext(remoteUrl:string, vtype:VideoRoleType, loop:boolean = false, extra:any = {}) { this.removeEmoAudioNext(); - console.log("微信 播放emo视频2--->", remoteUrl); + logger.log("微信 播放emo视频2--->", remoteUrl); this.curPlayType = vtype let self = this; if (!this._emoTempVideo) { this._emoTempVideo = this.createVideoHandle(); // this._emoTempVideo.onPlay(() => { - // console.log("微信 临时背景视频播放开始"); + // logger.log("微信 临时背景视频播放开始"); // }) this._emoTempVideo.onTimeUpdate((_tinfo:any) =>{ - // console.log("微信 临时背景视频播放进度", self._emoTempShow, _tinfo); + // logger.log("微信 临时背景视频播放进度", self._emoTempShow, _tinfo); if (!self._emoTempShow) { if (_tinfo && _tinfo.position > 0.01) { - console.log("微信 emo视频2已准备好"); + logger.log("微信 emo视频2已准备好"); self._emoTempShow = true; self.removeEmoAudio() self.setEmoReadyAudio(self._emoTempVideo) @@ -706,19 +707,19 @@ export class KSSDK{ this.videoAdaInfo.x = -(this.videoWidth * ratioh - size.width) / 2 this.videoAdaInfo.y = 0 } - console.log("微信 视频适配信息", this.videoAdaInfo, size) + logger.log("微信 视频适配信息", this.videoAdaInfo, size) return this.videoAdaInfo } //设置暂停播放的主视频 private vpWait: any = null; setBgAudioPause(wait:any) { - console.log("微信 主视频暂停播放") + logger.log("微信 主视频暂停播放") this.vpWait = wait this.vpWait.pause() } replayBgAudioPause() { - console.log("微信 主视频继续播放") + logger.log("微信 主视频继续播放") if (this.vpWait) { this.vpWait.play() } @@ -727,7 +728,7 @@ export class KSSDK{ //设置准备好要播放的表情视频 private emoReady: any = null; setEmoReadyAudio(au: any) { - console.log("微信 设置emo ready视频") + logger.log("微信 设置emo ready视频") if (this.emoReady) { this.emoReady.stop() this.videoMoveOut(this.emoReady) @@ -737,7 +738,7 @@ export class KSSDK{ } //移除准备好要播放的表情视频 removeEmoReadyAudio() { - console.log("微信 移除emo ready视频") + logger.log("微信 移除emo ready视频") if (this.emoReady) { this.emoReady.stop() this.videoMoveOut(this.emoReady) @@ -747,7 +748,7 @@ export class KSSDK{ //播放准备好要播放的表情视频 doPlayEmoReadyAudio():boolean { if (this.emoReady) { - console.log("微信 播放emo ready视频") + logger.log("微信 播放emo ready视频") this.emoReady.play() this.videoMoveIn(this.emoReady) return true @@ -756,7 +757,7 @@ export class KSSDK{ } //表情视频播放结束 doEmoFinish() { - console.log("微信emo ready视频播放结束") + logger.log("微信emo ready视频播放结束") this.removeEmoReadyAudio() this.replayBgAudioPause() } @@ -764,15 +765,15 @@ export class KSSDK{ //region 复制到剪贴板 /**复制文本到剪贴板 */ copyToClipboard(text: string, cb?: Function) { - console.log("快手 复制到剪贴板:", text); + logger.log("快手 复制到剪贴板:", text); window['ks'].setClipboardData({ data: text, success: () => { - console.log("快手 复制成功"); + logger.log("快手 复制成功"); cb && cb(true); }, fail: (err) => { - console.log("快手 复制失败:", err); + logger.log("快手 复制失败:", err); cb && cb(false); } }); diff --git a/assets/Scripts/Main/Channel/luffaSDK.ts b/assets/Scripts/Main/Channel/luffaSDK.ts index 20179ea8..0622497d 100644 --- a/assets/Scripts/Main/Channel/luffaSDK.ts +++ b/assets/Scripts/Main/Channel/luffaSDK.ts @@ -5,6 +5,7 @@ import { I_SDK_UserInfo_Callback, SDKManager } from "./SDKManager"; import Utils from "../Common/Utils"; import uma from "../../../utils/uma.wx.min.js"; import { InnerMsgCode } from "../Config/InnerMsgCode"; +import { logger } from "db://assets/Scripts/Main/Common/Logger"; //广告ID const wx_banner_ad_unit_id = "test"; @@ -35,7 +36,7 @@ export class luffaSDK { // 保持屏幕常亮 window["wx"].setKeepScreenOn({ keepScreenOn: true }); luffaSDK.g_InGameScene = window["wx"].getLaunchOptionsSync().scene; - console.log("init luffa - 进入游戏的场景值", luffaSDK.g_InGameScene); + logger.log("init luffa - 进入游戏的场景值", luffaSDK.g_InGameScene); //this.init_video(); //初始化视频广告 //this.init_splash(); //初始化插屏广告 @@ -50,7 +51,7 @@ export class luffaSDK { checkAutoSetting(autoKey: string, cb: Function = null) { window["wx"].getSetting({ success(res: any) { - console.log("微信 - 检测权限状态 succ:", JSON.stringify(res)); + logger.log("微信 - 检测权限状态 succ:", JSON.stringify(res)); if (autoKey == "userInfo" && res.authSetting["scope.userInfo"]) { cb && cb(true); } else { @@ -58,7 +59,7 @@ export class luffaSDK { } }, fail(res: any) { - console.log("微信 - 检测权限状态 fail:", JSON.stringify(res)); + logger.log("微信 - 检测权限状态 fail:", JSON.stringify(res)); cb && cb(false); }, }); @@ -68,11 +69,11 @@ export class luffaSDK { * 获取个人信息 */ getUserInfo(cb: I_SDK_UserInfo_Callback = null) { - console.log("微信 - 正在获取用户信息..."); + logger.log("微信 - 正在获取用户信息..."); var self = this; window["wx"].getUserInfo({ success: (res) => { - console.log("微信 - 获取用户信息成功:", res); + logger.log("微信 - 获取用户信息成功:", res); cb && cb({ avatarUrl: res.userInfo.avatarUrl, @@ -80,7 +81,7 @@ export class luffaSDK { }); }, fail: (err) => { - console.log("微信 - 获取用户信息失败:", err); + logger.log("微信 - 获取用户信息失败:", err); self.openUserAuthorize(cb); }, }); @@ -91,7 +92,7 @@ export class luffaSDK { window["wx"].getSetting({ scope: "scope.userInfo", success(res: any) { - console.log("微信 authorize succ:", JSON.stringify(res)); + logger.log("微信 authorize succ:", JSON.stringify(res)); if (res.authSetting["scope.userInfo"]) { self.getUserInfo(cb); @@ -110,21 +111,21 @@ export class luffaSDK { textAlign: "center", }, }); - console.log("微信 点击开始游戏授权用户信息"); + logger.log("微信 点击开始游戏授权用户信息"); button.onTap((res) => { button.destroy(); // if (res.userInfo) { - // console.log(res.userInfo) + // logger.log(res.userInfo) // //此时可进行登录操作 // cb && cb(res.userInfo) // } - console.log("微信 点击Tap", res); + logger.log("微信 点击Tap", res); self.getUserInfo(cb); }); } }, fail(err) { - console.log("微信 - authorize fail", err); + logger.log("微信 - authorize fail", err); }, }); } @@ -134,16 +135,16 @@ export class luffaSDK { window["wx"].login({ success: (res) => { if (res.code) { - console.log("微信 - 登录成功", res.code); + logger.log("微信 - 登录成功", res.code); cb && cb({ platform: 1, code: res.code }); } else { - console.log("微信 - 登录失败", res.errMsg); + logger.log("微信 - 登录失败", res.errMsg); cb && cb({ platform: 1, code: null }); } }, fail(res: any) { - console.log(`微信 login 调用失败`); - console.log(res.anonymousCode); + logger.log(`微信 login 调用失败`); + logger.log(res.anonymousCode); cb && cb({ platform: 1, code: null }); }, }); @@ -152,7 +153,7 @@ export class luffaSDK { //初始化视频广告 private init_video() { if ((wx_video_ad_unit_id as any) == "test") { - console.log("微信 激励广告id未配置,跳过此类型初始化"); + logger.log("微信 激励广告id未配置,跳过此类型初始化"); return; } @@ -161,13 +162,13 @@ export class luffaSDK { disableFallbackSharePage: true, // 是否禁用分享页,默认为false }); this.wx_video.onLoad(() => { - console.log("onLoad event emit"); + logger.log("onLoad event emit"); }); this.wx_video.onError((err) => { - console.log("onError event emit", err); + logger.log("onError event emit", err); }); this.wx_video.onClose((res) => { - console.log("onClose event emit", res); + logger.log("onClose event emit", res); // 用户点击了【关闭广告】按钮 // 小于 2.1.0 的基础库版本,res 是一个 undefined if ((res && res.isEnded) || res === undefined) { @@ -186,7 +187,7 @@ export class luffaSDK { //初始化插屏广告 private init_splash() { if ((wx_splash_ad_unit_id as any) == "test") { - console.log("微信 插屏广告id未配置,跳过此类型初始化"); + logger.log("微信 插屏广告id未配置,跳过此类型初始化"); return; } // 创建插屏广告实例,提前初始化 @@ -195,13 +196,13 @@ export class luffaSDK { adUnitId: wx_splash_ad_unit_id, }); this.wx_splash.onLoad(() => { - console.log("splash onLoad event emit"); + logger.log("splash onLoad event emit"); }); this.wx_splash.onError((err) => { - console.log("splash onError event emit", err); + logger.log("splash onError event emit", err); }); this.wx_splash.onClose((res) => { - console.log("splash onClose event emit", res); + logger.log("splash onClose event emit", res); }); } } @@ -209,7 +210,7 @@ export class luffaSDK { //初始化Banner private init_banner() { if ((wx_banner_ad_unit_id as any) == "test") { - console.log("微信 横幅广告id未配置,跳过此类型初始化"); + logger.log("微信 横幅广告id未配置,跳过此类型初始化"); return; } let winSize = window["wx"].getSystemInfoSync(); @@ -237,7 +238,7 @@ export class luffaSDK { //显示视频广告 show_video(callback: Function, tag: number) { if ((wx_video_ad_unit_id as any) == "test") { - console.log("未接入广告ID,视频广告请求直接返回"); + logger.log("未接入广告ID,视频广告请求直接返回"); callback && callback(); SDKManager.video_ad_back(); return; @@ -271,7 +272,7 @@ export class luffaSDK { this.wx_splash.show(); }) .catch((err) => { - console.log(err); + logger.log(err); }); } } @@ -385,7 +386,7 @@ export class luffaSDK { let picmap = this.SharePicAry[rand1]; let rand2 = Utils.getRandomInt(0, this.ShareTextAry.length - 1); let text = this.ShareTextAry[rand2]; - console.log("分享:", rand1, rand2); + logger.log("分享:", rand1, rand2); return { title: text, query: "ShareCode=" + "user_default", //ModelPlayer.I.getPlayerId(), @@ -395,7 +396,7 @@ export class luffaSDK { } //主动拉起分享 show_share(rewardCB?: Function) { - console.log("主动拉起分享"); + logger.log("主动拉起分享"); let info: any = this.shareInfo(); info.succ = rewardCB; info.fail = null; @@ -411,7 +412,7 @@ export class luffaSDK { //显示游戏圈 show_gameClub(leftRatio, topRatio, widthRatio, heightRatio) { - console.log("显示游戏圈"); + logger.log("显示游戏圈"); if (this.wx_gameClub) { this.wx_gameClub.show(); } else { @@ -421,7 +422,7 @@ export class luffaSDK { let w = windowinfo.screenWidth * widthRatio; //按钮宽高 let h = windowinfo.screenHeight * heightRatio; - console.log( + logger.log( "游戏圈按钮配置:", windowinfo, leftRatio, @@ -449,7 +450,7 @@ export class luffaSDK { } //隐藏游戏圈 hide_gameClub() { - console.log("隐藏游戏圈"); + logger.log("隐藏游戏圈"); if (this.wx_gameClub) { this.wx_gameClub.hide(); } @@ -465,7 +466,7 @@ export class luffaSDK { private _iacIdx = 0; //音频播放索引 playBase64Audio(base64, loop) { if (!this.checkSupportBase64Audio()) { - console.log("微信平台不支持base64音频播放"); + logger.log("微信平台不支持base64音频播放"); return; } @@ -480,24 +481,24 @@ export class luffaSDK { //1.删除上一个音频 const lastPath = window["wx"].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["wx"].env.USER_DATA_PATH + `/ordernew${self._iacIdx}.mp3`; - console.log("微信 正在保存本次音频 ->", audioPath); + logger.log("微信 正在保存本次音频 ->", audioPath); fs.writeFile({ filePath: audioPath, data: substring, @@ -507,18 +508,18 @@ export class luffaSDK { self._innerAudioContext = window["wx"].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); }, }); }, @@ -533,7 +534,7 @@ export class luffaSDK { //监听向微信后台请求检查更新结果事件。微信在小程序每次启动(包括热启动)时自动检查更新,不需由开发者主动触发。 updateManager.onCheckForUpdate((res) => { // 请求完新版本信息的回调 - console.log("微信 检查是否有新版本:", res.hasUpdate); + logger.log("微信 检查是否有新版本:", res.hasUpdate); }); //监听小程序有版本更新事件。客户端主动触发下载(无需开发者触发),下载成功后回调 @@ -552,7 +553,7 @@ export class luffaSDK { //监听小程序更新失败事件。小程序有新版本,客户端主动触发下载(无需开发者触发),下载失败(可能是网络原因等)时回调 updateManager.onUpdateFailed(function (err) { - console.log("微信 新版本下载失败", err); + logger.log("微信 新版本下载失败", err); }); } @@ -561,7 +562,7 @@ export class luffaSDK { if (window["wx"].openCustomerServiceConversation) { return true; } - console.log("微信 不支持联系客服"); + logger.log("微信 不支持联系客服"); return false; } //进入联系客服 @@ -574,10 +575,10 @@ export class luffaSDK { wx.openCustomerServiceConversation({ success: (res) => { const { path, query } = res; - console.log("微信 进入客服成功", path, query); + logger.log("微信 进入客服成功", path, query); }, fail: (res) => { - console.log("微信 进入客服失败", res); + logger.log("微信 进入客服失败", res); }, }); } @@ -598,18 +599,18 @@ export class luffaSDK { return; } let self = this; - console.log("微信 播放背景视频组件1", remoteUrl); + logger.log("微信 播放背景视频组件1", remoteUrl); this.curPlayType = vtype; if (!this._bgVideo) { this._bgVideo = this.createVideoHandle(); // this._bgVideo.onPlay(() => { - // console.log("微信 背景视频播放开始"); + // logger.log("微信 背景视频播放开始"); // }) this._bgVideo.onTimeUpdate((_tinfo: any) => { - // console.log("微信 背景视频播放进度", self._bgShow, _tinfo); + // logger.log("微信 背景视频播放进度", self._bgShow, _tinfo); if (!self._bgShow) { if (_tinfo && _tinfo.position > 0.01) { - console.log("微信 背景视频1进入视野"); + logger.log("微信 背景视频1进入视野"); self.videoMoveIn(self._bgVideo); self._bgShow = true; self.removeBgAudioNext(); @@ -645,19 +646,19 @@ export class luffaSDK { extra: any = {} ) { this.removeBgAudioNext(); - console.log("微信 创建背景视频组件2--->", remoteUrl); + logger.log("微信 创建背景视频组件2--->", remoteUrl); this.curPlayType = vtype; let self = this; if (!this._bgTempVideo) { this._bgTempVideo = this.createVideoHandle(); // this._bgTempVideo.onPlay(() => { - // console.log("微信 临时背景视频播放开始"); + // logger.log("微信 临时背景视频播放开始"); // }) this._bgTempVideo.onTimeUpdate((_tinfo: any) => { - // console.log("微信 临时背景视频播放进度", self._bgTempShow, _tinfo); + // logger.log("微信 临时背景视频播放进度", self._bgTempShow, _tinfo); if (!self._bgTempShow) { if (_tinfo && _tinfo.position > 0.01) { - console.log("微信 背景视频2进入视野"); + logger.log("微信 背景视频2进入视野"); self._bgTempShow = true; self.videoMoveIn(self._bgTempVideo); self.removeBgAudio(); @@ -698,18 +699,18 @@ export class luffaSDK { return; } let self = this; - console.log("微信 播放emo视频1", remoteUrl); + logger.log("微信 播放emo视频1", remoteUrl); this.curPlayType = vtype; if (!this._emoVideo) { this._emoVideo = this.createVideoHandle(); // this._emoVideo.onPlay(() => { - // console.log("微信 背景视频播放开始"); + // logger.log("微信 背景视频播放开始"); // }) this._emoVideo.onTimeUpdate((_tinfo: any) => { - // console.log("微信 背景视频播放进度", self._emoShow, _tinfo); + // logger.log("微信 背景视频播放进度", self._emoShow, _tinfo); if (!self._emoShow) { if (_tinfo && _tinfo.position > 0.01) { - console.log("微信 emo视频1准备好了"); + logger.log("微信 emo视频1准备好了"); self._emoShow = true; self.removeEmoAudioNext(); self.setEmoReadyAudio(self._emoVideo); @@ -744,19 +745,19 @@ export class luffaSDK { extra: any = {} ) { this.removeEmoAudioNext(); - console.log("微信 播放emo视频2--->", remoteUrl); + logger.log("微信 播放emo视频2--->", remoteUrl); this.curPlayType = vtype; let self = this; if (!this._emoTempVideo) { this._emoTempVideo = this.createVideoHandle(); // this._emoTempVideo.onPlay(() => { - // console.log("微信 临时背景视频播放开始"); + // logger.log("微信 临时背景视频播放开始"); // }) this._emoTempVideo.onTimeUpdate((_tinfo: any) => { - // console.log("微信 临时背景视频播放进度", self._emoTempShow, _tinfo); + // logger.log("微信 临时背景视频播放进度", self._emoTempShow, _tinfo); if (!self._emoTempShow) { if (_tinfo && _tinfo.position > 0.01) { - console.log("微信 emo视频2已准备好"); + logger.log("微信 emo视频2已准备好"); self._emoTempShow = true; self.removeEmoAudio(); self.setEmoReadyAudio(self._emoTempVideo); @@ -839,19 +840,19 @@ export class luffaSDK { this.videoAdaInfo.x = -(this.videoWidth * ratioh - size.width) / 2; this.videoAdaInfo.y = 0; } - console.log("微信 视频适配信息", this.videoAdaInfo, size); + logger.log("微信 视频适配信息", this.videoAdaInfo, size); return this.videoAdaInfo; } //设置暂停播放的主视频 private vpWait: any = null; setBgAudioPause(wait: any) { - console.log("微信 主视频暂停播放"); + logger.log("微信 主视频暂停播放"); this.vpWait = wait; this.vpWait.pause(); } replayBgAudioPause() { - console.log("微信 主视频继续播放"); + logger.log("微信 主视频继续播放"); if (this.vpWait) { this.vpWait.play(); } @@ -860,7 +861,7 @@ export class luffaSDK { //设置准备好要播放的表情视频 private emoReady: any = null; setEmoReadyAudio(au: any) { - console.log("微信 设置emo ready视频"); + logger.log("微信 设置emo ready视频"); if (this.emoReady) { this.emoReady.stop(); this.videoMoveOut(this.emoReady); @@ -870,7 +871,7 @@ export class luffaSDK { } //移除准备好要播放的表情视频 removeEmoReadyAudio() { - console.log("微信 移除emo ready视频"); + logger.log("微信 移除emo ready视频"); if (this.emoReady) { this.emoReady.stop(); this.videoMoveOut(this.emoReady); @@ -880,7 +881,7 @@ export class luffaSDK { //播放准备好要播放的表情视频 doPlayEmoReadyAudio(): boolean { if (this.emoReady) { - console.log("微信 播放emo ready视频"); + logger.log("微信 播放emo ready视频"); this.emoReady.play(); this.videoMoveIn(this.emoReady); return true; @@ -889,7 +890,7 @@ export class luffaSDK { } //表情视频播放结束 doEmoFinish() { - console.log("微信emo ready视频播放结束"); + logger.log("微信emo ready视频播放结束"); this.removeEmoReadyAudio(); this.replayBgAudioPause(); } @@ -897,44 +898,44 @@ export class luffaSDK { //region 微信同声传译 // private rrmgr: any = null; // startRecordRecognition() { - // console.log("微信 同声传译111") + // logger.log("微信 同声传译111") // if (!this.rrmgr) { // const plugin = requirePlugin("WechatSI"); // this.rrmgr = plugin.getRecordRecognitionManager(); - // console.log("微信 同声传译222") + // logger.log("微信 同声传译222") // // 监听识别结果 // this.rrmgr.onRecognize = (res) => { - // console.log("微信 同声传译识别结果:", res.result); + // logger.log("微信 同声传译识别结果:", res.result); // }; // // 监听录音结束 // this.rrmgr.onStop = (res) => { - // console.log("微信 同声传译录音结束", res); + // logger.log("微信 同声传译录音结束", res); // }; // } // this.rrmgr.start({ lang: "zh_CN" }); - // console.log("微信 同声传译333") + // logger.log("微信 同声传译333") // } // stopRecordRecognition() { // if (this.rrmgr) { // this.rrmgr.stop(); - // console.log("微信 同声传译444") + // logger.log("微信 同声传译444") // } // } //region 复制到剪贴板 /**复制文本到剪贴板 */ copyToClipboard(text: string, cb?: Function) { - console.log("微信 复制到剪贴板:", text); + logger.log("微信 复制到剪贴板:", text); window["wx"].setClipboardData({ data: text, success: () => { - console.log("微信 复制成功"); + logger.log("微信 复制成功"); cb && cb(true); }, fail: (err) => { - console.log("微信 复制失败:", err); + logger.log("微信 复制失败:", err); cb && cb(false); }, }); @@ -950,7 +951,7 @@ export class luffaSDK { // debug: true, // uploadUserInfo: true, // 上传用户信息,上传后可以看到有用户头像和昵称的分享信息 // }); - // console.log("微信 uma 初始化"); + // logger.log("微信 uma 初始化"); } //友盟统计是否开启 umaSwt() { @@ -959,6 +960,6 @@ export class luffaSDK { //友盟事件统计 umaEvent(eventName: string, value: any = {}) { window["wx"].uma.trackEvent(eventName, value); - console.log("微信 uma 统计:", eventName, value); + logger.log("微信 uma 统计:", eventName, value); } } diff --git a/assets/Scripts/Main/Channel/webSDK.ts b/assets/Scripts/Main/Channel/webSDK.ts index d1620f9d..6b77ff67 100644 --- a/assets/Scripts/Main/Channel/webSDK.ts +++ b/assets/Scripts/Main/Channel/webSDK.ts @@ -6,11 +6,12 @@ import { BgVideo } from "./BgVideo"; import Utils from "../Common/Utils"; import { InnerMsgCode } from "../Config/InnerMsgCode"; import { VideoRoleType } from "../Common/GlobalValue"; +import { logger } from "db://assets/Scripts/Main/Common/Logger"; export class WebSDK { //初始化 init(cb: Function = null) { - console.log("init webSDK"); + logger.log("init webSDK"); cb && cb(); } @@ -92,7 +93,7 @@ export class WebSDK { // 创建音频 URL const audioUrl = URL.createObjectURL(audioBlob); - console.log("web 播放base64音频", audioUrl); + logger.log("web 播放base64音频", audioUrl); // 创建音频元素并播放 if (this._audioInst == null) { this._audioInst = new Audio(audioUrl); @@ -104,12 +105,12 @@ export class WebSDK { //客服功能是否支持 kefuSupport() { - console.log("web 不支持联系客服"); + logger.log("web 不支持联系客服"); return false; } //进入联系客服 openKefu() { - console.log("web 进入联系客服"); + logger.log("web 进入联系客服"); } //region 播放主背景视频 @@ -147,7 +148,7 @@ export class WebSDK { return; } - console.log("web 初始化主背景视频"); + logger.log("web 初始化主背景视频"); if (!this.zhuVideo1) { this.zhuVideo1 = bgvideo.getVideoClone(); this.zhuVideo1.remoteUrl = @@ -323,18 +324,18 @@ export class WebSDK { //region 复制到剪贴板 /**复制文本到剪贴板 */ copyToClipboard(text: string, cb?: Function) { - console.log("web 复制到剪贴板:", text); + logger.log("web 复制到剪贴板:", text); if (navigator.clipboard && window.isSecureContext) { // 使用现代的 Clipboard API navigator.clipboard .writeText(text) .then(() => { - console.log("web 复制成功 (Clipboard API)"); + logger.log("web 复制成功 (Clipboard API)"); cb && cb(true); }) .catch((err) => { - console.log("web 复制失败 (Clipboard API):", err); + logger.log("web 复制失败 (Clipboard API):", err); this.fallbackCopyToClipboard(text, cb); }); } else { @@ -361,14 +362,14 @@ export class WebSDK { try { const successful = document.execCommand("copy"); if (successful) { - console.log("web 复制成功 (fallback)"); + logger.log("web 复制成功 (fallback)"); cb && cb(true); } else { - console.log("web 复制失败 (fallback)"); + logger.log("web 复制失败 (fallback)"); cb && cb(false); } } catch (err) { - console.log("web 复制异常 (fallback):", err); + logger.log("web 复制异常 (fallback):", err); cb && cb(false); } diff --git a/assets/Scripts/Main/Channel/wxSDK.ts b/assets/Scripts/Main/Channel/wxSDK.ts index 79aadd3b..cc3a3281 100644 --- a/assets/Scripts/Main/Channel/wxSDK.ts +++ b/assets/Scripts/Main/Channel/wxSDK.ts @@ -5,6 +5,7 @@ import { I_SDK_UserInfo_Callback, SDKManager } from "./SDKManager"; import Utils from "../Common/Utils"; import uma from "../../../utils/uma.wx.min.js"; import { InnerMsgCode } from "../Config/InnerMsgCode"; +import { logger } from "db://assets/Scripts/Main/Common/Logger"; //广告ID const wx_banner_ad_unit_id = "test"; @@ -35,7 +36,7 @@ export class WXSDK { // 保持屏幕常亮 window["wx"].setKeepScreenOn({ keepScreenOn: true }); WXSDK.g_InGameScene = window["wx"].getLaunchOptionsSync().scene; - console.log("init 微信 - 进入游戏的场景值", WXSDK.g_InGameScene); + logger.log("init 微信 - 进入游戏的场景值", WXSDK.g_InGameScene); //显示分享按钮 window["wx"].showShareMenu({ @@ -55,7 +56,7 @@ export class WXSDK { window["wx"].onHide(() => { if (this.ShareCb) { this.ShareSTime = new Date().getTime(); - console.log("分享时间差 记录:", this.ShareSTime); + logger.log("分享时间差 记录:", this.ShareSTime); } }); @@ -68,7 +69,7 @@ export class WXSDK { //小游戏回到前台 onWxShow(data: any) { - console.log("onWxShow:" + JSON.stringify(data)); + logger.log("onWxShow:" + JSON.stringify(data)); //返回小游戏场景值 if (data && data.query && data.query.ShareCode) { GlobalValue.ShareTocusid = data.query.ShareCode; @@ -77,7 +78,7 @@ export class WXSDK { 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(); @@ -104,7 +105,7 @@ export class WXSDK { checkAutoSetting(autoKey: string, cb: Function = null) { window["wx"].getSetting({ success(res: any) { - console.log("微信 - 检测权限状态 succ:", JSON.stringify(res)); + logger.log("微信 - 检测权限状态 succ:", JSON.stringify(res)); if (autoKey == "userInfo" && res.authSetting["scope.userInfo"]) { cb && cb(true); } else { @@ -112,7 +113,7 @@ export class WXSDK { } }, fail(res: any) { - console.log("微信 - 检测权限状态 fail:", JSON.stringify(res)); + logger.log("微信 - 检测权限状态 fail:", JSON.stringify(res)); cb && cb(false); }, }); @@ -122,11 +123,11 @@ export class WXSDK { * 获取个人信息 */ getUserInfo(cb: I_SDK_UserInfo_Callback = null) { - console.log("微信 - 正在获取用户信息..."); + logger.log("微信 - 正在获取用户信息..."); var self = this; window["wx"].getUserInfo({ success: (res) => { - console.log("微信 - 获取用户信息成功:", res); + logger.log("微信 - 获取用户信息成功:", res); cb && cb({ avatarUrl: res.userInfo.avatarUrl, @@ -134,7 +135,7 @@ export class WXSDK { }); }, fail: (err) => { - console.log("微信 - 获取用户信息失败:", err); + logger.log("微信 - 获取用户信息失败:", err); self.openUserAuthorize(cb); }, }); @@ -145,7 +146,7 @@ export class WXSDK { window["wx"].getSetting({ scope: "scope.userInfo", success(res: any) { - console.log("微信 authorize succ:", JSON.stringify(res)); + logger.log("微信 authorize succ:", JSON.stringify(res)); if (res.authSetting["scope.userInfo"]) { self.getUserInfo(cb); @@ -164,21 +165,21 @@ export class WXSDK { textAlign: "center", }, }); - console.log("微信 点击开始游戏授权用户信息"); + logger.log("微信 点击开始游戏授权用户信息"); button.onTap((res) => { button.destroy(); // if (res.userInfo) { - // console.log(res.userInfo) + // logger.log(res.userInfo) // //此时可进行登录操作 // cb && cb(res.userInfo) // } - console.log("微信 点击Tap", res); + logger.log("微信 点击Tap", res); self.getUserInfo(cb); }); } }, fail(err) { - console.log("微信 - authorize fail", err); + logger.log("微信 - authorize fail", err); }, }); } @@ -188,16 +189,16 @@ export class WXSDK { window["wx"].login({ success: (res) => { if (res.code) { - console.log("微信 - 登录成功", res.code); + logger.log("微信 - 登录成功", res.code); cb && cb({ platform: 1, code: res.code }); } else { - console.log("微信 - 登录失败", res.errMsg); + logger.log("微信 - 登录失败", res.errMsg); cb && cb({ platform: 1, code: null }); } }, fail(res: any) { - console.log(`微信 login 调用失败`); - console.log(res.anonymousCode); + logger.log(`微信 login 调用失败`); + logger.log(res.anonymousCode); cb && cb({ platform: 1, code: null }); }, }); @@ -206,7 +207,7 @@ export class WXSDK { //初始化视频广告 private init_video() { if ((wx_video_ad_unit_id as any) == "test") { - console.log("微信 激励广告id未配置,跳过此类型初始化"); + logger.log("微信 激励广告id未配置,跳过此类型初始化"); return; } @@ -215,13 +216,13 @@ export class WXSDK { disableFallbackSharePage: true, // 是否禁用分享页,默认为false }); this.wx_video.onLoad(() => { - console.log("onLoad event emit"); + logger.log("onLoad event emit"); }); this.wx_video.onError((err) => { - console.log("onError event emit", err); + logger.log("onError event emit", err); }); this.wx_video.onClose((res) => { - console.log("onClose event emit", res); + logger.log("onClose event emit", res); // 用户点击了【关闭广告】按钮 // 小于 2.1.0 的基础库版本,res 是一个 undefined if ((res && res.isEnded) || res === undefined) { @@ -240,7 +241,7 @@ export class WXSDK { //初始化插屏广告 private init_splash() { if ((wx_splash_ad_unit_id as any) == "test") { - console.log("微信 插屏广告id未配置,跳过此类型初始化"); + logger.log("微信 插屏广告id未配置,跳过此类型初始化"); return; } // 创建插屏广告实例,提前初始化 @@ -249,13 +250,13 @@ export class WXSDK { adUnitId: wx_splash_ad_unit_id, }); this.wx_splash.onLoad(() => { - console.log("splash onLoad event emit"); + logger.log("splash onLoad event emit"); }); this.wx_splash.onError((err) => { - console.log("splash onError event emit", err); + logger.log("splash onError event emit", err); }); this.wx_splash.onClose((res) => { - console.log("splash onClose event emit", res); + logger.log("splash onClose event emit", res); }); } } @@ -263,7 +264,7 @@ export class WXSDK { //初始化Banner private init_banner() { if ((wx_banner_ad_unit_id as any) == "test") { - console.log("微信 横幅广告id未配置,跳过此类型初始化"); + logger.log("微信 横幅广告id未配置,跳过此类型初始化"); return; } let winSize = window["wx"].getSystemInfoSync(); @@ -291,7 +292,7 @@ export class WXSDK { //显示视频广告 show_video(callback: Function, tag: number) { if ((wx_video_ad_unit_id as any) == "test") { - console.log("未接入广告ID,视频广告请求直接返回"); + logger.log("未接入广告ID,视频广告请求直接返回"); callback && callback(); SDKManager.video_ad_back(); return; @@ -325,7 +326,7 @@ export class WXSDK { this.wx_splash.show(); }) .catch((err) => { - console.log(err); + logger.log(err); }); } } @@ -439,7 +440,7 @@ export class WXSDK { let picmap = this.SharePicAry[rand1]; let rand2 = Utils.getRandomInt(0, this.ShareTextAry.length - 1); let text = this.ShareTextAry[rand2]; - console.log("分享:", rand1, rand2); + logger.log("分享:", rand1, rand2); return { title: text, query: "ShareCode=" + "user_default", //ModelPlayer.I.getPlayerId(), @@ -449,7 +450,7 @@ export class WXSDK { } //主动拉起分享 show_share(rewardCB?: Function) { - console.log("主动拉起分享"); + logger.log("主动拉起分享"); let info: any = this.shareInfo(); info.succ = rewardCB; info.fail = null; @@ -465,7 +466,7 @@ export class WXSDK { //显示游戏圈 show_gameClub(leftRatio, topRatio, widthRatio, heightRatio) { - console.log("显示游戏圈"); + logger.log("显示游戏圈"); if (this.wx_gameClub) { this.wx_gameClub.show(); } else { @@ -475,7 +476,7 @@ export class WXSDK { let w = windowinfo.screenWidth * widthRatio; //按钮宽高 let h = windowinfo.screenHeight * heightRatio; - console.log( + logger.log( "游戏圈按钮配置:", windowinfo, leftRatio, @@ -503,7 +504,7 @@ export class WXSDK { } //隐藏游戏圈 hide_gameClub() { - console.log("隐藏游戏圈"); + logger.log("隐藏游戏圈"); if (this.wx_gameClub) { this.wx_gameClub.hide(); } @@ -519,7 +520,7 @@ export class WXSDK { private _iacIdx = 0; //音频播放索引 playBase64Audio(base64, loop) { if (!this.checkSupportBase64Audio()) { - console.log("微信平台不支持base64音频播放"); + logger.log("微信平台不支持base64音频播放"); return; } @@ -534,24 +535,24 @@ export class WXSDK { //1.删除上一个音频 const lastPath = window["wx"].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["wx"].env.USER_DATA_PATH + `/ordernew${self._iacIdx}.mp3`; - console.log("微信 正在保存本次音频 ->", audioPath); + logger.log("微信 正在保存本次音频 ->", audioPath); fs.writeFile({ filePath: audioPath, data: substring, @@ -561,18 +562,18 @@ export class WXSDK { self._innerAudioContext = window["wx"].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); }, }); }, @@ -587,7 +588,7 @@ export class WXSDK { //监听向微信后台请求检查更新结果事件。微信在小程序每次启动(包括热启动)时自动检查更新,不需由开发者主动触发。 updateManager.onCheckForUpdate((res) => { // 请求完新版本信息的回调 - console.log("微信 检查是否有新版本:", res.hasUpdate); + logger.log("微信 检查是否有新版本:", res.hasUpdate); }); //监听小程序有版本更新事件。客户端主动触发下载(无需开发者触发),下载成功后回调 @@ -606,7 +607,7 @@ export class WXSDK { //监听小程序更新失败事件。小程序有新版本,客户端主动触发下载(无需开发者触发),下载失败(可能是网络原因等)时回调 updateManager.onUpdateFailed(function (err) { - console.log("微信 新版本下载失败", err); + logger.log("微信 新版本下载失败", err); }); } @@ -615,7 +616,7 @@ export class WXSDK { if (window["wx"].openCustomerServiceConversation) { return true; } - console.log("微信 不支持联系客服"); + logger.log("微信 不支持联系客服"); return false; } //进入联系客服 @@ -628,10 +629,10 @@ export class WXSDK { wx.openCustomerServiceConversation({ success: (res) => { const { path, query } = res; - console.log("微信 进入客服成功", path, query); + logger.log("微信 进入客服成功", path, query); }, fail: (res) => { - console.log("微信 进入客服失败", res); + logger.log("微信 进入客服失败", res); }, }); } @@ -651,18 +652,18 @@ export class WXSDK { return; } let self = this; - console.log("微信 播放背景视频组件1", remoteUrl); + logger.log("微信 播放背景视频组件1", remoteUrl); //this.curPlayType = vtype; if (!this._bgVideo) { this._bgVideo = this.createVideoHandle(); // this._bgVideo.onPlay(() => { - // console.log("微信 背景视频播放开始"); + // logger.log("微信 背景视频播放开始"); // }) this._bgVideo.onTimeUpdate((_tinfo: any) => { - // console.log("微信 背景视频播放进度", self._bgShow, _tinfo); + // logger.log("微信 背景视频播放进度", self._bgShow, _tinfo); if (!self._bgShow) { if (_tinfo && _tinfo.position > 0.01) { - console.log("微信 背景视频1进入视野"); + logger.log("微信 背景视频1进入视野"); self.videoMoveIn(self._bgVideo); self._bgShow = true; self.removeBgAudioNext(); @@ -697,18 +698,18 @@ export class WXSDK { extra: any = {} ) { this.removeBgAudioNext(); - console.log("微信 创建背景视频组件2--->", remoteUrl); + logger.log("微信 创建背景视频组件2--->", remoteUrl); let self = this; if (!this._bgTempVideo) { this._bgTempVideo = this.createVideoHandle(); // this._bgTempVideo.onPlay(() => { - // console.log("微信 临时背景视频播放开始"); + // logger.log("微信 临时背景视频播放开始"); // }) this._bgTempVideo.onTimeUpdate((_tinfo: any) => { - // console.log("微信 临时背景视频播放进度", self._bgTempShow, _tinfo); + // logger.log("微信 临时背景视频播放进度", self._bgTempShow, _tinfo); if (!self._bgTempShow) { if (_tinfo && _tinfo.position > 0.01) { - console.log("微信 背景视频2进入视野"); + logger.log("微信 背景视频2进入视野"); self._bgTempShow = true; self.videoMoveIn(self._bgTempVideo); self.removeBgAudio(); @@ -749,18 +750,18 @@ export class WXSDK { return; } let self = this; - console.log("微信 播放emo视频1", remoteUrl); + logger.log("微信 播放emo视频1", remoteUrl); this.curPlayType = vtype; if (!this._emoVideo) { this._emoVideo = this.createVideoHandle(); // this._emoVideo.onPlay(() => { - // console.log("微信 背景视频播放开始"); + // logger.log("微信 背景视频播放开始"); // }) this._emoVideo.onTimeUpdate((_tinfo: any) => { - // console.log("微信 背景视频播放进度", self._emoShow, _tinfo); + // logger.log("微信 背景视频播放进度", self._emoShow, _tinfo); if (!self._emoShow) { if (_tinfo && _tinfo.position > 0.01) { - console.log("微信 emo视频1准备好了"); + logger.log("微信 emo视频1准备好了"); self._emoShow = true; self.removeEmoAudioNext(); self.setEmoReadyAudio(self._emoVideo); @@ -795,19 +796,19 @@ export class WXSDK { extra: any = {} ) { this.removeEmoAudioNext(); - console.log("微信 播放emo视频2--->", remoteUrl); + logger.log("微信 播放emo视频2--->", remoteUrl); this.curPlayType = vtype; let self = this; if (!this._emoTempVideo) { this._emoTempVideo = this.createVideoHandle(); // this._emoTempVideo.onPlay(() => { - // console.log("微信 临时背景视频播放开始"); + // logger.log("微信 临时背景视频播放开始"); // }) this._emoTempVideo.onTimeUpdate((_tinfo: any) => { - // console.log("微信 临时背景视频播放进度", self._emoTempShow, _tinfo); + // logger.log("微信 临时背景视频播放进度", self._emoTempShow, _tinfo); if (!self._emoTempShow) { if (_tinfo && _tinfo.position > 0.01) { - console.log("微信 emo视频2已准备好"); + logger.log("微信 emo视频2已准备好"); self._emoTempShow = true; self.removeEmoAudio(); self.setEmoReadyAudio(self._emoTempVideo); @@ -890,19 +891,19 @@ export class WXSDK { this.videoAdaInfo.x = -(this.videoWidth * ratioh - size.width) / 2; this.videoAdaInfo.y = 0; } - console.log("微信 视频适配信息", this.videoAdaInfo, size); + logger.log("微信 视频适配信息", this.videoAdaInfo, size); return this.videoAdaInfo; } //设置暂停播放的主视频 private vpWait: any = null; setBgAudioPause(wait: any) { - console.log("微信 主视频暂停播放"); + logger.log("微信 主视频暂停播放"); this.vpWait = wait; this.vpWait.pause(); } replayBgAudioPause() { - console.log("微信 主视频继续播放"); + logger.log("微信 主视频继续播放"); if (this.vpWait) { this.vpWait.play(); } @@ -911,7 +912,7 @@ export class WXSDK { //设置准备好要播放的表情视频 private emoReady: any = null; setEmoReadyAudio(au: any) { - console.log("微信 设置emo ready视频"); + logger.log("微信 设置emo ready视频"); if (this.emoReady) { this.emoReady.stop(); this.videoMoveOut(this.emoReady); @@ -921,7 +922,7 @@ export class WXSDK { } //移除准备好要播放的表情视频 removeEmoReadyAudio() { - console.log("微信 移除emo ready视频"); + logger.log("微信 移除emo ready视频"); if (this.emoReady) { this.emoReady.stop(); this.videoMoveOut(this.emoReady); @@ -931,7 +932,7 @@ export class WXSDK { //播放准备好要播放的表情视频 doPlayEmoReadyAudio(): boolean { if (this.emoReady) { - console.log("微信 播放emo ready视频"); + logger.log("微信 播放emo ready视频"); this.emoReady.play(); this.videoMoveIn(this.emoReady); return true; @@ -940,7 +941,7 @@ export class WXSDK { } //表情视频播放结束 doEmoFinish() { - console.log("微信emo ready视频播放结束"); + logger.log("微信emo ready视频播放结束"); this.removeEmoReadyAudio(); this.replayBgAudioPause(); } @@ -948,44 +949,44 @@ export class WXSDK { //region 微信同声传译 // private rrmgr: any = null; // startRecordRecognition() { - // console.log("微信 同声传译111") + // logger.log("微信 同声传译111") // if (!this.rrmgr) { // const plugin = requirePlugin("WechatSI"); // this.rrmgr = plugin.getRecordRecognitionManager(); - // console.log("微信 同声传译222") + // logger.log("微信 同声传译222") // // 监听识别结果 // this.rrmgr.onRecognize = (res) => { - // console.log("微信 同声传译识别结果:", res.result); + // logger.log("微信 同声传译识别结果:", res.result); // }; // // 监听录音结束 // this.rrmgr.onStop = (res) => { - // console.log("微信 同声传译录音结束", res); + // logger.log("微信 同声传译录音结束", res); // }; // } // this.rrmgr.start({ lang: "zh_CN" }); - // console.log("微信 同声传译333") + // logger.log("微信 同声传译333") // } // stopRecordRecognition() { // if (this.rrmgr) { // this.rrmgr.stop(); - // console.log("微信 同声传译444") + // logger.log("微信 同声传译444") // } // } //region 复制到剪贴板 /**复制文本到剪贴板 */ copyToClipboard(text: string, cb?: Function) { - console.log("微信 复制到剪贴板:", text); + logger.log("微信 复制到剪贴板:", text); window["wx"].setClipboardData({ data: text, success: () => { - console.log("微信 复制成功"); + logger.log("微信 复制成功"); cb && cb(true); }, fail: (err) => { - console.log("微信 复制失败:", err); + logger.log("微信 复制失败:", err); cb && cb(false); }, }); @@ -1001,7 +1002,7 @@ export class WXSDK { debug: true, uploadUserInfo: true, // 上传用户信息,上传后可以看到有用户头像和昵称的分享信息 }); - console.log("微信 uma 初始化"); + logger.log("微信 uma 初始化"); } //友盟统计是否开启 umaSwt() { @@ -1010,6 +1011,6 @@ export class WXSDK { //友盟事件统计 umaEvent(eventName: string, value: any = {}) { window["wx"].uma.trackEvent(eventName, value); - console.log("微信 uma 统计:", eventName, value); + logger.log("微信 uma 统计:", eventName, value); } } diff --git a/assets/Scripts/Main/Common/Utils.ts b/assets/Scripts/Main/Common/Utils.ts index 588e3202..9374e480 100644 --- a/assets/Scripts/Main/Common/Utils.ts +++ b/assets/Scripts/Main/Common/Utils.ts @@ -13,6 +13,7 @@ import { } from "cc"; import li_EventManager from "./li_EventManager"; import LanguageUtils from "./LanguageUtils"; +import { logger } from "db://assets/Scripts/Main/Common/Logger"; const { ccclass, property } = _decorator; @@ -22,21 +23,21 @@ export default class Utils { public static Log(msg: string | any, ...subst: any[]) { let IsLocalCSChanel = true; if (IsLocalCSChanel) { - console.log(msg, subst); + logger.log(msg, subst); } } //警告日志 public static Warning(msg: string | any, ...subst: any[]) { let IsLocalCSChanel = true; if (IsLocalCSChanel) { - console.warn(msg, subst); + logger.warn(msg, subst); } } //错误日志 public static Error(msg: string | any, ...subst: any[]) { let IsLocalCSChanel = true; if (IsLocalCSChanel) { - console.error(msg, subst); + logger.error(msg, subst); } } @@ -258,7 +259,7 @@ export default class Utils { public static getScaleRatio(mod: number = 1) { let windowSize = view.getVisibleSize(); let designSize = view.getDesignResolutionSize(); - // console.log("游戏分辨率:", windowSize, designSize); + // logger.log("游戏分辨率:", windowSize, designSize); if (mod == 1) { return windowSize.height / designSize.height; } else { @@ -367,7 +368,7 @@ export default class Utils { public static ProfilerTimePrint(key: string = "") { let time = new Date().getTime(); let timecha = time - Utils._eplTime; - console.log(`${key}消耗时间:${timecha}毫秒`); + logger.log(`${key}消耗时间:${timecha}毫秒`); Utils._eplTime = time; } @@ -381,7 +382,7 @@ export default class Utils { const days = Math.floor(diffSeconds / (60 * 60 * 24)); const hours = Math.floor((diffSeconds % (60 * 60 * 24)) / 3600); const minutes = Math.floor((diffSeconds % 3600) / 60); - console.log( + logger.log( "vip失效剩余时间差(秒):", diffSeconds, "天:", diff --git a/assets/Scripts/Main/Manager/AudioManager.ts b/assets/Scripts/Main/Manager/AudioManager.ts index 03282ceb..df8935bb 100644 --- a/assets/Scripts/Main/Manager/AudioManager.ts +++ b/assets/Scripts/Main/Manager/AudioManager.ts @@ -2,6 +2,7 @@ import { _decorator, Node, AudioClip, AudioSource, director, assetManager } from import PlayerDataManager from "./PlayerDataManager"; import ResManager from "./ResManager"; import Resource from "../Config/Resource"; +import { logger } from "db://assets/Scripts/Main/Common/Logger"; const { ccclass, property } = _decorator; @@ -44,7 +45,7 @@ export default class AudioManager { if (!cfgs[sound]) return; let path = `Sound/${cfgs[sound].AssetName}` - console.log("PlayEffect:", sound, path) + logger.log("PlayEffect:", sound, path) ResManager.I.getBundleAudio(path, (res: AudioClip)=>{ this._audoSource.playOneShot(res, volume) }); @@ -68,7 +69,7 @@ export default class AudioManager { this.curBgId = sound; this.curBgId_confirm = sound; let path = `Music/${cfgs[sound].AssetName}` - console.log("PlayMusic:", sound, path) + logger.log("PlayMusic:", sound, path) ResManager.I.getBundleAudio(path, (res: AudioClip)=>{ this._audoSource.clip = res this._audoSource.play() @@ -80,13 +81,13 @@ export default class AudioManager { /**播放远程背景乐 */ PlayRemoteMusic(url, loop:boolean = true, volume:number=1.0) { - console.log(`下载远程背景乐: url= ${url}`) + logger.log(`下载远程背景乐: url= ${url}`) assetManager.loadRemote(url, { ext: '.mp3'}, (err, res: AudioClip) => { if (err) { - console.log(err); + logger.log(err); return } - console.log(`播放远程背景乐: res= ${res}`) + logger.log(`播放远程背景乐: res= ${res}`) this.StopMusic() this._audoSource.clip = res this._audoSource.play() diff --git a/assets/Scripts/Main/Manager/GameManager.ts b/assets/Scripts/Main/Manager/GameManager.ts index 67de025f..4cfb0b1f 100644 --- a/assets/Scripts/Main/Manager/GameManager.ts +++ b/assets/Scripts/Main/Manager/GameManager.ts @@ -7,6 +7,7 @@ import SubManager from "../../Sub/SubManager"; import HttpUnit from "../Common/HttpUnit"; import { SDKManager } from "../Channel/SDKManager"; import { VideoRoleType } from "../Common/GlobalValue"; +import { logger } from "db://assets/Scripts/Main/Common/Logger"; const { ccclass, property } = _decorator; @@ -68,7 +69,7 @@ export default class GameManager { let resData = JSON.parse(data.data) if (GameManager.curStage != E_TalkStage.waitNpcTalk) return if (resData.isFinished) { - console.log("npc回复:", resData) + logger.log("npc回复:", resData) GameManager.CurNpcTalkData = resData Utils.sendInnerMsg(InnerMsgCode.Data_NpcTalkBack, resData || {}) } @@ -122,7 +123,7 @@ export default class GameManager { if (umRecords.length > 0 && SDKManager.umaSwt()){ let umr = umRecords.join(',') HttpUnit.ins.sendLevelRecord({level_ids:umr}, (_data)=>{ - console.log('友盟记录关卡',_data) + logger.log('友盟记录关卡',_data) let userId = HttpUnit.GetID() let curDate = Utils.GetNowFormatDay() for (let i = 0; i < umRecords.length; i++) { @@ -513,7 +514,7 @@ export default class GameManager { } /**解锁一个私家珍藏id */ static UnlockZhencang(record_id:string, levelId: string) { - console.log("解锁私家珍藏:", record_id, levelId) + logger.log("解锁私家珍藏:", record_id, levelId) HttpUnit.ins.getZhencangList({limit:999, page:1, type:1}, (data) => { if (data){ this._doUnlockZhencang(data.data, record_id, levelId) @@ -559,7 +560,7 @@ export default class GameManager { let item = lockAry[randIdx] HttpUnit.ins.sendZhencangId({record_id:record_id, level_id:levelId, img:item.id}, (_data) => { if (_data) { - console.log("获得珍藏卡:", item) + logger.log("获得珍藏卡:", item) GameManager.refreshZhencangCanget() } }) diff --git a/assets/Scripts/Sub/UI/SceneBgVideoLayer.ts b/assets/Scripts/Sub/UI/SceneBgVideoLayer.ts index 4a96b003..0501fc0f 100644 --- a/assets/Scripts/Sub/UI/SceneBgVideoLayer.ts +++ b/assets/Scripts/Sub/UI/SceneBgVideoLayer.ts @@ -13,6 +13,8 @@ import li_BaseView from "../../Main/Common/li_BaseView"; import ResManager from "../../Main/Manager/ResManager"; import { DataManager, DataId } from "../../chat18x/data/DataManager"; import { EnvData } from "../../chat18x/data/EnvData"; +import { logger } from "db://assets/Scripts/Main/Common/Logger"; + const { ccclass, property } = _decorator; //场景背景层 - 视频模式 @@ -39,7 +41,7 @@ export class SceneBgVideoLayer extends li_BaseView { Utils.parseNode(this.node, this._nodeTab); this.videoPlayer = this._nodeTab.videoPlayer.getComponent(VideoPlayer); if (!this.videoPlayer) { - console.error("SceneBgVideoLayer: video节点未找到或没有VideoPlayer组件"); + logger.error("SceneBgVideoLayer: video节点未找到或没有VideoPlayer组件"); } this.initVideoEvents(); SceneBgVideoLayer.handle = this; @@ -129,13 +131,13 @@ export class SceneBgVideoLayer extends li_BaseView { const uiTransform = this.videoPlayer.node.getComponent(UITransform); if (uiTransform) { uiTransform.setAnchorPoint(0.5, 0.5); - console.log("SceneBgVideoLayer: 设置视频锚点为 (0.5, 0.5)"); + logger.log("SceneBgVideoLayer: 设置视频锚点为 (0.5, 0.5)"); } // 立即开始播放,尺寸和位置将在 READY_TO_PLAY 事件中设置 this.videoPlayer.play(); this.isPlaying = true; - console.log(`SceneBgVideoLayer: 开始加载视频 ${path}, 配置:`, config); + logger.log(`SceneBgVideoLayer: 开始加载视频 ${path}, 配置:`, config); } ); } @@ -146,7 +148,7 @@ export class SceneBgVideoLayer extends li_BaseView { pause() { if (this.videoPlayer && this.isPlaying) { this.videoPlayer.pause(); - console.log("SceneBgVideoLayer: 暂停视频"); + logger.log("SceneBgVideoLayer: 暂停视频"); } } @@ -156,7 +158,7 @@ export class SceneBgVideoLayer extends li_BaseView { resume() { if (this.videoPlayer && !this.videoPlayer.isPlaying) { this.videoPlayer.play(); - console.log("SceneBgVideoLayer: 继续播放视频"); + logger.log("SceneBgVideoLayer: 继续播放视频"); } } @@ -167,7 +169,7 @@ export class SceneBgVideoLayer extends li_BaseView { if (this.videoPlayer) { this.videoPlayer.stop(); this.clearVideoState(); - console.log("SceneBgVideoLayer: 停止视频"); + logger.log("SceneBgVideoLayer: 停止视频"); } } @@ -179,10 +181,10 @@ export class SceneBgVideoLayer extends li_BaseView { if (this.videoPlayer) { if (typeof scale === "number") { this.videoPlayer.node.setScale(new Vec3(scale, scale, 1)); - console.log(`SceneBgVideoLayer: 设置视频缩放 ${scale}`); + logger.log(`SceneBgVideoLayer: 设置视频缩放 ${scale}`); } else { this.videoPlayer.node.setScale(scale); - console.log( + logger.log( `SceneBgVideoLayer: 设置视频缩放 (${scale.x}, ${scale.y}, ${scale.z})` ); } @@ -209,7 +211,7 @@ export class SceneBgVideoLayer extends li_BaseView { size: targetSize, position: position, }; - console.log("SceneBgVideoLayer: 视频未准备好,配置已存储等待应用"); + logger.log("SceneBgVideoLayer: 视频未准备好,配置已存储等待应用"); } } @@ -248,7 +250,7 @@ export class SceneBgVideoLayer extends li_BaseView { targetWorldPos = new Vec3(pos.x, pos.y, pos.z || 0); } this.videoPlayer.node.setWorldPosition(targetWorldPos); - console.log( + logger.log( `SceneBgVideoLayer: 设置视频位置 (${targetWorldPos.x}, ${targetWorldPos.y}, ${targetWorldPos.z})` ); } @@ -270,34 +272,34 @@ export class SceneBgVideoLayer extends li_BaseView { const scale = Math.max(scaleX, scaleY); this.videoPlayer.node.setScale(new Vec3(scale, scale, 1)); - console.log( + logger.log( `SceneBgVideoLayer: 设置视频缩放 ${scale} (原始尺寸: ${videoSize.width}x${videoSize.height}, 目标尺寸: ${targetWidth}x${targetHeight})` ); } else { - console.warn("SceneBgVideoLayer: 无法获取视频尺寸,跳过缩放设置"); + logger.warn("SceneBgVideoLayer: 无法获取视频尺寸,跳过缩放设置"); } } else if (config.scale) { // 如果显式传入了 scale 参数,直接应用 if (typeof config.scale === "number") { this.videoPlayer.node.setScale(new Vec3(config.scale, config.scale, 1)); - console.log(`SceneBgVideoLayer: 设置显式缩放 ${config.scale}`); + logger.log(`SceneBgVideoLayer: 设置显式缩放 ${config.scale}`); } else { this.videoPlayer.node.setScale(config.scale); - console.log( + logger.log( `SceneBgVideoLayer: 设置显式缩放 (${config.scale.x}, ${config.scale.y}, ${config.scale.z})` ); } } else { // 没有指定尺寸或缩放,保持原始缩放 this.videoPlayer.node.setScale(Vec3.ONE); - console.log("SceneBgVideoLayer: 保持默认缩放 (1, 1, 1)"); + logger.log("SceneBgVideoLayer: 保持默认缩放 (1, 1, 1)"); } } //================== 事件回调 ================== private onVideoReadyToPlay = () => { - console.log("SceneBgVideoLayer: 视频准备完成"); + logger.log("SceneBgVideoLayer: 视频准备完成"); // 应用待处理的视频配置 if (this.pendingVideoConfig) { @@ -312,12 +314,12 @@ export class SceneBgVideoLayer extends li_BaseView { private onVideoEvent = (event: any, eventType: string) => { switch (eventType) { case "completed": - console.log("SceneBgVideoLayer: 视频播放完成"); + logger.log("SceneBgVideoLayer: 视频播放完成"); this.clearVideoState(); this.onVideoEnd(); break; case "error": - console.error("SceneBgVideoLayer: 视频播放错误"); + logger.error("SceneBgVideoLayer: 视频播放错误"); this.clearVideoState(); this.onVideoError(); break;