更新支付配置
This commit is contained in:
parent
86a184926b
commit
9e627d3b69
File diff suppressed because it is too large
Load Diff
|
@ -39,6 +39,7 @@ export default class GameManager extends cc.Component {
|
|||
load3: boolean = false;
|
||||
load4: boolean = false;
|
||||
load5: boolean = false;
|
||||
load6: boolean = false;
|
||||
scheduleCallback: any;
|
||||
timeNumber: number;
|
||||
|
||||
|
@ -55,7 +56,7 @@ export default class GameManager extends cc.Component {
|
|||
this.readMusicConfig();
|
||||
|
||||
|
||||
this.load1 = this.load2 = this.load3 = this.load4 = this.load5 = false;
|
||||
this.load1 = this.load2 = this.load3 = this.load4 = this.load5 = this.load6 = false;
|
||||
setTimeout(() => {
|
||||
this.readUserData();
|
||||
}, 200);
|
||||
|
@ -214,6 +215,11 @@ export default class GameManager extends cc.Component {
|
|||
MiniGameSdk.API.shushu_Init();
|
||||
Utils.getUserInfo((data) => {
|
||||
console.log("登陆成功", data);
|
||||
if (data.outTradeNo.length > 0) {
|
||||
console.log("______________________________有未发放奖励");
|
||||
cc.fx.GameConfig.GM_INFO.allOutTradeNo = data.outTradeNo;
|
||||
}
|
||||
this.load6 = true;
|
||||
});
|
||||
let levelInfo = cc.fx.StorageMessage.getStorage("level");
|
||||
//旧的读取数据设置数据方法,以强联网为主
|
||||
|
@ -235,6 +241,7 @@ export default class GameManager extends cc.Component {
|
|||
this.load3 = true;
|
||||
this.load4 = true;
|
||||
this.load5 = true;
|
||||
this.load6 = true;
|
||||
cc.fx.GameTool.getHealth(null);
|
||||
}
|
||||
// 存储用户数据
|
||||
|
@ -682,7 +689,7 @@ export default class GameManager extends cc.Component {
|
|||
}
|
||||
|
||||
update(dt) {
|
||||
if (this.load1 && this.load2 && this.load3 && this.load4 && this.load5 && this.timeNumber <= 0) {
|
||||
if (this.load1 && this.load2 && this.load3 && this.load4 && this.load5 && this.load6 == true && this.timeNumber <= 0) {
|
||||
this.load1 = this.load2 = false;
|
||||
MiniGameSdk.API.shushu_Login();
|
||||
MiniGameSdk.API.yinli_Init();
|
||||
|
|
|
@ -247,7 +247,7 @@ export default class MapConroler extends cc.Component {
|
|||
this.add_Time = 0;
|
||||
NumberToImage.getTimeMargin(this.timeNumber, 50, "time_", this.timeLabel)
|
||||
|
||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||
this.updateCoin();
|
||||
// var timeTemp = cc.fx.GameTool.getTimeMargin(this.timeNumber);
|
||||
// this.timeLabel.string = timeTemp.toString();
|
||||
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 50, 20, "level_", this.levelLabel, true)
|
||||
|
@ -1520,7 +1520,8 @@ export default class MapConroler extends cc.Component {
|
|||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_cost", dataTemp);
|
||||
MiniGameSdk.API.showToast("继续游戏");
|
||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||
this.updateCoin();
|
||||
// NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||
if (data.type == "time") {
|
||||
if (cc.fx.GameConfig.GM_INFO.review < 2)
|
||||
cc.fx.GameConfig.GM_INFO.review += 1;
|
||||
|
@ -1791,7 +1792,8 @@ export default class MapConroler extends cc.Component {
|
|||
}
|
||||
|
||||
handleBuySuccess(data) {
|
||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||
this.node.parent.parent.parent.getComponent("SceneManager").resetBtn();
|
||||
this.updateCoin();
|
||||
this.pause = false;
|
||||
this.startBoom();
|
||||
const timestamp = Date.now();
|
||||
|
@ -1850,6 +1852,10 @@ export default class MapConroler extends cc.Component {
|
|||
|
||||
}
|
||||
|
||||
updateCoin() {
|
||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||
}
|
||||
|
||||
//使用锤子道具
|
||||
useHammer() {
|
||||
if (this.node.parent.getChildByName("Ice").active == true || this.hammer == true
|
||||
|
@ -1899,6 +1905,7 @@ export default class MapConroler extends cc.Component {
|
|||
buyMagic() {
|
||||
if (cc.fx.GameConfig.GM_INFO.coin < 1500) {
|
||||
MiniGameSdk.API.showToast("金币不足,无法购买道具");
|
||||
this.node.parent.parent.parent.getComponent("SceneManager").resetBtn();
|
||||
setTimeout(() => {
|
||||
this.openShop();
|
||||
}, 500);
|
||||
|
@ -1910,6 +1917,7 @@ export default class MapConroler extends cc.Component {
|
|||
buyHammer() {
|
||||
if (cc.fx.GameConfig.GM_INFO.coin < 1000) {
|
||||
MiniGameSdk.API.showToast("金币不足,无法购买道具");
|
||||
this.node.parent.parent.parent.getComponent("SceneManager").resetBtn();
|
||||
setTimeout(() => {
|
||||
this.openShop();
|
||||
}, 500);
|
||||
|
@ -1921,6 +1929,7 @@ export default class MapConroler extends cc.Component {
|
|||
buyFreeze() {
|
||||
if (cc.fx.GameConfig.GM_INFO.coin < 1500) {
|
||||
MiniGameSdk.API.showToast("金币不足,无法购买道具");
|
||||
this.node.parent.parent.parent.getComponent("SceneManager").resetBtn();
|
||||
setTimeout(() => {
|
||||
this.openShop();
|
||||
}, 500);
|
||||
|
|
|
@ -96,10 +96,10 @@ export default class SceneManager extends cc.Component {
|
|||
}, 1000);
|
||||
|
||||
}
|
||||
//更新关卡获得金币
|
||||
//更新关卡获得金币
|
||||
updateWinCoin() {
|
||||
console.log("更新关卡获得金币");
|
||||
let winCoin = 40;
|
||||
let winCoin = 40;
|
||||
if (winCoin > 0) {
|
||||
NumberToImage.numberToImageNodes(winCoin, 50, 8, "time_", this.winCoin, false);
|
||||
} else {
|
||||
|
@ -117,8 +117,8 @@ export default class SceneManager extends cc.Component {
|
|||
}
|
||||
this.node.getChildByName("Game").getChildByName("bg").getComponent(cc.Sprite).spriteFrame = spriteFrame;
|
||||
})
|
||||
|
||||
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level+1), 43, 15, "level_", this.level, true);
|
||||
|
||||
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 43, 15, "level_", this.level, true);
|
||||
//time金币数量
|
||||
NumberToImage.numberToImageNodes(1000, 25, 15, "button_", this.timeCoin, false);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ export default class SceneManager extends cc.Component {
|
|||
|
||||
returnHome() {
|
||||
if (this.node.getChildByName("Pause").getChildByName("btn").getComponent("btnControl")._touch) {
|
||||
this.closePause();
|
||||
this.closePause();
|
||||
if (MapConroler._instance.gameStart == true) {
|
||||
MiniGameSdk.API.showToast("体力值减少");
|
||||
// cc.fx.GameTool.setUserHealth(-1, (data) => {
|
||||
|
@ -217,7 +217,7 @@ export default class SceneManager extends cc.Component {
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
cc.director.loadScene("HomeScene");
|
||||
}, 1200);
|
||||
|
@ -269,7 +269,7 @@ export default class SceneManager extends cc.Component {
|
|||
}
|
||||
}
|
||||
|
||||
closeShop(){
|
||||
closeShop() {
|
||||
if (this.shopNode) {
|
||||
this.shopNode.active = false;
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ export default class SceneManager extends cc.Component {
|
|||
openPropBuy(name) {
|
||||
MapConroler._instance.pause = true;
|
||||
MapConroler._instance.stopBoom();
|
||||
|
||||
|
||||
this.btnName = name;
|
||||
let propWindow = this.node.getChildByName("Game").getChildByName("propWindow");
|
||||
propWindow.active = true;
|
||||
|
@ -320,6 +320,12 @@ export default class SceneManager extends cc.Component {
|
|||
MapConroler._instance.buyMagic();
|
||||
}
|
||||
}
|
||||
|
||||
resetBtn() {
|
||||
let propWindow = this.node.getChildByName("Game").getChildByName("propWindow");
|
||||
propWindow.getChildByName("buy_Btn").getComponent("btnControl").setTouch(true);
|
||||
}
|
||||
|
||||
//打开商店
|
||||
openShop() {
|
||||
if (!SceneManager.cachedShopPrefab) {
|
||||
|
@ -338,6 +344,10 @@ export default class SceneManager extends cc.Component {
|
|||
// console.log("shopNode parent:", this.shopNode.parent);
|
||||
}
|
||||
|
||||
updateCoin() {
|
||||
MapConroler._instance.updateCoin();
|
||||
}
|
||||
|
||||
|
||||
closePropBuy() {
|
||||
MapConroler._instance.pause = false;
|
||||
|
|
|
@ -1127,7 +1127,7 @@ export namespace MiniGameSdk {
|
|||
},
|
||||
// 根据环境变量设置 debug 模式
|
||||
debug: !isProduction,
|
||||
enableLog: true
|
||||
enableLog: false
|
||||
};
|
||||
// 创建 TA 实例
|
||||
API._ta = new ThinkingAnalyticsAPI(config);
|
||||
|
@ -1173,7 +1173,7 @@ export namespace MiniGameSdk {
|
|||
static updateCoinAndLevel() {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
console.log("上传金币和关卡信息给数数")
|
||||
API._ta.userSet({ current_level: cc.fx.GameConfig.GM_INFO.level });
|
||||
API._ta.userSet({ current_level: (cc.fx.GameConfig.GM_INFO.level + 1) });
|
||||
API._ta.userSet({ current_coin: cc.fx.GameConfig.GM_INFO.coin });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ export class GameConfig {
|
|||
score: number; //总得分
|
||||
scale: number; //玩家总计成功点火数
|
||||
iosOutTradeNo: string; //ios订单号
|
||||
allOutTradeNo: any[]; //订单号数组
|
||||
min_Time: number; //体力恢复的剩余时间
|
||||
freezeAmount: number; //冻结道具次数
|
||||
hammerAmount: number; //锤子道具次数
|
||||
|
@ -99,6 +100,7 @@ export class GameConfig {
|
|||
};
|
||||
|
||||
|
||||
|
||||
//游戏内信息
|
||||
|
||||
static get Instance() {
|
||||
|
@ -221,6 +223,7 @@ export class GameConfig {
|
|||
score: 0, //总得分
|
||||
scale: 1, //玩家总计成功点火数
|
||||
iosOutTradeNo: "", //ios订单号
|
||||
allOutTradeNo: [], //订单号数组
|
||||
min_Time: 0, //体力恢复的剩余时间
|
||||
freezeAmount: 0, //冻结道具次数
|
||||
hammerAmount: 0, //锤子道具次数
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { MiniGameSdk } from "../../Sdk/MiniGameSdk";
|
||||
|
||||
export default class Utils {
|
||||
static uid: string = "";
|
||||
static session_key = "";
|
||||
|
@ -19,7 +21,7 @@ export default class Utils {
|
|||
Utils.openid = ret.data.openid;
|
||||
Utils.session_key = ret.data.session_key;
|
||||
Utils.uid = ret.data._id;
|
||||
callBack(Utils.uid);
|
||||
callBack(ret);
|
||||
})
|
||||
} else {
|
||||
console.log('登录失败!' + res.errMsg)
|
||||
|
@ -35,19 +37,33 @@ export default class Utils {
|
|||
Utils.POST("wx/orderPaySig", { uid: Utils.uid, itemid: id, itemCount: count, itemPrice: price }, res => {
|
||||
if (res.code == 1) {
|
||||
Utils.outTradeNo = res.data.outTradeNo;
|
||||
// let timeoutId: number;
|
||||
// const timeoutDuration = 30000; // 30 秒超时时间
|
||||
// // 设置超时定时器
|
||||
// timeoutId = setTimeout(() => {
|
||||
// console.error('支付请求超时');
|
||||
// callBack("请求支付超时");
|
||||
// }, timeoutDuration);
|
||||
//@ts-ignore
|
||||
wx.requestMidasPaymentGameItem({
|
||||
signData: res.data.signData,
|
||||
paySig: res.data.paySig,
|
||||
signature: res.data.signature,
|
||||
success(res, errCode) {
|
||||
// clearTimeout(timeoutId); // 清除超时定时器
|
||||
console.log('成功', res, errCode);
|
||||
callBack(res);
|
||||
},
|
||||
fail({ errMsg, errCode }) {
|
||||
console.error('失败');
|
||||
console.error(errMsg, errCode)
|
||||
callBack(null);
|
||||
// clearTimeout(timeoutId); // 清除超时定时器
|
||||
console.log('失败');
|
||||
console.log(errMsg, errCode)
|
||||
let data = {
|
||||
errMsg: errMsg,
|
||||
errCode: errCode,
|
||||
err: "请求支付失败",
|
||||
}
|
||||
callBack(data);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -57,11 +73,12 @@ export default class Utils {
|
|||
|
||||
}
|
||||
static getPayInfo(callBack) {
|
||||
const delays = [1000, 10000, 30000, 60000, 60000]; // 延迟时间数组
|
||||
const delays = [1000, 3000, 3000, 3000, 3000]; // 延迟时间数组
|
||||
let attempt = 0; // 轮询次数
|
||||
|
||||
const poll = () => {
|
||||
if (attempt >= delays.length) {
|
||||
MiniGameSdk.API.showToast("网络异常,如充值成功,重进游戏可领取奖励");
|
||||
callBack({ code: 0, data: { pay_state: -1 }, message: '轮询超时' });
|
||||
return;
|
||||
}
|
||||
|
@ -83,7 +100,7 @@ export default class Utils {
|
|||
}
|
||||
|
||||
static setPayInfo(callBack) {
|
||||
const delays = [1000, 5000, 10000, 20000, 30000]; // 延迟时间数组
|
||||
const delays = [1000, 3000, 3000, 3000, 3000];// 延迟时间数组
|
||||
let attempt = 0; // 重试次数
|
||||
const sendRequest = () => {
|
||||
if (attempt > delays.length) {
|
||||
|
@ -134,11 +151,12 @@ export default class Utils {
|
|||
});
|
||||
}
|
||||
static getIosPayInfo(callBack) {
|
||||
const delays = [1000, 10000, 30000, 60000, 60000]; // 延迟时间数组
|
||||
const delays = [1000, 3000, 3000, 3000, 3000]; // 延迟时间数组
|
||||
let attempt = 0; // 轮询次数
|
||||
|
||||
const poll = () => {
|
||||
if (attempt >= delays.length) {
|
||||
MiniGameSdk.API.showToast("网络异常,如充值成功,重进游戏可领取奖励");
|
||||
callBack({ code: 0, data: null, message: '轮询超时' });
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
"premultiplyAlpha": false,
|
||||
"genMipmaps": false,
|
||||
"packable": true,
|
||||
"width": 2042,
|
||||
"height": 1680,
|
||||
"width": 2025,
|
||||
"height": 1420,
|
||||
"platformSettings": {},
|
||||
"subMetas": {}
|
||||
}
|
|
@ -139,7 +139,7 @@ export default class NewClass extends cc.Component {
|
|||
}
|
||||
|
||||
onShow() {
|
||||
if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null) {
|
||||
if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null && cc.fx.GameConfig.GM_INFO.iosOutTradeNo != "") {
|
||||
console.log("有苹果订单号,开始轮训");
|
||||
Utils.getIosPayInfo((data) => {
|
||||
console.log("获得轮训结果:", data);
|
||||
|
@ -254,9 +254,9 @@ export default class NewClass extends cc.Component {
|
|||
|
||||
// Utils.GoKEFu();
|
||||
if (systemType == "ios") {
|
||||
MiniGameSdk.API.showToast("IOS系统暂不支持支付");
|
||||
this.btn_Touch = true;
|
||||
// Utils.GoKEFu();
|
||||
// MiniGameSdk.API.showToast("IOS系统暂不支持支付");
|
||||
// this.btn_Touch = true;
|
||||
Utils.GoKEFu();
|
||||
}
|
||||
else {
|
||||
const data = {
|
||||
|
@ -267,11 +267,11 @@ export default class NewClass extends cc.Component {
|
|||
type: systemType,
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("init_order", data);
|
||||
|
||||
console.log("7.14_____________________", "调用充值接口");
|
||||
Utils.buyProp(id, count, price, (res) => {
|
||||
console.log("获得充值结果", res);
|
||||
if (res == null) {
|
||||
MiniGameSdk.API.showToast("网络异常,充值失败请稍后再试");
|
||||
MiniGameSdk.API.showToast("充值失败");
|
||||
this.btn_Touch = true;
|
||||
const dataFail = {
|
||||
outTradeNo: Utils.outTradeNo,
|
||||
|
@ -284,13 +284,32 @@ export default class NewClass extends cc.Component {
|
|||
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
|
||||
return;
|
||||
}
|
||||
else if (res.err) {
|
||||
MiniGameSdk.API.showToast("充值失败");
|
||||
console.log(res);
|
||||
this.btn_Touch = true;
|
||||
let name = "支付拉起失败";
|
||||
if (res.errCode == -2) {
|
||||
name = "用户取消充值";
|
||||
}
|
||||
const dataFail = {
|
||||
outTradeNo: Utils.outTradeNo,
|
||||
price: price,
|
||||
payment_name: productId,
|
||||
payment_num: 1,
|
||||
type: systemType,
|
||||
fail_reason: name,
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
Utils.getPayInfo((data) => {
|
||||
console.log("7.14_______________充值成功,准备轮训");
|
||||
console.log("获得轮训结果:", data);
|
||||
if (data.data.pay_state == 1) {
|
||||
this.btn_Touch = true;
|
||||
MiniGameSdk.API.showToast("取消充值");
|
||||
|
||||
const dataFail2 = {
|
||||
outTradeNo: Utils.outTradeNo,
|
||||
price: price,
|
||||
|
@ -303,9 +322,11 @@ export default class NewClass extends cc.Component {
|
|||
}
|
||||
else if (data.data.pay_state == 2) {
|
||||
this.btn_Touch = true;
|
||||
console.log("7.14_______________充值成功,轮训成功,准备发货");
|
||||
Utils.setPayInfo((data) => {
|
||||
console.log("设置轮训结果:", data);
|
||||
if (data.code === 1) {
|
||||
console.log("7.14_________正式发货");
|
||||
MiniGameSdk.API.showToast("充值成功");
|
||||
cc.fx.GameTool.shopBuy(productId);
|
||||
console.log("充值成功获得金币");
|
||||
|
@ -333,12 +354,16 @@ export default class NewClass extends cc.Component {
|
|||
cc.fx.GameTool.shushu_Track("payment_fail", dataFail4);
|
||||
}
|
||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||
this.node.parent.getComponent("JiaZai").updateCoin();
|
||||
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();
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
else {
|
||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||
this.node.parent.getComponent("JiaZai").updateCoin();
|
||||
const dataFail3 = {
|
||||
outTradeNo: Utils.outTradeNo,
|
||||
price: price,
|
||||
|
@ -348,6 +373,12 @@ export default class NewClass extends cc.Component {
|
|||
fail_reason: "拉起支付后,付款时网络异常付款失败",
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("payment_fail", dataFail3);
|
||||
this.btn_Touch = 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();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"last-module-event-record-time": 1751876016726,
|
||||
"last-module-event-record-time": 1752481846169,
|
||||
"group-list": [
|
||||
"default",
|
||||
"Map"
|
||||
|
|
Loading…
Reference in New Issue
Block a user