From 2cc2fd3cf355d0c50eabc2fe67e182db9ab4193f Mon Sep 17 00:00:00 2001 From: "COMPUTER\\EDY" <249929363@qq.com> Date: Fri, 10 Oct 2025 16:36:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=B0=E6=95=B0=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=20=E4=BB=A5=E5=8F=8A=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 37 ++- assets/Script/GameManager.ts | 281 ++++++++++----------- assets/Script/JiaZai.ts | 6 +- assets/Script/Map.ts | 19 +- assets/Script/Sdk/MiniGameSdk.ts | 44 ++-- assets/Script/module/Tool/GameTool.ts | 53 ++-- assets/action_bundle/script/DailyQuests.ts | 31 +-- assets/shop/script.meta | 13 - 8 files changed, 246 insertions(+), 238 deletions(-) delete mode 100644 assets/shop/script.meta diff --git a/.gitignore b/.gitignore index a8a0bf9..2f911f9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,39 @@ /packages/ /build-templates/ /build/ -/图片资源/ + +# Cocos Creator 资源元数据文件 +*.meta + +# 操作系统生成的文件 +.DS_Store +Thumbs.db + +# 日志文件 +*.log +logs/ + +# 运行时数据 +pids +*.pid +*.seed + +# 依赖目录 +node_modules/ + +# IDE 文件 +.vscode/ +.idea/ +*.swp +*.swo + +# 编译输出 +dist/ +bin/ +*.exe +*.dll +*.so +*.dylib + +# 其他资源目录(根据你的项目需要调整) +/图片资源/ \ No newline at end of file diff --git a/assets/Script/GameManager.ts b/assets/Script/GameManager.ts index 498f26c..8ee8faa 100644 --- a/assets/Script/GameManager.ts +++ b/assets/Script/GameManager.ts @@ -60,7 +60,6 @@ export default class GameManager extends cc.Component { this.getSetting(); this.readUserData(); this.getShareInfo(); - this.checkDailyQuests(); }, 100); @@ -86,10 +85,7 @@ export default class GameManager extends cc.Component { } } - checkDailyQuests() { - cc.fx.GameTool.getDailyQuestsInfo((data) => { - }) - } + start() { setTimeout(() => { @@ -180,156 +176,129 @@ export default class GameManager extends cc.Component { //#region 微信登录,以及读取用户信息 /** 微信登录,以及读取用户信息 */ readUserData(retryCount = 0) { - //@ts-ignore - if (typeof wx !== 'undefined' && wx !== null) { - MiniGameSdk.API.shushu_Init(); - this.nowTime = Date.now(); - // 最大重试次数 - const MAX_RETRIES = 30; - // 延迟时间数组,按照 1 秒 3 次、2 秒 5 次、5 秒 6 次、15 秒 5 次的规则生成 - const delays = [ - ...Array(3).fill(2000), - ...Array(5).fill(3000), - ...Array(6).fill(5000), - ...Array(5).fill(15000) - ]; - //cc.fx.GameConfig.GM_INFO.shushu_DistinctId - const attemptUserInfo = () => { - Utils.getUserInfo((data) => { - if (data.code == 1) { // 假设返回数据中有 success 字段表示成功 - console.log("登錄", data); - if (data.data.openid) { - cc.fx.GameConfig.GM_INFO.openid = data.data.openid; - cc.fx.StorageMessage.setStorage("openid", cc.fx.GameConfig.GM_INFO.openid); - } - if (data.data._id) { - cc.fx.GameConfig.GM_INFO.uid = data.data._id; - cc.fx.StorageMessage.setStorage("uid", data.data._id); - } - if (data.data.onlyId) { - cc.fx.GameConfig.GM_INFO.userId = data.data.onlyId; - } - if (data.data.outTradeNo.length > 0) { - cc.fx.GameConfig.GM_INFO.allOutTradeNo = []; - cc.fx.GameConfig.GM_INFO.allOutTradeNo = data.data.outTradeNo; - } - if (data.data.shareLv) { - if (data.data.shareLv.length > 0) { - cc.fx.GameConfig.GM_INFO.helpLevel = data.data.shareLv[0].lv; - } - } - if (data.data.username) { - cc.fx.GameConfig.GM_INFO.username = data.data.username; - } - if (data.data.useravatar) { - cc.fx.GameConfig.GM_INFO.useravatarIcon = data.data.useravatar; - if (cc.fx.GameConfig.GM_INFO.useravatarIcon.length < 10) - cc.fx.GameConfig.GM_INFO.useravatarIcon = "icon_" + cc.fx.GameConfig.GM_INFO.useravatarIcon - } - if (data.data.useravatarIcon) { - cc.fx.GameConfig.GM_INFO.useravaterkuang = data.data.useravatarIcon; - cc.fx.GameConfig.GM_INFO.useravaterkuang = "kuang_" + (parseInt(cc.fx.GameConfig.GM_INFO.useravaterkuang) + 1); - } - - if (data.data.task) { - let task = JSON.parse(data.data.task); - cc.fx.GameConfig.GM_INFO.tasks.levelPass = task["levelPass"]; - cc.fx.GameConfig.GM_INFO.tasks.share = task["share"]; - cc.fx.GameConfig.GM_INFO.tasks.useEnergy = task["useEnergy"]; - cc.fx.GameConfig.GM_INFO.tasks.useProp = task["useProp"]; - } - //如果有连胜记录,就赋值 - if (data.data.winStreak) { - console.log("从服务器得到连胜", data.data.winStreak); - cc.fx.GameConfig.GM_INFO.winStreak = parseInt(data.data.winStreak); - let winState = cc.fx.StorageMessage.getStorage("winState"); - console.log("本地连胜状态", winState); - if ((winState == null || winState == undefined) && winState != false) { - console.log("没有缓存进入这里"); - cc.fx.GameConfig.GM_INFO.winState = false; - if (cc.fx.GameConfig.GM_INFO.winStreak >= 10) { - cc.fx.GameConfig.GM_INFO.winState = true; - } - cc.fx.StorageMessage.setStorage("winState", cc.fx.GameConfig.GM_INFO.winState); - } - else { - cc.fx.GameConfig.GM_INFO.winState = winState; - console.log("连胜状态:", cc.fx.GameConfig.GM_INFO.winState); - if (winState == false) { - if (cc.fx.GameConfig.GM_INFO.winStreak >= 10) { - cc.fx.GameConfig.GM_INFO.winStreak = 0; - Utils.setWinStreak((data) => { - if (data.code == 1) { - console.log("连胜状态杀端清零成功"); - } - }) - } - } - } - cc.fx.StorageMessage.setStorage("winStreak", cc.fx.GameConfig.GM_INFO.winStreak); - } - else { - let winStreak = cc.fx.StorageMessage.getStorage("winStreak"); - if (winStreak == undefined || winStreak == "" || winStreak == null) { - cc.fx.GameConfig.GM_INFO.winStreak = 0; - cc.fx.StorageMessage.setStorage("winStreak", cc.fx.GameConfig.GM_INFO.winStreak); - } - else { - cc.fx.GameConfig.GM_INFO.winStreak = winStreak; - } - console.log("调用连胜上传"); - Utils.setWinStreak((data) => { - if (data.code == 1) { - console.log("设置连胜成功"); - } - }) - } - - this.setUserPower(data); - this.setmonth(data); - this.setRevive(data); - let levelInfo = cc.fx.StorageMessage.getStorage("level"); - //如果本地缓存没有关卡信息,默认为服务器信息为主 - if (levelInfo == undefined || levelInfo == "" || levelInfo == null) { - this.getUserDataToServer(data.data); - // this.oldReadData(retryCount); - } - //新的读取数据设置方法,以本地为主 - else { - this.getUserDataToLocal(data.data); - // this.newReadData(); - } - - cc.fx.GameTool.getHealth((data) => { - this.load5 = true; - }); - this.load6 = true; - } - else { - if (retryCount < MAX_RETRIES && retryCount < delays.length) { - const delay = delays[retryCount]; - console.error(`获取用户信息失败,第 ${retryCount + 1} 次重试,将在 ${delay / 1000} 秒后重试`); - setTimeout(() => { - retryCount++; - attemptUserInfo(); - }, delay); - } else { - console.error('获取用户信息失败,达到最大重试次数,退出游戏'); - // 退出游戏 - cc.game.end(); - } - } - }); - }; - attemptUserInfo(); + this.load3 = true; + this.load4 = true; + this.load5 = true; + this.load6 = true; + let levelInfo = cc.fx.StorageMessage.getStorage("level"); + //如果本地缓存没有关卡信息,默认为服务器信息为主 + if (levelInfo == undefined || levelInfo == "" || levelInfo == null) { + // this.getUserDataToServer(data.data); + const timestamp = Date.now(); + cc.fx.GameConfig.GM_INFO.level = 0; + let levelInfo = { "level": cc.fx.GameConfig.GM_INFO.level, "timestamp": timestamp }; + cc.fx.StorageMessage.setStorage("level", levelInfo); + cc.fx.GameConfig.GM_INFO.first = true; + // this.oldReadData(retryCount); } else { - this.load3 = true; - this.load4 = true; - this.load5 = true; - this.load6 = true; - cc.fx.GameTool.getHealth(null); + cc.fx.GameConfig.GM_INFO.level = levelInfo; } + cc.fx.GameTool.getHealth(null); + //@ts-ignore + // if (typeof wx !== 'undefined' && wx !== null) { + // MiniGameSdk.API.shushu_Init(); + // this.nowTime = Date.now(); + // // 最大重试次数 + // const MAX_RETRIES = 30; + // // 延迟时间数组,按照 1 秒 3 次、2 秒 5 次、5 秒 6 次、15 秒 5 次的规则生成 + // const delays = [ + // ...Array(3).fill(2000), + // ...Array(5).fill(3000), + // ...Array(6).fill(5000), + // ...Array(5).fill(15000) + // ]; + // //cc.fx.GameConfig.GM_INFO.shushu_DistinctId + // const attemptUserInfo = () => { + // Utils.getUserInfo((data) => { + // if (data.code == 1) { // 假设返回数据中有 success 字段表示成功 + // console.log("登錄", data); + // if (data.data.openid) { + // cc.fx.GameConfig.GM_INFO.openid = data.data.openid; + // cc.fx.StorageMessage.setStorage("openid", cc.fx.GameConfig.GM_INFO.openid); + // } + // if (data.data._id) { + // cc.fx.GameConfig.GM_INFO.uid = data.data._id; + // cc.fx.StorageMessage.setStorage("uid", data.data._id); + // } + // if (data.data.onlyId) { + // cc.fx.GameConfig.GM_INFO.userId = data.data.onlyId; + // } + // if (data.data.outTradeNo.length > 0) { + // cc.fx.GameConfig.GM_INFO.allOutTradeNo = []; + // cc.fx.GameConfig.GM_INFO.allOutTradeNo = data.data.outTradeNo; + // } + // if (data.data.shareLv) { + // if (data.data.shareLv.length > 0) { + // cc.fx.GameConfig.GM_INFO.helpLevel = data.data.shareLv[0].lv; + // } + // } + // if (data.data.username) { + // cc.fx.GameConfig.GM_INFO.username = data.data.username; + // } + // if (data.data.useravatar) { + // cc.fx.GameConfig.GM_INFO.useravatarIcon = data.data.useravatar; + // if (cc.fx.GameConfig.GM_INFO.useravatarIcon.length < 10) + // cc.fx.GameConfig.GM_INFO.useravatarIcon = "icon_" + cc.fx.GameConfig.GM_INFO.useravatarIcon + // } + // if (data.data.useravatarIcon) { + // cc.fx.GameConfig.GM_INFO.useravaterkuang = data.data.useravatarIcon; + // cc.fx.GameConfig.GM_INFO.useravaterkuang = "kuang_" + (parseInt(cc.fx.GameConfig.GM_INFO.useravaterkuang) + 1); + // } + + // if (data.data.task) { + // let task = JSON.parse(data.data.task); + // cc.fx.GameConfig.GM_INFO.tasks.levelPass = task["levelPass"]; + // cc.fx.GameConfig.GM_INFO.tasks.share = task["share"]; + // cc.fx.GameConfig.GM_INFO.tasks.useEnergy = task["useEnergy"]; + // cc.fx.GameConfig.GM_INFO.tasks.useProp = task["useProp"]; + // } + + // this.setUserPower(data); + // this.setmonth(data); + // this.setRevive(data); + // let levelInfo = cc.fx.StorageMessage.getStorage("level"); + // //如果本地缓存没有关卡信息,默认为服务器信息为主 + // if (levelInfo == undefined || levelInfo == "" || levelInfo == null) { + // this.getUserDataToServer(data.data); + // // this.oldReadData(retryCount); + // } + // //新的读取数据设置方法,以本地为主 + // else { + // this.getUserDataToLocal(data.data); + // // this.newReadData(); + // } + + // cc.fx.GameTool.getHealth((data) => { + // this.load5 = true; + // }); + // this.load6 = true; + // } + // else { + // if (retryCount < MAX_RETRIES && retryCount < delays.length) { + // const delay = delays[retryCount]; + // console.error(`获取用户信息失败,第 ${retryCount + 1} 次重试,将在 ${delay / 1000} 秒后重试`); + // setTimeout(() => { + // retryCount++; + // attemptUserInfo(); + // }, delay); + // } else { + // console.error('获取用户信息失败,达到最大重试次数,退出游戏'); + // // 退出游戏 + // cc.game.end(); + // } + // } + // }); + // }; + // attemptUserInfo(); + // } + // else { + // this.load3 = true; + // this.load4 = true; + // this.load5 = true; + // this.load6 = true; + // cc.fx.GameTool.getHealth(null); + // } // 存储用户数据 } //#region 读取音乐配置 @@ -439,7 +408,8 @@ export default class GameManager extends cc.Component { cc.fx.GameConfig.GM_INFO.first = true; if (data.register_time) { const time = data.register_time; - MiniGameSdk.API.shushu_userSet(time); + let share = cc.fx.GameTool.isFromShareByScene(); + MiniGameSdk.API.shushu_userSet(time, share); } } else { @@ -610,6 +580,11 @@ export default class GameManager extends cc.Component { MiniGameSdk.API.shushu_Login(); MiniGameSdk.API.yinli_Init(); MiniGameSdk.API.yinli_Login(); + if (cc.fx.GameConfig.GM_INFO.first == true) { + const time = Date.now(); + let share = cc.fx.GameTool.isFromShareByScene(); + MiniGameSdk.API.shushu_userSet(time, share); + } this.startGame(); } } diff --git a/assets/Script/JiaZai.ts b/assets/Script/JiaZai.ts index 7eb4728..1a9133e 100644 --- a/assets/Script/JiaZai.ts +++ b/assets/Script/JiaZai.ts @@ -214,6 +214,7 @@ export default class JiaZai extends cc.Component { } //监听后台 onGames() { + //@ts-ignore if (typeof wx !== 'undefined') { this.onShowListener = null; this.onHideListener = null; @@ -578,6 +579,7 @@ export default class JiaZai extends cc.Component { } uploadToCloud(level: number) { + //@ts-ignore if (typeof wx !== 'undefined') { //@ts-ignore wx.setUserCloudStorage({ @@ -655,7 +657,7 @@ export default class JiaZai extends cc.Component { }, 500); return; } - + //@ts-ignore if (typeof wx !== 'undefined') { //@ts-ignore wx.offShow(this.onShowListener); @@ -985,7 +987,7 @@ export default class JiaZai extends cc.Component { } // console.log("注册时间:", time); cc.fx.GameTool.shushu_Track("register", data); - MiniGameSdk.API.shushu_SetSuperProperties(time, false); + MiniGameSdk.API.shushu_SetSuperProperties(time); } } diff --git a/assets/Script/Map.ts b/assets/Script/Map.ts index eedcba9..5741def 100644 --- a/assets/Script/Map.ts +++ b/assets/Script/Map.ts @@ -1800,12 +1800,6 @@ export default class MapConroler extends cc.Component { // console.log("即将上报成功________________________:",this.add_Time); // console.log("成功消除一个",this.add_Time); //// cc.fx.GameTool.changeCoin(40 * cc.fx.GameConfig.GM_INFO.doubleCoin); - const data = { - change_reason: "level", - id: (1001 + ""), - num: 40 * cc.fx.GameConfig.GM_INFO.doubleCoin - } - cc.fx.GameTool.shushu_Track("resource_get", data); let overTime = Date.now(); this.count_Time = overTime - this.count_Time; if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) { @@ -1998,6 +1992,18 @@ export default class MapConroler extends cc.Component { runRewive(data) { console.log("复活回调函数内", data); this.isreview = true; + const dataTemp = { + change_reason: "share", + id: "2000", + num: 1 + } + cc.fx.GameTool.shushu_Track("resource_get", dataTemp); + const dataTemp2 = { + change_reason: "游戏内复活消耗金币", + id: "2000", + num: -1 + } + cc.fx.GameTool.shushu_Track("resource_cost", dataTemp2); //// cc.fx.GameTool.changeCoin(data.coin); // const dataTemp = { // change_reason: "游戏内复活消耗金币", @@ -2151,6 +2157,7 @@ export default class MapConroler extends cc.Component { uploadToCloud(level: number) { + //@ts-ignore if (typeof wx !== 'undefined') { //@ts-ignore wx.setUserCloudStorage({ diff --git a/assets/Script/Sdk/MiniGameSdk.ts b/assets/Script/Sdk/MiniGameSdk.ts index 54a4990..d5eb9d5 100644 --- a/assets/Script/Sdk/MiniGameSdk.ts +++ b/assets/Script/Sdk/MiniGameSdk.ts @@ -716,6 +716,7 @@ export namespace MiniGameSdk { static shareAppToFriends() { //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { // 判断是否在微信环境 + //@ts-ignore wx.setPreferredFramesPerSecond(60); // // 设置转发按钮点击后的回调 @@ -736,6 +737,7 @@ export namespace MiniGameSdk { title: '快来一起玩这个超有趣的小游戏吧!', // 修改为默认分享标题 imageUrl: img // 修改为默认分享图片 }; + //@ts-ignore // 仅设置分享内容,不主动触发分享 wx.onShareAppMessage(() => shareParams); @@ -747,7 +749,7 @@ export namespace MiniGameSdk { title: '你想玩上怎样的游戏?' }; }); - + //@ts-ignore wx.showShareMenu(() => { return { title: '你想玩上怎样的游戏?', @@ -757,12 +759,14 @@ export namespace MiniGameSdk { }); setTimeout(() => { + //@ts-ignore wx.showShareMenu({ menus: ['shareAppMessage', 'shareTimeline'] }) }, 2000); setTimeout(() => { + //@ts-ignore wx.showShareMenu({ menus: ['shareAppMessage', 'shareTimeline'] }) @@ -1227,6 +1231,7 @@ export namespace MiniGameSdk { */ static shushu_Init() { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { // console.log("开始接入数数平台"); //getWechatGameVersion @@ -1272,25 +1277,31 @@ export namespace MiniGameSdk { } static shushu_Login() { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { // console.log("数数登录时,获取到的openId:", cc.fx.GameConfig.GM_INFO.openid); API._ta.login(cc.fx.GameConfig.GM_INFO.openid); cc.fx.GameConfig.GM_INFO.shushu_AccountId = cc.fx.GameConfig.GM_INFO.openid; const result = "success"; API.shushu_Track("login", result); - API.shushu_SetSuperProperties(null, null); + API.shushu_SetSuperProperties(null); } } - static shushu_userSet(time) { + static shushu_userSet(time, share) { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { // console.log("设置用户注册属性"); API._ta.userSet({ register_time: time }); API._ta.userSet({ uid: cc.fx.GameConfig.GM_INFO.uid.toString() }); + if (share) { + API._ta.userSetOnce({ acq_type: "share" }); + } } } static updateCoinAndLevel() { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { // console.log("上传金币和关卡信息给数数") API._ta.userSet({ current_level: (cc.fx.GameConfig.GM_INFO.level + 1) }); @@ -1303,13 +1314,13 @@ export namespace MiniGameSdk { * 数数平台设置动态公共属性 */ - static shushu_SetSuperProperties(register_time, pay_user) { + static shushu_SetSuperProperties(register_time) { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null && API._ta) { var superProperties = {}; superProperties = { current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值 - //// tmp_coin: cc.fx.GameConfig.GM_INFO.coin,//当前金币 version: cc.fx.GameConfig.GM_INFO.version.toString(),//当前版本号 user_id: cc.fx.GameConfig.GM_INFO.uid.toString() //用户id }; @@ -1318,24 +1329,11 @@ export namespace MiniGameSdk { superProperties = { current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值 - //// tmp_coin: cc.fx.GameConfig.GM_INFO.coin,//当前金币 version: cc.fx.GameConfig.GM_INFO.version.toString(), register_time: register_time, user_id: cc.fx.GameConfig.GM_INFO.uid.toString(), //用户id - pay_user: pay_user }; } - if (pay_user != null && pay_user != false) { - // console.log("设置用户公共属性支付:————————————", pay_user); - superProperties = { - current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number - current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值 - //// tmp_coin: cc.fx.GameConfig.GM_INFO.coin,//当前金币 - version: cc.fx.GameConfig.GM_INFO.version.toString(), - user_id: cc.fx.GameConfig.GM_INFO.uid.toString(), //用户id - pay_user: pay_user - } - } // @ts-ignore // console.log("设置公共属性时:————————————", superProperties.uid); API._ta.setSuperProperties(superProperties);//设置公共事件属性 @@ -1344,6 +1342,7 @@ export namespace MiniGameSdk { } static getWechatGameVersion(): string | null { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { // @ts-ignore const accountInfo = wx.getAccountInfoSync(); @@ -1356,6 +1355,7 @@ export namespace MiniGameSdk { */ static shushu_Track(name, data, callback?: (success: boolean, error?: any) => void) { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { if (API._ta) { // 假设 track 方法返回一个 Promise @@ -1372,6 +1372,7 @@ export namespace MiniGameSdk { * @returns distinct_id 或 null */ static getShushuDistinctId(): string | null { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null && API._ta) { // 假设 SDK 提供 getDistinctId 方法 if (API._ta.getDistinctId) { @@ -1386,6 +1387,7 @@ export namespace MiniGameSdk { * @returns account_id 或 null */ static getShushuAccountId(): string | null { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null && API._ta) { // 假设 SDK 提供 getAccountId 方法 if (API._ta.getAccountId) { @@ -1397,6 +1399,7 @@ export namespace MiniGameSdk { //#region 引力平台- static yinli_Init() { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { const configYinli = { accessToken: "aGws0nluotbm6Jjiv9WMuzOAbXLydxwe", // 项目通行证,在:网站后台-->设置-->应用列表中找到Access Token列 复制(首次使用可能需要先新增应用) @@ -1441,6 +1444,7 @@ export namespace MiniGameSdk { } static yinli_Register() { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { API._ge.registerEvent(); } @@ -1455,6 +1459,7 @@ export namespace MiniGameSdk { * @param payMethod 付费方式 例如:支付宝、微信、银联等 */ static yinli_Pay(payAmount, orderId, payReason) { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { let version = cc.fx.GameTool.getWechatGameVersion(); if (version == "开发版" || version == "体验版") { @@ -1468,6 +1473,7 @@ export namespace MiniGameSdk { } static yinli_Login() { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { API._ge.loginEvent(); } @@ -1475,6 +1481,7 @@ export namespace MiniGameSdk { //分享 static shareGame() { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { let helpLevel = cc.fx.GameConfig.GM_INFO.level + 1; if (helpLevel > 373) { @@ -1519,6 +1526,7 @@ export namespace MiniGameSdk { //上传好友排行数据 static setNewCloudlevel() { + //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { console.log("往子域上传分数"); let newKVData = { key: 'level', value: String(cc.fx.GameConfig.GM_INFO.level) } diff --git a/assets/Script/module/Tool/GameTool.ts b/assets/Script/module/Tool/GameTool.ts index d51f024..e32d7f4 100644 --- a/assets/Script/module/Tool/GameTool.ts +++ b/assets/Script/module/Tool/GameTool.ts @@ -386,7 +386,7 @@ var GameTool = { count: cc.fx.GameConfig.GM_INFO.winStreak } cc.fx.GameTool.shushu_Track("hammer_frenzy", data2); - MiniGameSdk.API.shushu_SetSuperProperties(null, null); + MiniGameSdk.API.shushu_SetSuperProperties(null); } cc.fx.GameTool.setUserLevel((data) => { @@ -498,7 +498,7 @@ var GameTool = { "health": cc.fx.GameConfig.GM_INFO.hp, "timestamp": res.data.timestamp } - MiniGameSdk.API.shushu_SetSuperProperties(null, null); + MiniGameSdk.API.shushu_SetSuperProperties(null); cc.fx.StorageMessage.setStorage("health", healthInfo); } else { @@ -633,7 +633,7 @@ var GameTool = { } cc.fx.StorageMessage.setStorage("health", healthInfo); - MiniGameSdk.API.shushu_SetSuperProperties(null, null); + MiniGameSdk.API.shushu_SetSuperProperties(null); //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { //laf云函数 @@ -672,12 +672,13 @@ var GameTool = { } //console.log("_____________新版本", num); // cc.fx.GameTool.changeCoin(-cost); - const dataTemp = { - change_reason: "商城购买道具消耗", - id: (1001 + ""), - num: -cost - } - cc.fx.GameTool.shushu_Track("resource_cost", dataTemp); + + // const dataTemp = { + // change_reason: "商城购买道具消耗", + // id: (1001 + ""), + // num: -cost + // } + // cc.fx.GameTool.shushu_Track("resource_cost", dataTemp); let _id = ""; let propNumber = 0; @@ -702,7 +703,7 @@ var GameTool = { }) const data = { - change_reason: "game", + change_reason: "share", id: propid, num: num, compensate: false @@ -867,7 +868,6 @@ var GameTool = { case "enter_stage": eventData = { stage_id: (cc.fx.GameConfig.GM_INFO.level + 1), - is_frenzy: data.is_frenzy, } if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) { eventData = { @@ -880,7 +880,6 @@ var GameTool = { stage_id: (cc.fx.GameConfig.GM_INFO.level + 1), stage_duration: data.time, added_time: data.add_Time, - is_frenzy: data.is_frenzy, result: data.result } if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) { @@ -1041,21 +1040,21 @@ var GameTool = { cc.fx.GameTool.setUserProp(0, num, (data) => { }) const data1 = { - change_reason: "shop", + change_reason: "share", id: 2001, num: propData.freeze, compensate: compensate } cc.fx.GameTool.shushu_Track("resource_get", data1); const data2 = { - change_reason: "shop", + change_reason: "share", id: 2002, num: propData.hammer, compensate: compensate } cc.fx.GameTool.shushu_Track("resource_get", data2); const data3 = { - change_reason: "shop", + change_reason: "share", id: 2003, num: propData.magic_wand, compensate: compensate @@ -1188,6 +1187,7 @@ var GameTool = { }, getUserAvatar(callBack: Function) { + //@ts-ignore if (typeof wx === 'undefined') { // this.showRanks(); // 非微信环境直接显示 return; @@ -1321,6 +1321,29 @@ var GameTool = { }, 3000); } + }, + + isFromShareByScene(): boolean { + if (cc.sys.platform === cc.sys.WECHAT_GAME) { + try { + //@ts-ignore + const launchOptions = wx.getLaunchOptionsSync(); + const scene = launchOptions.scene; + // 常见的分享场景值: + // 1007: 单人聊天会话中的小程序消息卡片 + // 1008: 群聊会话中的小程序消息卡片 + // 1011: 扫描二维码 + // 1012: 长按图片识别二维码 + // 1013: 手机相册选取二维码 + // 1044: 小程序profile页 + const shareScenes = [1007, 1008, 1011, 1012, 1013]; + return shareScenes.includes(scene); + + } catch (error) { + console.error('获取场景值失败:', error); + } + } + return false; } }; diff --git a/assets/action_bundle/script/DailyQuests.ts b/assets/action_bundle/script/DailyQuests.ts index d779b53..a55e1dd 100644 --- a/assets/action_bundle/script/DailyQuests.ts +++ b/assets/action_bundle/script/DailyQuests.ts @@ -495,36 +495,7 @@ export default class DailyQuests extends cc.Component { getShopProp(propData) { //@ts-ignore - if (typeof wx !== 'undefined' && wx !== null) { - const num = 0; - //console.log("_________道具增加的数量为:", num); - cc.fx.GameConfig.GM_INFO.freezeAmount += propData.freeze; - cc.fx.GameConfig.GM_INFO.hammerAmount += propData.hammer; - cc.fx.GameConfig.GM_INFO.magicAmount += propData.magic_wand; - cc.fx.GameTool.setUserProp(0, num, (data) => { - }) - const data1 = { - change_reason: "quests", - id: 2001, - num: propData.freeze, - compensate: false - } - cc.fx.GameTool.shushu_Track("resource_get", data1); - const data2 = { - change_reason: "quests", - id: 2002, - num: propData.hammer, - compensate: false - } - cc.fx.GameTool.shushu_Track("resource_get", data2); - const data3 = { - change_reason: "quests", - id: 2003, - num: propData.magic_wand, - compensate: false - } - cc.fx.GameTool.shushu_Track("resource_get", data3); - } + } onDestroy() { diff --git a/assets/shop/script.meta b/assets/shop/script.meta deleted file mode 100644 index e56f9ba..0000000 --- a/assets/shop/script.meta +++ /dev/null @@ -1,13 +0,0 @@ -{ - "ver": "1.1.3", - "uuid": "f799ffac-758e-4e90-8535-3fbd6ac46969", - "importer": "folder", - "isBundle": false, - "bundleName": "", - "priority": 1, - "compressionType": {}, - "optimizeHotUpdate": {}, - "inlineSpriteFrames": {}, - "isRemoteBundle": {}, - "subMetas": {} -} \ No newline at end of file