优化UI图片资源
|
@ -97,6 +97,19 @@ export default class JiaZai extends cc.Component {
|
|||
if (cc.fx.GameConfig.GM_INFO.first) {
|
||||
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;
|
||||
}
|
||||
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 != "") {
|
||||
console.log("————————发送注册事件");
|
||||
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);
|
||||
|
||||
cc.fx.GameTool.getHealth(null);
|
||||
// cc.fx.GameConfig.LEVEL_INFO_init(false,0);s
|
||||
// cc.fx.GameConfig.LEVEL_INFO_init(false,0);
|
||||
setTimeout(() => {
|
||||
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);
|
||||
|
|
|
@ -1369,6 +1369,12 @@ export default class MapConroler extends cc.Component {
|
|||
// console.log("即将上报成功________________________:",this.add_Time);
|
||||
// console.log("成功消除一个",this.add_Time);
|
||||
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();
|
||||
this.count_Time = overTime - this.count_Time;
|
||||
cc.fx.GameTool.addLevel(this.count_Time, this.add_Time);
|
||||
|
@ -1507,6 +1513,12 @@ export default class MapConroler extends cc.Component {
|
|||
runRewive(data) {
|
||||
console.log("复活回调函数内", data);
|
||||
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("继续游戏");
|
||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||
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) => {
|
||||
})
|
||||
let data = {
|
||||
change_reason: "使用道具",
|
||||
id: "2001",
|
||||
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) => {
|
||||
})
|
||||
let data = {
|
||||
change_reason: "使用道具",
|
||||
id: "2002",
|
||||
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) => {
|
||||
})
|
||||
let data = {
|
||||
change_reason: "使用道具",
|
||||
id: "2003",
|
||||
num: -1
|
||||
}
|
||||
|
|
|
@ -1127,7 +1127,7 @@ export namespace MiniGameSdk {
|
|||
},
|
||||
// 根据环境变量设置 debug 模式
|
||||
debug: !isProduction,
|
||||
enableLog: false
|
||||
enableLog: true
|
||||
};
|
||||
// 创建 TA 实例
|
||||
API._ta = new ThinkingAnalyticsAPI(config);
|
||||
|
|
|
@ -70,6 +70,12 @@ export default class NewClass extends cc.Component {
|
|||
if (curCoin >= 1000) {
|
||||
this.switchButtons[1].active = false;
|
||||
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;
|
||||
const parentNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
|
||||
if (parentNode) {
|
||||
|
@ -83,6 +89,15 @@ export default class NewClass extends cc.Component {
|
|||
cc.fx.GameTool.setUserHealth(0, (data) => {
|
||||
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 {
|
||||
MiniGameSdk.API.showToast("金币不足,无法购买体力");
|
||||
|
|
|
@ -83,7 +83,7 @@ export class GameConfig {
|
|||
first: boolean; //是否首次进入游戏
|
||||
score: number; //总得分
|
||||
scale: number; //玩家总计成功点火数
|
||||
iosOutTradeNo: number; //ios订单号
|
||||
iosOutTradeNo: string; //ios订单号
|
||||
min_Time: number; //体力恢复的剩余时间
|
||||
freezeAmount: number; //冻结道具次数
|
||||
hammerAmount: number; //锤子道具次数
|
||||
|
@ -220,7 +220,7 @@ export class GameConfig {
|
|||
first: false, //是否首次进入游戏
|
||||
score: 0, //总得分
|
||||
scale: 1, //玩家总计成功点火数
|
||||
iosOutTradeNo: 0, //ios订单号
|
||||
iosOutTradeNo: "", //ios订单号
|
||||
min_Time: 0, //体力恢复的剩余时间
|
||||
freezeAmount: 0, //冻结道具次数
|
||||
hammerAmount: 0, //锤子道具次数
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
export default class Utils {
|
||||
static uid:string="";
|
||||
static session_key="";
|
||||
static appid:string="";
|
||||
static openid:string="";
|
||||
static outTradeNo:string ="";
|
||||
static httpip:string=`https://laf.nika4games.com/`;
|
||||
//#region 安卓支付
|
||||
static uid: string = "";
|
||||
static session_key = "";
|
||||
static appid: string = "";
|
||||
static openid: string = "";
|
||||
static outTradeNo: string = "";
|
||||
static httpip: string = `https://laf.nika4games.com/`;
|
||||
//#region 安卓支付
|
||||
/**获取用户信息*/
|
||||
static getUserInfo(callBack){
|
||||
static getUserInfo(callBack) {
|
||||
wx.login({
|
||||
success (res) {
|
||||
success(res) {
|
||||
console.log("登录成功");
|
||||
console.log(res);
|
||||
if (res.code) {
|
||||
Utils.POST("login",{code:res.code},ret=>{
|
||||
console.log("请求结果:",res);
|
||||
Utils.POST("login", { code: res.code }, ret => {
|
||||
console.log("请求结果:", res);
|
||||
console.log(ret);
|
||||
Utils.openid=ret.data.openid;
|
||||
Utils.session_key=ret.data.session_key;
|
||||
Utils.uid=ret.data._id;
|
||||
Utils.openid = ret.data.openid;
|
||||
Utils.session_key = ret.data.session_key;
|
||||
Utils.uid = ret.data._id;
|
||||
callBack(Utils.uid);
|
||||
})
|
||||
} else {
|
||||
|
@ -29,22 +29,22 @@ export default class Utils {
|
|||
}
|
||||
|
||||
/**道具直购接口*/
|
||||
static buyProp(id,count,price,callBack){
|
||||
console.log("请求uid:"+Utils.uid,"请求id:"+id,"请求数量:"+count,"请求价格:"+price);
|
||||
static buyProp(id, count, price, callBack) {
|
||||
console.log("请求uid:" + Utils.uid, "请求id:" + id, "请求数量:" + count, "请求价格:" + price);
|
||||
|
||||
Utils.POST("wx/orderPaySig",{uid:Utils.uid,itemid:id,itemCount:count,itemPrice:price},res=>{
|
||||
if(res.code==1){
|
||||
Utils.outTradeNo=res.data.outTradeNo;
|
||||
Utils.POST("wx/orderPaySig", { uid: Utils.uid, itemid: id, itemCount: count, itemPrice: price }, res => {
|
||||
if (res.code == 1) {
|
||||
Utils.outTradeNo = res.data.outTradeNo;
|
||||
//@ts-ignore
|
||||
wx.requestMidasPaymentGameItem({
|
||||
signData:res.data.signData,
|
||||
signData: res.data.signData,
|
||||
paySig: res.data.paySig,
|
||||
signature: res.data.signature,
|
||||
success(res, errCode) {
|
||||
console.log('成功', res, errCode);
|
||||
callBack(res);
|
||||
},
|
||||
fail({errMsg,errCode}) {
|
||||
fail({ errMsg, errCode }) {
|
||||
console.error('失败');
|
||||
console.error(errMsg, errCode)
|
||||
callBack(null);
|
||||
|
@ -91,7 +91,7 @@ export default class Utils {
|
|||
callBack({ code: 0, message: '请求失败,已达到最大重试次数' });
|
||||
return;
|
||||
}
|
||||
Utils.POST("wx/getOrderReward", {outTradeNo: Utils.outTradeNo}, res => {
|
||||
Utils.POST("wx/getOrderReward", { outTradeNo: Utils.outTradeNo }, res => {
|
||||
console.log("告知服务器发货:", res);
|
||||
if (res.code === 1) {
|
||||
// 请求成功,调用回调并返回结果
|
||||
|
@ -114,15 +114,15 @@ export default class Utils {
|
|||
//#region ios支付
|
||||
|
||||
/**跳转客服*/
|
||||
static GoKEFu(){
|
||||
static GoKEFu() {
|
||||
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,//价格单位是分
|
||||
const data = {
|
||||
tpye: "ios",
|
||||
outTradeNo: cc.fx.GameConfig.GM_INFO.iosOutTradeNo,
|
||||
propName: '金币',
|
||||
count: 1,
|
||||
price: 100,//价格单位是分
|
||||
}
|
||||
//@ts-ignore
|
||||
wx.openCustomerServiceConversation({
|
||||
|
@ -133,158 +133,171 @@ export default class Utils {
|
|||
}
|
||||
});
|
||||
}
|
||||
static getIosPayInfo(callBack){
|
||||
console.log("请求uid:"+Utils.uid);
|
||||
console.log("outTradeNo:"+this.outTradeNo);
|
||||
Utils.POST("wx/iosgetPayInfo",{outTradeNo:Utils.outTradeNo},res=>{
|
||||
console.log("查询字符结果");
|
||||
static getIosPayInfo(callBack) {
|
||||
const delays = [1000, 10000, 30000, 60000, 60000]; // 延迟时间数组
|
||||
let attempt = 0; // 轮询次数
|
||||
|
||||
const poll = () => {
|
||||
if (attempt >= delays.length) {
|
||||
callBack({ code: 0, 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("查询字符结果IOS");
|
||||
console.log(res);
|
||||
if(res.code==1){
|
||||
if(res.data){
|
||||
callBack("充值取消");
|
||||
if (res.code === 1) {
|
||||
callBack(res);
|
||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||
}else{
|
||||
callBack("充值成功");
|
||||
} else if (res.code === 0) {
|
||||
callBack(res);
|
||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||
}
|
||||
else {
|
||||
attempt++;
|
||||
setTimeout(poll, delays[attempt - 1]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
poll();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//#endregion
|
||||
//#endregion
|
||||
|
||||
//#region 微信云
|
||||
// static initServer(){
|
||||
// if(cc.sys.platform!=cc.sys.WECHAT_GAME)return;
|
||||
// //@ts-ignore
|
||||
// wx.cloud.init({
|
||||
// env: 'cloudbase-1gl7iex89268f11e'
|
||||
// })
|
||||
// }
|
||||
//#region 微信云
|
||||
// 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);
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//#endregion
|
||||
// },
|
||||
// success: function(res) {
|
||||
// console.log("请求成功");
|
||||
// console.log(res)
|
||||
// },
|
||||
// fail:function(res){
|
||||
// console.log("请求失败");
|
||||
// console.log(res);
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//#endregion
|
||||
|
||||
|
||||
/**
|
||||
|
@ -296,7 +309,7 @@ export default class Utils {
|
|||
* @param {*} callback
|
||||
* @memberof HttpUtil
|
||||
*/
|
||||
public static POST(url, param:object|any,callback) {
|
||||
public static POST(url, param: object | any, callback) {
|
||||
var xhr = cc.loader.getXMLHttpRequest();
|
||||
let dataStr = '';
|
||||
Object.keys(param).forEach(key => {
|
||||
|
@ -305,123 +318,123 @@ export default class Utils {
|
|||
if (dataStr !== '') {
|
||||
dataStr = dataStr.substr(0, dataStr.lastIndexOf('&'));
|
||||
}
|
||||
url=this.httpip+url;
|
||||
console.log("请求地址:"+url);
|
||||
url = this.httpip + url;
|
||||
console.log("请求地址:" + url);
|
||||
xhr.open("POST", url, true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
let response:any = xhr.responseText;
|
||||
let response: any = xhr.responseText;
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
let httpStatus = xhr.statusText;
|
||||
// callback(true, JSON.parse(response));
|
||||
try{
|
||||
response=JSON.parse(response);
|
||||
}catch{
|
||||
response={data:"数据有误",code:0};
|
||||
try {
|
||||
response = JSON.parse(response);
|
||||
} catch {
|
||||
response = { data: "数据有误", code: 0 };
|
||||
}
|
||||
callback(response);
|
||||
|
||||
} else {
|
||||
callback({data:"网络请求失败,请检查网络连接",code:0});
|
||||
callback({ data: "网络请求失败,请检查网络连接", code: 0 });
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send(dataStr);
|
||||
}
|
||||
|
||||
static http_sendRequest(path,data,handler,extraUrl=null){
|
||||
let xhr=cc.loader.getXMLHttpRequest();
|
||||
xhr.timeout=5000;//超时时间
|
||||
if(data==null){
|
||||
data={};
|
||||
static http_sendRequest(path, data, handler, extraUrl = null) {
|
||||
let xhr = cc.loader.getXMLHttpRequest();
|
||||
xhr.timeout = 5000;//超时时间
|
||||
if (data == null) {
|
||||
data = {};
|
||||
}
|
||||
// if(exports.token){//数据中加入安全密匙
|
||||
// data.token=exports.token;
|
||||
// }
|
||||
if(extraUrl==null){
|
||||
if (extraUrl == null) {
|
||||
//@ts-ignore
|
||||
if(Utils.isDebug){
|
||||
extraUrl="http://localhost:9003";
|
||||
}else{
|
||||
extraUrl=this.httpip;
|
||||
if (Utils.isDebug) {
|
||||
extraUrl = "http://localhost:9003";
|
||||
} else {
|
||||
extraUrl = this.httpip;
|
||||
}
|
||||
|
||||
}
|
||||
//解析请求路由以及格式化请求参数
|
||||
let sendtext="?";
|
||||
for(let k in data){
|
||||
if(sendtext !="?"){
|
||||
sendtext +="&";
|
||||
let sendtext = "?";
|
||||
for (let k in data) {
|
||||
if (sendtext != "?") {
|
||||
sendtext += "&";
|
||||
}
|
||||
sendtext +=(k +'='+data[k]);
|
||||
sendtext += (k + '=' + data[k]);
|
||||
}
|
||||
//组装完整的URL
|
||||
let requestURL=extraUrl+"/"+path+encodeURI(sendtext);
|
||||
let requestURL = extraUrl + "/" + path + encodeURI(sendtext);
|
||||
// console.log("发送请求:");
|
||||
// console.log(requestURL);
|
||||
//发送请求 Get形式发送请求
|
||||
xhr.open("GET",requestURL,true);
|
||||
xhr.open("GET", requestURL, true);
|
||||
if (cc.sys.isNative) {//如果是手机就设置请求头
|
||||
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
|
||||
}
|
||||
//计时判断是否超时
|
||||
let hasRetried=false;
|
||||
let timer=setTimeout(function(){
|
||||
let hasRetried = false;
|
||||
let timer = setTimeout(function () {
|
||||
//xhr.hasRetried=true;
|
||||
hasRetried=true;
|
||||
hasRetried = true;
|
||||
xhr.abort();
|
||||
console.log("http timeOut......");
|
||||
retryFun();
|
||||
},5000);
|
||||
}, 5000);
|
||||
//重新发送请求
|
||||
let retryFun=function(){
|
||||
Utils.http_sendRequest(path,data,handler,extraUrl);
|
||||
let retryFun = function () {
|
||||
Utils.http_sendRequest(path, data, handler, extraUrl);
|
||||
}
|
||||
//监听反馈
|
||||
xhr.onreadystatechange=function(){
|
||||
xhr.onreadystatechange = function () {
|
||||
clearTimeout(timer);
|
||||
if(xhr.readyState===4&&(xhr.status >= 200 && xhr.status < 300)){
|
||||
let ret=null;
|
||||
let respText=xhr.responseText;
|
||||
try{
|
||||
ret=JSON.parse(respText);
|
||||
}catch(e){
|
||||
console.log("http error:" +e);
|
||||
ret={
|
||||
code:1,
|
||||
msg:e
|
||||
if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 300)) {
|
||||
let ret = null;
|
||||
let respText = xhr.responseText;
|
||||
try {
|
||||
ret = JSON.parse(respText);
|
||||
} catch (e) {
|
||||
console.log("http error:" + e);
|
||||
ret = {
|
||||
code: 1,
|
||||
msg: e
|
||||
}
|
||||
}
|
||||
if(handler){
|
||||
if (handler) {
|
||||
handler(ret);
|
||||
}
|
||||
handler=null;
|
||||
}else if(xhr.readyState===4){
|
||||
handler = null;
|
||||
} else if (xhr.readyState === 4) {
|
||||
// if(xhr.hasRetried){
|
||||
// return;
|
||||
// }
|
||||
if(hasRetried){
|
||||
if (hasRetried) {
|
||||
return;
|
||||
}
|
||||
console.log('other readystate =='+xhr.readyState + ', status:' + xhr.status);
|
||||
if(xhr.readyState==4&&xhr.status==0){
|
||||
console.log('other readystate ==' + xhr.readyState + ', status:' + xhr.status);
|
||||
if (xhr.readyState == 4 && xhr.status == 0) {
|
||||
handler({
|
||||
err:1,
|
||||
msg:"网络连接失败,请稍后再试"
|
||||
err: 1,
|
||||
msg: "网络连接失败,请稍后再试"
|
||||
});
|
||||
return;
|
||||
}
|
||||
setTimeout(function(){
|
||||
setTimeout(function () {
|
||||
retryFun();
|
||||
},5000);
|
||||
}else{
|
||||
}, 5000);
|
||||
} else {
|
||||
//console.log('other readystate:' + xhr.readyState + ', status:' + xhr.status);
|
||||
}
|
||||
}
|
||||
try{
|
||||
try {
|
||||
xhr.send();
|
||||
}catch(e){
|
||||
} catch (e) {
|
||||
retryFun();
|
||||
}
|
||||
return xhr;
|
||||
|
|
|
@ -644,9 +644,16 @@ var GameTool = {
|
|||
num = 1;
|
||||
}
|
||||
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) => {
|
||||
})
|
||||
const data = {
|
||||
change_reason: "商城购买道具",
|
||||
id: (propid + ""),
|
||||
num: 3
|
||||
}
|
||||
|
@ -828,6 +835,7 @@ var GameTool = {
|
|||
shopBuy(productId) {
|
||||
let coin = 0;
|
||||
let price = 0;
|
||||
let getCoin = 0;
|
||||
switch (productId) {
|
||||
case "gold_1":
|
||||
cc.fx.GameTool.changeCoin(1200);
|
||||
|
@ -866,6 +874,13 @@ var GameTool = {
|
|||
MiniGameSdk.API.showToast("充值成功,获得240000金币");
|
||||
break;
|
||||
}
|
||||
const dataTemp = {
|
||||
change_reason: "商城RMB购买金币",
|
||||
id: (1001 + ""),
|
||||
num: coin
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_get", dataTemp);
|
||||
|
||||
const buyData = {
|
||||
item_id: productId,
|
||||
item_num: coin,
|
||||
|
@ -927,14 +942,14 @@ var GameTool = {
|
|||
break;
|
||||
case "resource_get":
|
||||
eventData = {
|
||||
change_reason: "购买道具", //获得来源
|
||||
change_reason: data.change_reason, //获得来源
|
||||
change_num: data.num, //获得数量
|
||||
resource_id: data.id //道具id
|
||||
}
|
||||
break;
|
||||
case "resource_cost":
|
||||
eventData = {
|
||||
change_reason: "使用道具", //获得来源
|
||||
change_reason: data.change_reason, //获得来源
|
||||
change_num: data.num, //获得数量
|
||||
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": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 98,
|
||||
"height": 98
|
||||
"width": 94,
|
||||
"height": 90
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__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",
|
||||
"uuid": "d0d3a854-9f5c-486f-8a9e-ebd1c96b68b5",
|
||||
"uuid": "9c710aa3-45b5-43fb-b76f-8d6af41a21d5",
|
||||
"importer": "texture",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
|
@ -12,11 +12,11 @@
|
|||
"height": 2340,
|
||||
"platformSettings": {},
|
||||
"subMetas": {
|
||||
"shop_2": {
|
||||
"shop_1": {
|
||||
"ver": "1.0.6",
|
||||
"uuid": "1880f261-dd18-4e9e-9f49-b2f194d5ef8f",
|
||||
"uuid": "403aa689-5ef4-4978-978a-74b806e0760f",
|
||||
"importer": "sprite-frame",
|
||||
"rawTextureUuid": "d0d3a854-9f5c-486f-8a9e-ebd1c96b68b5",
|
||||
"rawTextureUuid": "9c710aa3-45b5-43fb-b76f-8d6af41a21d5",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"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,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "1880f261-dd18-4e9e-9f49-b2f194d5ef8f"
|
||||
"__uuid__": "403aa689-5ef4-4978-978a-74b806e0760f"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
|
@ -4002,7 +4002,7 @@
|
|||
"component": "",
|
||||
"_componentId": "48bfeZuYFZE2qmgxbW2IigB",
|
||||
"handler": "buyProduct",
|
||||
"customEventData": "gold_pack_5"
|
||||
"customEventData": "gold_5"
|
||||
},
|
||||
{
|
||||
"__type__": "de906iE/HVHpI6VO7IMvKaI",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"ver": "1.3.2",
|
||||
"uuid": "b01ef5c5-2755-455d-acb4-ba3818f5e331",
|
||||
"importer": "prefab",
|
||||
"optimizationPolicy": "AUTO",
|
||||
"optimizationPolicy": "MULTI_INSTANCE",
|
||||
"asyncLoadAssets": false,
|
||||
"readonly": false,
|
||||
"subMetas": {}
|
||||
|
|
|
@ -53,14 +53,15 @@ export default class NewClass extends cc.Component {
|
|||
}
|
||||
//打开商店界面
|
||||
openShop() {
|
||||
Utils.outTradeNo = null;
|
||||
// 商品数据数组
|
||||
const products = [
|
||||
{ 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: "" },
|
||||
{ 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);
|
||||
|
@ -86,15 +87,15 @@ export default class NewClass extends cc.Component {
|
|||
|
||||
|
||||
|
||||
startCoinAnim(target: number) {
|
||||
startCoinAnim(target: number) {
|
||||
if (this.coinAnimating && this.coinEnd === target) return;
|
||||
this.coinStart = this.currentCoin;
|
||||
this.coinEnd = target;
|
||||
this.coinAnimTime = 0;
|
||||
this.coinAnimating = true;
|
||||
}
|
||||
}
|
||||
//优化
|
||||
protected update(dt: number): void {
|
||||
protected update(dt: number): void {
|
||||
if (this.coin && this.coinAnimating) {
|
||||
this.coinAnimTime += dt;
|
||||
let t = this.coinAnimTime / this.coinAnimDuration;
|
||||
|
@ -107,7 +108,7 @@ protected update(dt: number): void {
|
|||
NumberToImage.numberToImageNodes(this.currentCoin, 30, 15, "coin_", this.coin, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
playCoinAnim(target?: number) {
|
||||
this.coinAnim.active = true;
|
||||
|
@ -126,21 +127,26 @@ protected update(dt: number): void {
|
|||
//@ts-ignore
|
||||
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();
|
||||
}
|
||||
else if(this.node.parent.getComponent("SceneManager")){
|
||||
else if (this.node.parent.getComponent("SceneManager")) {
|
||||
this.node.parent.getComponent("SceneManager").closeShop();
|
||||
}
|
||||
// this.shop.destroy();
|
||||
}
|
||||
|
||||
onShow(){
|
||||
if(cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null){
|
||||
onShow() {
|
||||
if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null) {
|
||||
console.log("有苹果订单号,开始轮训");
|
||||
Utils.getIosPayInfo((data) =>{
|
||||
console.log("获得轮训结果:",data);
|
||||
Utils.getIosPayInfo((data) => {
|
||||
console.log("获得轮训结果:", data);
|
||||
if (data.code == 1) {
|
||||
cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null;
|
||||
MiniGameSdk.API.showToast("购买金币成功");
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +210,7 @@ protected update(dt: number): void {
|
|||
//点击充值购买
|
||||
|
||||
buyProduct(event, customData) {
|
||||
if(!this.btn_Touch){
|
||||
if (!this.btn_Touch) {
|
||||
return;
|
||||
}
|
||||
this.btn_Touch = false;
|
||||
|
@ -213,7 +219,7 @@ protected update(dt: number): void {
|
|||
let price = 100;
|
||||
let count = 1;
|
||||
id = productId;
|
||||
switch(productId){
|
||||
switch (productId) {
|
||||
case "gold_1":
|
||||
price = 600;
|
||||
break;
|
||||
|
@ -233,7 +239,7 @@ protected update(dt: number): void {
|
|||
price = 64800;
|
||||
break;
|
||||
}
|
||||
console.log("获得商品id:",id,count,price);
|
||||
console.log("获得商品id:", id, count, price);
|
||||
// 判断设备系统
|
||||
let systemType = "Android";
|
||||
try {
|
||||
|
@ -247,100 +253,101 @@ protected update(dt: number): void {
|
|||
}
|
||||
|
||||
// Utils.GoKEFu();
|
||||
if(systemType == "ios"){
|
||||
if (systemType == "ios") {
|
||||
MiniGameSdk.API.showToast("IOS系统暂不支持支付");
|
||||
this.btn_Touch = true;
|
||||
// Utils.GoKEFu();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
const data = {
|
||||
outTradeNo:Utils.outTradeNo,
|
||||
price:price,
|
||||
payment_name:productId,
|
||||
payment_num:1,
|
||||
type:systemType,
|
||||
outTradeNo: Utils.outTradeNo,
|
||||
price: price,
|
||||
payment_name: productId,
|
||||
payment_num: 1,
|
||||
type: systemType,
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("init_order",data);
|
||||
cc.fx.GameTool.shushu_Track("init_order", data);
|
||||
|
||||
Utils.buyProp(id,count,price,(res)=>{
|
||||
console.log("获得充值结果",res);
|
||||
if(res == null){
|
||||
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:"网络异常,没有拉起支付",
|
||||
outTradeNo: Utils.outTradeNo,
|
||||
price: price,
|
||||
payment_name: productId,
|
||||
payment_num: 1,
|
||||
type: systemType,
|
||||
fail_reason: "网络异常,没有拉起支付",
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("payment_fail",dataFail);
|
||||
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
|
||||
return;
|
||||
}
|
||||
else{
|
||||
Utils.getPayInfo((data) =>{
|
||||
console.log("获得轮训结果:",data);
|
||||
if(data.data.pay_state == 1){
|
||||
else {
|
||||
Utils.getPayInfo((data) => {
|
||||
console.log("获得轮训结果:", data);
|
||||
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",name);
|
||||
const dataFail2 = {
|
||||
outTradeNo: Utils.outTradeNo,
|
||||
price: price,
|
||||
payment_name: productId,
|
||||
payment_num: 1,
|
||||
type: systemType,
|
||||
fail_reason: "用户取消支付",
|
||||
}
|
||||
else if(data.data.pay_state == 2){
|
||||
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){
|
||||
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,
|
||||
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)
|
||||
cc.fx.GameTool.shushu_Track("payment", dataSuccess);
|
||||
let name = "购买金币道具:" + productId;
|
||||
MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name)
|
||||
}
|
||||
else{
|
||||
else {
|
||||
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
|
||||
const dataFail4 = {
|
||||
outTradeNo:Utils.outTradeNo,
|
||||
price:price,
|
||||
payment_name:productId,
|
||||
payment_num:1,
|
||||
type:systemType,
|
||||
fail_reason:"成功付款,但是发货时请求服务器失败,充值成功未发货",
|
||||
outTradeNo: Utils.outTradeNo,
|
||||
price: price,
|
||||
payment_name: productId,
|
||||
payment_num: 1,
|
||||
type: systemType,
|
||||
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);
|
||||
this.node.parent.getComponent("JiaZai").updateCoin();
|
||||
})
|
||||
}
|
||||
else{
|
||||
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:"拉起支付后,付款时网络异常付款失败",
|
||||
outTradeNo: Utils.outTradeNo,
|
||||
price: price,
|
||||
payment_name: productId,
|
||||
payment_num: 1,
|
||||
type: systemType,
|
||||
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",
|
||||
"mainIsRemote": false,
|
||||
"optimizeHotUpdate": false,
|
||||
"md5Cache": true,
|
||||
"md5Cache": false,
|
||||
"nativeMd5Cache": true,
|
||||
"encryptJs": true,
|
||||
"xxteaKey": "07ac496c-82b0-4f",
|
||||
|
|