Compare commits
No commits in common. "57bb8f0e21f5305b7c6e8ef5c51bcaaec9945f50" and "1a6096406e95cc039ee006377d660f937761ac4b" have entirely different histories.
57bb8f0e21
...
1a6096406e
|
@ -110,7 +110,7 @@ export default class Revive extends cc.Component {
|
||||||
else if (data.code == 2) {
|
else if (data.code == 2) {
|
||||||
this.closeLoad();
|
this.closeLoad();
|
||||||
console.log("轮训超时");
|
console.log("轮训超时");
|
||||||
MiniGameSdk.API.showToast("请检查网络,如充值成功,请重新登录领取");
|
MiniGameSdk.API.showToast("订单已关闭");
|
||||||
const dataFail = {
|
const dataFail = {
|
||||||
outTradeNo: iosOutTradeNo,
|
outTradeNo: iosOutTradeNo,
|
||||||
pay_amount: iosAmount,
|
pay_amount: iosAmount,
|
||||||
|
@ -181,6 +181,7 @@ export default class Revive extends cc.Component {
|
||||||
let shopComp = shop.getComponent("shop");
|
let shopComp = shop.getComponent("shop");
|
||||||
if (shopComp) {
|
if (shopComp) {
|
||||||
shopComp.openShop();
|
shopComp.openShop();
|
||||||
|
shopComp.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cc.fx.GameConfig.GM_INFO.revive = 1;
|
cc.fx.GameConfig.GM_INFO.revive = 1;
|
||||||
|
|
|
@ -62,7 +62,6 @@ export default class Utils {
|
||||||
payment_num: 1,
|
payment_num: 1,
|
||||||
type: systemType,
|
type: systemType,
|
||||||
}
|
}
|
||||||
console.log("创建订单", Utils.outTradeNo);
|
|
||||||
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;
|
||||||
|
@ -187,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({
|
||||||
|
@ -203,64 +202,47 @@ export default class Utils {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// static getIosPayInfo(order, callBack) {
|
|
||||||
// // 延迟时间数组,按照 1 秒 3 次、2 秒 5 次、5 秒 6 次、15 秒 5 次的规则生成
|
|
||||||
// const iosOutTradeNo = order;
|
|
||||||
// console.log("请求uid:" + Utils.uid);
|
|
||||||
// console.log("outTradeNo:" + iosOutTradeNo);
|
|
||||||
// Utils.POST("wx/iosgetPayInfo", { outTradeNo: iosOutTradeNo }, res => {
|
|
||||||
// console.log("查询字符结果IOS");
|
|
||||||
// console.log(res);
|
|
||||||
// if (res.code === 1) {
|
|
||||||
// callBack(res);
|
|
||||||
// } else {
|
|
||||||
// callBack(res);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
static getIosPayInfo(order, callBack) {
|
static getIosPayInfo(order, callBack) {
|
||||||
// 延迟 0.5 秒执行后续逻辑
|
// 延迟时间数组,按照 1 秒 3 次、2 秒 5 次、5 秒 6 次、15 秒 5 次的规则生成
|
||||||
setTimeout(() => {
|
const delays = [
|
||||||
// 最大重试次数
|
...Array(3).fill(1000),
|
||||||
const maxRetries = 3;
|
...Array(5).fill(2000),
|
||||||
let retryCount = 0;
|
...Array(6).fill(5000),
|
||||||
// 标志位,用于记录 callBack 是否已经被调用
|
...Array(5).fill(15000)
|
||||||
let isCallBackCalled = false;
|
];
|
||||||
|
let attempt = 0; // 轮询次数
|
||||||
|
const iosOutTradeNo = order;
|
||||||
|
|
||||||
const makeRequest = () => {
|
const poll = () => {
|
||||||
if (retryCount > maxRetries) {
|
if (attempt >= delays.length) {
|
||||||
if (!isCallBackCalled) {
|
MiniGameSdk.API.showToast("网络异常,如充值成功,重进游戏可领取奖励");
|
||||||
MiniGameSdk.API.showToast("网络异常,如充值成功,重进游戏可领取奖励");
|
callBack({ code: 2, data: null, message: '轮询超时' });
|
||||||
callBack({ code: 2, data: null, message: '轮询超时,达到最大重试次数' });
|
return;
|
||||||
isCallBackCalled = true;
|
}
|
||||||
}
|
|
||||||
return;
|
//console.log("请求uid:" + Utils.uid);
|
||||||
|
//console.log("outTradeNo:" + iosOutTradeNo);
|
||||||
|
Utils.POST("wx/iosgetPayInfo", { outTradeNo: iosOutTradeNo }, res => {
|
||||||
|
//console.log("查询字符结果IOS");
|
||||||
|
//console.log(res);
|
||||||
|
if (res.code === 1) {
|
||||||
|
callBack(res);
|
||||||
|
} else if (res.code === 0) {
|
||||||
|
callBack(res);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
attempt++;
|
||||||
|
setTimeout(poll, delays[attempt - 1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// 设置超时定时器
|
setTimeout(() => {
|
||||||
const timeoutId = setTimeout(() => {
|
poll();
|
||||||
retryCount++;
|
|
||||||
console.log(`请求超时,第 ${retryCount} 次重新申请接口`);
|
|
||||||
makeRequest();
|
|
||||||
}, 3000);
|
|
||||||
|
|
||||||
const iosOutTradeNo = order;
|
|
||||||
console.log("请求uid:" + Utils.uid);
|
|
||||||
console.log("outTradeNo:" + iosOutTradeNo);
|
|
||||||
Utils.POST("wx/iosgetPayInfo", { outTradeNo: iosOutTradeNo }, res => {
|
|
||||||
console.log("查询字符结果IOS");
|
|
||||||
console.log(res);
|
|
||||||
// 清除超时定时器
|
|
||||||
clearTimeout(timeoutId);
|
|
||||||
if (!isCallBackCalled) {
|
|
||||||
callBack(res);
|
|
||||||
isCallBackCalled = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
makeRequest();
|
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 微信云
|
//#region 微信云
|
||||||
|
|
|
@ -119,7 +119,6 @@ export default class NewClass extends cc.Component {
|
||||||
else if (data.code == 2) {
|
else if (data.code == 2) {
|
||||||
this.closeLoad();
|
this.closeLoad();
|
||||||
console.log("轮训超时");
|
console.log("轮训超时");
|
||||||
MiniGameSdk.API.showToast("请检查网络,如充值成功,请重新登录领取");
|
|
||||||
// MiniGameSdk.API.showToast("订单已关闭");
|
// MiniGameSdk.API.showToast("订单已关闭");
|
||||||
const dataFail = {
|
const dataFail = {
|
||||||
outTradeNo: iosOutTradeNo,
|
outTradeNo: iosOutTradeNo,
|
||||||
|
@ -237,6 +236,7 @@ export default class NewClass extends cc.Component {
|
||||||
let shopComp = shop.getComponent("shop");
|
let shopComp = shop.getComponent("shop");
|
||||||
if (shopComp) {
|
if (shopComp) {
|
||||||
shopComp.openShop();
|
shopComp.openShop();
|
||||||
|
shopComp.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,23 +200,19 @@ export default class NewClass extends cc.Component {
|
||||||
if (systemInfo.platform === 'ios') {
|
if (systemInfo.platform === 'ios') {
|
||||||
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
|
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
|
||||||
console.log("从后台进入前台订单号:", cc.fx.GameConfig.GM_INFO.iosOutTradeNo);
|
console.log("从后台进入前台订单号:", cc.fx.GameConfig.GM_INFO.iosOutTradeNo);
|
||||||
|
this.closeLoad();
|
||||||
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.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") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data.code == 1) {
|
if (data.code == 1) {
|
||||||
console.log("购买成功");
|
console.log("购买成功");
|
||||||
console.log("商品id:", iosID);
|
console.log("商品id:", iosID);
|
||||||
|
@ -285,7 +281,7 @@ export default class NewClass extends cc.Component {
|
||||||
else if (data.code == 2) {
|
else if (data.code == 2) {
|
||||||
this.closeLoad();
|
this.closeLoad();
|
||||||
console.log("轮训超时");
|
console.log("轮训超时");
|
||||||
MiniGameSdk.API.showToast("请检查网络,如充值成功,请重新登录领取");
|
MiniGameSdk.API.showToast("订单已关闭");
|
||||||
const dataFail = {
|
const dataFail = {
|
||||||
outTradeNo: iosOutTradeNo,
|
outTradeNo: iosOutTradeNo,
|
||||||
pay_amount: iosAmount,
|
pay_amount: iosAmount,
|
||||||
|
@ -296,7 +292,7 @@ export default class NewClass extends cc.Component {
|
||||||
}
|
}
|
||||||
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
|
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
|
||||||
}
|
}
|
||||||
this.closeLoad();
|
|
||||||
this.btn_Touch = true;
|
this.btn_Touch = true;
|
||||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||||
})
|
})
|
||||||
|
@ -470,6 +466,7 @@ export default class NewClass extends cc.Component {
|
||||||
console.error('获取系统信息失败', e);
|
console.error('获取系统信息失败', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Utils.GoKEFu();
|
||||||
if (systemType == "ios") {
|
if (systemType == "ios") {
|
||||||
// MiniGameSdk.API.showToast("IOS系统暂不支持支付");
|
// MiniGameSdk.API.showToast("IOS系统暂不支持支付");
|
||||||
// this.btn_Touch = true;
|
// this.btn_Touch = true;
|
||||||
|
@ -486,14 +483,7 @@ export default class NewClass extends cc.Component {
|
||||||
console.log("准备跳客服回话:");
|
console.log("准备跳客服回话:");
|
||||||
console.log(this.iosProductId);
|
console.log(this.iosProductId);
|
||||||
Utils.GoKEFu(iosPayInfo, (res) => {
|
Utils.GoKEFu(iosPayInfo, (res) => {
|
||||||
if (res == "success") {
|
this.closeLoad();
|
||||||
console.log("客服回话成功");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log("客服回话失败");
|
|
||||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
|
||||||
this.closeLoad();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -725,6 +715,11 @@ export default class NewClass extends cc.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
openmonthCard() {
|
openmonthCard() {
|
||||||
|
if (cc.sys.platform === cc.sys.WECHAT_GAME && this.onShowListener) {
|
||||||
|
console.log("shop移除onshow11111");
|
||||||
|
//@ts-ignore
|
||||||
|
wx.offShow(this.onShowListener);
|
||||||
|
}
|
||||||
const winCOIN = cc.find("Canvas"); // 假设 Canvas 节点
|
const winCOIN = cc.find("Canvas"); // 假设 Canvas 节点
|
||||||
if (winCOIN) {
|
if (winCOIN) {
|
||||||
const wincoin = winCOIN.getComponent(SceneManager);
|
const wincoin = winCOIN.getComponent(SceneManager);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user