This commit is contained in:
YZ\249929363 2025-08-04 17:47:07 +08:00
parent 5e2f85d646
commit 499f1bdb19
7 changed files with 137 additions and 126 deletions

View File

@ -251,8 +251,8 @@ export default class GameManager extends cc.Component {
Utils.getUserInfo((data) => {
if (data.code == 1) { // 假设返回数据中有 success 字段表示成功
//console.log("登录成功时间耗时:", Date.now() - this.nowTime);
console.log("登陆成功_____________");
console.log(data);
// console.log("111登陆成功_____________");
console.log("登錄", data);
//console.log("uid", data.data.onlyId);
if (data.data._id) {
cc.fx.GameConfig.GM_INFO.uid = data.data._id;

View File

@ -31,14 +31,6 @@ export default class Revive extends cc.Component {
onLoad() {
this.btn_Touch = true;
// 检测微信小游戏切到后台
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
// 定义监听函数
this.onShowListener = () => {
this.onShow();
};
//@ts-ignore
wx.onShow(this.onShowListener);
}
}
onShow() {
@ -140,7 +132,15 @@ export default class Revive extends cc.Component {
}
}
init() {
console.log()
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
this.onShowListener = null;
// 定义监听函数
this.onShowListener = () => {
this.onShow();
};
//@ts-ignore
wx.onShow(this.onShowListener);
}
this.btn_Touch = true;
if (cc.fx.GameConfig.GM_INFO.revive == 1) {
this.node.active = false;

View File

@ -12,7 +12,7 @@ export default class Utils {
static getUserInfo(callBack) {
wx.login({
success(res) {
console.log("登录成功");
console.log("微信login成功");
console.log(res);
if (res.code) {
Utils.POST("login", { code: res.code }, ret => {

View File

@ -37,14 +37,6 @@ export default class NewClass extends cc.Component {
onLoad() {
this.btn_Touch = true;
// 检测微信小游戏切到后台
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
// 定义监听函数
this.onShowListener = () => {
this.onShow();
};
//@ts-ignore
wx.onShow(this.onShowListener);
}
this.home = 0;
}
@ -156,6 +148,15 @@ export default class NewClass extends cc.Component {
}
init() {
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
this.onShowListener = null;
// 定义监听函数
this.onShowListener = () => {
this.onShow();
};
//@ts-ignore
wx.onShow(this.onShowListener);
}
this.btn_Touch = true;
if (cc.fx.GameConfig.GM_INFO.hp_Max == 7) {
this.monthCardBtn.active = false;

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "822b01d9-1503-471f-9590-548862a52e72",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -756,7 +756,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 1080,
"height": 3350
"height": 3200
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@ -768,7 +768,7 @@
"ctor": "Float64Array",
"array": [
0,
900,
55.944,
0,
0,
0,
@ -824,19 +824,19 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 1080,
"height": 2000
"height": 1700
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
"y": 1
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-73.284,
885.733,
0,
0,
0,

View File

@ -52,16 +52,7 @@ export default class NewClass extends cc.Component {
this.btn_Touch = true;
this.monthCard = false;
// 检测微信小游戏切到后台
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
// 定义监听函数
this.onShowListener = () => {
console.log("回到前台");
this.onShow();
};
//@ts-ignore
wx.onShow(this.onShowListener);
}
}
start() {
this.btn_Touch = true;
@ -70,6 +61,16 @@ export default class NewClass extends cc.Component {
}
init() {
this.onShowListener = null;
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
// 定义监听函数
this.onShowListener = () => {
console.log("回到前台");
this.onShow();
};
//@ts-ignore
wx.onShow(this.onShowListener);
}
this.btn_Touch = true;
var timeTemp = cc.fx.GameTool.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time);
// 同步显示
@ -194,7 +195,6 @@ export default class NewClass extends cc.Component {
const systemInfo = wx.getSystemInfoSync();
if (systemInfo.platform === 'ios') {
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
console.log("从后台进入获取当前商品名称:", this.iosProductId);
console.log("从后台进入前台订单号:", cc.fx.GameConfig.GM_INFO.iosOutTradeNo);
this.closeLoad();
if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null && cc.fx.GameConfig.GM_INFO.iosOutTradeNo != "") {
@ -203,99 +203,96 @@ export default class NewClass extends cc.Component {
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = "";
this.openLoad();
this.btn_Touch = true;
console.log("_________正式发货", "gold_1");
MiniGameSdk.API.showToast("充值成功");
cc.fx.GameTool.shopBuy("gold_5", false);
// Utils.getIosPayInfo(iosOutTradeNo,
// (data) => {
// console.log("获得轮训结果:", data);
// if (data.code == 1) {
// console.log("购买成功");
// const iosID = data.data.payment_name;
// console.log("商品id:", iosID);
// const dataSuccess = {
// outTradeNo: iosOutTradeNo,
// pay_amount: this.iosPrice,
// payment_name: iosID,
// payment_num: this.iosCount,
// type: "ios",
// }
// cc.fx.GameTool.shushu_Track("payment", dataSuccess);
// let name = "购买金币道具:" + this.iosProductId;
// let version = cc.fx.GameTool.getWechatGameVersion();
// if (version == "正式版") {
// MiniGameSdk.API.yinli_Pay(this.iosPrice, iosOutTradeNo, name)
// }
Utils.getIosPayInfo(iosOutTradeNo,
(data) => {
console.log("获得轮训结果:", data);
if (data.code == 1) {
console.log("购买成功");
const iosID = data.data.payment_name;
console.log("商品id:", iosID);
const dataSuccess = {
outTradeNo: iosOutTradeNo,
pay_amount: this.iosPrice,
payment_name: iosID,
payment_num: this.iosCount,
type: "ios",
}
cc.fx.GameTool.shushu_Track("payment", dataSuccess);
let name = "购买金币道具:" + this.iosProductId;
let version = cc.fx.GameTool.getWechatGameVersion();
if (version == "正式版") {
MiniGameSdk.API.yinli_Pay(this.iosPrice, iosOutTradeNo, name)
}
// Utils.setPayInfo(
// (res) => {
// this.closeLoad();
// //console.log("设置轮训结果:", res);
// if (res.code === 1) {
// console.log("_________正式发货", iosID);
// MiniGameSdk.API.showToast("充值成功");
// cc.fx.GameTool.shopBuy(iosID, false);
// if (iosID == "unlimited_health_bundle_1" ||
// iosID == "unlimited_health_bundle_2" ||
// iosID == "unlimited_health_bundle_3"
// ) {
// this.updatePower();
// }
// //console.log("充值成功获得金币");
// }
// else {
// MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
// const dataFail4 = {
// outTradeNo: iosOutTradeNo,
// price: this.iosPrice,
// payment_name: iosID,
// payment_num: this.iosCount,
// type: "ios",
// 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();
// }
// }, iosOutTradeNo)
// }
// else if (data.code == 0) {
// console.log("用户自己取消充值");
// MiniGameSdk.API.showToast("充值失败");
// this.closeLoad();
// this.btn_Touch = true;
// const dataFail = {
// outTradeNo: iosOutTradeNo,
// price: this.iosPrice,
// payment_name: this.iosProductId,
// payment_num: this.iosCount,
// type: "ios",
// fail_reason: "用户取消充值",
// }
// cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
// }
// else if (data.code == 2) {
// this.closeLoad();
// console.log("轮训超时");
// MiniGameSdk.API.showToast("订单已关闭");
// const dataFail = {
// outTradeNo: iosOutTradeNo,
// price: this.iosPrice,
// payment_name: this.iosProductId,
// payment_num: this.iosCount,
// type: "ios",
// fail_reason: "用户充值后,轮训结果超时",
// }
// cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
// }
Utils.setPayInfo(
(res) => {
this.closeLoad();
//console.log("设置轮训结果:", res);
if (res.code === 1) {
console.log("_________正式发货", iosID);
MiniGameSdk.API.showToast("充值成功");
cc.fx.GameTool.shopBuy(iosID, false);
if (iosID == "unlimited_health_bundle_1" ||
iosID == "unlimited_health_bundle_2" ||
iosID == "unlimited_health_bundle_3"
) {
this.updatePower();
}
//console.log("充值成功获得金币");
}
else {
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
const dataFail4 = {
outTradeNo: iosOutTradeNo,
price: this.iosPrice,
payment_name: iosID,
payment_num: this.iosCount,
type: "ios",
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();
}
}, iosOutTradeNo)
}
else if (data.code == 0) {
console.log("用户自己取消充值");
MiniGameSdk.API.showToast("充值失败");
this.closeLoad();
this.btn_Touch = true;
const dataFail = {
outTradeNo: iosOutTradeNo,
price: this.iosPrice,
payment_name: this.iosProductId,
payment_num: this.iosCount,
type: "ios",
fail_reason: "用户取消充值",
}
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
}
else if (data.code == 2) {
this.closeLoad();
console.log("轮训超时");
MiniGameSdk.API.showToast("订单已关闭");
const dataFail = {
outTradeNo: iosOutTradeNo,
price: this.iosPrice,
payment_name: this.iosProductId,
payment_num: this.iosCount,
type: "ios",
fail_reason: "用户充值后,轮训结果超时",
}
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
}
// this.btn_Touch = true;
// cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
// })
this.btn_Touch = true;
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
})
}
else {
this.closeLoad();