优化UI图片资源
|
@ -97,6 +97,19 @@ export default class JiaZai extends cc.Component {
|
||||||
if (cc.fx.GameConfig.GM_INFO.first) {
|
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);
|
const group = cc.fx.GameTool.setWechatGameGroup(2);
|
||||||
|
if (group == 0) {
|
||||||
|
cc.fx.GameConfig.GM_INFO.musicOpen = true;
|
||||||
|
}
|
||||||
|
else if (group == 1) {
|
||||||
|
cc.fx.GameConfig.GM_INFO.musicOpen = false;
|
||||||
|
}
|
||||||
|
const audioInfo = {
|
||||||
|
"musicOpen": cc.fx.GameConfig.GM_INFO.musicOpen, //音乐
|
||||||
|
"effectOpen": cc.fx.GameConfig.GM_INFO.effectOpen, //音效
|
||||||
|
"vibrateOpen": cc.fx.GameConfig.GM_INFO.vibrateOpen, //震动
|
||||||
|
}
|
||||||
|
cc.fx.StorageMessage.setStorage("music", audioInfo);
|
||||||
|
|
||||||
if (cc.fx.GameConfig.GM_INFO.openid != "") {
|
if (cc.fx.GameConfig.GM_INFO.openid != "") {
|
||||||
console.log("————————发送注册事件");
|
console.log("————————发送注册事件");
|
||||||
const time = cc.fx.GameTool.formatDate(new Date());
|
const time = cc.fx.GameTool.formatDate(new Date());
|
||||||
|
@ -126,7 +139,7 @@ export default class JiaZai extends cc.Component {
|
||||||
// console.log("关卡",cc.fx.GameConfig.GM_INFO.level+1);
|
// console.log("关卡",cc.fx.GameConfig.GM_INFO.level+1);
|
||||||
|
|
||||||
cc.fx.GameTool.getHealth(null);
|
cc.fx.GameTool.getHealth(null);
|
||||||
// cc.fx.GameConfig.LEVEL_INFO_init(false,0);s
|
// cc.fx.GameConfig.LEVEL_INFO_init(false,0);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
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);
|
||||||
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);
|
||||||
|
|
|
@ -1369,6 +1369,12 @@ export default class MapConroler extends cc.Component {
|
||||||
// console.log("即将上报成功________________________:",this.add_Time);
|
// console.log("即将上报成功________________________:",this.add_Time);
|
||||||
// console.log("成功消除一个",this.add_Time);
|
// console.log("成功消除一个",this.add_Time);
|
||||||
cc.fx.GameTool.changeCoin(40);
|
cc.fx.GameTool.changeCoin(40);
|
||||||
|
const data = {
|
||||||
|
change_reason: "闯关成功获得金币",
|
||||||
|
id: (1001 + ""),
|
||||||
|
num: 40
|
||||||
|
}
|
||||||
|
cc.fx.GameTool.shushu_Track("resource_get", data);
|
||||||
let overTime = Date.now();
|
let overTime = Date.now();
|
||||||
this.count_Time = overTime - this.count_Time;
|
this.count_Time = overTime - this.count_Time;
|
||||||
cc.fx.GameTool.addLevel(this.count_Time, this.add_Time);
|
cc.fx.GameTool.addLevel(this.count_Time, this.add_Time);
|
||||||
|
@ -1507,6 +1513,12 @@ export default class MapConroler extends cc.Component {
|
||||||
runRewive(data) {
|
runRewive(data) {
|
||||||
console.log("复活回调函数内", data);
|
console.log("复活回调函数内", data);
|
||||||
cc.fx.GameTool.changeCoin(data.coin);
|
cc.fx.GameTool.changeCoin(data.coin);
|
||||||
|
const dataTemp = {
|
||||||
|
change_reason: "游戏内复活消耗金币",
|
||||||
|
id: (1001 + ""),
|
||||||
|
num: data.coin
|
||||||
|
}
|
||||||
|
cc.fx.GameTool.shushu_Track("resource_cost", dataTemp);
|
||||||
MiniGameSdk.API.showToast("继续游戏");
|
MiniGameSdk.API.showToast("继续游戏");
|
||||||
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 (data.type == "time") {
|
if (data.type == "time") {
|
||||||
|
@ -1751,6 +1763,7 @@ export default class MapConroler extends cc.Component {
|
||||||
cc.fx.GameTool.setUserProp(2001, cc.fx.GameConfig.GM_INFO.freezeAmount, (data) => {
|
cc.fx.GameTool.setUserProp(2001, cc.fx.GameConfig.GM_INFO.freezeAmount, (data) => {
|
||||||
})
|
})
|
||||||
let data = {
|
let data = {
|
||||||
|
change_reason: "使用道具",
|
||||||
id: "2001",
|
id: "2001",
|
||||||
num: -1
|
num: -1
|
||||||
}
|
}
|
||||||
|
@ -1870,6 +1883,7 @@ export default class MapConroler extends cc.Component {
|
||||||
cc.fx.GameTool.setUserProp(2002, cc.fx.GameConfig.GM_INFO.hammerAmount, (data) => {
|
cc.fx.GameTool.setUserProp(2002, cc.fx.GameConfig.GM_INFO.hammerAmount, (data) => {
|
||||||
})
|
})
|
||||||
let data = {
|
let data = {
|
||||||
|
change_reason: "使用道具",
|
||||||
id: "2002",
|
id: "2002",
|
||||||
num: -1
|
num: -1
|
||||||
}
|
}
|
||||||
|
@ -1983,6 +1997,7 @@ export default class MapConroler extends cc.Component {
|
||||||
cc.fx.GameTool.setUserProp(2003, cc.fx.GameConfig.GM_INFO.magicAmount, (data) => {
|
cc.fx.GameTool.setUserProp(2003, cc.fx.GameConfig.GM_INFO.magicAmount, (data) => {
|
||||||
})
|
})
|
||||||
let data = {
|
let data = {
|
||||||
|
change_reason: "使用道具",
|
||||||
id: "2003",
|
id: "2003",
|
||||||
num: -1
|
num: -1
|
||||||
}
|
}
|
||||||
|
|
|
@ -1127,7 +1127,7 @@ export namespace MiniGameSdk {
|
||||||
},
|
},
|
||||||
// 根据环境变量设置 debug 模式
|
// 根据环境变量设置 debug 模式
|
||||||
debug: !isProduction,
|
debug: !isProduction,
|
||||||
enableLog: false
|
enableLog: true
|
||||||
};
|
};
|
||||||
// 创建 TA 实例
|
// 创建 TA 实例
|
||||||
API._ta = new ThinkingAnalyticsAPI(config);
|
API._ta = new ThinkingAnalyticsAPI(config);
|
||||||
|
|
|
@ -70,6 +70,12 @@ export default class NewClass extends cc.Component {
|
||||||
if (curCoin >= 1000) {
|
if (curCoin >= 1000) {
|
||||||
this.switchButtons[1].active = false;
|
this.switchButtons[1].active = false;
|
||||||
cc.fx.GameTool.changeCoin(-1000);
|
cc.fx.GameTool.changeCoin(-1000);
|
||||||
|
const data = {
|
||||||
|
change_reason: "首页购买体力",
|
||||||
|
id: (1001 + ""),
|
||||||
|
num: -1000
|
||||||
|
}
|
||||||
|
cc.fx.GameTool.shushu_Track("resource_cost", data);
|
||||||
cc.fx.GameConfig.GM_INFO.hp = 5;
|
cc.fx.GameConfig.GM_INFO.hp = 5;
|
||||||
const parentNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
|
const parentNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
|
||||||
if (parentNode) {
|
if (parentNode) {
|
||||||
|
@ -83,6 +89,15 @@ export default class NewClass extends cc.Component {
|
||||||
cc.fx.GameTool.setUserHealth(0, (data) => {
|
cc.fx.GameTool.setUserHealth(0, (data) => {
|
||||||
cc.fx.GameTool.getHealth(null);
|
cc.fx.GameTool.getHealth(null);
|
||||||
})
|
})
|
||||||
|
const buyData = {
|
||||||
|
item_id: "refill_health",
|
||||||
|
item_num: 3,
|
||||||
|
item_price: 1000,
|
||||||
|
cost_type: "gold"
|
||||||
|
}
|
||||||
|
console.log("____________即将上传Shop_buy", buyData);
|
||||||
|
cc.fx.GameTool.shushu_Track("shop_buy", buyData);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MiniGameSdk.API.showToast("金币不足,无法购买体力");
|
MiniGameSdk.API.showToast("金币不足,无法购买体力");
|
||||||
|
|
|
@ -83,7 +83,7 @@ export class GameConfig {
|
||||||
first: boolean; //是否首次进入游戏
|
first: boolean; //是否首次进入游戏
|
||||||
score: number; //总得分
|
score: number; //总得分
|
||||||
scale: number; //玩家总计成功点火数
|
scale: number; //玩家总计成功点火数
|
||||||
iosOutTradeNo: number; //ios订单号
|
iosOutTradeNo: string; //ios订单号
|
||||||
min_Time: number; //体力恢复的剩余时间
|
min_Time: number; //体力恢复的剩余时间
|
||||||
freezeAmount: number; //冻结道具次数
|
freezeAmount: number; //冻结道具次数
|
||||||
hammerAmount: number; //锤子道具次数
|
hammerAmount: number; //锤子道具次数
|
||||||
|
@ -220,7 +220,7 @@ export class GameConfig {
|
||||||
first: false, //是否首次进入游戏
|
first: false, //是否首次进入游戏
|
||||||
score: 0, //总得分
|
score: 0, //总得分
|
||||||
scale: 1, //玩家总计成功点火数
|
scale: 1, //玩家总计成功点火数
|
||||||
iosOutTradeNo: 0, //ios订单号
|
iosOutTradeNo: "", //ios订单号
|
||||||
min_Time: 0, //体力恢复的剩余时间
|
min_Time: 0, //体力恢复的剩余时间
|
||||||
freezeAmount: 0, //冻结道具次数
|
freezeAmount: 0, //冻结道具次数
|
||||||
hammerAmount: 0, //锤子道具次数
|
hammerAmount: 0, //锤子道具次数
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
export default class Utils {
|
export default class Utils {
|
||||||
static uid:string="";
|
static uid: string = "";
|
||||||
static session_key="";
|
static session_key = "";
|
||||||
static appid:string="";
|
static appid: string = "";
|
||||||
static openid:string="";
|
static openid: string = "";
|
||||||
static outTradeNo:string ="";
|
static outTradeNo: string = "";
|
||||||
static httpip:string=`https://laf.nika4games.com/`;
|
static httpip: string = `https://laf.nika4games.com/`;
|
||||||
//#region 安卓支付
|
//#region 安卓支付
|
||||||
/**获取用户信息*/
|
/**获取用户信息*/
|
||||||
static getUserInfo(callBack){
|
static getUserInfo(callBack) {
|
||||||
wx.login({
|
wx.login({
|
||||||
success (res) {
|
success(res) {
|
||||||
console.log("登录成功");
|
console.log("登录成功");
|
||||||
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 => {
|
||||||
console.log("请求结果:",res);
|
console.log("请求结果:", res);
|
||||||
console.log(ret);
|
console.log(ret);
|
||||||
Utils.openid=ret.data.openid;
|
Utils.openid = ret.data.openid;
|
||||||
Utils.session_key=ret.data.session_key;
|
Utils.session_key = ret.data.session_key;
|
||||||
Utils.uid=ret.data._id;
|
Utils.uid = ret.data._id;
|
||||||
callBack(Utils.uid);
|
callBack(Utils.uid);
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
console.log('登录失败!' + res.errMsg)
|
console.log('登录失败!' + res.errMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**道具直购接口*/
|
/**道具直购接口*/
|
||||||
static buyProp(id,count,price,callBack){
|
static buyProp(id, count, price, callBack) {
|
||||||
console.log("请求uid:"+Utils.uid,"请求id:"+id,"请求数量:"+count,"请求价格:"+price);
|
console.log("请求uid:" + Utils.uid, "请求id:" + id, "请求数量:" + count, "请求价格:" + price);
|
||||||
|
|
||||||
Utils.POST("wx/orderPaySig",{uid:Utils.uid,itemid:id,itemCount:count,itemPrice:price},res=>{
|
Utils.POST("wx/orderPaySig", { uid: Utils.uid, itemid: id, itemCount: count, itemPrice: price }, res => {
|
||||||
if(res.code==1){
|
if (res.code == 1) {
|
||||||
Utils.outTradeNo=res.data.outTradeNo;
|
Utils.outTradeNo = res.data.outTradeNo;
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
wx.requestMidasPaymentGameItem({
|
wx.requestMidasPaymentGameItem({
|
||||||
signData:res.data.signData,
|
signData: res.data.signData,
|
||||||
paySig: res.data.paySig,
|
paySig: res.data.paySig,
|
||||||
signature: res.data.signature,
|
signature: res.data.signature,
|
||||||
success(res, errCode) {
|
success(res, errCode) {
|
||||||
console.log('成功', res, errCode);
|
console.log('成功', res, errCode);
|
||||||
callBack(res);
|
callBack(res);
|
||||||
},
|
},
|
||||||
fail({errMsg,errCode}) {
|
fail({ errMsg, errCode }) {
|
||||||
console.error('失败');
|
console.error('失败');
|
||||||
console.error(errMsg, errCode)
|
console.error(errMsg, errCode)
|
||||||
callBack(null);
|
callBack(null);
|
||||||
|
@ -91,7 +91,7 @@ export default class Utils {
|
||||||
callBack({ code: 0, message: '请求失败,已达到最大重试次数' });
|
callBack({ code: 0, message: '请求失败,已达到最大重试次数' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Utils.POST("wx/getOrderReward", {outTradeNo: Utils.outTradeNo}, res => {
|
Utils.POST("wx/getOrderReward", { outTradeNo: Utils.outTradeNo }, res => {
|
||||||
console.log("告知服务器发货:", res);
|
console.log("告知服务器发货:", res);
|
||||||
if (res.code === 1) {
|
if (res.code === 1) {
|
||||||
// 请求成功,调用回调并返回结果
|
// 请求成功,调用回调并返回结果
|
||||||
|
@ -114,15 +114,15 @@ export default class Utils {
|
||||||
//#region ios支付
|
//#region ios支付
|
||||||
|
|
||||||
/**跳转客服*/
|
/**跳转客服*/
|
||||||
static GoKEFu(){
|
static GoKEFu() {
|
||||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = `wcx_` + Math.round(Math.random() * 10 ** 13) + Date.now();
|
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = `wcx_` + Math.round(Math.random() * 10 ** 13) + Date.now();
|
||||||
const data={
|
const data = {
|
||||||
tpye:"ios",
|
tpye: "ios",
|
||||||
outTradeNo:cc.fx.GameConfig.GM_INFO.iosOutTradeNo,
|
outTradeNo: cc.fx.GameConfig.GM_INFO.iosOutTradeNo,
|
||||||
propName:'金币',
|
propName: '金币',
|
||||||
count:1,
|
count: 1,
|
||||||
price:100,//价格单位是分
|
price: 100,//价格单位是分
|
||||||
}
|
}
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
wx.openCustomerServiceConversation({
|
wx.openCustomerServiceConversation({
|
||||||
|
@ -133,158 +133,171 @@ export default class Utils {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static getIosPayInfo(callBack){
|
static getIosPayInfo(callBack) {
|
||||||
console.log("请求uid:"+Utils.uid);
|
const delays = [1000, 10000, 30000, 60000, 60000]; // 延迟时间数组
|
||||||
console.log("outTradeNo:"+this.outTradeNo);
|
let attempt = 0; // 轮询次数
|
||||||
Utils.POST("wx/iosgetPayInfo",{outTradeNo:Utils.outTradeNo},res=>{
|
|
||||||
console.log("查询字符结果");
|
const poll = () => {
|
||||||
console.log(res);
|
if (attempt >= delays.length) {
|
||||||
if(res.code==1){
|
callBack({ code: 0, data: null, message: '轮询超时' });
|
||||||
if(res.data){
|
return;
|
||||||
callBack("充值取消");
|
}
|
||||||
|
|
||||||
|
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("查询字符结果IOS");
|
||||||
|
console.log(res);
|
||||||
|
if (res.code === 1) {
|
||||||
|
callBack(res);
|
||||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||||
}else{
|
} else if (res.code === 0) {
|
||||||
callBack("充值成功");
|
callBack(res);
|
||||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
});
|
attempt++;
|
||||||
|
setTimeout(poll, delays[attempt - 1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 微信云
|
//#region 微信云
|
||||||
// static initServer(){
|
// static initServer(){
|
||||||
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||||
// //@ts-ignore
|
// //@ts-ignore
|
||||||
// wx.cloud.init({
|
// wx.cloud.init({
|
||||||
// env: 'cloudbase-1gl7iex89268f11e'
|
// env: 'cloudbase-1gl7iex89268f11e'
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static getUserCode(){
|
// static getUserCode(){
|
||||||
// //@ts-ignore
|
// //@ts-ignore
|
||||||
// wx.login({
|
// wx.login({
|
||||||
// success (res) {
|
// success (res) {
|
||||||
// console.log("登录成功");
|
// console.log("登录成功");
|
||||||
// console.log(res);
|
// console.log(res);
|
||||||
// if (res.code) {
|
// if (res.code) {
|
||||||
// //@ts-ignore
|
// //@ts-ignore
|
||||||
// wx.cloud.callFunction({
|
// wx.cloud.callFunction({
|
||||||
// // 云函数名称
|
// // 云函数名称
|
||||||
// name: 'login',
|
// name: 'login',
|
||||||
// // 传给云函数的参数
|
// // 传给云函数的参数
|
||||||
// data: {
|
// data: {
|
||||||
// code:res.code,
|
// code:res.code,
|
||||||
// },
|
// },
|
||||||
// success: function(ret) {
|
// success: function(ret) {
|
||||||
// console.log("请求成功");
|
// console.log("请求成功");
|
||||||
// console.log("请求结果:");
|
// console.log("请求结果:");
|
||||||
// console.log(ret);
|
// console.log(ret);
|
||||||
// Utils.openid=ret.data.openid;
|
// Utils.openid=ret.data.openid;
|
||||||
// Utils.session_key=ret.data.session_key;
|
// Utils.session_key=ret.data.session_key;
|
||||||
// Utils.uid=ret.data._id;
|
// Utils.uid=ret.data._id;
|
||||||
// },
|
// },
|
||||||
// fail:function(res){
|
// fail:function(res){
|
||||||
// console.log("请求失败");
|
// console.log("请求失败");
|
||||||
// console.log(res);
|
// console.log(res);
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
// } else {
|
// } else {
|
||||||
// console.log('登录失败!' + res.errMsg)
|
// console.log('登录失败!' + res.errMsg)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static PayOder(){
|
// static PayOder(){
|
||||||
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||||
// //@ts-ignore
|
// //@ts-ignore
|
||||||
// wx.cloud.callFunction({
|
// wx.cloud.callFunction({
|
||||||
// // 云函数名称
|
// // 云函数名称
|
||||||
// name: 'userPayOrder',
|
// name: 'userPayOrder',
|
||||||
// // 传给云函数的参数
|
// // 传给云函数的参数
|
||||||
// data: {
|
// data: {
|
||||||
// itemid:"10011",
|
// itemid:"10011",
|
||||||
// itemCount:1,
|
// itemCount:1,
|
||||||
// itemPrice:100
|
// itemPrice:100
|
||||||
// },
|
// },
|
||||||
// success: function(res) {
|
// success: function(res) {
|
||||||
// console.log("请求成功");
|
// console.log("请求成功");
|
||||||
// console.log(res)
|
// console.log(res)
|
||||||
// if(res.result.code==1){
|
// if(res.result.code==1){
|
||||||
// Utils.outTradeNo=res.result.data.outTradeNo;
|
// Utils.outTradeNo=res.result.data.outTradeNo;
|
||||||
// console.log("订单号:"+Utils.outTradeNo);
|
// console.log("订单号:"+Utils.outTradeNo);
|
||||||
// //@ts-ignore
|
// //@ts-ignore
|
||||||
// wx.requestMidasPaymentGameItem({
|
// wx.requestMidasPaymentGameItem({
|
||||||
// signData:res.result.data.signData,
|
// signData:res.result.data.signData,
|
||||||
// paySig: res.result.data.paySig,
|
// paySig: res.result.data.paySig,
|
||||||
// signature: res.result.data.signature,
|
// signature: res.result.data.signature,
|
||||||
// success(res, errCode) {
|
// success(res, errCode) {
|
||||||
// console.log('成功', res, errCode);
|
// console.log('成功', res, errCode);
|
||||||
// },
|
// },
|
||||||
// fail({errMsg,errCode}) {
|
// fail({errMsg,errCode}) {
|
||||||
// console.error('失败');
|
// console.error('失败');
|
||||||
// console.error(errMsg, errCode)
|
// console.error(errMsg, errCode)
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// },
|
// },
|
||||||
// fail:function(res){
|
// fail:function(res){
|
||||||
// console.log("请求失败");
|
// console.log("请求失败");
|
||||||
// console.log(res);
|
// console.log(res);
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static getPayInfo1(callBack){
|
// static getPayInfo1(callBack){
|
||||||
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||||
// //@ts-ignore
|
// //@ts-ignore
|
||||||
// wx.cloud.callFunction({
|
// wx.cloud.callFunction({
|
||||||
// // 云函数名称
|
// // 云函数名称
|
||||||
// name: 'userGetPayState',
|
// name: 'userGetPayState',
|
||||||
// // 传给云函数的参数
|
// // 传给云函数的参数
|
||||||
// data: {
|
// data: {
|
||||||
// outTradeNo:Utils.outTradeNo
|
// outTradeNo:Utils.outTradeNo
|
||||||
// },
|
// },
|
||||||
// success: function(res) {
|
// success: function(res) {
|
||||||
// console.log("请求成功");
|
// console.log("请求成功");
|
||||||
// console.log(res)
|
// console.log(res)
|
||||||
// callBack("成功");
|
// callBack("成功");
|
||||||
// },
|
// },
|
||||||
// fail:function(res){
|
// fail:function(res){
|
||||||
// console.log("请求失败");
|
// console.log("请求失败");
|
||||||
// console.log(res);
|
// console.log(res);
|
||||||
// callBack("失败");
|
// callBack("失败");
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static toke(){
|
// static toke(){
|
||||||
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||||
// //@ts-ignore
|
// //@ts-ignore
|
||||||
// wx.cloud.callFunction({
|
// wx.cloud.callFunction({
|
||||||
// // 云函数名称
|
// // 云函数名称
|
||||||
// name: 'uerToken',
|
// name: 'uerToken',
|
||||||
// // 传给云函数的参数
|
// // 传给云函数的参数
|
||||||
// data: {
|
// data: {
|
||||||
|
|
||||||
// },
|
// },
|
||||||
// success: function(res) {
|
// success: function(res) {
|
||||||
// console.log("请求成功");
|
// console.log("请求成功");
|
||||||
// console.log(res)
|
// console.log(res)
|
||||||
// },
|
// },
|
||||||
// fail:function(res){
|
// fail:function(res){
|
||||||
// console.log("请求失败");
|
// console.log("请求失败");
|
||||||
// console.log(res);
|
// console.log(res);
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -296,7 +309,7 @@ export default class Utils {
|
||||||
* @param {*} callback
|
* @param {*} callback
|
||||||
* @memberof HttpUtil
|
* @memberof HttpUtil
|
||||||
*/
|
*/
|
||||||
public static POST(url, param:object|any,callback) {
|
public static POST(url, param: object | any, callback) {
|
||||||
var xhr = cc.loader.getXMLHttpRequest();
|
var xhr = cc.loader.getXMLHttpRequest();
|
||||||
let dataStr = '';
|
let dataStr = '';
|
||||||
Object.keys(param).forEach(key => {
|
Object.keys(param).forEach(key => {
|
||||||
|
@ -305,123 +318,123 @@ export default class Utils {
|
||||||
if (dataStr !== '') {
|
if (dataStr !== '') {
|
||||||
dataStr = dataStr.substr(0, dataStr.lastIndexOf('&'));
|
dataStr = dataStr.substr(0, dataStr.lastIndexOf('&'));
|
||||||
}
|
}
|
||||||
url=this.httpip+url;
|
url = this.httpip + url;
|
||||||
console.log("请求地址:"+url);
|
console.log("请求地址:" + url);
|
||||||
xhr.open("POST", url, true);
|
xhr.open("POST", url, true);
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState === 4) {
|
if (xhr.readyState === 4) {
|
||||||
let response:any = xhr.responseText;
|
let response: any = xhr.responseText;
|
||||||
if (xhr.status >= 200 && xhr.status < 300) {
|
if (xhr.status >= 200 && xhr.status < 300) {
|
||||||
let httpStatus = xhr.statusText;
|
let httpStatus = xhr.statusText;
|
||||||
// callback(true, JSON.parse(response));
|
// callback(true, JSON.parse(response));
|
||||||
try{
|
try {
|
||||||
response=JSON.parse(response);
|
response = JSON.parse(response);
|
||||||
}catch{
|
} catch {
|
||||||
response={data:"数据有误",code:0};
|
response = { data: "数据有误", code: 0 };
|
||||||
}
|
}
|
||||||
callback(response);
|
callback(response);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
callback({data:"网络请求失败,请检查网络连接",code:0});
|
callback({ data: "网络请求失败,请检查网络连接", code: 0 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.send(dataStr);
|
xhr.send(dataStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static http_sendRequest(path,data,handler,extraUrl=null){
|
static http_sendRequest(path, data, handler, extraUrl = null) {
|
||||||
let xhr=cc.loader.getXMLHttpRequest();
|
let xhr = cc.loader.getXMLHttpRequest();
|
||||||
xhr.timeout=5000;//超时时间
|
xhr.timeout = 5000;//超时时间
|
||||||
if(data==null){
|
if (data == null) {
|
||||||
data={};
|
data = {};
|
||||||
}
|
}
|
||||||
// if(exports.token){//数据中加入安全密匙
|
// if(exports.token){//数据中加入安全密匙
|
||||||
// data.token=exports.token;
|
// data.token=exports.token;
|
||||||
// }
|
// }
|
||||||
if(extraUrl==null){
|
if (extraUrl == null) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
if(Utils.isDebug){
|
if (Utils.isDebug) {
|
||||||
extraUrl="http://localhost:9003";
|
extraUrl = "http://localhost:9003";
|
||||||
}else{
|
} else {
|
||||||
extraUrl=this.httpip;
|
extraUrl = this.httpip;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//解析请求路由以及格式化请求参数
|
//解析请求路由以及格式化请求参数
|
||||||
let sendtext="?";
|
let sendtext = "?";
|
||||||
for(let k in data){
|
for (let k in data) {
|
||||||
if(sendtext !="?"){
|
if (sendtext != "?") {
|
||||||
sendtext +="&";
|
sendtext += "&";
|
||||||
}
|
}
|
||||||
sendtext +=(k +'='+data[k]);
|
sendtext += (k + '=' + data[k]);
|
||||||
}
|
}
|
||||||
//组装完整的URL
|
//组装完整的URL
|
||||||
let requestURL=extraUrl+"/"+path+encodeURI(sendtext);
|
let requestURL = extraUrl + "/" + path + encodeURI(sendtext);
|
||||||
// console.log("发送请求:");
|
// console.log("发送请求:");
|
||||||
// console.log(requestURL);
|
// console.log(requestURL);
|
||||||
//发送请求 Get形式发送请求
|
//发送请求 Get形式发送请求
|
||||||
xhr.open("GET",requestURL,true);
|
xhr.open("GET", requestURL, true);
|
||||||
if (cc.sys.isNative) {//如果是手机就设置请求头
|
if (cc.sys.isNative) {//如果是手机就设置请求头
|
||||||
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
|
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
|
||||||
}
|
}
|
||||||
//计时判断是否超时
|
//计时判断是否超时
|
||||||
let hasRetried=false;
|
let hasRetried = false;
|
||||||
let timer=setTimeout(function(){
|
let timer = setTimeout(function () {
|
||||||
//xhr.hasRetried=true;
|
//xhr.hasRetried=true;
|
||||||
hasRetried=true;
|
hasRetried = true;
|
||||||
xhr.abort();
|
xhr.abort();
|
||||||
console.log("http timeOut......");
|
console.log("http timeOut......");
|
||||||
retryFun();
|
retryFun();
|
||||||
},5000);
|
}, 5000);
|
||||||
//重新发送请求
|
//重新发送请求
|
||||||
let retryFun=function(){
|
let retryFun = function () {
|
||||||
Utils.http_sendRequest(path,data,handler,extraUrl);
|
Utils.http_sendRequest(path, data, handler, extraUrl);
|
||||||
}
|
}
|
||||||
//监听反馈
|
//监听反馈
|
||||||
xhr.onreadystatechange=function(){
|
xhr.onreadystatechange = function () {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
if(xhr.readyState===4&&(xhr.status >= 200 && xhr.status < 300)){
|
if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 300)) {
|
||||||
let ret=null;
|
let ret = null;
|
||||||
let respText=xhr.responseText;
|
let respText = xhr.responseText;
|
||||||
try{
|
try {
|
||||||
ret=JSON.parse(respText);
|
ret = JSON.parse(respText);
|
||||||
}catch(e){
|
} catch (e) {
|
||||||
console.log("http error:" +e);
|
console.log("http error:" + e);
|
||||||
ret={
|
ret = {
|
||||||
code:1,
|
code: 1,
|
||||||
msg:e
|
msg: e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(handler){
|
if (handler) {
|
||||||
handler(ret);
|
handler(ret);
|
||||||
}
|
}
|
||||||
handler=null;
|
handler = null;
|
||||||
}else if(xhr.readyState===4){
|
} else if (xhr.readyState === 4) {
|
||||||
// if(xhr.hasRetried){
|
// if(xhr.hasRetried){
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
if(hasRetried){
|
if (hasRetried) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('other readystate =='+xhr.readyState + ', status:' + xhr.status);
|
console.log('other readystate ==' + xhr.readyState + ', status:' + xhr.status);
|
||||||
if(xhr.readyState==4&&xhr.status==0){
|
if (xhr.readyState == 4 && xhr.status == 0) {
|
||||||
handler({
|
handler({
|
||||||
err:1,
|
err: 1,
|
||||||
msg:"网络连接失败,请稍后再试"
|
msg: "网络连接失败,请稍后再试"
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setTimeout(function(){
|
setTimeout(function () {
|
||||||
retryFun();
|
retryFun();
|
||||||
},5000);
|
}, 5000);
|
||||||
}else{
|
} else {
|
||||||
//console.log('other readystate:' + xhr.readyState + ', status:' + xhr.status);
|
//console.log('other readystate:' + xhr.readyState + ', status:' + xhr.status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try{
|
try {
|
||||||
xhr.send();
|
xhr.send();
|
||||||
}catch(e){
|
} catch (e) {
|
||||||
retryFun();
|
retryFun();
|
||||||
}
|
}
|
||||||
return xhr;
|
return xhr;
|
||||||
|
|
|
@ -644,9 +644,16 @@ var GameTool = {
|
||||||
num = 1;
|
num = 1;
|
||||||
}
|
}
|
||||||
cc.fx.GameTool.changeCoin(-cost);
|
cc.fx.GameTool.changeCoin(-cost);
|
||||||
|
const dataTemp = {
|
||||||
|
change_reason: "商城购买道具消耗",
|
||||||
|
id: (1001 + ""),
|
||||||
|
num: -cost
|
||||||
|
}
|
||||||
|
cc.fx.GameTool.shushu_Track("resource_cost", dataTemp);
|
||||||
cc.fx.GameTool.setUserProp(propid, num, (data) => {
|
cc.fx.GameTool.setUserProp(propid, num, (data) => {
|
||||||
})
|
})
|
||||||
const data = {
|
const data = {
|
||||||
|
change_reason: "商城购买道具",
|
||||||
id: (propid + ""),
|
id: (propid + ""),
|
||||||
num: 3
|
num: 3
|
||||||
}
|
}
|
||||||
|
@ -828,6 +835,7 @@ var GameTool = {
|
||||||
shopBuy(productId) {
|
shopBuy(productId) {
|
||||||
let coin = 0;
|
let coin = 0;
|
||||||
let price = 0;
|
let price = 0;
|
||||||
|
let getCoin = 0;
|
||||||
switch (productId) {
|
switch (productId) {
|
||||||
case "gold_1":
|
case "gold_1":
|
||||||
cc.fx.GameTool.changeCoin(1200);
|
cc.fx.GameTool.changeCoin(1200);
|
||||||
|
@ -866,6 +874,13 @@ var GameTool = {
|
||||||
MiniGameSdk.API.showToast("充值成功,获得240000金币");
|
MiniGameSdk.API.showToast("充值成功,获得240000金币");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
const dataTemp = {
|
||||||
|
change_reason: "商城RMB购买金币",
|
||||||
|
id: (1001 + ""),
|
||||||
|
num: coin
|
||||||
|
}
|
||||||
|
cc.fx.GameTool.shushu_Track("resource_get", dataTemp);
|
||||||
|
|
||||||
const buyData = {
|
const buyData = {
|
||||||
item_id: productId,
|
item_id: productId,
|
||||||
item_num: coin,
|
item_num: coin,
|
||||||
|
@ -927,14 +942,14 @@ var GameTool = {
|
||||||
break;
|
break;
|
||||||
case "resource_get":
|
case "resource_get":
|
||||||
eventData = {
|
eventData = {
|
||||||
change_reason: "购买道具", //获得来源
|
change_reason: data.change_reason, //获得来源
|
||||||
change_num: data.num, //获得数量
|
change_num: data.num, //获得数量
|
||||||
resource_id: data.id //道具id
|
resource_id: data.id //道具id
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "resource_cost":
|
case "resource_cost":
|
||||||
eventData = {
|
eventData = {
|
||||||
change_reason: "使用道具", //获得来源
|
change_reason: data.change_reason, //获得来源
|
||||||
change_num: data.num, //获得数量
|
change_num: data.num, //获得数量
|
||||||
resource_id: data.id //道具id
|
resource_id: data.id //道具id
|
||||||
}
|
}
|
||||||
|
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 467 KiB After Width: | Height: | Size: 467 KiB |
Before Width: | Height: | Size: 933 KiB |
|
@ -1,38 +0,0 @@
|
||||||
{
|
|
||||||
"ver": "2.3.7",
|
|
||||||
"uuid": "8ac53103-5eab-4857-b56c-2d055f0be6e3",
|
|
||||||
"importer": "texture",
|
|
||||||
"type": "sprite",
|
|
||||||
"wrapMode": "clamp",
|
|
||||||
"filterMode": "bilinear",
|
|
||||||
"premultiplyAlpha": false,
|
|
||||||
"genMipmaps": false,
|
|
||||||
"packable": true,
|
|
||||||
"width": 1071,
|
|
||||||
"height": 1257,
|
|
||||||
"platformSettings": {},
|
|
||||||
"subMetas": {
|
|
||||||
"tanchuang1": {
|
|
||||||
"ver": "1.0.6",
|
|
||||||
"uuid": "f2dcf5a7-9beb-4773-ad55-45a2f827a912",
|
|
||||||
"importer": "sprite-frame",
|
|
||||||
"rawTextureUuid": "8ac53103-5eab-4857-b56c-2d055f0be6e3",
|
|
||||||
"trimType": "auto",
|
|
||||||
"trimThreshold": 1,
|
|
||||||
"rotated": false,
|
|
||||||
"offsetX": 0,
|
|
||||||
"offsetY": 0,
|
|
||||||
"trimX": 0,
|
|
||||||
"trimY": 0,
|
|
||||||
"width": 1071,
|
|
||||||
"height": 1257,
|
|
||||||
"rawWidth": 1071,
|
|
||||||
"rawHeight": 1257,
|
|
||||||
"borderTop": 0,
|
|
||||||
"borderBottom": 0,
|
|
||||||
"borderLeft": 0,
|
|
||||||
"borderRight": 0,
|
|
||||||
"subMetas": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 296 KiB After Width: | Height: | Size: 296 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 215 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 8.6 KiB |
|
@ -992,8 +992,8 @@
|
||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 98,
|
"width": 94,
|
||||||
"height": 98
|
"height": 90
|
||||||
},
|
},
|
||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
|
|
Before Width: | Height: | Size: 221 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 43 KiB |
BIN
assets/shop/img/shop_1.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"ver": "2.3.7",
|
"ver": "2.3.7",
|
||||||
"uuid": "d0d3a854-9f5c-486f-8a9e-ebd1c96b68b5",
|
"uuid": "9c710aa3-45b5-43fb-b76f-8d6af41a21d5",
|
||||||
"importer": "texture",
|
"importer": "texture",
|
||||||
"type": "sprite",
|
"type": "sprite",
|
||||||
"wrapMode": "clamp",
|
"wrapMode": "clamp",
|
||||||
|
@ -12,11 +12,11 @@
|
||||||
"height": 2340,
|
"height": 2340,
|
||||||
"platformSettings": {},
|
"platformSettings": {},
|
||||||
"subMetas": {
|
"subMetas": {
|
||||||
"shop_2": {
|
"shop_1": {
|
||||||
"ver": "1.0.6",
|
"ver": "1.0.6",
|
||||||
"uuid": "1880f261-dd18-4e9e-9f49-b2f194d5ef8f",
|
"uuid": "403aa689-5ef4-4978-978a-74b806e0760f",
|
||||||
"importer": "sprite-frame",
|
"importer": "sprite-frame",
|
||||||
"rawTextureUuid": "d0d3a854-9f5c-486f-8a9e-ebd1c96b68b5",
|
"rawTextureUuid": "9c710aa3-45b5-43fb-b76f-8d6af41a21d5",
|
||||||
"trimType": "auto",
|
"trimType": "auto",
|
||||||
"trimThreshold": 1,
|
"trimThreshold": 1,
|
||||||
"rotated": false,
|
"rotated": false,
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 42 KiB |
|
@ -1,38 +0,0 @@
|
||||||
{
|
|
||||||
"ver": "2.3.7",
|
|
||||||
"uuid": "39980b3f-ffc1-450f-90bc-4861aa8c81fb",
|
|
||||||
"importer": "texture",
|
|
||||||
"type": "sprite",
|
|
||||||
"wrapMode": "clamp",
|
|
||||||
"filterMode": "bilinear",
|
|
||||||
"premultiplyAlpha": false,
|
|
||||||
"genMipmaps": false,
|
|
||||||
"packable": true,
|
|
||||||
"width": 1080,
|
|
||||||
"height": 2340,
|
|
||||||
"platformSettings": {},
|
|
||||||
"subMetas": {
|
|
||||||
"shop_2": {
|
|
||||||
"ver": "1.0.6",
|
|
||||||
"uuid": "5652a0a0-3753-477b-afbd-e68830208955",
|
|
||||||
"importer": "sprite-frame",
|
|
||||||
"rawTextureUuid": "39980b3f-ffc1-450f-90bc-4861aa8c81fb",
|
|
||||||
"trimType": "auto",
|
|
||||||
"trimThreshold": 1,
|
|
||||||
"rotated": false,
|
|
||||||
"offsetX": 0,
|
|
||||||
"offsetY": 0,
|
|
||||||
"trimX": 0,
|
|
||||||
"trimY": 0,
|
|
||||||
"width": 1080,
|
|
||||||
"height": 2340,
|
|
||||||
"rawWidth": 1080,
|
|
||||||
"rawHeight": 2340,
|
|
||||||
"borderTop": 0,
|
|
||||||
"borderBottom": 0,
|
|
||||||
"borderLeft": 0,
|
|
||||||
"borderRight": 0,
|
|
||||||
"subMetas": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Before Width: | Height: | Size: 932 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 536 KiB After Width: | Height: | Size: 138 KiB |
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 40 KiB |
|
@ -328,7 +328,7 @@
|
||||||
"_srcBlendFactor": 770,
|
"_srcBlendFactor": 770,
|
||||||
"_dstBlendFactor": 771,
|
"_dstBlendFactor": 771,
|
||||||
"_spriteFrame": {
|
"_spriteFrame": {
|
||||||
"__uuid__": "1880f261-dd18-4e9e-9f49-b2f194d5ef8f"
|
"__uuid__": "403aa689-5ef4-4978-978a-74b806e0760f"
|
||||||
},
|
},
|
||||||
"_type": 0,
|
"_type": 0,
|
||||||
"_sizeMode": 0,
|
"_sizeMode": 0,
|
||||||
|
@ -4002,7 +4002,7 @@
|
||||||
"component": "",
|
"component": "",
|
||||||
"_componentId": "48bfeZuYFZE2qmgxbW2IigB",
|
"_componentId": "48bfeZuYFZE2qmgxbW2IigB",
|
||||||
"handler": "buyProduct",
|
"handler": "buyProduct",
|
||||||
"customEventData": "gold_pack_5"
|
"customEventData": "gold_5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "de906iE/HVHpI6VO7IMvKaI",
|
"__type__": "de906iE/HVHpI6VO7IMvKaI",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"ver": "1.3.2",
|
"ver": "1.3.2",
|
||||||
"uuid": "b01ef5c5-2755-455d-acb4-ba3818f5e331",
|
"uuid": "b01ef5c5-2755-455d-acb4-ba3818f5e331",
|
||||||
"importer": "prefab",
|
"importer": "prefab",
|
||||||
"optimizationPolicy": "AUTO",
|
"optimizationPolicy": "MULTI_INSTANCE",
|
||||||
"asyncLoadAssets": false,
|
"asyncLoadAssets": false,
|
||||||
"readonly": false,
|
"readonly": false,
|
||||||
"subMetas": {}
|
"subMetas": {}
|
||||||
|
|
|
@ -30,7 +30,7 @@ export default class NewClass extends cc.Component {
|
||||||
private coinStart: number = 0;
|
private coinStart: number = 0;
|
||||||
private coinEnd: number = 0;
|
private coinEnd: number = 0;
|
||||||
private coinAnimating: boolean = false;
|
private coinAnimating: boolean = false;
|
||||||
//飞金币动画
|
//飞金币动画
|
||||||
@property(cc.Node)
|
@property(cc.Node)
|
||||||
coinAnim: cc.Node = null;
|
coinAnim: cc.Node = null;
|
||||||
private buy: boolean = false;
|
private buy: boolean = false;
|
||||||
|
@ -49,18 +49,19 @@ export default class NewClass extends cc.Component {
|
||||||
start() {
|
start() {
|
||||||
this.btn_Touch = true;
|
this.btn_Touch = true;
|
||||||
this.openShop();
|
this.openShop();
|
||||||
this.setHealthInfo();
|
this.setHealthInfo();
|
||||||
}
|
}
|
||||||
//打开商店界面
|
//打开商店界面
|
||||||
openShop() {
|
openShop() {
|
||||||
|
Utils.outTradeNo = null;
|
||||||
// 商品数据数组
|
// 商品数据数组
|
||||||
const products = [
|
const products = [
|
||||||
{ product_id: "gold_1", name: "金币包1", price: 600, coin:1200, title: "3x2六档金币" },
|
{ 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_2", name: "金币包2", price: 3600, coin: 8000, title: "" },
|
||||||
{ product_id: "gold_3", name: "金币包3", price: 6800, coin:16000, 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_4", name: "金币包4", price: 12800, coin: 32000, title: "" },
|
||||||
{ product_id: "gold_5", name: "金币包5", price: 32800, coin:100000, title: "" },
|
{ product_id: "gold_5", name: "金币包5", price: 32800, coin: 100000, title: "" },
|
||||||
{ product_id: "gold_6", name: "金币包6", price: 64800, coin:240000, title: "" },
|
{ product_id: "gold_6", name: "金币包6", price: 64800, coin: 240000, title: "" },
|
||||||
];
|
];
|
||||||
for (let i = 1; i <= 6 && i < this.itemList.children.length; i++) {
|
for (let i = 1; i <= 6 && i < this.itemList.children.length; i++) {
|
||||||
const spriteComp = this.itemList.children[i].children[0].getComponent(cc.Sprite);
|
const spriteComp = this.itemList.children[i].children[0].getComponent(cc.Sprite);
|
||||||
|
@ -86,30 +87,30 @@ export default class NewClass extends cc.Component {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
startCoinAnim(target: number) {
|
startCoinAnim(target: number) {
|
||||||
if (this.coinAnimating && this.coinEnd === target) return;
|
if (this.coinAnimating && this.coinEnd === target) return;
|
||||||
this.coinStart = this.currentCoin;
|
this.coinStart = this.currentCoin;
|
||||||
this.coinEnd = target;
|
this.coinEnd = target;
|
||||||
this.coinAnimTime = 0;
|
this.coinAnimTime = 0;
|
||||||
this.coinAnimating = true;
|
this.coinAnimating = true;
|
||||||
}
|
}
|
||||||
//优化
|
//优化
|
||||||
protected update(dt: number): void {
|
protected update(dt: number): void {
|
||||||
if (this.coin && this.coinAnimating) {
|
if (this.coin && this.coinAnimating) {
|
||||||
this.coinAnimTime += dt;
|
this.coinAnimTime += dt;
|
||||||
let t = this.coinAnimTime / this.coinAnimDuration;
|
let t = this.coinAnimTime / this.coinAnimDuration;
|
||||||
if (t >= 1) {
|
if (t >= 1) {
|
||||||
this.currentCoin = this.coinEnd;
|
this.currentCoin = this.coinEnd;
|
||||||
this.coinAnimating = false;
|
this.coinAnimating = false;
|
||||||
NumberToImage.numberToImageNodes(this.currentCoin, 30, 15, "coin_", this.coin, true);
|
NumberToImage.numberToImageNodes(this.currentCoin, 30, 15, "coin_", this.coin, true);
|
||||||
} else {
|
} else {
|
||||||
this.currentCoin = Math.floor(this.coinStart + (this.coinEnd - this.coinStart) * t);
|
this.currentCoin = Math.floor(this.coinStart + (this.coinEnd - this.coinStart) * t);
|
||||||
NumberToImage.numberToImageNodes(this.currentCoin, 30, 15, "coin_", this.coin, true);
|
NumberToImage.numberToImageNodes(this.currentCoin, 30, 15, "coin_", this.coin, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
playCoinAnim(target?: number) {
|
playCoinAnim(target?: number) {
|
||||||
this.coinAnim.active = true;
|
this.coinAnim.active = true;
|
||||||
this.coinAnim.getComponent(sp.Skeleton).setAnimation(0, "feijinbi", false);
|
this.coinAnim.getComponent(sp.Skeleton).setAnimation(0, "feijinbi", false);
|
||||||
// 监听动画完成事件
|
// 监听动画完成事件
|
||||||
|
@ -117,7 +118,7 @@ protected update(dt: number): void {
|
||||||
// 动画播放完成后销毁节点
|
// 动画播放完成后销毁节点
|
||||||
this.coinAnim.active = false;
|
this.coinAnim.active = false;
|
||||||
});
|
});
|
||||||
this.startCoinAnim(5000);
|
this.startCoinAnim(5000);
|
||||||
}
|
}
|
||||||
//关闭商店界面
|
//关闭商店界面
|
||||||
closeShop() {
|
closeShop() {
|
||||||
|
@ -126,21 +127,26 @@ protected update(dt: number): void {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
wx.offShow(this.onShowListener);
|
wx.offShow(this.onShowListener);
|
||||||
}
|
}
|
||||||
|
Utils.outTradeNo = null;
|
||||||
//销毁预制体
|
//销毁预制体
|
||||||
if(this.node.parent.getComponent("JiaZai")){
|
if (this.node.parent.getComponent("JiaZai")) {
|
||||||
this.node.parent.getComponent("JiaZai").closeShop();
|
this.node.parent.getComponent("JiaZai").closeShop();
|
||||||
}
|
}
|
||||||
else if(this.node.parent.getComponent("SceneManager")){
|
else if (this.node.parent.getComponent("SceneManager")) {
|
||||||
this.node.parent.getComponent("SceneManager").closeShop();
|
this.node.parent.getComponent("SceneManager").closeShop();
|
||||||
}
|
}
|
||||||
// this.shop.destroy();
|
// this.shop.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow(){
|
onShow() {
|
||||||
if(cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null){
|
if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null) {
|
||||||
console.log("有苹果订单号,开始轮训");
|
console.log("有苹果订单号,开始轮训");
|
||||||
Utils.getIosPayInfo((data) =>{
|
Utils.getIosPayInfo((data) => {
|
||||||
console.log("获得轮训结果:",data);
|
console.log("获得轮训结果:", data);
|
||||||
|
if (data.code == 1) {
|
||||||
|
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||||
|
MiniGameSdk.API.showToast("购买金币成功");
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +172,7 @@ protected update(dt: number): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startTimeCutDown() {
|
startTimeCutDown() {
|
||||||
this.scheduleCallback = function () {
|
this.scheduleCallback = function () {
|
||||||
if (this.pause) return;
|
if (this.pause) return;
|
||||||
if (cc.fx.GameConfig.GM_INFO.min_Time <= 0) {
|
if (cc.fx.GameConfig.GM_INFO.min_Time <= 0) {
|
||||||
|
@ -204,7 +210,7 @@ protected update(dt: number): void {
|
||||||
//点击充值购买
|
//点击充值购买
|
||||||
|
|
||||||
buyProduct(event, customData) {
|
buyProduct(event, customData) {
|
||||||
if(!this.btn_Touch){
|
if (!this.btn_Touch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.btn_Touch = false;
|
this.btn_Touch = false;
|
||||||
|
@ -213,7 +219,7 @@ protected update(dt: number): void {
|
||||||
let price = 100;
|
let price = 100;
|
||||||
let count = 1;
|
let count = 1;
|
||||||
id = productId;
|
id = productId;
|
||||||
switch(productId){
|
switch (productId) {
|
||||||
case "gold_1":
|
case "gold_1":
|
||||||
price = 600;
|
price = 600;
|
||||||
break;
|
break;
|
||||||
|
@ -233,11 +239,11 @@ protected update(dt: number): void {
|
||||||
price = 64800;
|
price = 64800;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
console.log("获得商品id:",id,count,price);
|
console.log("获得商品id:", id, count, price);
|
||||||
// 判断设备系统
|
// 判断设备系统
|
||||||
let systemType = "Android";
|
let systemType = "Android";
|
||||||
try {
|
try {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const systemInfo = wx.getSystemInfoSync();
|
const systemInfo = wx.getSystemInfoSync();
|
||||||
if (systemInfo.platform === 'ios') {
|
if (systemInfo.platform === 'ios') {
|
||||||
systemType = "ios";
|
systemType = "ios";
|
||||||
|
@ -247,100 +253,101 @@ protected update(dt: number): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utils.GoKEFu();
|
// Utils.GoKEFu();
|
||||||
if(systemType == "ios"){
|
if (systemType == "ios") {
|
||||||
MiniGameSdk.API.showToast("IOS系统暂不支持支付");
|
MiniGameSdk.API.showToast("IOS系统暂不支持支付");
|
||||||
|
this.btn_Touch = true;
|
||||||
// Utils.GoKEFu();
|
// Utils.GoKEFu();
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
const data = {
|
const data = {
|
||||||
outTradeNo:Utils.outTradeNo,
|
outTradeNo: Utils.outTradeNo,
|
||||||
price:price,
|
price: price,
|
||||||
payment_name:productId,
|
payment_name: productId,
|
||||||
payment_num:1,
|
payment_num: 1,
|
||||||
type:systemType,
|
type: systemType,
|
||||||
}
|
}
|
||||||
cc.fx.GameTool.shushu_Track("init_order",data);
|
cc.fx.GameTool.shushu_Track("init_order", data);
|
||||||
|
|
||||||
Utils.buyProp(id,count,price,(res)=>{
|
Utils.buyProp(id, count, price, (res) => {
|
||||||
console.log("获得充值结果",res);
|
console.log("获得充值结果", res);
|
||||||
if(res == null){
|
if (res == null) {
|
||||||
MiniGameSdk.API.showToast("网络异常,充值失败请稍后再试");
|
MiniGameSdk.API.showToast("网络异常,充值失败请稍后再试");
|
||||||
this.btn_Touch = true;
|
this.btn_Touch = true;
|
||||||
const dataFail = {
|
const dataFail = {
|
||||||
outTradeNo:Utils.outTradeNo,
|
outTradeNo: Utils.outTradeNo,
|
||||||
price:price,
|
price: price,
|
||||||
payment_name:productId,
|
payment_name: productId,
|
||||||
payment_num:1,
|
payment_num: 1,
|
||||||
type:systemType,
|
type: systemType,
|
||||||
fail_reason:"网络异常,没有拉起支付",
|
fail_reason: "网络异常,没有拉起支付",
|
||||||
}
|
}
|
||||||
cc.fx.GameTool.shushu_Track("payment_fail",dataFail);
|
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
Utils.getPayInfo((data) =>{
|
Utils.getPayInfo((data) => {
|
||||||
console.log("获得轮训结果:",data);
|
console.log("获得轮训结果:", data);
|
||||||
if(data.data.pay_state == 1){
|
if (data.data.pay_state == 1) {
|
||||||
this.btn_Touch = true;
|
this.btn_Touch = true;
|
||||||
MiniGameSdk.API.showToast("取消充值");
|
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",name);
|
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){
|
else if (data.data.pay_state == 2) {
|
||||||
this.btn_Touch = true;
|
this.btn_Touch = true;
|
||||||
Utils.setPayInfo((data) => {
|
Utils.setPayInfo((data) => {
|
||||||
console.log("设置轮训结果:",data);
|
console.log("设置轮训结果:", data);
|
||||||
if(data.code === 1){
|
if (data.code === 1) {
|
||||||
MiniGameSdk.API.showToast("充值成功");
|
MiniGameSdk.API.showToast("充值成功");
|
||||||
cc.fx.GameTool.shopBuy(productId);
|
cc.fx.GameTool.shopBuy(productId);
|
||||||
console.log("充值成功获得金币");
|
console.log("充值成功获得金币");
|
||||||
const dataSuccess = {
|
const dataSuccess = {
|
||||||
outTradeNo:Utils.outTradeNo,
|
outTradeNo: Utils.outTradeNo,
|
||||||
price:price,
|
price: price,
|
||||||
payment_name:productId,
|
payment_name: productId,
|
||||||
payment_num:1,
|
payment_num: 1,
|
||||||
type:systemType,
|
type: systemType,
|
||||||
}
|
}
|
||||||
cc.fx.GameTool.shushu_Track("payment",dataSuccess);
|
cc.fx.GameTool.shushu_Track("payment", dataSuccess);
|
||||||
let name = "购买金币道具:"+ productId;
|
let name = "购买金币道具:" + productId;
|
||||||
MiniGameSdk.API.yinli_Pay(price,Utils.outTradeNo,name)
|
MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name)
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
|
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
|
||||||
const dataFail4 = {
|
const dataFail4 = {
|
||||||
outTradeNo:Utils.outTradeNo,
|
outTradeNo: Utils.outTradeNo,
|
||||||
price:price,
|
price: price,
|
||||||
payment_name:productId,
|
payment_name: productId,
|
||||||
payment_num:1,
|
payment_num: 1,
|
||||||
type:systemType,
|
type: systemType,
|
||||||
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);
|
||||||
this.node.parent.getComponent("JiaZai").updateCoin();
|
this.node.parent.getComponent("JiaZai").updateCoin();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
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);
|
||||||
this.node.parent.getComponent("JiaZai").updateCoin();
|
this.node.parent.getComponent("JiaZai").updateCoin();
|
||||||
const dataFail3 = {
|
const dataFail3 = {
|
||||||
outTradeNo:Utils.outTradeNo,
|
outTradeNo: Utils.outTradeNo,
|
||||||
price:price,
|
price: price,
|
||||||
payment_name:productId,
|
payment_name: productId,
|
||||||
payment_num:1,
|
payment_num: 1,
|
||||||
type:systemType,
|
type: systemType,
|
||||||
fail_reason:"拉起支付后,付款时网络异常付款失败",
|
fail_reason: "拉起支付后,付款时网络异常付款失败",
|
||||||
}
|
}
|
||||||
cc.fx.GameTool.shushu_Track("payment_fail",dataFail3);
|
cc.fx.GameTool.shushu_Track("payment_fail", dataFail3);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Before Width: | Height: | Size: 247 KiB After Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 198 KiB |
Before Width: | Height: | Size: 229 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.2 KiB |
|
@ -15,7 +15,7 @@
|
||||||
"mainCompressionType": "subpackage",
|
"mainCompressionType": "subpackage",
|
||||||
"mainIsRemote": false,
|
"mainIsRemote": false,
|
||||||
"optimizeHotUpdate": false,
|
"optimizeHotUpdate": false,
|
||||||
"md5Cache": true,
|
"md5Cache": false,
|
||||||
"nativeMd5Cache": true,
|
"nativeMd5Cache": true,
|
||||||
"encryptJs": true,
|
"encryptJs": true,
|
||||||
"xxteaKey": "07ac496c-82b0-4f",
|
"xxteaKey": "07ac496c-82b0-4f",
|
||||||
|
|