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) => { Utils.getUserInfo((data) => {
if (data.code == 1) { // 假设返回数据中有 success 字段表示成功 if (data.code == 1) { // 假设返回数据中有 success 字段表示成功
//console.log("登录成功时间耗时:", Date.now() - this.nowTime); //console.log("登录成功时间耗时:", Date.now() - this.nowTime);
console.log("登陆成功_____________"); // console.log("111登陆成功_____________");
console.log(data); console.log("登錄", data);
//console.log("uid", data.data.onlyId); //console.log("uid", data.data.onlyId);
if (data.data._id) { if (data.data._id) {
cc.fx.GameConfig.GM_INFO.uid = 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() { onLoad() {
this.btn_Touch = true; this.btn_Touch = true;
// 检测微信小游戏切到后台 // 检测微信小游戏切到后台
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
// 定义监听函数
this.onShowListener = () => {
this.onShow();
};
//@ts-ignore
wx.onShow(this.onShowListener);
}
} }
onShow() { onShow() {
@ -140,7 +132,15 @@ export default class Revive extends cc.Component {
} }
} }
init() { 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; this.btn_Touch = true;
if (cc.fx.GameConfig.GM_INFO.revive == 1) { if (cc.fx.GameConfig.GM_INFO.revive == 1) {
this.node.active = false; this.node.active = false;

View File

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

View File

@ -37,14 +37,6 @@ export default class NewClass extends cc.Component {
onLoad() { onLoad() {
this.btn_Touch = true; 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; this.home = 0;
} }
@ -156,6 +148,15 @@ export default class NewClass extends cc.Component {
} }
init() { 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; this.btn_Touch = true;
if (cc.fx.GameConfig.GM_INFO.hp_Max == 7) { if (cc.fx.GameConfig.GM_INFO.hp_Max == 7) {
this.monthCardBtn.active = false; 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": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 1080, "width": 1080,
"height": 3350 "height": 3200
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@ -768,7 +768,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
900, 55.944,
0, 0,
0, 0,
0, 0,
@ -824,19 +824,19 @@
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 1080, "width": 1080,
"height": 2000 "height": 1700
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0.5, "x": 0.5,
"y": 0.5 "y": 1
}, },
"_trs": { "_trs": {
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
-73.284, 885.733,
0, 0,
0, 0,
0, 0,

View File

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