From 006bd001fcd5206dca647a8f29f7d880af7456ce Mon Sep 17 00:00:00 2001 From: "YZ\\249929363" <249929363@qq.com> Date: Thu, 17 Jul 2025 20:22:06 +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/JiaZai.ts | 18 +- assets/Script/module/Pay/Utils.ts | 27 ++- assets/Script/module/Tool/GameTool.ts | 98 +++++++++- assets/shop/script/shop.ts | 251 ++++++++++++++------------ settings/builder.json | 2 +- 6 files changed, 265 insertions(+), 135 deletions(-) diff --git a/assets/Script/GameManager.ts b/assets/Script/GameManager.ts index 64b396f..d04aaa6 100644 --- a/assets/Script/GameManager.ts +++ b/assets/Script/GameManager.ts @@ -168,6 +168,7 @@ export default class GameManager extends cc.Component { startGame() { console.log("进入场景之前_____________", cc.fx.GameConfig.GM_INFO.first); + console.log(cc.fx.GameConfig.GM_INFO.level); // 加载 music bundle cc.assetManager.loadBundle('music', (err, bundle) => { if (err) { @@ -240,6 +241,7 @@ export default class GameManager extends cc.Component { console.log("体力值完成进入游戏"); this.load5 = true; }); + this.load6 = true; }); } else { @@ -706,7 +708,9 @@ export default class GameManager extends cc.Component { } update(dt) { + //console.log("加载1:", this.load1, "加载2:", this.load2, "加载3:", this.load3, "加载4:", this.load4, "加载5:", this.load5, "加载6:", this.load6, "时间:", this.timeNumber); if (this.load1 && this.load2 && this.load3 && this.load4 && this.load5 && this.load6 == true && this.timeNumber <= 0) { + console.log("进入游戏_______________"); this.load1 = this.load2 = false; MiniGameSdk.API.shushu_Login(); MiniGameSdk.API.yinli_Init(); diff --git a/assets/Script/JiaZai.ts b/assets/Script/JiaZai.ts index 06fbce5..6fec5ec 100644 --- a/assets/Script/JiaZai.ts +++ b/assets/Script/JiaZai.ts @@ -101,16 +101,16 @@ export default class JiaZai extends cc.Component { return; } JiaZai.cachedRewardPrefab = prefab; - let data = [ - { type: "coin", count: 125294 }, - { type: "coin", count: 7498 }, - { type: "freeze", count: 2 }, - { type: "hammer", count: 2 }, - { type: "magic", count: 2 }, - { type: "infinite_health", count: 1800 * 4 }, - ] + // let data = [ + // { type: "coin", count: 125294 }, + // { type: "coin", count: 7498 }, + // { type: "freeze", count: 2 }, + // { type: "hammer", count: 2 }, + // { type: "magic", count: 2 }, + // { type: "infinite_health", count: 1800 * 4 }, + // ] - this.openRewardWindow(data); + // this.openRewardWindow(data); this.getOrder(); }); }); diff --git a/assets/Script/module/Pay/Utils.ts b/assets/Script/module/Pay/Utils.ts index 84e4f10..4789188 100644 --- a/assets/Script/module/Pay/Utils.ts +++ b/assets/Script/module/Pay/Utils.ts @@ -665,12 +665,29 @@ export default class Utils { if (uid != undefined && uid != "" && uid != null) { cc.fx.GameConfig.GM_INFO.uid = uid; } - let setData = { - uid: cc.fx.GameConfig.GM_INFO.uid, - action: 'save', - propType: propid, - propData: amount, + let setData = null; + if (propid == 0) { + setData = { + uid: cc.fx.GameConfig.GM_INFO.uid, + action: 'save', + propType: propid, + propData: { + freeze: cc.fx.GameConfig.GM_INFO.freezeAmount, + hammer: cc.fx.GameConfig.GM_INFO.hammerAmount, + magic_wand: cc.fx.GameConfig.GM_INFO.wandAmount, + }, + } } + else { + setData = { + uid: cc.fx.GameConfig.GM_INFO.uid, + action: 'save', + propType: propid, + propData: amount, + } + } + + console.log("上传道具类型", propid, "上传道具数量:", amount); Utils.POST("userProp", setData, res => { console.log("获得userProp数据:", res); if (res.code === 1) { diff --git a/assets/Script/module/Tool/GameTool.ts b/assets/Script/module/Tool/GameTool.ts index 74fd425..fb31c54 100644 --- a/assets/Script/module/Tool/GameTool.ts +++ b/assets/Script/module/Tool/GameTool.ts @@ -1,4 +1,5 @@ +import Freeze from "../../prop/Freeze"; import SceneManager from "../../SceneManager"; import { MiniGameSdk } from "../../Sdk/MiniGameSdk"; import Utils from "../Pay/Utils"; @@ -706,7 +707,6 @@ var GameTool = { console.log("____________即将上传Shop_buy", buyData); cc.fx.GameTool.shushu_Track("shop_buy", buyData); - callback(); } }, @@ -885,6 +885,7 @@ var GameTool = { let coin = 0; let price = 0; let getCoin = 0; + switch (productId) { case "gold_1": cc.fx.GameTool.changeCoin(1200); @@ -922,6 +923,38 @@ var GameTool = { price = 64800; MiniGameSdk.API.showToast("充值成功,获得240000金币"); break; + case "unlimited_health_bundle_1": + cc.fx.GameTool.changeCoin(5000); + coin = 5000; + price = 1800; + MiniGameSdk.API.showToast("获得无限体力小组合包"); + break; + case "unlimited_health_bundle_2": + cc.fx.GameTool.changeCoin(12000); + coin = 12000; + price = 6600; + let propData = { + "freeze": 2, + "hammer": 2, + "magic_wand": 2, + "price": price + } + this.getShopProp(propData, null); + MiniGameSdk.API.showToast("获得无限体力大组合包"); + break; + case "unlimited_health_bundle_3": + cc.fx.GameTool.changeCoin(30000); + coin = 30000; + price = 10800; + let propData2 = { + "freeze": 6, + "hammer": 6, + "magic_wand": 6, + "price": price + } + this.getShopProp(propData2, null); + MiniGameSdk.API.showToast("获得无限体力超组合包"); + break; } const dataTemp = { change_reason: "shop", @@ -1103,7 +1136,68 @@ var GameTool = { } } else return 1; - } + }, + + + //购买行为,获得道具 + getShopProp(propData, callback: Function) { + //@ts-ignore + if (typeof wx !== 'undefined' && wx !== null) { + const num = propData.freeze; + 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: "shop", + id: 2001, + num: propData.freeze + } + cc.fx.GameTool.shushu_Track("resource_get", data1); + const data2 = { + change_reason: "shop", + id: 2002, + num: propData.hammer + } + cc.fx.GameTool.shushu_Track("resource_get", data2); + const data3 = { + change_reason: "shop", + id: 2003, + num: propData.magic_wand + } + cc.fx.GameTool.shushu_Track("resource_get", data3); + const buyData1 = { + item_id: "freeze_in_game", + item_num: propData.freeze, + item_price: propData.price, + cost_type: "cash" + } + + cc.fx.GameTool.shushu_Track("shop_buy", buyData1); + const buyData2 = { + item_id: "hammer_in_game", + item_num: propData.hammer, + item_price: propData.price, + cost_type: "cash" + } + + cc.fx.GameTool.shushu_Track("shop_buy", buyData2); + const buyData3 = { + item_id: "wand_in_game", + item_num: propData.magic_wand, + item_price: propData.price, + cost_type: "cash" + } + + cc.fx.GameTool.shushu_Track("shop_buy", buyData3); + + if (callback) { + callback(); + } + } + }, }; export { GameTool }; \ No newline at end of file diff --git a/assets/shop/script/shop.ts b/assets/shop/script/shop.ts index a8cb80f..cce47c2 100644 --- a/assets/shop/script/shop.ts +++ b/assets/shop/script/shop.ts @@ -335,6 +335,15 @@ export default class NewClass extends cc.Component { case "gold_6": price = 64800; break; + case "unlimited_health_bundle_1": + price = 1800; + break; + case "unlimited_health_bundle_2": + price = 6600; + break; + case "unlimited_health_bundle_3": + price = 10800; + break; } //console.log("获得商品id:", id, count, price); // 判断设备系统 @@ -367,6 +376,9 @@ export default class NewClass extends cc.Component { }); } else { + console.log("上品ID:", productId); + MiniGameSdk.API.showToast(productId); + cc.fx.GameTool.shopBuy(productId); const data = { outTradeNo: Utils.outTradeNo, price: price, @@ -376,125 +388,128 @@ export default class NewClass extends cc.Component { } cc.fx.GameTool.shushu_Track("init_order", data); this.openLoad(); + + + //console.log("7.14_____________________", "调用充值接口"); - Utils.buyProp(id, count, price, (res) => { - //console.log("获得充值结果", res); - if (res == null) { - MiniGameSdk.API.showToast("充值失败"); - this.btn_Touch = true; - const dataFail = { - outTradeNo: Utils.outTradeNo, - price: price, - payment_name: productId, - payment_num: 1, - type: systemType, - fail_reason: "网络异常,没有拉起支付", - } - cc.fx.GameTool.shushu_Track("payment_fail", dataFail); - this.closeLoad(); - return; - } - else if (res.err) { - MiniGameSdk.API.showToast("充值失败"); - //console.log(res); - this.btn_Touch = true; - let name = "支付拉起失败"; - if (res.errCode == -2) { - name = "用户取消充值"; - } - const dataFail = { - outTradeNo: Utils.outTradeNo, - price: price, - payment_name: productId, - payment_num: 1, - type: systemType, - fail_reason: name, - } - cc.fx.GameTool.shushu_Track("payment_fail", dataFail); - this.closeLoad(); - return; - } - else { - Utils.getPayInfo((data) => { - //console.log("7.14_______________充值成功,准备轮训"); - //console.log("获得轮训结果:", data); - this.closeLoad(); - if (data.data.pay_state == 1) { - this.btn_Touch = true; - MiniGameSdk.API.showToast("取消充值"); - const dataFail2 = { - outTradeNo: Utils.outTradeNo, - price: price, - payment_name: productId, - payment_num: 1, - type: systemType, - fail_reason: "用户取消支付", - } - cc.fx.GameTool.shushu_Track("payment_fail", dataFail2); - } - else if (data.data.pay_state == 2) { - this.btn_Touch = true; - const dataSuccess = { - outTradeNo: Utils.outTradeNo, - price: price, - payment_name: productId, - payment_num: 1, - type: systemType, - } - cc.fx.GameTool.shushu_Track("payment", dataSuccess); - let name = "购买金币道具:" + productId; - MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name) - //console.log("7.14_______________充值成功,轮训成功,准备发货"); - Utils.setPayInfo( - (res) => { - //console.log("设置轮训结果:", res); - if (res.code === 1) { - //console.log("7.14_________正式发货"); - MiniGameSdk.API.showToast("充值成功"); - cc.fx.GameTool.shopBuy(productId); - //console.log("充值成功获得金币"); - } - else { - MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放"); - const dataFail4 = { - outTradeNo: Utils.outTradeNo, - price: price, - payment_name: productId, - payment_num: 1, - type: systemType, - 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(); - } - }, null) - } - else { - NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); - const dataFail3 = { - outTradeNo: Utils.outTradeNo, - price: price, - payment_name: productId, - payment_num: 1, - type: systemType, - fail_reason: "拉起支付后,付款时网络异常付款失败", - } - cc.fx.GameTool.shushu_Track("payment_fail", dataFail3); - this.btn_Touch = 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(); - } - } - }) - } - }); + // Utils.buyProp(id, count, price, (res) => { + // //console.log("获得充值结果", res); + // if (res == null) { + // MiniGameSdk.API.showToast("充值失败"); + // this.btn_Touch = true; + // const dataFail = { + // outTradeNo: Utils.outTradeNo, + // price: price, + // payment_name: productId, + // payment_num: 1, + // type: systemType, + // fail_reason: "网络异常,没有拉起支付", + // } + // cc.fx.GameTool.shushu_Track("payment_fail", dataFail); + // this.closeLoad(); + // return; + // } + // else if (res.err) { + // MiniGameSdk.API.showToast("充值失败"); + // //console.log(res); + // this.btn_Touch = true; + // let name = "支付拉起失败"; + // if (res.errCode == -2) { + // name = "用户取消充值"; + // } + // const dataFail = { + // outTradeNo: Utils.outTradeNo, + // price: price, + // payment_name: productId, + // payment_num: 1, + // type: systemType, + // fail_reason: name, + // } + // cc.fx.GameTool.shushu_Track("payment_fail", dataFail); + // this.closeLoad(); + // return; + // } + // else { + // Utils.getPayInfo((data) => { + // //console.log("7.14_______________充值成功,准备轮训"); + // //console.log("获得轮训结果:", data); + // this.closeLoad(); + // if (data.data.pay_state == 1) { + // this.btn_Touch = true; + // MiniGameSdk.API.showToast("取消充值"); + // const dataFail2 = { + // outTradeNo: Utils.outTradeNo, + // price: price, + // payment_name: productId, + // payment_num: 1, + // type: systemType, + // fail_reason: "用户取消支付", + // } + // cc.fx.GameTool.shushu_Track("payment_fail", dataFail2); + // } + // else if (data.data.pay_state == 2) { + // this.btn_Touch = true; + // const dataSuccess = { + // outTradeNo: Utils.outTradeNo, + // price: price, + // payment_name: productId, + // payment_num: 1, + // type: systemType, + // } + // cc.fx.GameTool.shushu_Track("payment", dataSuccess); + // let name = "购买金币道具:" + productId; + // MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name) + // //console.log("7.14_______________充值成功,轮训成功,准备发货"); + // Utils.setPayInfo( + // (res) => { + // //console.log("设置轮训结果:", res); + // if (res.code === 1) { + // //console.log("7.14_________正式发货"); + // MiniGameSdk.API.showToast("充值成功"); + // cc.fx.GameTool.shopBuy(productId); + // //console.log("充值成功获得金币"); + // } + // else { + // MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放"); + // const dataFail4 = { + // outTradeNo: Utils.outTradeNo, + // price: price, + // payment_name: productId, + // payment_num: 1, + // type: systemType, + // 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(); + // } + // }, null) + // } + // else { + // NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); + // const dataFail3 = { + // outTradeNo: Utils.outTradeNo, + // price: price, + // payment_name: productId, + // payment_num: 1, + // type: systemType, + // fail_reason: "拉起支付后,付款时网络异常付款失败", + // } + // cc.fx.GameTool.shushu_Track("payment_fail", dataFail3); + // this.btn_Touch = 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(); + // } + // } + // }) + // } + // }); } } diff --git a/settings/builder.json b/settings/builder.json index e007733..7165a3d 100644 --- a/settings/builder.json +++ b/settings/builder.json @@ -15,7 +15,7 @@ "mainCompressionType": "subpackage", "mainIsRemote": false, "optimizeHotUpdate": false, - "md5Cache": false, + "md5Cache": true, "nativeMd5Cache": true, "encryptJs": true, "xxteaKey": "07ac496c-82b0-4f",