更新月卡功能
This commit is contained in:
parent
5cfaf3a5cd
commit
0118f2bd90
|
@ -176,11 +176,13 @@ export default class JiaZai extends cc.Component {
|
|||
//console.log("音乐开关", cc.fx.GameConfig.GM_INFO.musicOpen);
|
||||
AudioManager._instance.playMusicGame();
|
||||
// this.openMonthCard();
|
||||
console.log("3333333333");
|
||||
this.onGames();
|
||||
}
|
||||
//监听后台
|
||||
onGames() {
|
||||
if (typeof wx !== 'undefined') {
|
||||
console.log("从这里开始进入监听了————————————————————");
|
||||
this.onShowListener = null;
|
||||
this.onHideListener = null;
|
||||
// 定义监听函数
|
||||
|
@ -200,21 +202,32 @@ export default class JiaZai extends cc.Component {
|
|||
}
|
||||
onGameHide() {
|
||||
console.log("执行onGameHide", cc.fx.GameConfig.GM_INFO.min_Time);
|
||||
this.isFirstLaunch = false;
|
||||
if (this.isFirstLaunch != null && this.isFirstLaunch != undefined) this.isFirstLaunch = false;
|
||||
if (this) {
|
||||
if (this.node) {
|
||||
this.stopHeathTimeCutDown();
|
||||
this.stopTimeCutDown();
|
||||
this.stopPowerTime();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onGameShow() {
|
||||
console.log("执行开始游戏gameshow")
|
||||
cc.fx.GameTool.getHealth((data) => {
|
||||
if (this.level) {
|
||||
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 43, 15, "level_", this.level, true);
|
||||
}
|
||||
if (this.coin) {
|
||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||
}
|
||||
this.setHealthInfo(true);
|
||||
});
|
||||
|
||||
console.log("执行on", cc.fx.GameConfig.GM_INFO.min_Time);
|
||||
if (this) {
|
||||
if (this.node) {
|
||||
if (this.node.getChildByName("heathpop")) {
|
||||
if (this.node.getChildByName("heathpop").active == true) {
|
||||
const heathComponent = this.node.getChildByName("heathpop").getComponent("heathnum");
|
||||
|
@ -224,9 +237,11 @@ export default class JiaZai extends cc.Component {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
start() {
|
||||
// //console.log("已经进入Home界面");
|
||||
|
@ -797,13 +812,15 @@ export default class JiaZai extends cc.Component {
|
|||
cc.fx.GameConfig.GM_INFO.doubleCoin = 2;
|
||||
cc.fx.GameConfig.GM_INFO.hp_Max = 7;
|
||||
cc.fx.GameConfig.GM_INFO.hp = 7;
|
||||
this.openLoad();
|
||||
this.buyMonthCard(productId);
|
||||
}
|
||||
else if (order.itemid == "reborn_Gift") {
|
||||
coinTemp = 1000;
|
||||
}
|
||||
let title = "充值补发奖励金币:" + coinTemp;
|
||||
// MiniGameSdk.API.showToast(title);
|
||||
cc.fx.GameTool.shopBuy(productId, true);
|
||||
if (order.itemid != "month_Card") cc.fx.GameTool.shopBuy(productId, true);
|
||||
console.log("充值成功获得金币");
|
||||
} else {
|
||||
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
|
||||
|
@ -1126,5 +1143,48 @@ export default class JiaZai extends cc.Component {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//购买月卡
|
||||
buyMonthCard(id) {
|
||||
Utils.setMonthlyCard(0, (data) => {
|
||||
console.log("购买月卡", data.code);
|
||||
if (data.code == 1) {
|
||||
// let rewardData = [
|
||||
// { type: "coin", count: 6000 },
|
||||
// ]
|
||||
cc.fx.GameTool.shopBuy(id, false);
|
||||
cc.fx.GameConfig.GM_INFO.hp_Max = 7;
|
||||
cc.fx.GameConfig.GM_INFO.hp = 7;
|
||||
|
||||
cc.fx.GameTool.getMonthlyCardValidityDays().then(days => {
|
||||
cc.fx.GameConfig.GM_INFO.monthTime = days.days;
|
||||
//本地储存当前服务器时间
|
||||
let dateStr = new Date(days.time);
|
||||
cc.fx.StorageMessage.setStorage("mCardDate", dateStr);
|
||||
});
|
||||
// cc.fx.GameTool.changeCoin(6000);
|
||||
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
|
||||
const jiazaiComp = jiazaiNode.getComponent(JiaZai);
|
||||
if (jiazaiComp) {
|
||||
console.log("获取到JiaZai组件", jiazaiComp);
|
||||
setTimeout(() => {
|
||||
jiazaiComp.setHealthInfo(false);
|
||||
jiazaiComp.startTimeCutDown();
|
||||
jiazaiComp.updateCoin();
|
||||
|
||||
}, 300);
|
||||
} else {
|
||||
console.log("无法获取JiaZai组件");
|
||||
}
|
||||
cc.fx.GameConfig.GM_INFO.doubleCoin = 2;
|
||||
cc.fx.GameTool.setUserHealth(0, (data) => {
|
||||
cc.fx.GameTool.getHealth(null);
|
||||
})
|
||||
}
|
||||
this.closeLoad();
|
||||
})
|
||||
// update (dt) {}
|
||||
}
|
||||
|
||||
// update (dt) {}
|
||||
}
|
||||
|
|
|
@ -171,6 +171,7 @@ export default class Utils {
|
|||
|
||||
/**跳转客服*/
|
||||
static GoKEFu(iosPayInfo, callBack) {
|
||||
console.log("创建新的订单,清空老订单");
|
||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = `wcx_` + Math.round(Math.random() * 10 ** 13) + Date.now();
|
||||
const data = {
|
||||
|
|
|
@ -52,7 +52,7 @@ export default class NewClass extends cc.Component {
|
|||
this.btn_Touch = true;
|
||||
Utils.getIosPayInfo(iosOutTradeNo,
|
||||
(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);
|
||||
|
@ -133,6 +133,7 @@ export default class NewClass extends cc.Component {
|
|||
}
|
||||
|
||||
this.btn_Touch = true;
|
||||
console.log("月卡自己置空订单号");
|
||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||
})
|
||||
}
|
||||
|
@ -256,8 +257,9 @@ export default class NewClass extends cc.Component {
|
|||
console.log("123iiiii222")
|
||||
}
|
||||
if (jiazaiComp) {
|
||||
console.log("22222222")
|
||||
jiazaiComp.onGames();
|
||||
console.log("1222")
|
||||
|
||||
}
|
||||
|
||||
this.node.active = false;
|
||||
|
|
|
@ -186,6 +186,7 @@ export default class NewClass extends cc.Component {
|
|||
const wincoin1 = winCOIN.getComponent(JiaZai);
|
||||
if (wincoin1) {
|
||||
if (wincoin1) {
|
||||
console.log("111111111");
|
||||
wincoin1.onGames();
|
||||
wincoin1.rewarded();
|
||||
}
|
||||
|
@ -203,18 +204,19 @@ export default class NewClass extends cc.Component {
|
|||
if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null && cc.fx.GameConfig.GM_INFO.iosOutTradeNo != "") {
|
||||
console.log("有苹果订单号,开始轮训");
|
||||
const iosOutTradeNo = cc.fx.GameConfig.GM_INFO.iosOutTradeNo;
|
||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = "";
|
||||
// cc.fx.GameConfig.GM_INFO.iosOutTradeNo = "";
|
||||
// this.closeLoad();
|
||||
// this.openLoad();
|
||||
this.btn_Touch = true;
|
||||
|
||||
Utils.getIosPayInfo(iosOutTradeNo,
|
||||
(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 (iosID == "reborn_Gift" || iosID == "month_Card") {
|
||||
console.log("商城检测到是月卡返回");
|
||||
return;
|
||||
}
|
||||
if (data.code == 1) {
|
||||
|
@ -298,7 +300,8 @@ export default class NewClass extends cc.Component {
|
|||
}
|
||||
this.closeLoad();
|
||||
this.btn_Touch = true;
|
||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||
// console.log("商城置空订单号");
|
||||
// cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||
})
|
||||
}
|
||||
else {
|
||||
|
@ -491,7 +494,7 @@ export default class NewClass extends cc.Component {
|
|||
}
|
||||
else {
|
||||
console.log("客服回话失败");
|
||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||
// cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||
this.closeLoad();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user