修复充值BUG等异常。

This commit is contained in:
YZ\249929363 2025-08-05 17:59:54 +08:00
parent 5393ceeeb1
commit c15ea4d981
11 changed files with 1789 additions and 1476 deletions

File diff suppressed because it is too large Load Diff

View File

@ -965,7 +965,7 @@ export default class Block extends cc.Component {
MapConroler._instance.special_Treatment(this.node); MapConroler._instance.special_Treatment(this.node);
var self = this; var self = this;
this.removeMapBlock(); this.removeMapBlock();
MapConroler._instance.judgeWin(1); MapConroler._instance.judgeWin(0);
let pos = this.node.getPosition(); let pos = this.node.getPosition();
if (self.type == BlockType.) { if (self.type == BlockType.) {
let scaleX = self.node.scaleX; let scaleX = self.node.scaleX;

View File

@ -651,7 +651,7 @@ export default class JiaZai extends cc.Component {
console.error('获取系统信息失败', e); console.error('获取系统信息失败', e);
} }
if (cc.fx.GameConfig.GM_INFO.allOutTradeNo.length != 0) { if (cc.fx.GameConfig.GM_INFO.allOutTradeNo.length != 0) {
//console.log("有需要补发数据", cc.fx.GameConfig.GM_INFO.allOutTradeNo); console.log("有需要补发数据", cc.fx.GameConfig.GM_INFO.allOutTradeNo);
// 递归函数,按顺序处理每个订单 // 递归函数,按顺序处理每个订单
const processOrder = (index: number) => { const processOrder = (index: number) => {
@ -701,8 +701,8 @@ export default class JiaZai extends cc.Component {
} else { } else {
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放"); MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
const dataFail4 = { const dataFail4 = {
outTradeNo: Utils.outTradeNo, outTradeNo: order.outTradeNo,
price: parseInt(order.goodsPrice), pay_amount: parseInt(order.goodsPrice) || 0,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -716,7 +716,7 @@ export default class JiaZai extends cc.Component {
// 处理下一个订单 // 处理下一个订单
processOrder(index + 1); processOrder(index + 1);
}, order.outTradeNo); }, order.outTradeNo);
let price = order.price || 0; let price = parseInt(order.goodsPrice) || 0;
const dataSuccess = { const dataSuccess = {
outTradeNo: order.outTradeNo, outTradeNo: order.outTradeNo,
pay_amount: price, pay_amount: price,
@ -728,7 +728,7 @@ export default class JiaZai extends cc.Component {
cc.fx.GameTool.shushu_Track("payment", dataSuccess); cc.fx.GameTool.shushu_Track("payment", dataSuccess);
let version = cc.fx.GameTool.getWechatGameVersion(); let version = cc.fx.GameTool.getWechatGameVersion();
if (version == "正式版") { if (version == "正式版") {
MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name); MiniGameSdk.API.yinli_Pay(price, order.outTradeNo, name);
} }
@ -940,6 +940,11 @@ export default class JiaZai extends cc.Component {
cc.fx.GameConfig.GM_INFO.otherLevel = level; cc.fx.GameConfig.GM_INFO.otherLevel = level;
console.log('从分享链接获取到的关卡信息:', level); console.log('从分享链接获取到的关卡信息:', level);
console.log('从分享链接获取到的 UID:', uid); console.log('从分享链接获取到的 UID:', uid);
let eventData = {
identity: "helper", //发起者为helped 帮助者为helper
level: level //被帮助关卡等级
}
cc.fx.GameTool.shushu_Track("stage_help", eventData); //帮助通关
this.openLoad(); this.openLoad();
} }

View File

@ -1794,7 +1794,6 @@ export default class MapConroler extends cc.Component {
//执行复活函数 //执行复活函数
runRewiveCopy() { runRewiveCopy() {
this.isreview = true; this.isreview = true;
console.log("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww")
MiniGameSdk.API.showToast("继续游戏"); MiniGameSdk.API.showToast("继续游戏");
this.gameOver = false; this.gameOver = false;
this.gameWin = false; this.gameWin = false;
@ -1912,6 +1911,14 @@ export default class MapConroler extends cc.Component {
if (type == "boom" || type == "lock") { if (type == "boom" || type == "lock") {
time = 2000; time = 2000;
} }
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
let eventData = {
identity: "helper", //发起者为helped 帮助者为helper
level: cc.fx.GameConfig.GM_INFO.otherLevel, //被帮助关卡等级
success: false, //是否成功
}
cc.fx.GameTool.shushu_Track("stage_help", eventData); //帮助通关
}
setTimeout(() => { setTimeout(() => {
this.node.parent.parent.getChildByName("Lose").active = true; this.node.parent.parent.getChildByName("Lose").active = true;
@ -1925,9 +1932,14 @@ export default class MapConroler extends cc.Component {
this.revive.getComponent(Revive).init(); this.revive.getComponent(Revive).init();
this.node.parent.parent.getChildByName("Lose").getChildByName("lose").getChildByName("Boom").active = false; this.node.parent.parent.getChildByName("Lose").getChildByName("lose").getChildByName("Boom").active = false;
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) { if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
this.node.parent.parent.getChildByName("Lose").getChildByName("lose").getChildByName("share").active = false; this.node.parent.parent.getChildByName("Lose").getChildByName("share").active = false;
}
else {
console.log("有分享按钮");
setTimeout(() => {
this.node.parent.parent.getChildByName("Lose").getChildByName("share").active = true;
}, 350);
} }
else this.node.parent.parent.getChildByName("Lose").getChildByName("lose").getChildByName("share").active = true;
if (type) { if (type) {
if (type == "time") { if (type == "time") {
this.node.parent.parent.getChildByName("Lose").getChildByName("lose").getChildByName("Time").active = true; this.node.parent.parent.getChildByName("Lose").getChildByName("lose").getChildByName("Time").active = true;
@ -1993,7 +2005,7 @@ export default class MapConroler extends cc.Component {
.to(0.2, { scale: 1.05 }, { easing: 'backOut' }) .to(0.2, { scale: 1.05 }, { easing: 'backOut' })
.to(0.15, { scale: 1.0 }, { easing: 'sineOut' }) .to(0.15, { scale: 1.0 }, { easing: 'sineOut' })
.start(); .start();
this.node.parent.parent.getChildByName("NewMode").getChildByName("newmode").getComponent("NewMode").setMode(type); this.node.parent.parent.getChildByName("NewMode").getComponent("NewMode").setMode(type);
} }
@ -3144,7 +3156,13 @@ export default class MapConroler extends cc.Component {
.delay(0.1) .delay(0.1)
//.to(0, { position: cc.v3(0, -880, 0), scale: 0 }) //.to(0, { position: cc.v3(0, -880, 0), scale: 0 })
.call(() => { .call(() => {
nextBtn.active = true; if (cc.fx.GameConfig.GM_INFO.otherLevel == 0) {
nextBtn.active = true;
}
else {
cc.fx.GameConfig.GM_INFO.otherLevel = 0;
cc.fx.GameConfig.GM_INFO.otherUid = "";
}
}) })
.to(0.15, { scale: 1.25 }, { easing: 'backOut' }) .to(0.15, { scale: 1.25 }, { easing: 'backOut' })
.to(0.08, { scale: 0.9 }, { easing: 'quadIn' }) .to(0.08, { scale: 0.9 }, { easing: 'quadIn' })
@ -3240,8 +3258,15 @@ export default class MapConroler extends cc.Component {
setOtherLevel() { setOtherLevel() {
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) { if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
console.log("帮助他人通关");
let level = cc.fx.GameConfig.GM_INFO.otherLevel; let level = cc.fx.GameConfig.GM_INFO.otherLevel;
let uid = cc.fx.GameConfig.GM_INFO.otherUid; let uid = cc.fx.GameConfig.GM_INFO.otherUid;
let eventData = {
identity: "helper", //发起者为helped 帮助者为helper
level: level, //被帮助关卡等级
success: true, //是否成功
}
cc.fx.GameTool.shushu_Track("stage_help", eventData); //帮助通关
Utils.shareLevel(level, uid, (data) => { Utils.shareLevel(level, uid, (data) => {
console.log("分享结果:", data); console.log("分享结果:", data);
}); });

View File

@ -5,7 +5,7 @@
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class NewClass extends cc.Component { export default class NewClass extends cc.Component {
@ -24,40 +24,40 @@ export default class NewClass extends cc.Component {
// onLoad () {} // onLoad () {}
start () { start() {
for(let i=0; i<cc.fx.GameConfig.NEW_LEVEL.length; i++){ for (let i = 0; i < cc.fx.GameConfig.NEW_LEVEL.length; i++) {
if((cc.fx.GameConfig.GM_INFO.level+1) == cc.fx.GameConfig.NEW_LEVEL[i].level){ if ((cc.fx.GameConfig.GM_INFO.level + 1) == cc.fx.GameConfig.NEW_LEVEL[i].level) {
this.propName = cc.fx.GameConfig.NEW_LEVEL[i].name; this.propName = cc.fx.GameConfig.NEW_LEVEL[i].name;
const path = 'Window_Prop/' + this.propName; const path = 'Window_Prop/' + this.propName;
cc.resources.load(path, cc.SpriteFrame, (err, spriteFrame: cc.SpriteFrame) => { cc.resources.load(path, cc.SpriteFrame, (err, spriteFrame: cc.SpriteFrame) => {
if (err) { if (err) {
console.error('动态加载背景图失败:', err); console.error('动态加载背景图失败:', err);
return; return;
} }
this.node.getChildByName("icon").getComponent(cc.Sprite).spriteFrame = spriteFrame; this.node.getChildByName("newmode").getChildByName("icon").getComponent(cc.Sprite).spriteFrame = spriteFrame;
}) })
break; break;
} }
} }
} }
setMode(mode:number){ setMode(mode: number) {
this.btnStatic = mode; this.btnStatic = mode;
let name = "GameScene"; let name = "GameScene";
if(mode == 1){ if (mode == 1) {
name = "HomeScene"; name = "HomeScene";
} }
cc.director.preloadScene(name, ()=>{ cc.director.preloadScene(name, () => {
}) })
} }
clickBtn(){ clickBtn() {
cc.fx.AudioManager._instance.playEffect("anniu_Big",null); cc.fx.AudioManager._instance.playEffect("anniu_Big", null);
if(this.btnStatic == 1){ if (this.btnStatic == 1) {
cc.director.loadScene("HomeScene"); cc.director.loadScene("HomeScene");
} }
else if(this.btnStatic == 2){ else if (this.btnStatic == 2) {
cc.director.loadScene("GameScene"); cc.director.loadScene("GameScene");
} }
} }

View File

@ -45,18 +45,21 @@ export default class Revive extends cc.Component {
Utils.getIosPayInfo(iosOutTradeNo, Utils.getIosPayInfo(iosOutTradeNo,
(data) => { (data) => {
console.log("获得轮训结果:", data); console.log("获得轮训结果:", data);
const iosID = data.data?.payment_name || this.iosProductId;
let iosAmount = data.data?.goodsPrice || this.iosPrice;
iosAmount = parseInt(iosAmount);
if (data.code == 1) { if (data.code == 1) {
console.log("购买成功"); console.log("购买成功");
const dataSuccess = { const dataSuccess = {
outTradeNo: iosOutTradeNo, outTradeNo: iosOutTradeNo,
pay_amount: this.iosPrice, pay_amount: iosAmount,
payment_name: this.iosProductId, payment_name: iosID,
payment_num: this.iosCount, payment_num: this.iosCount,
type: "ios", type: "ios",
} }
cc.fx.GameTool.shushu_Track("payment", dataSuccess); cc.fx.GameTool.shushu_Track("payment", dataSuccess);
let name = "购买金币道具:" + this.iosProductId; let name = "购买金币道具:" + iosID;
MiniGameSdk.API.yinli_Pay(this.iosPrice, iosOutTradeNo, name) MiniGameSdk.API.yinli_Pay(iosAmount, iosOutTradeNo, name)
Utils.setPayInfo( Utils.setPayInfo(
(res) => { (res) => {
this.closeLoad(); this.closeLoad();
@ -64,9 +67,9 @@ export default class Revive extends cc.Component {
if (res.code === 1) { if (res.code === 1) {
console.log("_________正式发货"); console.log("_________正式发货");
MiniGameSdk.API.showToast("充值成功"); MiniGameSdk.API.showToast("充值成功");
cc.fx.GameTool.shopBuy(this.iosProductId, false); cc.fx.GameTool.shopBuy(iosID, false);
this.revivew() this.revivew()
if (this.iosProductId == "reborn_Gift") { if (iosID == "reborn_Gift") {
this.buyGift(); this.buyGift();
} }
//console.log("充值成功获得金币"); //console.log("充值成功获得金币");
@ -75,16 +78,16 @@ export default class Revive extends cc.Component {
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放"); MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
const dataFail4 = { const dataFail4 = {
outTradeNo: iosOutTradeNo, outTradeNo: iosOutTradeNo,
price: this.iosPrice, pay_amount: iosAmount,
payment_name: this.iosProductId, payment_name: iosID,
payment_num: this.iosCount, payment_num: this.iosCount,
type: "ios", type: "ios",
fail_reason: "成功付款,但是发货时请求服务器失败,充值成功未发货", fail_reason: "成功付款,但是发货时请求服务器失败,充值成功未发货",
} }
cc.fx.GameTool.shushu_Track("payment_fail", dataFail4); cc.fx.GameTool.shushu_Track("payment_fail", dataFail4);
} }
if (this.node.parent.parent.parent.parent.getComponent("SceneManager")) { if (this.node.parent.parent.parent.parent.parent.getComponent("SceneManager")) {
this.node.parent.parent.parent.parent.getComponent("SceneManager").updateCoin(); this.node.parent.parent.parent.parent.parent.getComponent("SceneManager").updateCoin();
} }
}, iosOutTradeNo) }, iosOutTradeNo)
} }
@ -95,8 +98,8 @@ export default class Revive extends cc.Component {
this.btn_Touch = true; this.btn_Touch = true;
const dataFail = { const dataFail = {
outTradeNo: iosOutTradeNo, outTradeNo: iosOutTradeNo,
price: this.iosPrice, pay_amount: iosAmount,
payment_name: this.iosProductId, payment_name: iosID,
payment_num: this.iosCount, payment_num: this.iosCount,
type: "ios", type: "ios",
fail_reason: "用户取消充值", fail_reason: "用户取消充值",
@ -109,8 +112,8 @@ export default class Revive extends cc.Component {
MiniGameSdk.API.showToast("订单已关闭"); MiniGameSdk.API.showToast("订单已关闭");
const dataFail = { const dataFail = {
outTradeNo: iosOutTradeNo, outTradeNo: iosOutTradeNo,
price: this.iosPrice, pay_amount: iosAmount,
payment_name: this.iosProductId, payment_name: iosID,
payment_num: this.iosCount, payment_num: this.iosCount,
type: "ios", type: "ios",
fail_reason: "用户充值后,轮训结果超时", fail_reason: "用户充值后,轮训结果超时",
@ -245,15 +248,15 @@ export default class Revive extends cc.Component {
this.openLoad(); this.openLoad();
this.btn_Touch = true; this.btn_Touch = true;
//console.log("7.14_____________________", "调用充值接口"); console.log("7.14_____________________", "调用充值接口");
Utils.buyProp(id, count, price, systemType, productId, (res) => { Utils.buyProp(id, count, price, systemType, productId, (res) => {
//console.log("获得充值结果", res); console.log("获得充值结果", res);
if (res == null) { if (res == null) {
MiniGameSdk.API.showToast("充值失败"); MiniGameSdk.API.showToast("充值失败");
this.btn_Touch = true; this.btn_Touch = true;
const dataFail = { const dataFail = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -273,7 +276,7 @@ export default class Revive extends cc.Component {
} }
const dataFail = { const dataFail = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -285,15 +288,15 @@ export default class Revive extends cc.Component {
} }
else { else {
Utils.getPayInfo((data) => { Utils.getPayInfo((data) => {
//console.log("7.14_______________充值成功,准备轮训"); console.log("7.14_______________充值成功,准备轮训");
//console.log("获得轮训结果:", data); console.log("获得轮训结果:", data);
this.closeLoad(); this.closeLoad();
if (data.data.pay_state == 1) { if (data.data.pay_state == 1) {
this.btn_Touch = true; this.btn_Touch = true;
MiniGameSdk.API.showToast("取消充值"); MiniGameSdk.API.showToast("取消充值");
const dataFail2 = { const dataFail2 = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -331,7 +334,7 @@ export default class Revive extends cc.Component {
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放"); MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
const dataFail4 = { const dataFail4 = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -340,8 +343,8 @@ export default class Revive extends cc.Component {
cc.fx.GameTool.shushu_Track("payment_fail", dataFail4); cc.fx.GameTool.shushu_Track("payment_fail", dataFail4);
} }
if (this.node.parent.parent.parent.parent.getComponent("SceneManager")) { if (this.node.parent.parent.parent.parent.parent.getComponent("SceneManager")) {
this.node.parent.parent.parent.parent.getComponent("SceneManager").updateCoin(); this.node.parent.parent.parent.parent.parent.getComponent("SceneManager").updateCoin();
} }
}, Utils.outTradeNo) }, Utils.outTradeNo)
} }
@ -349,7 +352,7 @@ export default class Revive extends cc.Component {
const dataFail3 = { const dataFail3 = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -357,8 +360,8 @@ export default class Revive extends cc.Component {
} }
cc.fx.GameTool.shushu_Track("payment_fail", dataFail3); cc.fx.GameTool.shushu_Track("payment_fail", dataFail3);
this.btn_Touch = true; this.btn_Touch = true;
if (this.node.parent.parent.parent.parent.getComponent("SceneManager")) { if (this.node.parent.parent.parent.parent.parent.getComponent("SceneManager")) {
this.node.parent.parent.parent.parent.getComponent("SceneManager").updateCoin(); this.node.parent.parent.parent.parent.parent.getComponent("SceneManager").updateCoin();
} }
} }
}) })
@ -367,13 +370,13 @@ export default class Revive extends cc.Component {
} }
} }
openLoad() { openLoad() {
this.node.parent.parent.parent.parent.getChildByName("Loading").active = true; this.node.parent.parent.parent.parent.parent.getChildByName("Loading").active = true;
this.node.parent.parent.parent.parent.getChildByName("Loading").getChildByName("load").stopAllActions(); this.node.parent.parent.parent.parent.parent.getChildByName("Loading").getChildByName("load").stopAllActions();
this.node.parent.parent.parent.parent.getChildByName("Loading").getChildByName("load").runAction(cc.rotateTo(2, 1080).repeatForever()); this.node.parent.parent.parent.parent.parent.getChildByName("Loading").getChildByName("load").runAction(cc.rotateTo(2, 1080).repeatForever());
} }
closeLoad() { closeLoad() {
this.node.parent.parent.parent.parent.getChildByName("Loading").active = false; this.node.parent.parent.parent.parent.parent.getChildByName("Loading").active = false;
} }

View File

@ -1110,7 +1110,7 @@ export namespace MiniGameSdk {
static shushu_Init() { static shushu_Init() {
if (typeof wx !== 'undefined' && wx !== null) { if (typeof wx !== 'undefined' && wx !== null) {
console.log("开始接入数数平台"); // console.log("开始接入数数平台");
//getWechatGameVersion //getWechatGameVersion
let appId = "121591378fc1423893deb12041413eb3"; let appId = "121591378fc1423893deb12041413eb3";
let test = cc.fx.GameTool.getWechatGameVersion(); let test = cc.fx.GameTool.getWechatGameVersion();
@ -1137,24 +1137,24 @@ export namespace MiniGameSdk {
const distinctId = MiniGameSdk.API.getShushuDistinctId(); const distinctId = MiniGameSdk.API.getShushuDistinctId();
if (distinctId) { if (distinctId) {
cc.fx.GameConfig.GM_INFO.shushu_DistinctId = distinctId; cc.fx.GameConfig.GM_INFO.shushu_DistinctId = distinctId;
console.log('用户的 distinct_id 是:', distinctId); // console.log('用户的 distinct_id 是:', distinctId);
} else { } else {
console.log('未获取到用户的 distinct_id'); // console.log('未获取到用户的 distinct_id');
} }
const accountId = MiniGameSdk.API.getShushuAccountId(); const accountId = MiniGameSdk.API.getShushuAccountId();
if (accountId) { if (accountId) {
cc.fx.GameConfig.GM_INFO.shushu_AccountId = accountId; cc.fx.GameConfig.GM_INFO.shushu_AccountId = accountId;
console.log('用户的 account_id 是:', accountId); // console.log('用户的 account_id 是:', accountId);
} else { } else {
console.log('未获取到用户的 account_id'); // console.log('未获取到用户的 account_id');
} }
} }
} }
static shushu_Login() { static shushu_Login() {
if (typeof wx !== 'undefined' && wx !== null) { if (typeof wx !== 'undefined' && wx !== null) {
console.log("数数登录时获取到的openId:", cc.fx.GameConfig.GM_INFO.openid); // console.log("数数登录时获取到的openId:", cc.fx.GameConfig.GM_INFO.openid);
API._ta.login(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; cc.fx.GameConfig.GM_INFO.shushu_AccountId = cc.fx.GameConfig.GM_INFO.openid;
const result = "success"; const result = "success";
@ -1165,7 +1165,7 @@ export namespace MiniGameSdk {
static shushu_userSet(time) { static shushu_userSet(time) {
if (typeof wx !== 'undefined' && wx !== null) { if (typeof wx !== 'undefined' && wx !== null) {
console.log("设置用户注册属性"); // console.log("设置用户注册属性");
API._ta.userSet({ register_time: time }); API._ta.userSet({ register_time: time });
API._ta.userSet({ uid: cc.fx.GameConfig.GM_INFO.uid.toString() }); API._ta.userSet({ uid: cc.fx.GameConfig.GM_INFO.uid.toString() });
} }
@ -1173,7 +1173,7 @@ export namespace MiniGameSdk {
static updateCoinAndLevel() { static updateCoinAndLevel() {
if (typeof wx !== 'undefined' && wx !== null) { if (typeof wx !== 'undefined' && wx !== null) {
console.log("上传金币和关卡信息给数数") // console.log("上传金币和关卡信息给数数")
API._ta.userSet({ current_level: (cc.fx.GameConfig.GM_INFO.level + 1) }); API._ta.userSet({ current_level: (cc.fx.GameConfig.GM_INFO.level + 1) });
API._ta.userSet({ current_coin: cc.fx.GameConfig.GM_INFO.coin }); API._ta.userSet({ current_coin: cc.fx.GameConfig.GM_INFO.coin });
API._ta.userSet({ uid: cc.fx.GameConfig.GM_INFO.uid.toString() }); API._ta.userSet({ uid: cc.fx.GameConfig.GM_INFO.uid.toString() });
@ -1195,7 +1195,7 @@ export namespace MiniGameSdk {
uid: cc.fx.GameConfig.GM_INFO.uid.toString() //用户id uid: cc.fx.GameConfig.GM_INFO.uid.toString() //用户id
}; };
if (register_time != null) { if (register_time != null) {
console.log("设置用户公共属性注册:————————————", register_time); // console.log("设置用户公共属性注册:————————————", register_time);
superProperties = { superProperties = {
current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number
current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值 current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值
@ -1207,7 +1207,7 @@ export namespace MiniGameSdk {
}; };
} }
if (pay_user != null && pay_user != false) { if (pay_user != null && pay_user != false) {
console.log("设置用户公共属性支付:————————————", pay_user); // console.log("设置用户公共属性支付:————————————", pay_user);
superProperties = { superProperties = {
current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number
current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值 current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值
@ -1218,7 +1218,7 @@ export namespace MiniGameSdk {
} }
} }
// @ts-ignore // @ts-ignore
console.log("设置公共属性时:————————————", superProperties.uid); // console.log("设置公共属性时:————————————", superProperties.uid);
API._ta.setSuperProperties(superProperties);//设置公共事件属性 API._ta.setSuperProperties(superProperties);//设置公共事件属性
API.updateCoinAndLevel(); API.updateCoinAndLevel();
} }
@ -1305,10 +1305,10 @@ export namespace MiniGameSdk {
enable_sync_attribution: false,//渠道归因 enable_sync_attribution: false,//渠道归因
}) })
.then((res) => { .then((res) => {
console.log("引力引擎初始化成功", res) // console.log("引力引擎初始化成功", res)
}) })
.catch((err) => { .catch((err) => {
console.log("引力引擎初始化失败 " + err); // console.log("引力引擎初始化失败 " + err);
}); });
if (cc.fx.GameConfig.GM_INFO.shushu_AccountId == "") cc.fx.GameConfig.GM_INFO.shushu_AccountId = if (cc.fx.GameConfig.GM_INFO.shushu_AccountId == "") cc.fx.GameConfig.GM_INFO.shushu_AccountId =
@ -1369,6 +1369,12 @@ export namespace MiniGameSdk {
if (cc.sys.platform === cc.sys.WECHAT_GAME) { if (cc.sys.platform === cc.sys.WECHAT_GAME) {
//@ts-ignore //@ts-ignore
wx.shareAppMessage(shareParams); wx.shareAppMessage(shareParams);
let eventData = {
identity: "helped", //发起者为helped 帮助者为helper
level: level //被帮助关卡等级
}
console.log("分享给好友", eventData);
cc.fx.GameTool.shushu_Track("stage_help", eventData); //帮助通关
} }
} }
} }

View File

@ -12,8 +12,8 @@ export default class Utils {
static getUserInfo(callBack) { static getUserInfo(callBack) {
wx.login({ wx.login({
success(res) { success(res) {
console.log("微信login成功"); //console.log("微信login成功");
console.log(res.code); //console.log(res.code);
if (res.code) { if (res.code) {
// 延迟时间数组,可按需调整 // 延迟时间数组,可按需调整
const delays = [1000, 2000, 3000, 4000, 5000]; const delays = [1000, 2000, 3000, 4000, 5000];
@ -21,13 +21,13 @@ export default class Utils {
const poll = () => { const poll = () => {
if (attempt >= delays.length) { if (attempt >= delays.length) {
console.log('登录请求轮询超时'); //console.log('登录请求轮询超时');
callBack({ code: 0, data: { openid: "登录失败" }, message: '轮询超时' }); callBack({ code: 0, data: { openid: "登录失败" }, message: '轮询超时' });
return; return;
} }
Utils.POST("login", { code: res.code }, ret => { Utils.POST("login", { code: res.code }, ret => {
console.log("请求结果:", ret); //console.log("请求结果:", ret);
if (ret.code === 1) { // 假设返回 code 为 1 表示成功 if (ret.code === 1) { // 假设返回 code 为 1 表示成功
Utils.openid = ret.data.openid; Utils.openid = ret.data.openid;
Utils.session_key = ret.data.session_key; Utils.session_key = ret.data.session_key;
@ -42,7 +42,7 @@ export default class Utils {
poll(); poll();
} else { } else {
console.log('登录失败!' + res.errMsg) //console.log('登录失败!' + res.errMsg)
callBack({ code: 0, data: { openid: "登录失败" }, message: res.errMsg }); callBack({ code: 0, data: { openid: "登录失败" }, message: res.errMsg });
} }
} }
@ -51,7 +51,7 @@ export default class Utils {
/**道具直购接口*/ /**道具直购接口*/
static buyProp(id, count, price, systemType, productId, callBack) { static buyProp(id, count, price, systemType, productId, callBack) {
console.log("请求uid:" + Utils.uid, "请求id:" + id, "请求数量:" + count, "请求价格:" + price); //console.log("请求uid:" + Utils.uid, "请求id:" + id, "请求数量:" + count, "请求价格:" + price);
Utils.POST("wx/orderPaySig", { uid: Utils.uid, itemid: id, itemCount: count, itemPrice: price }, res => { Utils.POST("wx/orderPaySig", { uid: Utils.uid, itemid: id, itemCount: count, itemPrice: price }, res => {
if (res.code == 1) { if (res.code == 1) {
@ -63,7 +63,7 @@ export default class Utils {
type: systemType, type: systemType,
} }
cc.fx.GameTool.shushu_Track("init_order", data); cc.fx.GameTool.shushu_Track("init_order", data);
console.log("创建的最新订单的订单号:", Utils.outTradeNo); //console.log("创建的最新订单的订单号:", Utils.outTradeNo);
// let timeoutId: number; // let timeoutId: number;
// const timeoutDuration = 30000; // 30 秒超时时间 // const timeoutDuration = 30000; // 30 秒超时时间
// // 设置超时定时器 // // 设置超时定时器
@ -78,13 +78,13 @@ export default class Utils {
signature: res.data.signature, signature: res.data.signature,
success(res, errCode) { success(res, errCode) {
// clearTimeout(timeoutId); // 清除超时定时器 // clearTimeout(timeoutId); // 清除超时定时器
console.log('成功', res, errCode); //console.log('成功', res, errCode);
callBack(res); callBack(res);
}, },
fail({ errMsg, errCode }) { fail({ errMsg, errCode }) {
// clearTimeout(timeoutId); // 清除超时定时器 // clearTimeout(timeoutId); // 清除超时定时器
console.log('失败'); //console.log('失败');
console.log(errMsg, errCode) //console.log(errMsg, errCode)
let data = { let data = {
errMsg: errMsg, errMsg: errMsg,
errCode: errCode, errCode: errCode,
@ -116,10 +116,10 @@ export default class Utils {
return; return;
} }
console.log("请求uid:", Utils.uid); //console.log("请求uid:", Utils.uid);
console.log("outTradeNo:", Utils.outTradeNo); //console.log("outTradeNo:", Utils.outTradeNo);
Utils.POST("wx/getPayInfo", { uid: Utils.uid, outTradeNo: Utils.outTradeNo }, res => { Utils.POST("wx/getPayInfo", { uid: Utils.uid, outTradeNo: Utils.outTradeNo }, res => {
console.log("查询字符结果:", res); //console.log("查询字符结果:", res);
if (res.code === 1 && (res.data.pay_state === 1 || res.data.pay_state === 2)) { if (res.code === 1 && (res.data.pay_state === 1 || res.data.pay_state === 2)) {
callBack(res); callBack(res);
} else { } else {
@ -143,16 +143,16 @@ export default class Utils {
} }
let orderTemp = Utils.outTradeNo; let orderTemp = Utils.outTradeNo;
if (order) orderTemp = order; if (order) orderTemp = order;
console.log("告知服务器发货的订单号:", orderTemp); //console.log("告知服务器发货的订单号:", orderTemp);
Utils.POST("wx/getOrderReward", { outTradeNo: orderTemp }, res => { Utils.POST("wx/getOrderReward", { outTradeNo: orderTemp }, res => {
console.log("告知服务器发货:", res); //console.log("告知服务器发货:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("告知服务器发货成功:", res); //console.log("告知服务器发货成功:", res);
// 请求成功,调用回调并返回结果 // 请求成功,调用回调并返回结果
callBack(res); callBack(res);
} else { } else {
// 请求失败,增加重试次数并设置下一次请求的延迟 // 请求失败,增加重试次数并设置下一次请求的延迟
console.log("告知服务器发货失败:", res); //console.log("告知服务器发货失败:", res);
attempt++; attempt++;
if (attempt <= delays.length) { if (attempt <= delays.length) {
setTimeout(sendRequest, delays[attempt - 1]); setTimeout(sendRequest, delays[attempt - 1]);
@ -186,7 +186,7 @@ export default class Utils {
payment_num: iosPayInfo.payment_count, payment_num: iosPayInfo.payment_count,
type: "ios", type: "ios",
} }
console.log("ios创建订单信息:", data); //console.log("ios创建订单信息:", data);
cc.fx.GameTool.shushu_Track("init_order", shushu_data); cc.fx.GameTool.shushu_Track("init_order", shushu_data);
//@ts-ignore //@ts-ignore
wx.openCustomerServiceConversation({ wx.openCustomerServiceConversation({
@ -194,10 +194,10 @@ export default class Utils {
showMessageCard: false, // 是否展示消息卡片 showMessageCard: false, // 是否展示消息卡片
success() { success() {
callBack("success"); callBack("success");
console.log('客服会话已successr'); //console.log('客服会话已successr');
}, },
fail() { fail() {
console.log('客服会话已over'); //console.log('客服会话已over');
callBack("fail"); callBack("fail");
} }
}); });
@ -220,11 +220,11 @@ export default class Utils {
return; return;
} }
console.log("请求uid:" + Utils.uid); //console.log("请求uid:" + Utils.uid);
console.log("outTradeNo:" + iosOutTradeNo); //console.log("outTradeNo:" + iosOutTradeNo);
Utils.POST("wx/iosgetPayInfo", { outTradeNo: iosOutTradeNo }, res => { Utils.POST("wx/iosgetPayInfo", { outTradeNo: iosOutTradeNo }, res => {
console.log("查询字符结果IOS"); //console.log("查询字符结果IOS");
console.log(res); //console.log(res);
if (res.code === 1) { if (res.code === 1) {
callBack(res); callBack(res);
} else if (res.code === 0) { } else if (res.code === 0) {
@ -258,8 +258,8 @@ export default class Utils {
// //@ts-ignore // //@ts-ignore
// wx.login({ // wx.login({
// success (res) { // success (res) {
// console.log("登录成功"); // //console.log("登录成功");
// console.log(res); // //console.log(res);
// if (res.code) { // if (res.code) {
// //@ts-ignore // //@ts-ignore
// wx.cloud.callFunction({ // wx.cloud.callFunction({
@ -270,20 +270,20 @@ export default class Utils {
// code:res.code, // code:res.code,
// }, // },
// success: function(ret) { // success: function(ret) {
// console.log("请求成功"); // //console.log("请求成功");
// console.log("请求结果:"); // //console.log("请求结果:");
// console.log(ret); // //console.log(ret);
// Utils.openid=ret.data.openid; // Utils.openid=ret.data.openid;
// Utils.session_key=ret.data.session_key; // Utils.session_key=ret.data.session_key;
// Utils.uid=ret.data._id; // Utils.uid=ret.data._id;
// }, // },
// fail:function(res){ // fail:function(res){
// console.log("请求失败"); // //console.log("请求失败");
// console.log(res); // //console.log(res);
// } // }
// }) // })
// } else { // } else {
// console.log('登录失败!' + res.errMsg) // //console.log('登录失败!' + res.errMsg)
// } // }
// } // }
// }) // })
@ -302,18 +302,18 @@ export default class Utils {
// itemPrice:100 // itemPrice:100
// }, // },
// success: function(res) { // success: function(res) {
// console.log("请求成功"); // //console.log("请求成功");
// console.log(res) // //console.log(res)
// if(res.result.code==1){ // if(res.result.code==1){
// Utils.outTradeNo=res.result.data.outTradeNo; // Utils.outTradeNo=res.result.data.outTradeNo;
// console.log("订单号:"+Utils.outTradeNo); // //console.log("订单号:"+Utils.outTradeNo);
// //@ts-ignore // //@ts-ignore
// wx.requestMidasPaymentGameItem({ // wx.requestMidasPaymentGameItem({
// signData:res.result.data.signData, // signData:res.result.data.signData,
// paySig: res.result.data.paySig, // paySig: res.result.data.paySig,
// signature: res.result.data.signature, // signature: res.result.data.signature,
// success(res, errCode) { // success(res, errCode) {
// console.log('成功', res, errCode); // //console.log('成功', res, errCode);
// }, // },
// fail({errMsg,errCode}) { // fail({errMsg,errCode}) {
// console.error('失败'); // console.error('失败');
@ -324,8 +324,8 @@ export default class Utils {
// }, // },
// fail:function(res){ // fail:function(res){
// console.log("请求失败"); // //console.log("请求失败");
// console.log(res); // //console.log(res);
// } // }
// }) // })
// } // }
@ -341,13 +341,13 @@ export default class Utils {
// outTradeNo:Utils.outTradeNo // outTradeNo:Utils.outTradeNo
// }, // },
// success: function(res) { // success: function(res) {
// console.log("请求成功"); // //console.log("请求成功");
// console.log(res) // //console.log(res)
// callBack("成功"); // callBack("成功");
// }, // },
// fail:function(res){ // fail:function(res){
// console.log("请求失败"); // //console.log("请求失败");
// console.log(res); // //console.log(res);
// callBack("失败"); // callBack("失败");
// } // }
// }) // })
@ -364,12 +364,12 @@ export default class Utils {
// }, // },
// success: function(res) { // success: function(res) {
// console.log("请求成功"); // //console.log("请求成功");
// console.log(res) // //console.log(res)
// }, // },
// fail:function(res){ // fail:function(res){
// console.log("请求失败"); // //console.log("请求失败");
// console.log(res); // //console.log(res);
// } // }
// }) // })
// } // }
@ -397,7 +397,7 @@ export default class Utils {
dataStr = dataStr.substr(0, dataStr.lastIndexOf('&')); dataStr = dataStr.substr(0, dataStr.lastIndexOf('&'));
} }
url = this.httpip + url; url = this.httpip + url;
console.log("请求地址:" + url); //console.log("请求地址:" + url);
xhr.open("POST", url, true); xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
@ -447,8 +447,8 @@ export default class Utils {
} }
//组装完整的URL //组装完整的URL
let requestURL = extraUrl + "/" + path + encodeURI(sendtext); let requestURL = extraUrl + "/" + path + encodeURI(sendtext);
// console.log("发送请求:"); // //console.log("发送请求:");
// console.log(requestURL); // //console.log(requestURL);
//发送请求 Get形式发送请求 //发送请求 Get形式发送请求
xhr.open("GET", requestURL, true); xhr.open("GET", requestURL, true);
if (cc.sys.isNative) {//如果是手机就设置请求头 if (cc.sys.isNative) {//如果是手机就设置请求头
@ -460,7 +460,7 @@ export default class Utils {
//xhr.hasRetried=true; //xhr.hasRetried=true;
hasRetried = true; hasRetried = true;
xhr.abort(); xhr.abort();
console.log("http timeOut......"); //console.log("http timeOut......");
retryFun(); retryFun();
}, 5000); }, 5000);
//重新发送请求 //重新发送请求
@ -476,7 +476,7 @@ export default class Utils {
try { try {
ret = JSON.parse(respText); ret = JSON.parse(respText);
} catch (e) { } catch (e) {
console.log("http error:" + e); //console.log("http error:" + e);
ret = { ret = {
code: 1, code: 1,
msg: e msg: e
@ -493,7 +493,7 @@ export default class Utils {
if (hasRetried) { if (hasRetried) {
return; return;
} }
console.log('other readystate ==' + xhr.readyState + ', status:' + xhr.status); //console.log('other readystate ==' + xhr.readyState + ', status:' + xhr.status);
if (xhr.readyState == 4 && xhr.status == 0) { if (xhr.readyState == 4 && xhr.status == 0) {
handler({ handler({
err: 1, err: 1,
@ -532,12 +532,12 @@ export default class Utils {
} }
Utils.POST("userData", data, res => { Utils.POST("userData", data, res => {
console.log("获得userData数据:", res); //console.log("获得userData数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:获取用户数据成功", res); //console.log("服务器:获取用户数据成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
console.log("服务器:获取用户数据失败", res); //console.log("服务器:获取用户数据失败", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -559,12 +559,12 @@ export default class Utils {
userData: data userData: data
} }
Utils.POST("userData", setData, res => { Utils.POST("userData", setData, res => {
console.log("获得userData数据:", res); //console.log("获得userData数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:获取用户数据成功", res); //console.log("服务器:获取用户数据成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
console.log("服务器:获取用户数据失败", res); //console.log("服务器:获取用户数据失败", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -585,12 +585,12 @@ export default class Utils {
action: 'read', action: 'read',
} }
Utils.POST("userCoin", setData, res => { Utils.POST("userCoin", setData, res => {
console.log("获得userCoin数据:", res); //console.log("获得userCoin数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:获得金币成功", res); //console.log("服务器:获得金币成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
console.log("服务器:获得金币失败", res); //console.log("服务器:获得金币失败", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -611,14 +611,14 @@ export default class Utils {
action: 'save', action: 'save',
coinAmount: Math.floor(cc.fx.GameConfig.GM_INFO.coin) coinAmount: Math.floor(cc.fx.GameConfig.GM_INFO.coin)
} }
console.log("服务器:上传金币", Math.floor(cc.fx.GameConfig.GM_INFO.coin)); //console.log("服务器:上传金币", Math.floor(cc.fx.GameConfig.GM_INFO.coin));
Utils.POST("userCoin", setData, res => { Utils.POST("userCoin", setData, res => {
console.log("获得userCoin数据:", res); //console.log("获得userCoin数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:上传金币成功", res); //console.log("服务器:上传金币成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
console.log("服务器:上传金币失败", res); //console.log("服务器:上传金币失败", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -639,12 +639,12 @@ export default class Utils {
action: 'read', action: 'read',
} }
Utils.POST("userLevel", setData, res => { Utils.POST("userLevel", setData, res => {
console.log("获得userLevel数据:", res); //console.log("获得userLevel数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:获得等级成功", res); //console.log("服务器:获得等级成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
console.log("服务器:获得等级失败", res); //console.log("服务器:获得等级失败", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -666,12 +666,12 @@ export default class Utils {
levelAmount: parseInt(cc.fx.GameConfig.GM_INFO.level) levelAmount: parseInt(cc.fx.GameConfig.GM_INFO.level)
} }
Utils.POST("userLevel", setData, res => { Utils.POST("userLevel", setData, res => {
console.log("获得userLevel数据:", res); //console.log("获得userLevel数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:上传等级成功", res); //console.log("服务器:上传等级成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
console.log("服务器:上传等级失败", res); //console.log("服务器:上传等级失败", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -692,12 +692,12 @@ export default class Utils {
action: 'read', action: 'read',
} }
Utils.POST("userProp", setData, res => { Utils.POST("userProp", setData, res => {
console.log("获得userProp数据:", res); //console.log("获得userProp数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:获得道具成功", res); //console.log("服务器:获得道具成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
console.log("服务器:获得道具失败", res); //console.log("服务器:获得道具失败", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -731,14 +731,14 @@ export default class Utils {
} }
} }
console.log("上传道具类型", propid, "上传道具数量:", amount); //console.log("上传道具类型", propid, "上传道具数量:", amount);
Utils.POST("userProp", setData, res => { Utils.POST("userProp", setData, res => {
console.log("获得userProp数据:", res); //console.log("获得userProp数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:上传道具成功", res); //console.log("服务器:上传道具成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
console.log("服务器:上传道具失败", res); //console.log("服务器:上传道具失败", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -760,12 +760,12 @@ export default class Utils {
action: 'read', action: 'read',
} }
Utils.POST("userHealth", setData, res => { Utils.POST("userHealth", setData, res => {
console.log("获得userHealth数据:", res); //console.log("获得userHealth数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:获得体力成功", res); //console.log("服务器:获得体力成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
console.log("服务器:获得体力失败", res); //console.log("服务器:获得体力失败", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -788,12 +788,12 @@ export default class Utils {
timestamp: timestamp timestamp: timestamp
} }
Utils.POST("userHealth", setData, res => { Utils.POST("userHealth", setData, res => {
console.log("获得userHealth数据:", res); //console.log("获得userHealth数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:上传体力成功", res); //console.log("服务器:上传体力成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
console.log("服务器:上传体力失败", res); //console.log("服务器:上传体力失败", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -814,12 +814,12 @@ export default class Utils {
action: 'read', action: 'read',
} }
Utils.POST("userPower", setData, res => { Utils.POST("userPower", setData, res => {
console.log("获得userPower数据:", res); //console.log("获得userPower数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:获得无限体力成功", res); //console.log("服务器:获得无限体力成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
console.log("服务器:获得无限体力失败", res); //console.log("服务器:获得无限体力失败", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -842,12 +842,12 @@ export default class Utils {
} }
Utils.POST("userPower", setData, res => { Utils.POST("userPower", setData, res => {
console.log("获得userPower数据:", res); //console.log("获得userPower数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:上传无限体力成功", res); //console.log("服务器:上传无限体力成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
console.log("服务器:上传无限体力失败", res); //console.log("服务器:上传无限体力失败", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -865,12 +865,12 @@ export default class Utils {
uid: cc.fx.GameConfig.GM_INFO.uid, uid: cc.fx.GameConfig.GM_INFO.uid,
} }
Utils.POST("monthGetReward", setData, res => { Utils.POST("monthGetReward", setData, res => {
// console.log("获得monthGetReward数据:", res); // //console.log("获得monthGetReward数据:", res);
if (res.code === 1) { if (res.code === 1) {
// console.log("服务器:领取获得monthGetReward成功'✅ ", res); // //console.log("服务器:领取获得monthGetReward成功'✅ ", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
// console.log("服务器:获得monthGetReward失败'❌ ", res); // //console.log("服务器:获得monthGetReward失败'❌ ", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -881,7 +881,7 @@ export default class Utils {
static getMonthlyCard(callBack) { static getMonthlyCard(callBack) {
if (typeof wx !== 'undefined' && wx !== null) { if (typeof wx !== 'undefined' && wx !== null) {
let uid = cc.fx.StorageMessage.getStorage("uid"); let uid = cc.fx.StorageMessage.getStorage("uid");
// console.log("获取monthlyCard信息:", uid, monthCardTime); // //console.log("获取monthlyCard信息:", uid, monthCardTime);
//旧的读取数据设置数据方法,以强联网为主 //旧的读取数据设置数据方法,以强联网为主
if (uid != undefined && uid != "" && uid != null) { if (uid != undefined && uid != "" && uid != null) {
cc.fx.GameConfig.GM_INFO.uid = uid; cc.fx.GameConfig.GM_INFO.uid = uid;
@ -892,12 +892,12 @@ export default class Utils {
} }
Utils.POST("monthlyCard", setData, res => { Utils.POST("monthlyCard", setData, res => {
// console.log("获得monthlyCard数据:", res); // //console.log("获得monthlyCard数据:", res);
if (res.code === 1) { if (res.code === 1) {
// console.log("服务器:获取monthlyCard成功'✅ ", res); // //console.log("服务器:获取monthlyCard成功'✅ ", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
// console.log("服务器:获取monthlyCard失败'❌ ", res); // //console.log("服务器:获取monthlyCard失败'❌ ", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -908,7 +908,7 @@ export default class Utils {
static setMonthlyCard(monthCardTime, callBack) { static setMonthlyCard(monthCardTime, callBack) {
if (typeof wx !== 'undefined' && wx !== null) { if (typeof wx !== 'undefined' && wx !== null) {
let uid = cc.fx.StorageMessage.getStorage("uid"); let uid = cc.fx.StorageMessage.getStorage("uid");
// console.log("上传monthlyCard信息:", uid, monthCardTime); // //console.log("上传monthlyCard信息:", uid, monthCardTime);
//旧的读取数据设置数据方法,以强联网为主 //旧的读取数据设置数据方法,以强联网为主
if (uid != undefined && uid != "" && uid != null) { if (uid != undefined && uid != "" && uid != null) {
cc.fx.GameConfig.GM_INFO.uid = uid; cc.fx.GameConfig.GM_INFO.uid = uid;
@ -920,12 +920,12 @@ export default class Utils {
} }
Utils.POST("monthlyCard", setData, res => { Utils.POST("monthlyCard", setData, res => {
// console.log("获得monthlyCard数据:", res); // //console.log("获得monthlyCard数据:", res);
if (res.code === 1) { if (res.code === 1) {
// console.log("服务器:上传monthlyCard成功'✅ ", res); // //console.log("服务器:上传monthlyCard成功'✅ ", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
// console.log("服务器:上传monthlyCard失败'❌ ", res); // //console.log("服务器:上传monthlyCard失败'❌ ", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -946,7 +946,7 @@ export default class Utils {
Utils.POST("canRebonGift", setData, res => { Utils.POST("canRebonGift", setData, res => {
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:canRebonGift'✅ ", res); //console.log("服务器:canRebonGift'✅ ", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
if (callBack) callBack(res); if (callBack) callBack(res);
@ -960,7 +960,7 @@ export default class Utils {
static rebornGift(rebornGift, callBack) { static rebornGift(rebornGift, callBack) {
if (typeof wx !== 'undefined' && wx !== null) { if (typeof wx !== 'undefined' && wx !== null) {
let uid = cc.fx.StorageMessage.getStorage("uid"); let uid = cc.fx.StorageMessage.getStorage("uid");
// console.log("上传monthlyCard信息:", uid, monthCardTime); // //console.log("上传monthlyCard信息:", uid, monthCardTime);
//旧的读取数据设置数据方法,以强联网为主 //旧的读取数据设置数据方法,以强联网为主
if (uid != undefined && uid != "" && uid != null) { if (uid != undefined && uid != "" && uid != null) {
cc.fx.GameConfig.GM_INFO.uid = uid; cc.fx.GameConfig.GM_INFO.uid = uid;
@ -972,12 +972,12 @@ export default class Utils {
} }
Utils.POST("rebornGift", setData, res => { Utils.POST("rebornGift", setData, res => {
// console.log("获得rebornGift数据:", res); // //console.log("获得rebornGift数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:上传rebornGift成功'✅ ", res); //console.log("服务器:上传rebornGift成功'✅ ", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
// console.log("服务器:上传rebornGift失败'❌ ", res); // //console.log("服务器:上传rebornGift失败'❌ ", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} }
}); });
@ -1011,9 +1011,9 @@ export default class Utils {
} }
Utils.POST("shareLvSuccess", data, res => { Utils.POST("shareLvSuccess", data, res => {
console.log("获得shareLvSuccess数据:", res); //console.log("获得shareLvSuccess数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:分享帮助通过关卡数据成功", res); //console.log("服务器:分享帮助通过关卡数据成功", res);
callBack(res); callBack(res);
} else { } else {
attempt++; attempt++;
@ -1033,9 +1033,9 @@ export default class Utils {
}; };
if (typeof wx !== 'undefined' && wx !== null) { if (typeof wx !== 'undefined' && wx !== null) {
Utils.POST("getShareLv", data, res => { Utils.POST("getShareLv", data, res => {
console.log("获得shareLvSuccess数据:", res); //console.log("获得shareLvSuccess数据:", res);
if (res.code === 1) { if (res.code === 1) {
console.log("服务器:分享帮助通过关卡数据成功", res); //console.log("服务器:分享帮助通过关卡数据成功", res);
if (callBack) callBack(res); if (callBack) callBack(res);
} else { } else {
if (callBack) callBack(res); if (callBack) callBack(res);

View File

@ -1190,6 +1190,11 @@ var GameTool = {
eventData = { eventData = {
stage_id: (cc.fx.GameConfig.GM_INFO.level + 1) stage_id: (cc.fx.GameConfig.GM_INFO.level + 1)
} }
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
eventData = {
stage_id: cc.fx.GameConfig.GM_INFO.otherLevel,
}
}
break; break;
case "finish_stage": case "finish_stage":
eventData = { eventData = {
@ -1198,6 +1203,14 @@ var GameTool = {
added_time: data.add_Time, added_time: data.add_Time,
result: data.result result: data.result
} }
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
eventData = {
stage_id: cc.fx.GameConfig.GM_INFO.otherLevel,
stage_duration: data.time,
added_time: data.add_Time,
result: data.result
}
}
break; break;
case "resource_get": case "resource_get":
eventData = { eventData = {
@ -1234,7 +1247,7 @@ var GameTool = {
case "payment": //发起充值时 case "payment": //发起充值时
eventData = { eventData = {
order_id: data.outTradeNo, order_id: data.outTradeNo,
pay_amount: data.price, pay_amount: data.pay_amount,
payment_name: data.payment_name, payment_name: data.payment_name,
payment_num: data.payment_num, payment_num: data.payment_num,
payment_type: data.type, payment_type: data.type,
@ -1243,17 +1256,24 @@ var GameTool = {
case "payment_fail": //发起充值时 case "payment_fail": //发起充值时
eventData = { eventData = {
order_id: data.outTradeNo, order_id: data.outTradeNo,
pay_amount: data.price, pay_amount: data.pay_amount,
payment_name: data.payment_name, payment_name: data.payment_name,
payment_num: data.payment_num, payment_num: data.payment_num,
payment_type: data.type, payment_type: data.type,
fail_reason: data.fail_reason, fail_reason: data.fail_reason,
} }
break; break;
case "stage_help": //帮助通关时
eventData = {
identity: data.identity, //发起者为helped 帮助者为helper
level: data.level, //被帮助关卡等级
success: data.success || null, //被帮助关卡是否成功
}
break;
} }
if (name == "finish_stage") { if (name == "stage_help") {
//console.log("准备上报完成"); console.log("准备上报完成", data);
//console.log(eventData); console.log(eventData);
// MiniGameSdk.API.showToast("准备上报完成游戏"); // MiniGameSdk.API.showToast("准备上报完成游戏");
} }
// MiniGameSdk.API.shushu_Track(name,eventData); // MiniGameSdk.API.shushu_Track(name,eventData);

View File

@ -52,18 +52,21 @@ export default class NewClass extends cc.Component {
Utils.getIosPayInfo(iosOutTradeNo, Utils.getIosPayInfo(iosOutTradeNo,
(data) => { (data) => {
console.log("获得轮训结果:", data); console.log("获得轮训结果:", data);
const iosID = data.data?.payment_name || this.iosProductId;
let iosAmount = data.data?.goodsPrice || this.iosPrice;
iosAmount = parseInt(iosAmount);
if (data.code == 1) { if (data.code == 1) {
console.log("购买成功"); console.log("购买成功");
const dataSuccess = { const dataSuccess = {
outTradeNo: iosOutTradeNo, outTradeNo: iosOutTradeNo,
pay_amount: this.iosPrice, pay_amount: iosAmount,
payment_name: this.iosProductId, payment_name: iosID,
payment_num: this.iosCount, payment_num: this.iosCount,
type: "ios", type: "ios",
} }
cc.fx.GameTool.shushu_Track("payment", dataSuccess); cc.fx.GameTool.shushu_Track("payment", dataSuccess);
let name = "购买金币道具:" + this.iosProductId; let name = "购买金币道具:" + iosID;
MiniGameSdk.API.yinli_Pay(this.iosPrice, iosOutTradeNo, name) MiniGameSdk.API.yinli_Pay(iosAmount, iosOutTradeNo, name)
Utils.setPayInfo( Utils.setPayInfo(
(res) => { (res) => {
this.closeLoad(); this.closeLoad();
@ -72,8 +75,8 @@ export default class NewClass extends cc.Component {
console.log("_________正式发货"); console.log("_________正式发货");
MiniGameSdk.API.showToast("充值成功"); MiniGameSdk.API.showToast("充值成功");
if (this.iosProductId == "month_Card") { if (iosID == "month_Card") {
this.buyMonthCard(this.iosProductId); this.buyMonthCard(iosID);
} }
//console.log("充值成功获得金币"); //console.log("充值成功获得金币");
} }
@ -81,8 +84,8 @@ export default class NewClass extends cc.Component {
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放"); MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
const dataFail4 = { const dataFail4 = {
outTradeNo: iosOutTradeNo, outTradeNo: iosOutTradeNo,
price: this.iosPrice, pay_amount: iosAmount,
payment_name: this.iosProductId, payment_name: iosID,
payment_num: this.iosCount, payment_num: this.iosCount,
type: "ios", type: "ios",
fail_reason: "成功付款,但是发货时请求服务器失败,充值成功未发货", fail_reason: "成功付款,但是发货时请求服务器失败,充值成功未发货",
@ -103,8 +106,8 @@ export default class NewClass extends cc.Component {
this.btn_Touch = true; this.btn_Touch = true;
const dataFail = { const dataFail = {
outTradeNo: iosOutTradeNo, outTradeNo: iosOutTradeNo,
price: this.iosPrice, pay_amount: iosAmount,
payment_name: this.iosProductId, payment_name: iosID,
payment_num: this.iosCount, payment_num: this.iosCount,
type: "ios", type: "ios",
fail_reason: "用户取消充值", fail_reason: "用户取消充值",
@ -117,8 +120,8 @@ export default class NewClass extends cc.Component {
// MiniGameSdk.API.showToast("订单已关闭"); // MiniGameSdk.API.showToast("订单已关闭");
const dataFail = { const dataFail = {
outTradeNo: iosOutTradeNo, outTradeNo: iosOutTradeNo,
price: this.iosPrice, pay_amount: iosAmount,
payment_name: this.iosProductId, payment_name: iosID,
payment_num: this.iosCount, payment_num: this.iosCount,
type: "ios", type: "ios",
fail_reason: "用户充值后,轮训结果超时", fail_reason: "用户充值后,轮训结果超时",
@ -354,7 +357,7 @@ export default class NewClass extends cc.Component {
this.btn_Touch = true; this.btn_Touch = true;
const dataFail = { const dataFail = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -374,7 +377,7 @@ export default class NewClass extends cc.Component {
} }
const dataFail = { const dataFail = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -394,7 +397,7 @@ export default class NewClass extends cc.Component {
MiniGameSdk.API.showToast("取消充值"); MiniGameSdk.API.showToast("取消充值");
const dataFail2 = { const dataFail2 = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -431,7 +434,7 @@ export default class NewClass extends cc.Component {
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放"); MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
const dataFail4 = { const dataFail4 = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -451,7 +454,7 @@ export default class NewClass extends cc.Component {
const dataFail3 = { const dataFail3 = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,

View File

@ -206,22 +206,24 @@ export default class NewClass extends cc.Component {
Utils.getIosPayInfo(iosOutTradeNo, Utils.getIosPayInfo(iosOutTradeNo,
(data) => { (data) => {
console.log("获得轮训结果:", data); console.log("获得轮训结果:", data);
const iosID = data.data?.payment_name || this.iosProductId;
let iosAmount = data.data?.goodsPrice || this.iosPrice;
iosAmount = parseInt(iosAmount);
if (data.code == 1) { if (data.code == 1) {
console.log("购买成功"); console.log("购买成功");
const iosID = data.data.payment_name;
console.log("商品id:", iosID); console.log("商品id:", iosID);
const dataSuccess = { const dataSuccess = {
outTradeNo: iosOutTradeNo, outTradeNo: iosOutTradeNo,
pay_amount: this.iosPrice, pay_amount: iosAmount,
payment_name: iosID, payment_name: iosID,
payment_num: this.iosCount, payment_num: this.iosCount,
type: "ios", type: "ios",
} }
cc.fx.GameTool.shushu_Track("payment", dataSuccess); cc.fx.GameTool.shushu_Track("payment", dataSuccess);
let name = "购买金币道具:" + this.iosProductId; let name = "购买金币道具:" + iosID;
let version = cc.fx.GameTool.getWechatGameVersion(); let version = cc.fx.GameTool.getWechatGameVersion();
if (version == "正式版") { if (version == "正式版") {
MiniGameSdk.API.yinli_Pay(this.iosPrice, iosOutTradeNo, name) MiniGameSdk.API.yinli_Pay(iosAmount, iosOutTradeNo, name)
} }
Utils.setPayInfo( Utils.setPayInfo(
@ -244,7 +246,7 @@ export default class NewClass extends cc.Component {
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放"); MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
const dataFail4 = { const dataFail4 = {
outTradeNo: iosOutTradeNo, outTradeNo: iosOutTradeNo,
price: this.iosPrice, pay_amount: iosAmount,
payment_name: iosID, payment_name: iosID,
payment_num: this.iosCount, payment_num: this.iosCount,
type: "ios", type: "ios",
@ -267,8 +269,8 @@ export default class NewClass extends cc.Component {
this.btn_Touch = true; this.btn_Touch = true;
const dataFail = { const dataFail = {
outTradeNo: iosOutTradeNo, outTradeNo: iosOutTradeNo,
price: this.iosPrice, pay_amount: iosAmount,
payment_name: this.iosProductId, payment_name: iosID,
payment_num: this.iosCount, payment_num: this.iosCount,
type: "ios", type: "ios",
fail_reason: "用户取消充值", fail_reason: "用户取消充值",
@ -281,8 +283,8 @@ export default class NewClass extends cc.Component {
MiniGameSdk.API.showToast("订单已关闭"); MiniGameSdk.API.showToast("订单已关闭");
const dataFail = { const dataFail = {
outTradeNo: iosOutTradeNo, outTradeNo: iosOutTradeNo,
price: this.iosPrice, pay_amount: iosAmount,
payment_name: this.iosProductId, payment_name: iosID,
payment_num: this.iosCount, payment_num: this.iosCount,
type: "ios", type: "ios",
fail_reason: "用户充值后,轮训结果超时", fail_reason: "用户充值后,轮训结果超时",
@ -483,7 +485,7 @@ export default class NewClass extends cc.Component {
this.btn_Touch = true; this.btn_Touch = true;
const dataFail = { const dataFail = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -503,7 +505,7 @@ export default class NewClass extends cc.Component {
} }
const dataFail = { const dataFail = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -516,7 +518,7 @@ export default class NewClass extends cc.Component {
else { else {
Utils.getPayInfo((data) => { Utils.getPayInfo((data) => {
// MiniGameSdk.API.showToast("充值成功"); // MiniGameSdk.API.showToast("充值成功");
console.log("7.28_______________充值成功,准备轮训"); console.log("7.28_______________充值成功,准备轮训", data);
//console.log("获得轮训结果:", data); //console.log("获得轮训结果:", data);
this.closeLoad(); this.closeLoad();
if (data.data.pay_state == 1) { if (data.data.pay_state == 1) {
@ -524,7 +526,7 @@ export default class NewClass extends cc.Component {
MiniGameSdk.API.showToast("取消充值"); MiniGameSdk.API.showToast("取消充值");
const dataFail2 = { const dataFail2 = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -568,7 +570,7 @@ export default class NewClass extends cc.Component {
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放"); MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
const dataFail4 = { const dataFail4 = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,
@ -588,7 +590,7 @@ export default class NewClass extends cc.Component {
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
const dataFail3 = { const dataFail3 = {
outTradeNo: Utils.outTradeNo, outTradeNo: Utils.outTradeNo,
price: price, pay_amount: price,
payment_name: productId, payment_name: productId,
payment_num: 1, payment_num: 1,
type: systemType, type: systemType,