更新支付相关

This commit is contained in:
YZ\249929363 2025-07-15 18:27:19 +08:00
parent 9e627d3b69
commit f646c4a386
10 changed files with 1184 additions and 93 deletions

View File

@ -191,18 +191,21 @@
},
{
"__id__": 263
},
{
"__id__": 268
}
],
"_active": true,
"_components": [
{
"__id__": 268
"__id__": 277
},
{
"__id__": 269
"__id__": 278
},
{
"__id__": 270
"__id__": 279
}
],
"_prefab": null,
@ -12677,6 +12680,401 @@
"_N$enableBatch": false,
"_id": "c8qlI72JZCSKV6jXEK7mpe"
},
{
"__type__": "cc.Node",
"_name": "Loading",
"_objFlags": 0,
"_parent": {
"__id__": 4
},
"_children": [
{
"__id__": 269
},
{
"__id__": 272
},
{
"__id__": 274
}
],
"_active": false,
"_components": [
{
"__id__": 276
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1080,
"height": 1920
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "4ePjggj8tN46YqiIA+HRsb"
},
{
"__type__": "cc.Node",
"_name": "New Sprite(Splash)",
"_objFlags": 0,
"_parent": {
"__id__": 268
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 270
},
{
"__id__": 271
}
],
"_prefab": null,
"_opacity": 120,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 3000,
"height": 3000
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "d4h9nSj9RMM6HnwFOVyjf1"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 269
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "98Iik4j1ZAqqcF9AyC7FLx"
},
{
"__type__": "cc.BlockInputEvents",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 269
},
"_enabled": true,
"_id": "f7VWpZp11LWprv6A8lnYhR"
},
{
"__type__": "cc.Node",
"_name": "load",
"_objFlags": 0,
"_parent": {
"__id__": 268
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 273
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 689,
"height": 656
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
0.5,
0.5,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "eaR6sogyxOcJaWjbE5eSF1"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 272
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "794efc8c-624c-469f-84c0-24ce84022c54"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "5cezb/BW9Fw54XLAdLou49"
},
{
"__type__": "cc.Node",
"_name": "New Label",
"_objFlags": 0,
"_parent": {
"__id__": 268
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 275
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 135,
"height": 56.7
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "c1KHBTOahGpJS93C2sB/lp"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 274
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "请稍后",
"_N$string": "请稍后",
"_fontSize": 45,
"_lineHeight": 45,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "88GNsUUo5Mc6gDnzEvAq40"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 268
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "ce9uaZDp9PG6PxkobFhUHt"
},
{
"__type__": "cc.Canvas",
"_name": "",

View File

@ -215,9 +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;
if (data.data.outTradeNo.length > 0) {
console.log("设置补发数据", data.data.outTradeNo);
cc.fx.GameConfig.GM_INFO.allOutTradeNo = [];
cc.fx.GameConfig.GM_INFO.allOutTradeNo = data.data.outTradeNo;
console.log("______________________________有未发放奖励", cc.fx.GameConfig.GM_INFO.allOutTradeNo);
}
this.load6 = true;
});

View File

@ -63,7 +63,7 @@ export default class JiaZai extends cc.Component {
onLoad() {
cc.game.setFrameRate(63);
LQCollideSystem.is_enable = true;
// console.log("加载关卡配置2");
// //console.log("加载关卡配置2");
// window.initMgr();
GameManager._instance.Block_Color = this.Block_Color;
let version = cc.fx.GameTool.getWechatGameVersion();
@ -95,7 +95,7 @@ export default class JiaZai extends cc.Component {
if (cc.fx.GameConfig.GM_INFO.first) {
console.log("————————准备注册事件", cc.fx.GameConfig.GM_INFO.openid);
//console.log("————————准备注册事件", cc.fx.GameConfig.GM_INFO.openid);
const group = cc.fx.GameTool.setWechatGameGroup(2);
if (group == 0) {
cc.fx.GameConfig.GM_INFO.musicOpen = true;
@ -111,7 +111,7 @@ export default class JiaZai extends cc.Component {
cc.fx.StorageMessage.setStorage("music", audioInfo);
if (cc.fx.GameConfig.GM_INFO.openid != "") {
console.log("————————发送注册事件");
//console.log("————————发送注册事件");
const time = cc.fx.GameTool.formatDate(new Date());
let data = {
register_time: time, // 注册时间
@ -129,14 +129,16 @@ 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();
this.getOrder();
}
start() {
// console.log("已经进入Home界面");
// console.log("金币",cc.fx.GameConfig.GM_INFO.coin);
// console.log("关卡",cc.fx.GameConfig.GM_INFO.level+1);
// //console.log("已经进入Home界面");
// //console.log("金币",cc.fx.GameConfig.GM_INFO.coin);
// //console.log("关卡",cc.fx.GameConfig.GM_INFO.level+1);
cc.fx.GameTool.getHealth(null);
// cc.fx.GameConfig.LEVEL_INFO_init(false,0);
@ -216,7 +218,7 @@ export default class JiaZai extends cc.Component {
this.stopHeathTimeCutDown();
let timeTemp = cc.fx.GameTool.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time);
console.log("健康值倒计时结束,当前时间:", timeTemp, cc.fx.GameConfig.GM_INFO.min_Time);
//console.log("健康值倒计时结束,当前时间:", timeTemp, cc.fx.GameConfig.GM_INFO.min_Time);
if (timeLabelNode) {
NumberToImage.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time, 50, "time_", timeLabelNode);
}
@ -250,11 +252,14 @@ export default class JiaZai extends cc.Component {
if (this.Stamina && this.Stamina.getChildByName("time")) {
this.Stamina.getChildByName("time").getComponent(cc.Label).string = timeTemp;
}
MiniGameSdk.API.showToast("恢复一点体力");
cc.fx.GameTool.setUserHealth(1, (data) => {
cc.fx.GameTool.getHealth(null);
this.setHealthInfo();
})
if (cc.fx.GameConfig.GM_INFO.hp < 5) {
MiniGameSdk.API.showToast("恢复一点体力");
cc.fx.GameTool.setUserHealth(1, (data) => {
cc.fx.GameTool.getHealth(null);
this.setHealthInfo();
})
}
}
else {
cc.fx.GameConfig.GM_INFO.min_Time -= 1;
@ -363,7 +368,7 @@ export default class JiaZai extends cc.Component {
// 非第一次使用,直接激活节点
this.shopNode.active = true;
}
// console.log("shopNode parent:", this.shopNode.parent);
// //console.log("shopNode parent:", this.shopNode.parent);
}
// 关闭商店
@ -394,9 +399,9 @@ export default class JiaZai extends cc.Component {
openPause() {
cc.fx.AudioManager._instance.playEffect("anniu_little", null);
console.log(cc.fx.GameConfig.GM_INFO);
//console.log(cc.fx.GameConfig.GM_INFO);
if (cc.fx.GameConfig.GM_INFO.openid == undefined) {
console.log(cc.fx.GameConfig.GM_INFO.openid);
//console.log(cc.fx.GameConfig.GM_INFO.openid);
cc.fx.GameConfig.GM_INFO.openid = "";
}
this.node.getChildByName("Pause").active = true;
@ -443,9 +448,94 @@ export default class JiaZai extends cc.Component {
}
updateCoin() {
console.log("主页更新金币", cc.fx.GameConfig.GM_INFO.coin);
//console.log("主页更新金币", cc.fx.GameConfig.GM_INFO.coin);
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
}
getOrder() {
if (typeof wx !== 'undefined' && wx !== null) {
// 判断设备系统
let systemType = "Android";
try {
//@ts-ignore
const systemInfo = wx.getSystemInfoSync();
if (systemInfo.platform === 'ios') {
systemType = "ios";
}
} catch (e) {
console.error('获取系统信息失败', e);
}
if (cc.fx.GameConfig.GM_INFO.allOutTradeNo.length != 0) {
//console.log("有需要补发数据", cc.fx.GameConfig.GM_INFO.allOutTradeNo);
// 递归函数,按顺序处理每个订单
const processOrder = (index: number) => {
if (index >= cc.fx.GameConfig.GM_INFO.allOutTradeNo.length) {
return; // 所有订单处理完成
}
let order = cc.fx.GameConfig.GM_INFO.allOutTradeNo[index];
console.log("需要补发数据", order);
if (order.itemid == "gold_1" || order.itemid == "gold_2" || order.itemid == "gold_3"
|| order.itemid == "gold_4" || order.itemid == "gold_5" || order.itemid == "gold_6"
) {
this.openLoad();
console.log("补发名称:", order.itemid);
let productId = order.itemid;
Utils.setPayInfo((res) => {
console.log("设置轮训结果:", res);
this.closeLoad();
if (res.code === 1) {
console.log("7.14_________正式发货");
let coinTemp = 0;
if (order.itemid == "gold_1") { coinTemp = 1200; }
else if (order.itemid == "gold_2") { coinTemp = 8000; }
else if (order.itemid == "gold_3") { coinTemp = 16000; }
else if (order.itemid == "gold_4") { coinTemp = 32000; }
else if (order.itemid == "gold_5") { coinTemp = 100000; }
else if (order.itemid == "gold_6") { coinTemp = 240000; }
let title = "充值补发奖励金币:" + coinTemp;
MiniGameSdk.API.showToast(title);
cc.fx.GameTool.shopBuy(productId);
console.log("充值成功获得金币");
} else {
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
const dataFail4 = {
outTradeNo: Utils.outTradeNo,
price: parseInt(order.goodsPrice),
payment_name: productId,
payment_num: 1,
type: systemType,
fail_reason: "成功付款,但是发货时请求服务器失败,重新进入游戏后轮训发货又失败",
}
cc.fx.GameTool.shushu_Track("payment_fail", dataFail4);
}
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
this.updateCoin();
// 处理下一个订单
processOrder(index + 1);
}, order.outTradeNo);
} else {
// 如果当前订单不处理,直接处理下一个订单
processOrder(index + 1);
}
};
// 从第一个订单开始处理
processOrder(0);
}
}
}
openLoad() {
this.node.getChildByName("Loading").active = true;
this.node.getChildByName("Loading").getChildByName("load").stopAllActions();
this.node.getChildByName("Loading").getChildByName("load").runAction(cc.rotateTo(2, 1080).repeatForever());
}
closeLoad() {
this.node.getChildByName("Loading").active = false;
}
// update (dt) {}
}

View File

@ -1362,15 +1362,17 @@ export default class MapConroler extends cc.Component {
// alert("游戏成功");
MiniGameSdk.API.showToast(cc.fx.GameConfig.GM_INFO.level);
this.gameWin = true;
console.log("恢复一点体力", cc.fx.GameConfig.GM_INFO.level);
cc.fx.GameTool.setUserHealth(1, (data) => {
})
if (cc.fx.GameConfig.GM_INFO.hp < 5) {
console.log("恢复一点体力", cc.fx.GameConfig.GM_INFO.level);
cc.fx.GameTool.setUserHealth(1, (data) => {
})
}
this.stopTimeCutDown();
// console.log("即将上报成功________________________:",this.add_Time);
// console.log("成功消除一个",this.add_Time);
cc.fx.GameTool.changeCoin(40);
const data = {
change_reason: "闯关成功获得金币",
change_reason: "level",
id: (1001 + ""),
num: 40
}

View File

@ -73,12 +73,12 @@ export default class Utils {
}
static getPayInfo(callBack) {
const delays = [1000, 3000, 3000, 3000, 3000]; // 延迟时间数组
const delays = [1000, 3000, 6000, 9000, 12000];// 延迟时间数组
let attempt = 0; // 轮询次数
const poll = () => {
if (attempt >= delays.length) {
MiniGameSdk.API.showToast("网络异常,如充值成功,重进游戏可领取奖励");
MiniGameSdk.API.showToast("网络异常,如付款成功,重进游戏可领取奖励");
callBack({ code: 0, data: { pay_state: -1 }, message: '轮询超时' });
return;
}
@ -99,8 +99,8 @@ export default class Utils {
poll();
}
static setPayInfo(callBack) {
const delays = [1000, 3000, 3000, 3000, 3000];// 延迟时间数组
static setPayInfo(callBack, order) {
const delays = [1000, 3000, 6000, 9000, 12000];// 延迟时间数组
let attempt = 0; // 重试次数
const sendRequest = () => {
if (attempt > delays.length) {
@ -108,13 +108,17 @@ export default class Utils {
callBack({ code: 0, message: '请求失败,已达到最大重试次数' });
return;
}
Utils.POST("wx/getOrderReward", { outTradeNo: Utils.outTradeNo }, res => {
let orderTemp = Utils.outTradeNo;
if (order) orderTemp = order;
Utils.POST("wx/getOrderReward", { outTradeNo: orderTemp }, res => {
console.log("告知服务器发货:", res);
if (res.code === 1) {
console.log("告知服务器发货成功:", res);
// 请求成功,调用回调并返回结果
callBack(res);
} else {
// 请求失败,增加重试次数并设置下一次请求的延迟
console.log("告知服务器发货失败:", res);
attempt++;
if (attempt <= delays.length) {
setTimeout(sendRequest, delays[attempt - 1]);
@ -131,16 +135,24 @@ export default class Utils {
//#region ios支付
/**跳转客服*/
static GoKEFu() {
static GoKEFu(iosPayInfo) {
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = `wcx_` + Math.round(Math.random() * 10 ** 13) + Date.now();
const data = {
tpye: "ios",
outTradeNo: cc.fx.GameConfig.GM_INFO.iosOutTradeNo,
propName: '金币',
count: 1,
price: 100,//价格单位是分
propName: iosPayInfo.payment_name,
count: iosPayInfo.payment_count,
price: iosPayInfo.price,//价格单位是分
}
const shushu_data = {
outTradeNo: cc.fx.GameConfig.GM_INFO.iosOutTradeNo,
price: iosPayInfo.price,
payment_name: iosPayInfo.payment_name,
payment_num: iosPayInfo.payment_count,
type: "ios",
}
cc.fx.GameTool.shushu_Track("init_order", shushu_data);
//@ts-ignore
wx.openCustomerServiceConversation({
sessionFrom: JSON.stringify(data), // 会话来源(可选)
@ -150,28 +162,27 @@ export default class Utils {
}
});
}
static getIosPayInfo(callBack) {
const delays = [1000, 3000, 3000, 3000, 3000]; // 延迟时间数组
static getIosPayInfo(order, callBack) {
const delays = [1000, 3000, 6000, 9000, 12000];// 延迟时间数组
let attempt = 0; // 轮询次数
const iosOutTradeNo = order;
const poll = () => {
if (attempt >= delays.length) {
MiniGameSdk.API.showToast("网络异常,如充值成功,重进游戏可领取奖励");
callBack({ code: 0, data: null, message: '轮询超时' });
callBack({ code: 2, data: null, message: '轮询超时' });
return;
}
console.log("请求uid:" + Utils.uid);
console.log("outTradeNo:" + cc.fx.GameConfig.GM_INFO.iosOutTradeNo);
Utils.POST("wx/iosgetPayInfo", { outTradeNo: cc.fx.GameConfig.GM_INFO.iosOutTradeNo }, res => {
console.log("outTradeNo:" + iosOutTradeNo);
Utils.POST("wx/iosgetPayInfo", { outTradeNo: iosOutTradeNo }, res => {
console.log("查询字符结果IOS");
console.log(res);
if (res.code === 1) {
callBack(res);
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
} else if (res.code === 0) {
callBack(res);
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
}
else {
attempt++;
@ -183,8 +194,6 @@ export default class Utils {
poll();
}
//#endregion
//#region 微信云
@ -367,9 +376,7 @@ export default class Utils {
if (data == null) {
data = {};
}
// if(exports.token){//数据中加入安全密匙
// data.token=exports.token;
// }
if (extraUrl == null) {
//@ts-ignore
if (Utils.isDebug) {

View File

@ -652,17 +652,18 @@ var GameTool = {
cc.fx.GameTool.shushu_Track("resource_cost", dataTemp);
cc.fx.GameTool.setUserProp(propid, num, (data) => {
})
const data = {
change_reason: "商城购买道具",
id: (propid + ""),
num: 3
}
cc.fx.GameTool.shushu_Track("resource_get", data);
let _id = "";
if (propid == 2001) _id = "freeze_in_game";
else if (propid == 2002) _id = "hammer_in_game";
else if (propid == 2003) _id = "wand_in_game";
const data = {
change_reason: "game",
id: _id,
num: 3
}
cc.fx.GameTool.shushu_Track("resource_get", data);
const buyData = {
item_id: _id,
item_num: 3,
@ -875,8 +876,8 @@ var GameTool = {
break;
}
const dataTemp = {
change_reason: "商城RMB购买金币",
id: (1001 + ""),
change_reason: "shop",
id: productId,
num: coin
}
cc.fx.GameTool.shushu_Track("resource_get", dataTemp);

BIN
assets/shop/img/load.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "05d21d52-d94e-49d8-ac95-2d225e80df66",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1024,
"height": 1024,
"platformSettings": {},
"subMetas": {
"load": {
"ver": "1.0.6",
"uuid": "794efc8c-624c-469f-84c0-24ce84022c54",
"importer": "sprite-frame",
"rawTextureUuid": "05d21d52-d94e-49d8-ac95-2d225e80df66",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -3.5,
"offsetY": 120,
"trimX": 164,
"trimY": 64,
"width": 689,
"height": 656,
"rawWidth": 1024,
"rawHeight": 1024,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

View File

@ -34,19 +34,22 @@
},
{
"__id__": 327
},
{
"__id__": 335
}
],
"_active": true,
"_components": [
{
"__id__": 335
"__id__": 348
},
{
"__id__": 336
"__id__": 349
}
],
"_prefab": {
"__id__": 337
"__id__": 350
},
"_opacity": 255,
"_color": {
@ -12418,6 +12421,453 @@
"fileId": "66oM+CvTZBh6i/lRCAsoRc",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "Loading",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 336
},
{
"__id__": 340
},
{
"__id__": 343
}
],
"_active": false,
"_components": [
{
"__id__": 346
}
],
"_prefab": {
"__id__": 347
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1080,
"height": 1920
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "New Sprite(Splash)",
"_objFlags": 0,
"_parent": {
"__id__": 335
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 337
},
{
"__id__": 338
}
],
"_prefab": {
"__id__": 339
},
"_opacity": 120,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 3000,
"height": 3000
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 336
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.BlockInputEvents",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 336
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "47UiHH16RKK6j+4cK469um",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "load",
"_objFlags": 0,
"_parent": {
"__id__": 335
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 341
}
],
"_prefab": {
"__id__": 342
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 689,
"height": 656
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
0.5,
0.5,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 340
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "794efc8c-624c-469f-84c0-24ce84022c54"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "e0njfM7epDhL+otsGYSeCR",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "New Label",
"_objFlags": 0,
"_parent": {
"__id__": 335
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 344
}
],
"_prefab": {
"__id__": 345
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 135,
"height": 56.7
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 343
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "请稍后",
"_N$string": "请稍后",
"_fontSize": 45,
"_lineHeight": 45,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "fa+8dDqrdLTrl/Ji8K9LMX",
"sync": false
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 335
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "b50PfruR5P1axiaB0Q563i",
"sync": false
},
{
"__type__": "48bfeZuYFZE2qmgxbW2IigB",
"_name": "",

View File

@ -34,6 +34,12 @@ export default class NewClass extends cc.Component {
@property(cc.Node)
coinAnim: cc.Node = null;
private buy: boolean = false;
private iosPrice: number = 0;
private iosProductId: string = "";
private iosCount: number = 1;
onLoad() {
this.btn_Touch = true;
// 检测微信小游戏切到后台
@ -44,12 +50,14 @@ export default class NewClass extends cc.Component {
};
//@ts-ignore
wx.onShow(this.onShowListener);
}
}
start() {
this.btn_Touch = true;
this.openShop();
this.setHealthInfo();
}
//打开商店界面
openShop() {
@ -139,18 +147,101 @@ export default class NewClass extends cc.Component {
}
onShow() {
if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null && cc.fx.GameConfig.GM_INFO.iosOutTradeNo != "") {
console.log("有苹果订单号,开始轮训");
Utils.getIosPayInfo((data) => {
console.log("获得轮训结果:", data);
if (data.code == 1) {
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
MiniGameSdk.API.showToast("购买金币成功");
}
})
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null && cc.fx.GameConfig.GM_INFO.iosOutTradeNo != "") {
//console.log("有苹果订单号,开始轮训");
const iosOutTradeNo = cc.fx.GameConfig.GM_INFO.iosOutTradeNo;
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = "";
Utils.getIosPayInfo(iosOutTradeNo,
(data) => {
console.log("获得轮训结果:", data);
if (data.code == 1) {
console.log("购买成功");
const dataSuccess = {
outTradeNo: iosOutTradeNo,
price: this.iosPrice,
payment_name: this.iosProductId,
payment_num: this.iosCount,
type: "ios",
}
cc.fx.GameTool.shushu_Track("payment", dataSuccess);
let name = "购买金币道具:" + this.iosProductId;
MiniGameSdk.API.yinli_Pay(this.iosPrice, iosOutTradeNo, name)
Utils.setPayInfo((res) => {
this.closeLoad();
//console.log("设置轮训结果:", res);
if (res.code === 1) {
console.log("_________正式发货");
MiniGameSdk.API.showToast("充值成功");
cc.fx.GameTool.shopBuy(this.iosProductId);
//console.log("充值成功获得金币");
}
else {
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
const dataFail4 = {
outTradeNo: iosOutTradeNo,
price: this.iosPrice,
payment_name: this.iosProductId,
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();
}
}, null)
}
else if (data.code == 0) {
console.log("用户自己取消充值");
MiniGameSdk.API.showToast("充值失败");
this.closeLoad();
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;
})
}
}
}
openLoad() {
this.node.getChildByName("Loading").active = true;
this.node.getChildByName("Loading").getChildByName("load").stopAllActions();
this.node.getChildByName("Loading").getChildByName("load").runAction(cc.rotateTo(2, 1080).repeatForever());
}
closeLoad() {
this.node.getChildByName("Loading").active = false;
}
setHealthInfo() {
if (cc.fx.GameConfig.GM_INFO.hp >= 5) {
@ -239,7 +330,7 @@ export default class NewClass extends cc.Component {
price = 64800;
break;
}
console.log("获得商品id:", id, count, price);
//console.log("获得商品id:", id, count, price);
// 判断设备系统
let systemType = "Android";
try {
@ -256,7 +347,16 @@ export default class NewClass extends cc.Component {
if (systemType == "ios") {
// MiniGameSdk.API.showToast("IOS系统暂不支持支付");
// this.btn_Touch = true;
Utils.GoKEFu();
this.openLoad();
let iosPayInfo = {
price: price,
payment_name: productId,
payment_count: 1,
}
this.iosPrice = price;
this.iosProductId = productId;
this.iosCount = 1;
Utils.GoKEFu(iosPayInfo);
}
else {
const data = {
@ -267,9 +367,10 @@ export default class NewClass extends cc.Component {
type: systemType,
}
cc.fx.GameTool.shushu_Track("init_order", data);
console.log("7.14_____________________", "调用充值接口");
this.openLoad();
//console.log("7.14_____________________", "调用充值接口");
Utils.buyProp(id, count, price, (res) => {
console.log("获得充值结果", res);
//console.log("获得充值结果", res);
if (res == null) {
MiniGameSdk.API.showToast("充值失败");
this.btn_Touch = true;
@ -282,11 +383,12 @@ export default class NewClass extends cc.Component {
fail_reason: "网络异常,没有拉起支付",
}
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
this.closeLoad();
return;
}
else if (res.err) {
MiniGameSdk.API.showToast("充值失败");
console.log(res);
//console.log(res);
this.btn_Touch = true;
let name = "支付拉起失败";
if (res.errCode == -2) {
@ -301,12 +403,14 @@ export default class NewClass extends cc.Component {
fail_reason: name,
}
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
this.closeLoad();
return;
}
else {
Utils.getPayInfo((data) => {
console.log("7.14_______________充值成功,准备轮训");
console.log("获得轮训结果:", data);
//console.log("7.14_______________充值成功,准备轮训");
//console.log("获得轮训结果:", data);
this.closeLoad();
if (data.data.pay_state == 1) {
this.btn_Touch = true;
MiniGameSdk.API.showToast("取消充值");
@ -322,24 +426,24 @@ 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_________正式发货");
const dataSuccess = {
outTradeNo: Utils.outTradeNo,
price: price,
payment_name: productId,
payment_num: 1,
type: systemType,
}
cc.fx.GameTool.shushu_Track("payment", dataSuccess);
let name = "购买金币道具:" + productId;
MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name)
//console.log("7.14_______________充值成功,轮训成功,准备发货");
Utils.setPayInfo((res) => {
//console.log("设置轮训结果:", res);
if (res.code === 1) {
//console.log("7.14_________正式发货");
MiniGameSdk.API.showToast("充值成功");
cc.fx.GameTool.shopBuy(productId);
console.log("充值成功获得金币");
const dataSuccess = {
outTradeNo: Utils.outTradeNo,
price: price,
payment_name: productId,
payment_num: 1,
type: systemType,
}
cc.fx.GameTool.shushu_Track("payment", dataSuccess);
let name = "购买金币道具:" + productId;
MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name)
//console.log("充值成功获得金币");
}
else {
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
@ -359,8 +463,7 @@ export default class NewClass extends cc.Component {
else if (this.node.parent.getComponent("SceneManager")) {
this.node.parent.getComponent("SceneManager").updateCoin();
}
})
}, null)
}
else {
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);