修改 一些代码
This commit is contained in:
parent
3127af522f
commit
a7edab0b6e
File diff suppressed because it is too large
Load Diff
|
@ -300,7 +300,10 @@ export default class Block extends cc.Component {
|
|||
let spriteFrame = this.ice_SpriteFrame._spriteFrames[name];
|
||||
freeze.getChildByName("icon").getComponent(cc.Sprite).spriteFrame = spriteFrame;
|
||||
let freezeX = posConfig.pos6.x-(this.node.width*(this.node.anchorX-0.5)); let freezeY = posConfig.pos6.y + this.node.height/2;
|
||||
freeze.setPosition(freezeX,freezeY);
|
||||
if(this.block_Info.block == 2){
|
||||
freeze.setPosition(freezeX+4,freezeY-10);
|
||||
}
|
||||
else freeze.setPosition(freezeX,freezeY);
|
||||
freeze.getComponent("Freeze").init(this.block_Info.freezeTime);
|
||||
freeze.getChildByName("time").setPosition(posConfig.pos5.x-10-freezeX,posConfig.pos5.y-2-freezeY);
|
||||
break;
|
||||
|
|
|
@ -13,7 +13,12 @@ import Utils from "./module/Pay/Utils";
|
|||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class NewClass extends cc.Component {
|
||||
export default class JiaZai extends cc.Component {
|
||||
|
||||
// 缓存 shop 预制体
|
||||
private static cachedShopPrefab: cc.Prefab | null = null;
|
||||
// 缓存 shop 节点
|
||||
private shopNode: cc.Node | null = null;
|
||||
|
||||
@property(cc.Node)
|
||||
node1: cc.Node = null;
|
||||
|
@ -58,6 +63,25 @@ export default class NewClass extends cc.Component {
|
|||
// console.log("加载关卡配置2");
|
||||
// window.initMgr();
|
||||
GameManager._instance.Block_Color = this.Block_Color;
|
||||
|
||||
// 预加载 shop 预制体
|
||||
if (!JiaZai.cachedShopPrefab) {
|
||||
cc.assetManager.loadBundle('shop', (err: Error, bundle: cc.AssetManager.Bundle) => {
|
||||
if (err) {
|
||||
cc.error(err.message || err);
|
||||
return;
|
||||
}
|
||||
bundle.load('prefab/shop', cc.Prefab, (err: Error, prefab: cc.Prefab) => {
|
||||
if (err) {
|
||||
cc.error(err.message || err);
|
||||
return;
|
||||
}
|
||||
JiaZai.cachedShopPrefab = prefab;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (cc.fx.GameConfig.GM_INFO.first) {
|
||||
console.log("————————准备注册事件", cc.fx.GameConfig.GM_INFO.openid);
|
||||
if (cc.fx.GameConfig.GM_INFO.openid != "") {
|
||||
|
@ -111,7 +135,6 @@ export default class NewClass extends cc.Component {
|
|||
|
||||
}
|
||||
|
||||
|
||||
//打开heath弹窗,创建预制体
|
||||
openHeath() {
|
||||
let health = cc.instantiate(this.health);
|
||||
|
@ -203,20 +226,27 @@ export default class NewClass extends cc.Component {
|
|||
|
||||
//打开商店
|
||||
openShop() {
|
||||
// 加载 shop bundle
|
||||
cc.assetManager.loadBundle('shop', (err: Error, bundle: cc.AssetManager.Bundle) => {
|
||||
bundle.load('prefab/shop', cc.Prefab, (err: Error, prefab: cc.Prefab) => {
|
||||
if (err) {
|
||||
cc.error(err.message || err);
|
||||
if (!JiaZai.cachedShopPrefab) {
|
||||
cc.error('Shop prefab is not loaded yet.');
|
||||
return;
|
||||
}
|
||||
if (prefab) {
|
||||
const shopNode = cc.instantiate(prefab);
|
||||
this.node.addChild(shopNode);
|
||||
console.log("shopNode parent:", shopNode.parent);
|
||||
|
||||
if (!this.shopNode) {
|
||||
// 第一次使用,创建节点
|
||||
this.shopNode = cc.instantiate(JiaZai.cachedShopPrefab);
|
||||
this.node.addChild(this.shopNode);
|
||||
} else {
|
||||
// 非第一次使用,直接激活节点
|
||||
this.shopNode.active = true;
|
||||
}
|
||||
// console.log("shopNode parent:", this.shopNode.parent);
|
||||
}
|
||||
|
||||
// 关闭商店
|
||||
closeShop() {
|
||||
if (this.shopNode) {
|
||||
this.shopNode.active = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
closeRank() {
|
||||
|
|
|
@ -193,13 +193,14 @@ export default class MapConroler extends cc.Component {
|
|||
// this.node.getChildByName("Wall").zIndex = 10;
|
||||
this.timeLabel = this.node.parent.getChildByName("Top").getChildByName("time");
|
||||
this.levelLabel = this.node.parent.getChildByName("Top").getChildByName("level");
|
||||
this.coin = this.node.parent.getChildByName("Top").getChildByName("coin");
|
||||
this.coin = this.node.parent.getChildByName("Top").getChildByName("shop").getChildByName("coin");
|
||||
this.timeNumber = cc.fx.GameConfig.LEVEL_INFO[0].time;
|
||||
console.log("当前关卡时间", this.timeNumber);
|
||||
|
||||
this.count_Time = 0;
|
||||
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);
|
||||
// var timeTemp = cc.fx.GameTool.getTimeMargin(this.timeNumber);
|
||||
// this.timeLabel.string = timeTemp.toString();
|
||||
|
@ -1647,7 +1648,7 @@ export default class MapConroler extends cc.Component {
|
|||
|
||||
this.pause = true;
|
||||
this.node.parent.getChildByName("Ice").active = true;
|
||||
this.node.parent.getChildByName("Top").getChildByName("Ice").active = true;
|
||||
// this.node.parent.getChildByName("Top").getChildByName("Ice").active = true;
|
||||
|
||||
cc.fx.GameConfig.GM_INFO.freezeAmount -= 1;
|
||||
if (cc.fx.GameConfig.GM_INFO.freezeAmount < 0)
|
||||
|
@ -1679,7 +1680,7 @@ export default class MapConroler extends cc.Component {
|
|||
let freezeBtn = this.node.parent.getChildByName("Bottom").getChildByName("timeBtn");
|
||||
freezeBtn.getComponent("btnControl").setTouch(true);
|
||||
this.node.parent.getChildByName("Ice").active = false;
|
||||
this.node.parent.getChildByName("Top").getChildByName("Ice").active = false;
|
||||
// this.node.parent.getChildByName("Top").getChildByName("Ice").active = false;
|
||||
this.pause = false;
|
||||
// this.startTimeCutDown();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ const { ccclass, property } = cc._decorator;
|
|||
@ccclass
|
||||
export default class SceneManager extends cc.Component {
|
||||
|
||||
// 缓存 shop 预制体
|
||||
private static cachedShopPrefab: cc.Prefab | null = null;
|
||||
// 缓存 shop 节点
|
||||
private shopNode: cc.Node | null = null;
|
||||
|
||||
@property(cc.Label)
|
||||
label: cc.Label = null;
|
||||
|
||||
|
@ -64,7 +69,22 @@ export default class SceneManager extends cc.Component {
|
|||
onLoad() {
|
||||
cc.game.setFrameRate(63);
|
||||
this.changeBg();
|
||||
|
||||
// 预加载 shop 预制体
|
||||
if (!SceneManager.cachedShopPrefab) {
|
||||
cc.assetManager.loadBundle('shop', (err: Error, bundle: cc.AssetManager.Bundle) => {
|
||||
if (err) {
|
||||
cc.error(err.message || err);
|
||||
return;
|
||||
}
|
||||
bundle.load('prefab/shop', cc.Prefab, (err: Error, prefab: cc.Prefab) => {
|
||||
if (err) {
|
||||
cc.error(err.message || err);
|
||||
return;
|
||||
}
|
||||
SceneManager.cachedShopPrefab = prefab;
|
||||
});
|
||||
});
|
||||
}
|
||||
setTimeout(() => {
|
||||
cc.director.preloadScene("HomeScene", (err) => {
|
||||
if (err) {
|
||||
|
@ -243,7 +263,12 @@ export default class SceneManager extends cc.Component {
|
|||
this.node.getChildByName("Pause").active = true;
|
||||
MapConroler._instance.pause = true;
|
||||
}
|
||||
}
|
||||
|
||||
closeShop(){
|
||||
if (this.shopNode) {
|
||||
this.shopNode.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
closePause() {
|
||||
|
@ -282,20 +307,20 @@ export default class SceneManager extends cc.Component {
|
|||
}
|
||||
//打开商店
|
||||
openShop() {
|
||||
// 加载 shop bundle
|
||||
cc.assetManager.loadBundle('shop', (err: Error, bundle: cc.AssetManager.Bundle) => {
|
||||
bundle.load('prefab/shop', cc.Prefab, (err: Error, prefab: cc.Prefab) => {
|
||||
if (err) {
|
||||
cc.error(err.message || err);
|
||||
if (!SceneManager.cachedShopPrefab) {
|
||||
cc.error('Shop prefab is not loaded yet.');
|
||||
return;
|
||||
}
|
||||
if (prefab) {
|
||||
const shopNode = cc.instantiate(prefab);
|
||||
this.node.addChild(shopNode);
|
||||
console.log("shopNode parent:", shopNode.parent);
|
||||
|
||||
if (!this.shopNode) {
|
||||
// 第一次使用,创建节点
|
||||
this.shopNode = cc.instantiate(SceneManager.cachedShopPrefab);
|
||||
this.node.addChild(this.shopNode);
|
||||
} else {
|
||||
// 非第一次使用,直接激活节点
|
||||
this.shopNode.active = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
// console.log("shopNode parent:", this.shopNode.parent);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ export class GameConfig {
|
|||
cc.fx.GameConfig.GM_INFO.level = 204;
|
||||
}
|
||||
let name = "Json/level" + (cc.fx.GameConfig.GM_INFO.level+1);
|
||||
debugger;
|
||||
|
||||
// //console.log("关卡名称:",name);
|
||||
// name = "Json/level" + 68;
|
||||
// cc.fx.StorageMessage.setStorage("level",cc.fx.GameConfig.GM_INFO.level.toString());
|
||||
|
|
|
@ -14,7 +14,7 @@ export default class Utils {
|
|||
console.log(res);
|
||||
if (res.code) {
|
||||
Utils.POST("login",{code:res.code},ret=>{
|
||||
console.log("请求结果:");
|
||||
console.log("请求结果:",res);
|
||||
console.log(ret);
|
||||
Utils.openid=ret.data.openid;
|
||||
Utils.session_key=ret.data.session_key;
|
||||
|
@ -131,133 +131,133 @@ export default class Utils {
|
|||
//#endregion
|
||||
|
||||
//#region 微信云
|
||||
static initServer(){
|
||||
if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
//@ts-ignore
|
||||
wx.cloud.init({
|
||||
env: 'cloudbase-1gl7iex89268f11e'
|
||||
})
|
||||
}
|
||||
// static initServer(){
|
||||
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
// //@ts-ignore
|
||||
// wx.cloud.init({
|
||||
// env: 'cloudbase-1gl7iex89268f11e'
|
||||
// })
|
||||
// }
|
||||
|
||||
static getUserCode(){
|
||||
//@ts-ignore
|
||||
wx.login({
|
||||
success (res) {
|
||||
console.log("登录成功");
|
||||
console.log(res);
|
||||
if (res.code) {
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
// 云函数名称
|
||||
name: 'login',
|
||||
// 传给云函数的参数
|
||||
data: {
|
||||
code:res.code,
|
||||
},
|
||||
success: function(ret) {
|
||||
console.log("请求成功");
|
||||
console.log("请求结果:");
|
||||
console.log(ret);
|
||||
Utils.openid=ret.data.openid;
|
||||
Utils.session_key=ret.data.session_key;
|
||||
Utils.uid=ret.data._id;
|
||||
},
|
||||
fail:function(res){
|
||||
console.log("请求失败");
|
||||
console.log(res);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('登录失败!' + res.errMsg)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
// static getUserCode(){
|
||||
// //@ts-ignore
|
||||
// wx.login({
|
||||
// success (res) {
|
||||
// console.log("登录成功");
|
||||
// console.log(res);
|
||||
// if (res.code) {
|
||||
// //@ts-ignore
|
||||
// wx.cloud.callFunction({
|
||||
// // 云函数名称
|
||||
// name: 'login',
|
||||
// // 传给云函数的参数
|
||||
// data: {
|
||||
// code:res.code,
|
||||
// },
|
||||
// success: function(ret) {
|
||||
// console.log("请求成功");
|
||||
// console.log("请求结果:");
|
||||
// console.log(ret);
|
||||
// Utils.openid=ret.data.openid;
|
||||
// Utils.session_key=ret.data.session_key;
|
||||
// Utils.uid=ret.data._id;
|
||||
// },
|
||||
// fail:function(res){
|
||||
// console.log("请求失败");
|
||||
// console.log(res);
|
||||
// }
|
||||
// })
|
||||
// } else {
|
||||
// console.log('登录失败!' + res.errMsg)
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
static PayOder(){
|
||||
if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
// 云函数名称
|
||||
name: 'userPayOrder',
|
||||
// 传给云函数的参数
|
||||
data: {
|
||||
itemid:"10011",
|
||||
itemCount:1,
|
||||
itemPrice:100
|
||||
},
|
||||
success: function(res) {
|
||||
console.log("请求成功");
|
||||
console.log(res)
|
||||
if(res.result.code==1){
|
||||
Utils.outTradeNo=res.result.data.outTradeNo;
|
||||
console.log("订单号:"+Utils.outTradeNo);
|
||||
//@ts-ignore
|
||||
wx.requestMidasPaymentGameItem({
|
||||
signData:res.result.data.signData,
|
||||
paySig: res.result.data.paySig,
|
||||
signature: res.result.data.signature,
|
||||
success(res, errCode) {
|
||||
console.log('成功', res, errCode);
|
||||
},
|
||||
fail({errMsg,errCode}) {
|
||||
console.error('失败');
|
||||
console.error(errMsg, errCode)
|
||||
}
|
||||
})
|
||||
}
|
||||
// static PayOder(){
|
||||
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
// //@ts-ignore
|
||||
// wx.cloud.callFunction({
|
||||
// // 云函数名称
|
||||
// name: 'userPayOrder',
|
||||
// // 传给云函数的参数
|
||||
// data: {
|
||||
// itemid:"10011",
|
||||
// itemCount:1,
|
||||
// itemPrice:100
|
||||
// },
|
||||
// success: function(res) {
|
||||
// console.log("请求成功");
|
||||
// console.log(res)
|
||||
// if(res.result.code==1){
|
||||
// Utils.outTradeNo=res.result.data.outTradeNo;
|
||||
// console.log("订单号:"+Utils.outTradeNo);
|
||||
// //@ts-ignore
|
||||
// wx.requestMidasPaymentGameItem({
|
||||
// signData:res.result.data.signData,
|
||||
// paySig: res.result.data.paySig,
|
||||
// signature: res.result.data.signature,
|
||||
// success(res, errCode) {
|
||||
// console.log('成功', res, errCode);
|
||||
// },
|
||||
// fail({errMsg,errCode}) {
|
||||
// console.error('失败');
|
||||
// console.error(errMsg, errCode)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
},
|
||||
fail:function(res){
|
||||
console.log("请求失败");
|
||||
console.log(res);
|
||||
}
|
||||
})
|
||||
}
|
||||
// },
|
||||
// fail:function(res){
|
||||
// console.log("请求失败");
|
||||
// console.log(res);
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
static getPayInfo1(callBack){
|
||||
if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
// 云函数名称
|
||||
name: 'userGetPayState',
|
||||
// 传给云函数的参数
|
||||
data: {
|
||||
outTradeNo:Utils.outTradeNo
|
||||
},
|
||||
success: function(res) {
|
||||
console.log("请求成功");
|
||||
console.log(res)
|
||||
callBack("成功");
|
||||
},
|
||||
fail:function(res){
|
||||
console.log("请求失败");
|
||||
console.log(res);
|
||||
callBack("失败");
|
||||
}
|
||||
})
|
||||
}
|
||||
// static getPayInfo1(callBack){
|
||||
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
// //@ts-ignore
|
||||
// wx.cloud.callFunction({
|
||||
// // 云函数名称
|
||||
// name: 'userGetPayState',
|
||||
// // 传给云函数的参数
|
||||
// data: {
|
||||
// outTradeNo:Utils.outTradeNo
|
||||
// },
|
||||
// success: function(res) {
|
||||
// console.log("请求成功");
|
||||
// console.log(res)
|
||||
// callBack("成功");
|
||||
// },
|
||||
// fail:function(res){
|
||||
// console.log("请求失败");
|
||||
// console.log(res);
|
||||
// callBack("失败");
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
static toke(){
|
||||
if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
// 云函数名称
|
||||
name: 'uerToken',
|
||||
// 传给云函数的参数
|
||||
data: {
|
||||
// static toke(){
|
||||
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
// //@ts-ignore
|
||||
// wx.cloud.callFunction({
|
||||
// // 云函数名称
|
||||
// name: 'uerToken',
|
||||
// // 传给云函数的参数
|
||||
// data: {
|
||||
|
||||
},
|
||||
success: function(res) {
|
||||
console.log("请求成功");
|
||||
console.log(res)
|
||||
},
|
||||
fail:function(res){
|
||||
console.log("请求失败");
|
||||
console.log(res);
|
||||
}
|
||||
})
|
||||
}
|
||||
// },
|
||||
// success: function(res) {
|
||||
// console.log("请求成功");
|
||||
// console.log(res)
|
||||
// },
|
||||
// fail:function(res){
|
||||
// console.log("请求失败");
|
||||
// console.log(res);
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//#endregion
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
import SceneManager from "../../SceneManager";
|
||||
import { MiniGameSdk } from "../../Sdk/MiniGameSdk";
|
||||
import Utils from "../Pay/Utils";
|
||||
//@ts-ignore
|
||||
//最大工具类 各种公共方法,以及处理上传,获取后端接口数据
|
||||
var GameTool = {
|
||||
|
@ -643,7 +644,7 @@ var GameTool = {
|
|||
|
||||
const buyData = {
|
||||
item_id:_id,
|
||||
item_num:1,
|
||||
item_num:3,
|
||||
item_price:1500,
|
||||
cost_type:"gold"
|
||||
}
|
||||
|
@ -809,32 +810,53 @@ var GameTool = {
|
|||
|
||||
//商城购买
|
||||
shopBuy(productId){
|
||||
let coin = 0;
|
||||
let price = 0;
|
||||
switch(productId){
|
||||
case "gold_1":
|
||||
cc.fx.GameTool.changeCoin(1200);
|
||||
coin = 1200;
|
||||
price = 600;
|
||||
MiniGameSdk.API.showToast("充值成功,获得1200金币");
|
||||
break;
|
||||
case "gold_2":
|
||||
cc.fx.GameTool.changeCoin(8000);
|
||||
coin = 8000;
|
||||
price = 3600;
|
||||
MiniGameSdk.API.showToast("充值成功,获得8000金币");
|
||||
break;
|
||||
case "gold_3":
|
||||
cc.fx.GameTool.changeCoin(16000);
|
||||
coin = 16000;
|
||||
price = 6800;
|
||||
MiniGameSdk.API.showToast("充值成功,获得16000金币");
|
||||
break;
|
||||
case "gold_4":
|
||||
cc.fx.GameTool.changeCoin(32000);
|
||||
coin = 32000;
|
||||
price = 12800;
|
||||
MiniGameSdk.API.showToast("充值成功,获得32000金币");
|
||||
break;
|
||||
case "gold_5":
|
||||
cc.fx.GameTool.changeCoin(100000);
|
||||
coin = 100000;
|
||||
price = 32800;
|
||||
MiniGameSdk.API.showToast("充值成功,获得100000金币");
|
||||
break;
|
||||
case "gold_6":
|
||||
cc.fx.GameTool.changeCoin(240000);
|
||||
coin = 240000;
|
||||
price = 64800;
|
||||
MiniGameSdk.API.showToast("充值成功,获得240000金币");
|
||||
break;
|
||||
}
|
||||
const buyData = {
|
||||
item_id:productId,
|
||||
item_num:coin,
|
||||
item_price:price,
|
||||
cost_type:"cash"
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("shop_buy",buyData);
|
||||
},
|
||||
|
||||
formatDate(date: Date): string {
|
||||
|
@ -900,7 +922,34 @@ var GameTool = {
|
|||
item_price: data.item_price,
|
||||
cost_type: data.cost_type,
|
||||
}
|
||||
console.log("数据:",eventData);
|
||||
break;
|
||||
case "init_order": //发起充值时
|
||||
eventData = {
|
||||
order_id: data.outTradeNo,
|
||||
pay_amount: data.price,
|
||||
payment_name: data.payment_name,
|
||||
payment_num: data.payment_num,
|
||||
payment_type: data.type,
|
||||
}
|
||||
break;
|
||||
case "payment": //发起充值时
|
||||
eventData = {
|
||||
order_id: data.outTradeNo,
|
||||
pay_amount: data.price,
|
||||
payment_name: data.payment_name,
|
||||
payment_num: data.payment_num,
|
||||
payment_type: data.type,
|
||||
}
|
||||
break;
|
||||
case "payment_fail": //发起充值时
|
||||
eventData = {
|
||||
order_id: data.outTradeNo,
|
||||
pay_amount: data.price,
|
||||
payment_name: data.payment_name,
|
||||
payment_num: data.payment_num,
|
||||
payment_type: data.type,
|
||||
fail_reason: data.fail_reason,
|
||||
}
|
||||
break;
|
||||
}
|
||||
// MiniGameSdk.API.shushu_Track(name,eventData);
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 94 KiB |
|
@ -1,38 +0,0 @@
|
|||
{
|
||||
"ver": "2.3.7",
|
||||
"uuid": "707d9e1d-7462-4b68-abd1-ae01b980fde2",
|
||||
"importer": "texture",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"genMipmaps": false,
|
||||
"packable": true,
|
||||
"width": 1057,
|
||||
"height": 361,
|
||||
"platformSettings": {},
|
||||
"subMetas": {
|
||||
"ice2": {
|
||||
"ver": "1.0.6",
|
||||
"uuid": "097fb6b3-a8de-49fd-8da8-5a65561d8fc2",
|
||||
"importer": "sprite-frame",
|
||||
"rawTextureUuid": "707d9e1d-7462-4b68-abd1-ae01b980fde2",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 1057,
|
||||
"height": 361,
|
||||
"rawWidth": 1057,
|
||||
"rawHeight": 361,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -262,7 +262,9 @@
|
|||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": null,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "11ca11bf-c649-466a-aa87-a88c13ef46ca"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 1,
|
||||
"_fillType": 0,
|
||||
|
@ -274,7 +276,9 @@
|
|||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_atlas": {
|
||||
"__uuid__": "f2c494b7-b6df-488f-b194-358235b0f180"
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1647,7 +1647,7 @@
|
|||
"component": "",
|
||||
"_componentId": "48bfeZuYFZE2qmgxbW2IigB",
|
||||
"handler": "buyProduct",
|
||||
"customEventData": "gold_pack_1"
|
||||
"customEventData": "gold_1"
|
||||
},
|
||||
{
|
||||
"__type__": "de906iE/HVHpI6VO7IMvKaI",
|
||||
|
@ -2343,7 +2343,7 @@
|
|||
"component": "",
|
||||
"_componentId": "48bfeZuYFZE2qmgxbW2IigB",
|
||||
"handler": "buyProduct",
|
||||
"customEventData": "gold_pack_2"
|
||||
"customEventData": "gold_2"
|
||||
},
|
||||
{
|
||||
"__type__": "de906iE/HVHpI6VO7IMvKaI",
|
||||
|
@ -3039,7 +3039,7 @@
|
|||
"component": "",
|
||||
"_componentId": "48bfeZuYFZE2qmgxbW2IigB",
|
||||
"handler": "buyProduct",
|
||||
"customEventData": "gold_pack_3"
|
||||
"customEventData": "gold_3"
|
||||
},
|
||||
{
|
||||
"__type__": "de906iE/HVHpI6VO7IMvKaI",
|
||||
|
@ -3735,7 +3735,7 @@
|
|||
"component": "",
|
||||
"_componentId": "48bfeZuYFZE2qmgxbW2IigB",
|
||||
"handler": "buyProduct",
|
||||
"customEventData": "gold_pack_4"
|
||||
"customEventData": "gold_4"
|
||||
},
|
||||
{
|
||||
"__type__": "de906iE/HVHpI6VO7IMvKaI",
|
||||
|
@ -4431,7 +4431,7 @@
|
|||
"component": "",
|
||||
"_componentId": "48bfeZuYFZE2qmgxbW2IigB",
|
||||
"handler": "buyProduct",
|
||||
"customEventData": "gold_pack_5"
|
||||
"customEventData": "gold_5"
|
||||
},
|
||||
{
|
||||
"__type__": "de906iE/HVHpI6VO7IMvKaI",
|
||||
|
@ -5127,7 +5127,7 @@
|
|||
"component": "",
|
||||
"_componentId": "48bfeZuYFZE2qmgxbW2IigB",
|
||||
"handler": "buyProduct",
|
||||
"customEventData": "gold_pack_6"
|
||||
"customEventData": "gold_6"
|
||||
},
|
||||
{
|
||||
"__type__": "de906iE/HVHpI6VO7IMvKaI",
|
||||
|
|
|
@ -31,12 +31,12 @@ export default class NewClass extends cc.Component {
|
|||
openShop() {
|
||||
// 商品数据数组
|
||||
const products = [
|
||||
{ product_id: "gold_pack_1", name: "金币包1", price: 600, coin:1200, title: "3x2六档金币" },
|
||||
{ product_id: "gold_pack_2", name: "金币包2", price: 3600, coin:8000, title: "" },
|
||||
{ product_id: "gold_pack_3", name: "金币包3", price: 6800, coin:16000, title: "" },
|
||||
{ product_id: "gold_pack_4", name: "金币包4", price: 12800, coin:32000, title: "" },
|
||||
{ product_id: "gold_pack_5", name: "金币包5", price: 32800, coin:100000, title: "" },
|
||||
{ product_id: "gold_pack_6", name: "金币包6", price: 64800, coin:240000, title: "" },
|
||||
{ product_id: "gold_1", name: "金币包1", price: 600, coin:1200, title: "3x2六档金币" },
|
||||
{ product_id: "gold_2", name: "金币包2", price: 3600, coin:8000, title: "" },
|
||||
{ product_id: "gold_3", name: "金币包3", price: 6800, coin:16000, title: "" },
|
||||
{ product_id: "gold_4", name: "金币包4", price: 12800, coin:32000, title: "" },
|
||||
{ product_id: "gold_5", name: "金币包5", price: 32800, coin:100000, title: "" },
|
||||
{ product_id: "gold_6", name: "金币包6", price: 64800, coin:240000, title: "" },
|
||||
];
|
||||
for (let i = 1; i <= 6 && i < this.itemList.children.length; i++) {
|
||||
const spriteComp = this.itemList.children[i].children[0].getComponent(cc.Sprite);
|
||||
|
@ -63,7 +63,13 @@ export default class NewClass extends cc.Component {
|
|||
//关闭商店界面
|
||||
closeShop() {
|
||||
//销毁预制体
|
||||
this.shop.destroy();
|
||||
if(this.node.parent.getComponent("JiaZai")){
|
||||
this.node.parent.getComponent("JiaZai").closeShop();
|
||||
}
|
||||
else if(this.node.parent.getComponent("SceneManager")){
|
||||
this.node.parent.getComponent("SceneManager").closeShop();
|
||||
}
|
||||
// this.shop.destroy();
|
||||
}
|
||||
|
||||
//点击充值购买
|
||||
|
@ -99,11 +105,40 @@ export default class NewClass extends cc.Component {
|
|||
break;
|
||||
}
|
||||
console.log("获得商品id:",id,count,price);
|
||||
// 判断设备系统
|
||||
let systemType = "Android";
|
||||
try {
|
||||
const systemInfo = wx.getSystemInfoSync();
|
||||
if (systemInfo.platform === 'ios') {
|
||||
systemType = "iOS";
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取系统信息失败', e);
|
||||
}
|
||||
|
||||
const data = {
|
||||
outTradeNo:Utils.outTradeNo,
|
||||
price:price,
|
||||
payment_name:productId,
|
||||
payment_num:1,
|
||||
type:systemType,
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("init_order",data);
|
||||
|
||||
Utils.buyProp(id,count,price,(res)=>{
|
||||
console.log("获得充值结果",res);
|
||||
if(res == null){
|
||||
MiniGameSdk.API.showToast("网络异常,充值失败请稍后再试");
|
||||
this.btn_Touch = true;
|
||||
const dataFail = {
|
||||
outTradeNo:Utils.outTradeNo,
|
||||
price:price,
|
||||
payment_name:productId,
|
||||
payment_num:1,
|
||||
type:systemType,
|
||||
fail_reason:"网络异常,没有拉起支付",
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("payment_fail",dataFail);
|
||||
return;
|
||||
}
|
||||
else{
|
||||
|
@ -112,22 +147,61 @@ export default class NewClass extends cc.Component {
|
|||
if(data.data.pay_state == 1){
|
||||
this.btn_Touch = true;
|
||||
MiniGameSdk.API.showToast("取消充值");
|
||||
const dataFail2 = {
|
||||
outTradeNo:Utils.outTradeNo,
|
||||
price:price,
|
||||
payment_name:productId,
|
||||
payment_num:1,
|
||||
type:systemType,
|
||||
fail_reason:"用户取消支付",
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("payment_fail",dataFail2);
|
||||
}
|
||||
else if(data.data.pay_state == 2){
|
||||
this.btn_Touch = true;
|
||||
Utils.setPayInfo((data) => {
|
||||
console.log("设置轮训结果:",data);
|
||||
|
||||
})
|
||||
if(data.code === 1){
|
||||
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_fail",dataSuccess);
|
||||
}
|
||||
else{
|
||||
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
|
||||
const dataFail4 = {
|
||||
outTradeNo:Utils.outTradeNo,
|
||||
price:price,
|
||||
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.node.parent.getComponent("JiaZai").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,
|
||||
payment_name:productId,
|
||||
payment_num:1,
|
||||
type:systemType,
|
||||
fail_reason:"拉起支付后,付款时网络异常付款失败",
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("payment_fail",dataFail3);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user