更新月卡功能
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);
|
//console.log("音乐开关", cc.fx.GameConfig.GM_INFO.musicOpen);
|
||||||
AudioManager._instance.playMusicGame();
|
AudioManager._instance.playMusicGame();
|
||||||
// this.openMonthCard();
|
// this.openMonthCard();
|
||||||
|
console.log("3333333333");
|
||||||
this.onGames();
|
this.onGames();
|
||||||
}
|
}
|
||||||
//监听后台
|
//监听后台
|
||||||
onGames() {
|
onGames() {
|
||||||
if (typeof wx !== 'undefined') {
|
if (typeof wx !== 'undefined') {
|
||||||
|
console.log("从这里开始进入监听了————————————————————");
|
||||||
this.onShowListener = null;
|
this.onShowListener = null;
|
||||||
this.onHideListener = null;
|
this.onHideListener = null;
|
||||||
// 定义监听函数
|
// 定义监听函数
|
||||||
|
@ -200,32 +202,45 @@ export default class JiaZai extends cc.Component {
|
||||||
}
|
}
|
||||||
onGameHide() {
|
onGameHide() {
|
||||||
console.log("执行onGameHide", cc.fx.GameConfig.GM_INFO.min_Time);
|
console.log("执行onGameHide", cc.fx.GameConfig.GM_INFO.min_Time);
|
||||||
this.isFirstLaunch = false;
|
if (this.isFirstLaunch != null && this.isFirstLaunch != undefined) this.isFirstLaunch = false;
|
||||||
this.stopHeathTimeCutDown();
|
if (this) {
|
||||||
this.stopTimeCutDown();
|
if (this.node) {
|
||||||
this.stopPowerTime();
|
this.stopHeathTimeCutDown();
|
||||||
|
this.stopTimeCutDown();
|
||||||
|
this.stopPowerTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onGameShow() {
|
onGameShow() {
|
||||||
console.log("执行开始游戏gameshow")
|
console.log("执行开始游戏gameshow")
|
||||||
cc.fx.GameTool.getHealth((data) => {
|
cc.fx.GameTool.getHealth((data) => {
|
||||||
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 43, 15, "level_", this.level, true);
|
if (this.level) {
|
||||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
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);
|
this.setHealthInfo(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("执行on", cc.fx.GameConfig.GM_INFO.min_Time);
|
console.log("执行on", cc.fx.GameConfig.GM_INFO.min_Time);
|
||||||
if (this.node.getChildByName("heathpop")) {
|
if (this) {
|
||||||
if (this.node.getChildByName("heathpop").active == true) {
|
if (this.node) {
|
||||||
const heathComponent = this.node.getChildByName("heathpop").getComponent("heathnum");
|
if (this.node.getChildByName("heathpop")) {
|
||||||
if (heathComponent && heathComponent.timeNode &&
|
if (this.node.getChildByName("heathpop").active == true) {
|
||||||
cc.fx.GameConfig.GM_INFO.hp < cc.fx.GameConfig.GM_INFO.hp_Max) {
|
const heathComponent = this.node.getChildByName("heathpop").getComponent("heathnum");
|
||||||
this.startHeathTimeCutDown(heathComponent.timeNode);
|
if (heathComponent && heathComponent.timeNode &&
|
||||||
|
cc.fx.GameConfig.GM_INFO.hp < cc.fx.GameConfig.GM_INFO.hp_Max) {
|
||||||
|
this.startHeathTimeCutDown(heathComponent.timeNode);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
|
@ -797,13 +812,15 @@ export default class JiaZai extends cc.Component {
|
||||||
cc.fx.GameConfig.GM_INFO.doubleCoin = 2;
|
cc.fx.GameConfig.GM_INFO.doubleCoin = 2;
|
||||||
cc.fx.GameConfig.GM_INFO.hp_Max = 7;
|
cc.fx.GameConfig.GM_INFO.hp_Max = 7;
|
||||||
cc.fx.GameConfig.GM_INFO.hp = 7;
|
cc.fx.GameConfig.GM_INFO.hp = 7;
|
||||||
|
this.openLoad();
|
||||||
|
this.buyMonthCard(productId);
|
||||||
}
|
}
|
||||||
else if (order.itemid == "reborn_Gift") {
|
else if (order.itemid == "reborn_Gift") {
|
||||||
coinTemp = 1000;
|
coinTemp = 1000;
|
||||||
}
|
}
|
||||||
let title = "充值补发奖励金币:" + coinTemp;
|
let title = "充值补发奖励金币:" + coinTemp;
|
||||||
// MiniGameSdk.API.showToast(title);
|
// MiniGameSdk.API.showToast(title);
|
||||||
cc.fx.GameTool.shopBuy(productId, true);
|
if (order.itemid != "month_Card") cc.fx.GameTool.shopBuy(productId, true);
|
||||||
console.log("充值成功获得金币");
|
console.log("充值成功获得金币");
|
||||||
} else {
|
} else {
|
||||||
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
|
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) {}
|
// update (dt) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,7 @@ export default class Utils {
|
||||||
|
|
||||||
/**跳转客服*/
|
/**跳转客服*/
|
||||||
static GoKEFu(iosPayInfo, callBack) {
|
static GoKEFu(iosPayInfo, callBack) {
|
||||||
|
console.log("创建新的订单,清空老订单");
|
||||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = `wcx_` + Math.round(Math.random() * 10 ** 13) + Date.now();
|
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = `wcx_` + Math.round(Math.random() * 10 ** 13) + Date.now();
|
||||||
const data = {
|
const data = {
|
||||||
|
|
|
@ -52,7 +52,7 @@ export default class NewClass extends cc.Component {
|
||||||
this.btn_Touch = true;
|
this.btn_Touch = true;
|
||||||
Utils.getIosPayInfo(iosOutTradeNo,
|
Utils.getIosPayInfo(iosOutTradeNo,
|
||||||
(data) => {
|
(data) => {
|
||||||
console.log("获得轮训结果:", data);
|
console.log("月卡获得轮训结果:", data);
|
||||||
const iosID = data.data?.payment_name || this.iosProductId;
|
const iosID = data.data?.payment_name || this.iosProductId;
|
||||||
let iosAmount = data.data?.goodsPrice || this.iosPrice;
|
let iosAmount = data.data?.goodsPrice || this.iosPrice;
|
||||||
iosAmount = parseInt(iosAmount);
|
iosAmount = parseInt(iosAmount);
|
||||||
|
@ -133,6 +133,7 @@ export default class NewClass extends cc.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.btn_Touch = true;
|
this.btn_Touch = true;
|
||||||
|
console.log("月卡自己置空订单号");
|
||||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -256,8 +257,9 @@ export default class NewClass extends cc.Component {
|
||||||
console.log("123iiiii222")
|
console.log("123iiiii222")
|
||||||
}
|
}
|
||||||
if (jiazaiComp) {
|
if (jiazaiComp) {
|
||||||
|
console.log("22222222")
|
||||||
jiazaiComp.onGames();
|
jiazaiComp.onGames();
|
||||||
console.log("1222")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.node.active = false;
|
this.node.active = false;
|
||||||
|
|
|
@ -186,6 +186,7 @@ export default class NewClass extends cc.Component {
|
||||||
const wincoin1 = winCOIN.getComponent(JiaZai);
|
const wincoin1 = winCOIN.getComponent(JiaZai);
|
||||||
if (wincoin1) {
|
if (wincoin1) {
|
||||||
if (wincoin1) {
|
if (wincoin1) {
|
||||||
|
console.log("111111111");
|
||||||
wincoin1.onGames();
|
wincoin1.onGames();
|
||||||
wincoin1.rewarded();
|
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 != "") {
|
if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null && cc.fx.GameConfig.GM_INFO.iosOutTradeNo != "") {
|
||||||
console.log("有苹果订单号,开始轮训");
|
console.log("有苹果订单号,开始轮训");
|
||||||
const iosOutTradeNo = cc.fx.GameConfig.GM_INFO.iosOutTradeNo;
|
const iosOutTradeNo = cc.fx.GameConfig.GM_INFO.iosOutTradeNo;
|
||||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = "";
|
// cc.fx.GameConfig.GM_INFO.iosOutTradeNo = "";
|
||||||
// this.closeLoad();
|
// this.closeLoad();
|
||||||
// this.openLoad();
|
// this.openLoad();
|
||||||
this.btn_Touch = true;
|
this.btn_Touch = true;
|
||||||
|
|
||||||
Utils.getIosPayInfo(iosOutTradeNo,
|
Utils.getIosPayInfo(iosOutTradeNo,
|
||||||
(data) => {
|
(data) => {
|
||||||
console.log("获得轮训结果:", data);
|
console.log("商城获得轮训结果:", data);
|
||||||
const iosID = data.data?.payment_name || this.iosProductId;
|
const iosID = data.data?.payment_name || this.iosProductId;
|
||||||
let iosAmount = data.data?.goodsPrice || this.iosPrice;
|
let iosAmount = data.data?.goodsPrice || this.iosPrice;
|
||||||
iosAmount = parseInt(iosAmount);
|
iosAmount = parseInt(iosAmount);
|
||||||
if (iosID == "reborn_Gift" || iosID == "month_Card") {
|
if (iosID == "reborn_Gift" || iosID == "month_Card") {
|
||||||
|
console.log("商城检测到是月卡返回");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.code == 1) {
|
if (data.code == 1) {
|
||||||
|
@ -298,7 +300,8 @@ export default class NewClass extends cc.Component {
|
||||||
}
|
}
|
||||||
this.closeLoad();
|
this.closeLoad();
|
||||||
this.btn_Touch = true;
|
this.btn_Touch = true;
|
||||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
// console.log("商城置空订单号");
|
||||||
|
// cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -491,7 +494,7 @@ export default class NewClass extends cc.Component {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("客服回话失败");
|
console.log("客服回话失败");
|
||||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
// cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||||
this.closeLoad();
|
this.closeLoad();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user