From 499f1bdb19f9b8de765cb1614268f0e891a4c2c7 Mon Sep 17 00:00:00 2001 From: "YZ\\249929363" <249929363@qq.com> Date: Mon, 4 Aug 2025 17:47:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Script/GameManager.ts | 4 +- assets/Script/Revive.ts | 18 +-- assets/Script/module/Pay/Utils.ts | 2 +- assets/Script/monthlyCard.ts | 17 +-- assets/resources/NewLevel.meta | 13 ++ assets/shop/prefab/shop.prefab | 10 +- assets/shop/script/shop.ts | 199 +++++++++++++++--------------- 7 files changed, 137 insertions(+), 126 deletions(-) create mode 100644 assets/resources/NewLevel.meta diff --git a/assets/Script/GameManager.ts b/assets/Script/GameManager.ts index e4fe283..834a5f1 100644 --- a/assets/Script/GameManager.ts +++ b/assets/Script/GameManager.ts @@ -251,8 +251,8 @@ export default class GameManager extends cc.Component { Utils.getUserInfo((data) => { if (data.code == 1) { // 假设返回数据中有 success 字段表示成功 //console.log("登录成功时间耗时:", Date.now() - this.nowTime); - console.log("登陆成功_____________"); - console.log(data); + // console.log("111登陆成功_____________"); + console.log("登錄", data); //console.log("uid", data.data.onlyId); if (data.data._id) { cc.fx.GameConfig.GM_INFO.uid = data.data._id; diff --git a/assets/Script/Revive.ts b/assets/Script/Revive.ts index 401e3ff..fbdd3ec 100644 --- a/assets/Script/Revive.ts +++ b/assets/Script/Revive.ts @@ -31,14 +31,6 @@ export default class Revive extends cc.Component { onLoad() { this.btn_Touch = true; // 检测微信小游戏切到后台 - if (cc.sys.platform === cc.sys.WECHAT_GAME) { - // 定义监听函数 - this.onShowListener = () => { - this.onShow(); - }; - //@ts-ignore - wx.onShow(this.onShowListener); - } } onShow() { @@ -140,7 +132,15 @@ export default class Revive extends cc.Component { } } init() { - console.log() + if (cc.sys.platform === cc.sys.WECHAT_GAME) { + this.onShowListener = null; + // 定义监听函数 + this.onShowListener = () => { + this.onShow(); + }; + //@ts-ignore + wx.onShow(this.onShowListener); + } this.btn_Touch = true; if (cc.fx.GameConfig.GM_INFO.revive == 1) { this.node.active = false; diff --git a/assets/Script/module/Pay/Utils.ts b/assets/Script/module/Pay/Utils.ts index e3351de..9e85e61 100644 --- a/assets/Script/module/Pay/Utils.ts +++ b/assets/Script/module/Pay/Utils.ts @@ -12,7 +12,7 @@ export default class Utils { static getUserInfo(callBack) { wx.login({ success(res) { - console.log("登录成功"); + console.log("微信login成功"); console.log(res); if (res.code) { Utils.POST("login", { code: res.code }, ret => { diff --git a/assets/Script/monthlyCard.ts b/assets/Script/monthlyCard.ts index 21172fa..360a0cf 100644 --- a/assets/Script/monthlyCard.ts +++ b/assets/Script/monthlyCard.ts @@ -37,14 +37,6 @@ export default class NewClass extends cc.Component { onLoad() { this.btn_Touch = true; // 检测微信小游戏切到后台 - if (cc.sys.platform === cc.sys.WECHAT_GAME) { - // 定义监听函数 - this.onShowListener = () => { - this.onShow(); - }; - //@ts-ignore - wx.onShow(this.onShowListener); - } this.home = 0; } @@ -156,6 +148,15 @@ export default class NewClass extends cc.Component { } init() { + if (cc.sys.platform === cc.sys.WECHAT_GAME) { + this.onShowListener = null; + // 定义监听函数 + this.onShowListener = () => { + this.onShow(); + }; + //@ts-ignore + wx.onShow(this.onShowListener); + } this.btn_Touch = true; if (cc.fx.GameConfig.GM_INFO.hp_Max == 7) { this.monthCardBtn.active = false; diff --git a/assets/resources/NewLevel.meta b/assets/resources/NewLevel.meta new file mode 100644 index 0000000..bfadd6e --- /dev/null +++ b/assets/resources/NewLevel.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.3", + "uuid": "822b01d9-1503-471f-9590-548862a52e72", + "importer": "folder", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/shop/prefab/shop.prefab b/assets/shop/prefab/shop.prefab index 1d74eb4..9e3d3eb 100644 --- a/assets/shop/prefab/shop.prefab +++ b/assets/shop/prefab/shop.prefab @@ -756,7 +756,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 1080, - "height": 3350 + "height": 3200 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -768,7 +768,7 @@ "ctor": "Float64Array", "array": [ 0, - 900, + 55.944, 0, 0, 0, @@ -824,19 +824,19 @@ "_contentSize": { "__type__": "cc.Size", "width": 1080, - "height": 2000 + "height": 1700 }, "_anchorPoint": { "__type__": "cc.Vec2", "x": 0.5, - "y": 0.5 + "y": 1 }, "_trs": { "__type__": "TypedArray", "ctor": "Float64Array", "array": [ 0, - -73.284, + 885.733, 0, 0, 0, diff --git a/assets/shop/script/shop.ts b/assets/shop/script/shop.ts index 355059b..664ff25 100644 --- a/assets/shop/script/shop.ts +++ b/assets/shop/script/shop.ts @@ -52,16 +52,7 @@ export default class NewClass extends cc.Component { this.btn_Touch = true; this.monthCard = false; // 检测微信小游戏切到后台 - if (cc.sys.platform === cc.sys.WECHAT_GAME) { - // 定义监听函数 - this.onShowListener = () => { - console.log("回到前台"); - this.onShow(); - }; - //@ts-ignore - wx.onShow(this.onShowListener); - } } start() { this.btn_Touch = true; @@ -70,6 +61,16 @@ export default class NewClass extends cc.Component { } init() { + this.onShowListener = null; + if (cc.sys.platform === cc.sys.WECHAT_GAME) { + // 定义监听函数 + this.onShowListener = () => { + console.log("回到前台"); + this.onShow(); + }; + //@ts-ignore + wx.onShow(this.onShowListener); + } this.btn_Touch = true; var timeTemp = cc.fx.GameTool.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time); // 同步显示 @@ -194,7 +195,6 @@ export default class NewClass extends cc.Component { const systemInfo = wx.getSystemInfoSync(); if (systemInfo.platform === 'ios') { if (cc.sys.platform === cc.sys.WECHAT_GAME) { - console.log("从后台进入获取当前商品名称:", this.iosProductId); console.log("从后台进入前台订单号:", cc.fx.GameConfig.GM_INFO.iosOutTradeNo); this.closeLoad(); if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null && cc.fx.GameConfig.GM_INFO.iosOutTradeNo != "") { @@ -203,99 +203,96 @@ export default class NewClass extends cc.Component { cc.fx.GameConfig.GM_INFO.iosOutTradeNo = ""; this.openLoad(); this.btn_Touch = true; - console.log("_________正式发货", "gold_1"); - MiniGameSdk.API.showToast("充值成功"); - cc.fx.GameTool.shopBuy("gold_5", false); - // Utils.getIosPayInfo(iosOutTradeNo, - // (data) => { - // console.log("获得轮训结果:", data); - // if (data.code == 1) { - // console.log("购买成功"); - // const iosID = data.data.payment_name; - // console.log("商品id:", iosID); - // const dataSuccess = { - // outTradeNo: iosOutTradeNo, - // pay_amount: this.iosPrice, - // payment_name: iosID, - // payment_num: this.iosCount, - // type: "ios", - // } - // cc.fx.GameTool.shushu_Track("payment", dataSuccess); - // let name = "购买金币道具:" + this.iosProductId; - // let version = cc.fx.GameTool.getWechatGameVersion(); - // if (version == "正式版") { - // MiniGameSdk.API.yinli_Pay(this.iosPrice, iosOutTradeNo, name) - // } + Utils.getIosPayInfo(iosOutTradeNo, + (data) => { + console.log("获得轮训结果:", data); + if (data.code == 1) { + console.log("购买成功"); + const iosID = data.data.payment_name; + console.log("商品id:", iosID); + const dataSuccess = { + outTradeNo: iosOutTradeNo, + pay_amount: this.iosPrice, + payment_name: iosID, + payment_num: this.iosCount, + type: "ios", + } + cc.fx.GameTool.shushu_Track("payment", dataSuccess); + let name = "购买金币道具:" + this.iosProductId; + let version = cc.fx.GameTool.getWechatGameVersion(); + if (version == "正式版") { + MiniGameSdk.API.yinli_Pay(this.iosPrice, iosOutTradeNo, name) + } - // Utils.setPayInfo( - // (res) => { - // this.closeLoad(); - // //console.log("设置轮训结果:", res); - // if (res.code === 1) { - // console.log("_________正式发货", iosID); - // MiniGameSdk.API.showToast("充值成功"); - // cc.fx.GameTool.shopBuy(iosID, false); - // if (iosID == "unlimited_health_bundle_1" || - // iosID == "unlimited_health_bundle_2" || - // iosID == "unlimited_health_bundle_3" - // ) { - // this.updatePower(); - // } - // //console.log("充值成功获得金币"); - // } - // else { - // MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放"); - // const dataFail4 = { - // outTradeNo: iosOutTradeNo, - // price: this.iosPrice, - // payment_name: iosID, - // payment_num: this.iosCount, - // type: "ios", - // fail_reason: "成功付款,但是发货时请求服务器失败,充值成功未发货", - // } - // cc.fx.GameTool.shushu_Track("payment_fail", dataFail4); - // } - // NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); - // if (this.node.parent.getComponent("JiaZai")) - // this.node.parent.getComponent("JiaZai").updateCoin(); - // else if (this.node.parent.getComponent("SceneManager")) { - // this.node.parent.getComponent("SceneManager").updateCoin(); - // } - // }, iosOutTradeNo) - // } - // else if (data.code == 0) { - // console.log("用户自己取消充值"); - // MiniGameSdk.API.showToast("充值失败"); - // this.closeLoad(); - // this.btn_Touch = true; - // const dataFail = { - // outTradeNo: iosOutTradeNo, - // price: this.iosPrice, - // payment_name: this.iosProductId, - // payment_num: this.iosCount, - // type: "ios", - // fail_reason: "用户取消充值", - // } - // cc.fx.GameTool.shushu_Track("payment_fail", dataFail); - // } - // else if (data.code == 2) { - // this.closeLoad(); - // console.log("轮训超时"); - // MiniGameSdk.API.showToast("订单已关闭"); - // const dataFail = { - // outTradeNo: iosOutTradeNo, - // price: this.iosPrice, - // payment_name: this.iosProductId, - // payment_num: this.iosCount, - // type: "ios", - // fail_reason: "用户充值后,轮训结果超时", - // } - // cc.fx.GameTool.shushu_Track("payment_fail", dataFail); - // } + Utils.setPayInfo( + (res) => { + this.closeLoad(); + //console.log("设置轮训结果:", res); + if (res.code === 1) { + console.log("_________正式发货", iosID); + MiniGameSdk.API.showToast("充值成功"); + cc.fx.GameTool.shopBuy(iosID, false); + if (iosID == "unlimited_health_bundle_1" || + iosID == "unlimited_health_bundle_2" || + iosID == "unlimited_health_bundle_3" + ) { + this.updatePower(); + } + //console.log("充值成功获得金币"); + } + else { + MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放"); + const dataFail4 = { + outTradeNo: iosOutTradeNo, + price: this.iosPrice, + payment_name: iosID, + payment_num: this.iosCount, + type: "ios", + fail_reason: "成功付款,但是发货时请求服务器失败,充值成功未发货", + } + cc.fx.GameTool.shushu_Track("payment_fail", dataFail4); + } + NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); + if (this.node.parent.getComponent("JiaZai")) + this.node.parent.getComponent("JiaZai").updateCoin(); + else if (this.node.parent.getComponent("SceneManager")) { + this.node.parent.getComponent("SceneManager").updateCoin(); + } + }, iosOutTradeNo) + } + else if (data.code == 0) { + console.log("用户自己取消充值"); + MiniGameSdk.API.showToast("充值失败"); + this.closeLoad(); + this.btn_Touch = true; + const dataFail = { + outTradeNo: iosOutTradeNo, + price: this.iosPrice, + payment_name: this.iosProductId, + payment_num: this.iosCount, + type: "ios", + fail_reason: "用户取消充值", + } + cc.fx.GameTool.shushu_Track("payment_fail", dataFail); + } + else if (data.code == 2) { + this.closeLoad(); + console.log("轮训超时"); + MiniGameSdk.API.showToast("订单已关闭"); + const dataFail = { + outTradeNo: iosOutTradeNo, + price: this.iosPrice, + payment_name: this.iosProductId, + payment_num: this.iosCount, + type: "ios", + fail_reason: "用户充值后,轮训结果超时", + } + cc.fx.GameTool.shushu_Track("payment_fail", dataFail); + } - // this.btn_Touch = true; - // cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null; - // }) + this.btn_Touch = true; + cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null; + }) } else { this.closeLoad();