更新数数统计 以及登录
This commit is contained in:
parent
719bcd4ba5
commit
2cc2fd3cf3
37
.gitignore
vendored
37
.gitignore
vendored
|
|
@ -4,4 +4,39 @@
|
|||
/packages/
|
||||
/build-templates/
|
||||
/build/
|
||||
/图片资源/
|
||||
|
||||
# Cocos Creator 资源元数据文件
|
||||
*.meta
|
||||
|
||||
# 操作系统生成的文件
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# 日志文件
|
||||
*.log
|
||||
logs/
|
||||
|
||||
# 运行时数据
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# 依赖目录
|
||||
node_modules/
|
||||
|
||||
# IDE 文件
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# 编译输出
|
||||
dist/
|
||||
bin/
|
||||
*.exe
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# 其他资源目录(根据你的项目需要调整)
|
||||
/图片资源/
|
||||
|
|
@ -60,7 +60,6 @@ export default class GameManager extends cc.Component {
|
|||
this.getSetting();
|
||||
this.readUserData();
|
||||
this.getShareInfo();
|
||||
this.checkDailyQuests();
|
||||
}, 100);
|
||||
|
||||
|
||||
|
|
@ -86,10 +85,7 @@ export default class GameManager extends cc.Component {
|
|||
}
|
||||
|
||||
}
|
||||
checkDailyQuests() {
|
||||
cc.fx.GameTool.getDailyQuestsInfo((data) => {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
setTimeout(() => {
|
||||
|
|
@ -180,156 +176,129 @@ export default class GameManager extends cc.Component {
|
|||
//#region 微信登录,以及读取用户信息
|
||||
/** 微信登录,以及读取用户信息 */
|
||||
readUserData(retryCount = 0) {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
MiniGameSdk.API.shushu_Init();
|
||||
this.nowTime = Date.now();
|
||||
// 最大重试次数
|
||||
const MAX_RETRIES = 30;
|
||||
// 延迟时间数组,按照 1 秒 3 次、2 秒 5 次、5 秒 6 次、15 秒 5 次的规则生成
|
||||
const delays = [
|
||||
...Array(3).fill(2000),
|
||||
...Array(5).fill(3000),
|
||||
...Array(6).fill(5000),
|
||||
...Array(5).fill(15000)
|
||||
];
|
||||
//cc.fx.GameConfig.GM_INFO.shushu_DistinctId
|
||||
const attemptUserInfo = () => {
|
||||
Utils.getUserInfo((data) => {
|
||||
if (data.code == 1) { // 假设返回数据中有 success 字段表示成功
|
||||
console.log("登錄", data);
|
||||
if (data.data.openid) {
|
||||
cc.fx.GameConfig.GM_INFO.openid = data.data.openid;
|
||||
cc.fx.StorageMessage.setStorage("openid", cc.fx.GameConfig.GM_INFO.openid);
|
||||
}
|
||||
if (data.data._id) {
|
||||
cc.fx.GameConfig.GM_INFO.uid = data.data._id;
|
||||
cc.fx.StorageMessage.setStorage("uid", data.data._id);
|
||||
}
|
||||
if (data.data.onlyId) {
|
||||
cc.fx.GameConfig.GM_INFO.userId = data.data.onlyId;
|
||||
}
|
||||
if (data.data.outTradeNo.length > 0) {
|
||||
cc.fx.GameConfig.GM_INFO.allOutTradeNo = [];
|
||||
cc.fx.GameConfig.GM_INFO.allOutTradeNo = data.data.outTradeNo;
|
||||
}
|
||||
if (data.data.shareLv) {
|
||||
if (data.data.shareLv.length > 0) {
|
||||
cc.fx.GameConfig.GM_INFO.helpLevel = data.data.shareLv[0].lv;
|
||||
}
|
||||
}
|
||||
if (data.data.username) {
|
||||
cc.fx.GameConfig.GM_INFO.username = data.data.username;
|
||||
}
|
||||
if (data.data.useravatar) {
|
||||
cc.fx.GameConfig.GM_INFO.useravatarIcon = data.data.useravatar;
|
||||
if (cc.fx.GameConfig.GM_INFO.useravatarIcon.length < 10)
|
||||
cc.fx.GameConfig.GM_INFO.useravatarIcon = "icon_" + cc.fx.GameConfig.GM_INFO.useravatarIcon
|
||||
}
|
||||
if (data.data.useravatarIcon) {
|
||||
cc.fx.GameConfig.GM_INFO.useravaterkuang = data.data.useravatarIcon;
|
||||
cc.fx.GameConfig.GM_INFO.useravaterkuang = "kuang_" + (parseInt(cc.fx.GameConfig.GM_INFO.useravaterkuang) + 1);
|
||||
}
|
||||
|
||||
if (data.data.task) {
|
||||
let task = JSON.parse(data.data.task);
|
||||
cc.fx.GameConfig.GM_INFO.tasks.levelPass = task["levelPass"];
|
||||
cc.fx.GameConfig.GM_INFO.tasks.share = task["share"];
|
||||
cc.fx.GameConfig.GM_INFO.tasks.useEnergy = task["useEnergy"];
|
||||
cc.fx.GameConfig.GM_INFO.tasks.useProp = task["useProp"];
|
||||
}
|
||||
//如果有连胜记录,就赋值
|
||||
if (data.data.winStreak) {
|
||||
console.log("从服务器得到连胜", data.data.winStreak);
|
||||
cc.fx.GameConfig.GM_INFO.winStreak = parseInt(data.data.winStreak);
|
||||
let winState = cc.fx.StorageMessage.getStorage("winState");
|
||||
console.log("本地连胜状态", winState);
|
||||
if ((winState == null || winState == undefined) && winState != false) {
|
||||
console.log("没有缓存进入这里");
|
||||
cc.fx.GameConfig.GM_INFO.winState = false;
|
||||
if (cc.fx.GameConfig.GM_INFO.winStreak >= 10) {
|
||||
cc.fx.GameConfig.GM_INFO.winState = true;
|
||||
}
|
||||
cc.fx.StorageMessage.setStorage("winState", cc.fx.GameConfig.GM_INFO.winState);
|
||||
}
|
||||
else {
|
||||
cc.fx.GameConfig.GM_INFO.winState = winState;
|
||||
console.log("连胜状态:", cc.fx.GameConfig.GM_INFO.winState);
|
||||
if (winState == false) {
|
||||
if (cc.fx.GameConfig.GM_INFO.winStreak >= 10) {
|
||||
cc.fx.GameConfig.GM_INFO.winStreak = 0;
|
||||
Utils.setWinStreak((data) => {
|
||||
if (data.code == 1) {
|
||||
console.log("连胜状态杀端清零成功");
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
cc.fx.StorageMessage.setStorage("winStreak", cc.fx.GameConfig.GM_INFO.winStreak);
|
||||
}
|
||||
else {
|
||||
let winStreak = cc.fx.StorageMessage.getStorage("winStreak");
|
||||
if (winStreak == undefined || winStreak == "" || winStreak == null) {
|
||||
cc.fx.GameConfig.GM_INFO.winStreak = 0;
|
||||
cc.fx.StorageMessage.setStorage("winStreak", cc.fx.GameConfig.GM_INFO.winStreak);
|
||||
}
|
||||
else {
|
||||
cc.fx.GameConfig.GM_INFO.winStreak = winStreak;
|
||||
}
|
||||
console.log("调用连胜上传");
|
||||
Utils.setWinStreak((data) => {
|
||||
if (data.code == 1) {
|
||||
console.log("设置连胜成功");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.setUserPower(data);
|
||||
this.setmonth(data);
|
||||
this.setRevive(data);
|
||||
let levelInfo = cc.fx.StorageMessage.getStorage("level");
|
||||
//如果本地缓存没有关卡信息,默认为服务器信息为主
|
||||
if (levelInfo == undefined || levelInfo == "" || levelInfo == null) {
|
||||
this.getUserDataToServer(data.data);
|
||||
// this.oldReadData(retryCount);
|
||||
}
|
||||
//新的读取数据设置方法,以本地为主
|
||||
else {
|
||||
this.getUserDataToLocal(data.data);
|
||||
// this.newReadData();
|
||||
}
|
||||
|
||||
cc.fx.GameTool.getHealth((data) => {
|
||||
this.load5 = true;
|
||||
});
|
||||
this.load6 = true;
|
||||
}
|
||||
else {
|
||||
if (retryCount < MAX_RETRIES && retryCount < delays.length) {
|
||||
const delay = delays[retryCount];
|
||||
console.error(`获取用户信息失败,第 ${retryCount + 1} 次重试,将在 ${delay / 1000} 秒后重试`);
|
||||
setTimeout(() => {
|
||||
retryCount++;
|
||||
attemptUserInfo();
|
||||
}, delay);
|
||||
} else {
|
||||
console.error('获取用户信息失败,达到最大重试次数,退出游戏');
|
||||
// 退出游戏
|
||||
cc.game.end();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
attemptUserInfo();
|
||||
this.load3 = true;
|
||||
this.load4 = true;
|
||||
this.load5 = true;
|
||||
this.load6 = true;
|
||||
let levelInfo = cc.fx.StorageMessage.getStorage("level");
|
||||
//如果本地缓存没有关卡信息,默认为服务器信息为主
|
||||
if (levelInfo == undefined || levelInfo == "" || levelInfo == null) {
|
||||
// this.getUserDataToServer(data.data);
|
||||
const timestamp = Date.now();
|
||||
cc.fx.GameConfig.GM_INFO.level = 0;
|
||||
let levelInfo = { "level": cc.fx.GameConfig.GM_INFO.level, "timestamp": timestamp };
|
||||
cc.fx.StorageMessage.setStorage("level", levelInfo);
|
||||
cc.fx.GameConfig.GM_INFO.first = true;
|
||||
// this.oldReadData(retryCount);
|
||||
}
|
||||
else {
|
||||
this.load3 = true;
|
||||
this.load4 = true;
|
||||
this.load5 = true;
|
||||
this.load6 = true;
|
||||
cc.fx.GameTool.getHealth(null);
|
||||
cc.fx.GameConfig.GM_INFO.level = levelInfo;
|
||||
}
|
||||
cc.fx.GameTool.getHealth(null);
|
||||
//@ts-ignore
|
||||
// if (typeof wx !== 'undefined' && wx !== null) {
|
||||
// MiniGameSdk.API.shushu_Init();
|
||||
// this.nowTime = Date.now();
|
||||
// // 最大重试次数
|
||||
// const MAX_RETRIES = 30;
|
||||
// // 延迟时间数组,按照 1 秒 3 次、2 秒 5 次、5 秒 6 次、15 秒 5 次的规则生成
|
||||
// const delays = [
|
||||
// ...Array(3).fill(2000),
|
||||
// ...Array(5).fill(3000),
|
||||
// ...Array(6).fill(5000),
|
||||
// ...Array(5).fill(15000)
|
||||
// ];
|
||||
// //cc.fx.GameConfig.GM_INFO.shushu_DistinctId
|
||||
// const attemptUserInfo = () => {
|
||||
// Utils.getUserInfo((data) => {
|
||||
// if (data.code == 1) { // 假设返回数据中有 success 字段表示成功
|
||||
// console.log("登錄", data);
|
||||
// if (data.data.openid) {
|
||||
// cc.fx.GameConfig.GM_INFO.openid = data.data.openid;
|
||||
// cc.fx.StorageMessage.setStorage("openid", cc.fx.GameConfig.GM_INFO.openid);
|
||||
// }
|
||||
// if (data.data._id) {
|
||||
// cc.fx.GameConfig.GM_INFO.uid = data.data._id;
|
||||
// cc.fx.StorageMessage.setStorage("uid", data.data._id);
|
||||
// }
|
||||
// if (data.data.onlyId) {
|
||||
// cc.fx.GameConfig.GM_INFO.userId = data.data.onlyId;
|
||||
// }
|
||||
// if (data.data.outTradeNo.length > 0) {
|
||||
// cc.fx.GameConfig.GM_INFO.allOutTradeNo = [];
|
||||
// cc.fx.GameConfig.GM_INFO.allOutTradeNo = data.data.outTradeNo;
|
||||
// }
|
||||
// if (data.data.shareLv) {
|
||||
// if (data.data.shareLv.length > 0) {
|
||||
// cc.fx.GameConfig.GM_INFO.helpLevel = data.data.shareLv[0].lv;
|
||||
// }
|
||||
// }
|
||||
// if (data.data.username) {
|
||||
// cc.fx.GameConfig.GM_INFO.username = data.data.username;
|
||||
// }
|
||||
// if (data.data.useravatar) {
|
||||
// cc.fx.GameConfig.GM_INFO.useravatarIcon = data.data.useravatar;
|
||||
// if (cc.fx.GameConfig.GM_INFO.useravatarIcon.length < 10)
|
||||
// cc.fx.GameConfig.GM_INFO.useravatarIcon = "icon_" + cc.fx.GameConfig.GM_INFO.useravatarIcon
|
||||
// }
|
||||
// if (data.data.useravatarIcon) {
|
||||
// cc.fx.GameConfig.GM_INFO.useravaterkuang = data.data.useravatarIcon;
|
||||
// cc.fx.GameConfig.GM_INFO.useravaterkuang = "kuang_" + (parseInt(cc.fx.GameConfig.GM_INFO.useravaterkuang) + 1);
|
||||
// }
|
||||
|
||||
// if (data.data.task) {
|
||||
// let task = JSON.parse(data.data.task);
|
||||
// cc.fx.GameConfig.GM_INFO.tasks.levelPass = task["levelPass"];
|
||||
// cc.fx.GameConfig.GM_INFO.tasks.share = task["share"];
|
||||
// cc.fx.GameConfig.GM_INFO.tasks.useEnergy = task["useEnergy"];
|
||||
// cc.fx.GameConfig.GM_INFO.tasks.useProp = task["useProp"];
|
||||
// }
|
||||
|
||||
// this.setUserPower(data);
|
||||
// this.setmonth(data);
|
||||
// this.setRevive(data);
|
||||
// let levelInfo = cc.fx.StorageMessage.getStorage("level");
|
||||
// //如果本地缓存没有关卡信息,默认为服务器信息为主
|
||||
// if (levelInfo == undefined || levelInfo == "" || levelInfo == null) {
|
||||
// this.getUserDataToServer(data.data);
|
||||
// // this.oldReadData(retryCount);
|
||||
// }
|
||||
// //新的读取数据设置方法,以本地为主
|
||||
// else {
|
||||
// this.getUserDataToLocal(data.data);
|
||||
// // this.newReadData();
|
||||
// }
|
||||
|
||||
// cc.fx.GameTool.getHealth((data) => {
|
||||
// this.load5 = true;
|
||||
// });
|
||||
// this.load6 = true;
|
||||
// }
|
||||
// else {
|
||||
// if (retryCount < MAX_RETRIES && retryCount < delays.length) {
|
||||
// const delay = delays[retryCount];
|
||||
// console.error(`获取用户信息失败,第 ${retryCount + 1} 次重试,将在 ${delay / 1000} 秒后重试`);
|
||||
// setTimeout(() => {
|
||||
// retryCount++;
|
||||
// attemptUserInfo();
|
||||
// }, delay);
|
||||
// } else {
|
||||
// console.error('获取用户信息失败,达到最大重试次数,退出游戏');
|
||||
// // 退出游戏
|
||||
// cc.game.end();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// };
|
||||
// attemptUserInfo();
|
||||
// }
|
||||
// else {
|
||||
// this.load3 = true;
|
||||
// this.load4 = true;
|
||||
// this.load5 = true;
|
||||
// this.load6 = true;
|
||||
// cc.fx.GameTool.getHealth(null);
|
||||
// }
|
||||
// 存储用户数据
|
||||
}
|
||||
//#region 读取音乐配置
|
||||
|
|
@ -439,7 +408,8 @@ export default class GameManager extends cc.Component {
|
|||
cc.fx.GameConfig.GM_INFO.first = true;
|
||||
if (data.register_time) {
|
||||
const time = data.register_time;
|
||||
MiniGameSdk.API.shushu_userSet(time);
|
||||
let share = cc.fx.GameTool.isFromShareByScene();
|
||||
MiniGameSdk.API.shushu_userSet(time, share);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -610,6 +580,11 @@ export default class GameManager extends cc.Component {
|
|||
MiniGameSdk.API.shushu_Login();
|
||||
MiniGameSdk.API.yinli_Init();
|
||||
MiniGameSdk.API.yinli_Login();
|
||||
if (cc.fx.GameConfig.GM_INFO.first == true) {
|
||||
const time = Date.now();
|
||||
let share = cc.fx.GameTool.isFromShareByScene();
|
||||
MiniGameSdk.API.shushu_userSet(time, share);
|
||||
}
|
||||
this.startGame();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ export default class JiaZai extends cc.Component {
|
|||
}
|
||||
//监听后台
|
||||
onGames() {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined') {
|
||||
this.onShowListener = null;
|
||||
this.onHideListener = null;
|
||||
|
|
@ -578,6 +579,7 @@ export default class JiaZai extends cc.Component {
|
|||
}
|
||||
|
||||
uploadToCloud(level: number) {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined') {
|
||||
//@ts-ignore
|
||||
wx.setUserCloudStorage({
|
||||
|
|
@ -655,7 +657,7 @@ export default class JiaZai extends cc.Component {
|
|||
}, 500);
|
||||
return;
|
||||
}
|
||||
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined') {
|
||||
//@ts-ignore
|
||||
wx.offShow(this.onShowListener);
|
||||
|
|
@ -985,7 +987,7 @@ export default class JiaZai extends cc.Component {
|
|||
}
|
||||
// console.log("注册时间:", time);
|
||||
cc.fx.GameTool.shushu_Track("register", data);
|
||||
MiniGameSdk.API.shushu_SetSuperProperties(time, false);
|
||||
MiniGameSdk.API.shushu_SetSuperProperties(time);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1800,12 +1800,6 @@ export default class MapConroler extends cc.Component {
|
|||
// console.log("即将上报成功________________________:",this.add_Time);
|
||||
// console.log("成功消除一个",this.add_Time);
|
||||
//// cc.fx.GameTool.changeCoin(40 * cc.fx.GameConfig.GM_INFO.doubleCoin);
|
||||
const data = {
|
||||
change_reason: "level",
|
||||
id: (1001 + ""),
|
||||
num: 40 * cc.fx.GameConfig.GM_INFO.doubleCoin
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_get", data);
|
||||
let overTime = Date.now();
|
||||
this.count_Time = overTime - this.count_Time;
|
||||
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
|
||||
|
|
@ -1998,6 +1992,18 @@ export default class MapConroler extends cc.Component {
|
|||
runRewive(data) {
|
||||
console.log("复活回调函数内", data);
|
||||
this.isreview = true;
|
||||
const dataTemp = {
|
||||
change_reason: "share",
|
||||
id: "2000",
|
||||
num: 1
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_get", dataTemp);
|
||||
const dataTemp2 = {
|
||||
change_reason: "游戏内复活消耗金币",
|
||||
id: "2000",
|
||||
num: -1
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_cost", dataTemp2);
|
||||
//// cc.fx.GameTool.changeCoin(data.coin);
|
||||
// const dataTemp = {
|
||||
// change_reason: "游戏内复活消耗金币",
|
||||
|
|
@ -2151,6 +2157,7 @@ export default class MapConroler extends cc.Component {
|
|||
|
||||
|
||||
uploadToCloud(level: number) {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined') {
|
||||
//@ts-ignore
|
||||
wx.setUserCloudStorage({
|
||||
|
|
|
|||
|
|
@ -716,6 +716,7 @@ export namespace MiniGameSdk {
|
|||
static shareAppToFriends() {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) { // 判断是否在微信环境
|
||||
//@ts-ignore
|
||||
wx.setPreferredFramesPerSecond(60);
|
||||
// // 设置转发按钮点击后的回调
|
||||
|
||||
|
|
@ -736,6 +737,7 @@ export namespace MiniGameSdk {
|
|||
title: '快来一起玩这个超有趣的小游戏吧!', // 修改为默认分享标题
|
||||
imageUrl: img // 修改为默认分享图片
|
||||
};
|
||||
//@ts-ignore
|
||||
// 仅设置分享内容,不主动触发分享
|
||||
wx.onShareAppMessage(() => shareParams);
|
||||
|
||||
|
|
@ -747,7 +749,7 @@ export namespace MiniGameSdk {
|
|||
title: '你想玩上怎样的游戏?'
|
||||
};
|
||||
});
|
||||
|
||||
//@ts-ignore
|
||||
wx.showShareMenu(() => {
|
||||
return {
|
||||
title: '你想玩上怎样的游戏?',
|
||||
|
|
@ -757,12 +759,14 @@ export namespace MiniGameSdk {
|
|||
});
|
||||
|
||||
setTimeout(() => {
|
||||
//@ts-ignore
|
||||
wx.showShareMenu({
|
||||
menus: ['shareAppMessage', 'shareTimeline']
|
||||
})
|
||||
}, 2000);
|
||||
|
||||
setTimeout(() => {
|
||||
//@ts-ignore
|
||||
wx.showShareMenu({
|
||||
menus: ['shareAppMessage', 'shareTimeline']
|
||||
})
|
||||
|
|
@ -1227,6 +1231,7 @@ export namespace MiniGameSdk {
|
|||
*/
|
||||
|
||||
static shushu_Init() {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
// console.log("开始接入数数平台");
|
||||
//getWechatGameVersion
|
||||
|
|
@ -1272,25 +1277,31 @@ export namespace MiniGameSdk {
|
|||
}
|
||||
|
||||
static shushu_Login() {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
// console.log("数数登录时,获取到的openId:", cc.fx.GameConfig.GM_INFO.openid);
|
||||
API._ta.login(cc.fx.GameConfig.GM_INFO.openid);
|
||||
cc.fx.GameConfig.GM_INFO.shushu_AccountId = cc.fx.GameConfig.GM_INFO.openid;
|
||||
const result = "success";
|
||||
API.shushu_Track("login", result);
|
||||
API.shushu_SetSuperProperties(null, null);
|
||||
API.shushu_SetSuperProperties(null);
|
||||
}
|
||||
}
|
||||
|
||||
static shushu_userSet(time) {
|
||||
static shushu_userSet(time, share) {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
// console.log("设置用户注册属性");
|
||||
API._ta.userSet({ register_time: time });
|
||||
API._ta.userSet({ uid: cc.fx.GameConfig.GM_INFO.uid.toString() });
|
||||
if (share) {
|
||||
API._ta.userSetOnce({ acq_type: "share" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static updateCoinAndLevel() {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
// console.log("上传金币和关卡信息给数数")
|
||||
API._ta.userSet({ current_level: (cc.fx.GameConfig.GM_INFO.level + 1) });
|
||||
|
|
@ -1303,13 +1314,13 @@ export namespace MiniGameSdk {
|
|||
* 数数平台设置动态公共属性
|
||||
*/
|
||||
|
||||
static shushu_SetSuperProperties(register_time, pay_user) {
|
||||
static shushu_SetSuperProperties(register_time) {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null && API._ta) {
|
||||
var superProperties = {};
|
||||
superProperties = {
|
||||
current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number
|
||||
current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值
|
||||
//// tmp_coin: cc.fx.GameConfig.GM_INFO.coin,//当前金币
|
||||
version: cc.fx.GameConfig.GM_INFO.version.toString(),//当前版本号
|
||||
user_id: cc.fx.GameConfig.GM_INFO.uid.toString() //用户id
|
||||
};
|
||||
|
|
@ -1318,24 +1329,11 @@ export namespace MiniGameSdk {
|
|||
superProperties = {
|
||||
current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number
|
||||
current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值
|
||||
//// tmp_coin: cc.fx.GameConfig.GM_INFO.coin,//当前金币
|
||||
version: cc.fx.GameConfig.GM_INFO.version.toString(),
|
||||
register_time: register_time,
|
||||
user_id: cc.fx.GameConfig.GM_INFO.uid.toString(), //用户id
|
||||
pay_user: pay_user
|
||||
};
|
||||
}
|
||||
if (pay_user != null && pay_user != false) {
|
||||
// console.log("设置用户公共属性支付:————————————", pay_user);
|
||||
superProperties = {
|
||||
current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number
|
||||
current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值
|
||||
//// tmp_coin: cc.fx.GameConfig.GM_INFO.coin,//当前金币
|
||||
version: cc.fx.GameConfig.GM_INFO.version.toString(),
|
||||
user_id: cc.fx.GameConfig.GM_INFO.uid.toString(), //用户id
|
||||
pay_user: pay_user
|
||||
}
|
||||
}
|
||||
// @ts-ignore
|
||||
// console.log("设置公共属性时:————————————", superProperties.uid);
|
||||
API._ta.setSuperProperties(superProperties);//设置公共事件属性
|
||||
|
|
@ -1344,6 +1342,7 @@ export namespace MiniGameSdk {
|
|||
}
|
||||
|
||||
static getWechatGameVersion(): string | null {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
// @ts-ignore
|
||||
const accountInfo = wx.getAccountInfoSync();
|
||||
|
|
@ -1356,6 +1355,7 @@ export namespace MiniGameSdk {
|
|||
*/
|
||||
|
||||
static shushu_Track(name, data, callback?: (success: boolean, error?: any) => void) {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
if (API._ta) {
|
||||
// 假设 track 方法返回一个 Promise
|
||||
|
|
@ -1372,6 +1372,7 @@ export namespace MiniGameSdk {
|
|||
* @returns distinct_id 或 null
|
||||
*/
|
||||
static getShushuDistinctId(): string | null {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null && API._ta) {
|
||||
// 假设 SDK 提供 getDistinctId 方法
|
||||
if (API._ta.getDistinctId) {
|
||||
|
|
@ -1386,6 +1387,7 @@ export namespace MiniGameSdk {
|
|||
* @returns account_id 或 null
|
||||
*/
|
||||
static getShushuAccountId(): string | null {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null && API._ta) {
|
||||
// 假设 SDK 提供 getAccountId 方法
|
||||
if (API._ta.getAccountId) {
|
||||
|
|
@ -1397,6 +1399,7 @@ export namespace MiniGameSdk {
|
|||
|
||||
//#region 引力平台-
|
||||
static yinli_Init() {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
const configYinli = {
|
||||
accessToken: "aGws0nluotbm6Jjiv9WMuzOAbXLydxwe", // 项目通行证,在:网站后台-->设置-->应用列表中找到Access Token列 复制(首次使用可能需要先新增应用)
|
||||
|
|
@ -1441,6 +1444,7 @@ export namespace MiniGameSdk {
|
|||
}
|
||||
|
||||
static yinli_Register() {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
API._ge.registerEvent();
|
||||
}
|
||||
|
|
@ -1455,6 +1459,7 @@ export namespace MiniGameSdk {
|
|||
* @param payMethod 付费方式 例如:支付宝、微信、银联等
|
||||
*/
|
||||
static yinli_Pay(payAmount, orderId, payReason) {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
let version = cc.fx.GameTool.getWechatGameVersion();
|
||||
if (version == "开发版" || version == "体验版") {
|
||||
|
|
@ -1468,6 +1473,7 @@ export namespace MiniGameSdk {
|
|||
}
|
||||
|
||||
static yinli_Login() {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
API._ge.loginEvent();
|
||||
}
|
||||
|
|
@ -1475,6 +1481,7 @@ export namespace MiniGameSdk {
|
|||
|
||||
//分享
|
||||
static shareGame() {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
let helpLevel = cc.fx.GameConfig.GM_INFO.level + 1;
|
||||
if (helpLevel > 373) {
|
||||
|
|
@ -1519,6 +1526,7 @@ export namespace MiniGameSdk {
|
|||
|
||||
//上传好友排行数据
|
||||
static setNewCloudlevel() {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
console.log("往子域上传分数");
|
||||
let newKVData = { key: 'level', value: String(cc.fx.GameConfig.GM_INFO.level) }
|
||||
|
|
|
|||
|
|
@ -386,7 +386,7 @@ var GameTool = {
|
|||
count: cc.fx.GameConfig.GM_INFO.winStreak
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("hammer_frenzy", data2);
|
||||
MiniGameSdk.API.shushu_SetSuperProperties(null, null);
|
||||
MiniGameSdk.API.shushu_SetSuperProperties(null);
|
||||
}
|
||||
|
||||
cc.fx.GameTool.setUserLevel((data) => {
|
||||
|
|
@ -498,7 +498,7 @@ var GameTool = {
|
|||
"health": cc.fx.GameConfig.GM_INFO.hp,
|
||||
"timestamp": res.data.timestamp
|
||||
}
|
||||
MiniGameSdk.API.shushu_SetSuperProperties(null, null);
|
||||
MiniGameSdk.API.shushu_SetSuperProperties(null);
|
||||
cc.fx.StorageMessage.setStorage("health", healthInfo);
|
||||
}
|
||||
else {
|
||||
|
|
@ -633,7 +633,7 @@ var GameTool = {
|
|||
}
|
||||
|
||||
cc.fx.StorageMessage.setStorage("health", healthInfo);
|
||||
MiniGameSdk.API.shushu_SetSuperProperties(null, null);
|
||||
MiniGameSdk.API.shushu_SetSuperProperties(null);
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
//laf云函数
|
||||
|
|
@ -672,12 +672,13 @@ var GameTool = {
|
|||
}
|
||||
//console.log("_____________新版本", num);
|
||||
// cc.fx.GameTool.changeCoin(-cost);
|
||||
const dataTemp = {
|
||||
change_reason: "商城购买道具消耗",
|
||||
id: (1001 + ""),
|
||||
num: -cost
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_cost", dataTemp);
|
||||
|
||||
// const dataTemp = {
|
||||
// change_reason: "商城购买道具消耗",
|
||||
// id: (1001 + ""),
|
||||
// num: -cost
|
||||
// }
|
||||
// cc.fx.GameTool.shushu_Track("resource_cost", dataTemp);
|
||||
|
||||
let _id = "";
|
||||
let propNumber = 0;
|
||||
|
|
@ -702,7 +703,7 @@ var GameTool = {
|
|||
})
|
||||
|
||||
const data = {
|
||||
change_reason: "game",
|
||||
change_reason: "share",
|
||||
id: propid,
|
||||
num: num,
|
||||
compensate: false
|
||||
|
|
@ -867,7 +868,6 @@ var GameTool = {
|
|||
case "enter_stage":
|
||||
eventData = {
|
||||
stage_id: (cc.fx.GameConfig.GM_INFO.level + 1),
|
||||
is_frenzy: data.is_frenzy,
|
||||
}
|
||||
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
|
||||
eventData = {
|
||||
|
|
@ -880,7 +880,6 @@ var GameTool = {
|
|||
stage_id: (cc.fx.GameConfig.GM_INFO.level + 1),
|
||||
stage_duration: data.time,
|
||||
added_time: data.add_Time,
|
||||
is_frenzy: data.is_frenzy,
|
||||
result: data.result
|
||||
}
|
||||
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
|
||||
|
|
@ -1041,21 +1040,21 @@ var GameTool = {
|
|||
cc.fx.GameTool.setUserProp(0, num, (data) => {
|
||||
})
|
||||
const data1 = {
|
||||
change_reason: "shop",
|
||||
change_reason: "share",
|
||||
id: 2001,
|
||||
num: propData.freeze,
|
||||
compensate: compensate
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_get", data1);
|
||||
const data2 = {
|
||||
change_reason: "shop",
|
||||
change_reason: "share",
|
||||
id: 2002,
|
||||
num: propData.hammer,
|
||||
compensate: compensate
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_get", data2);
|
||||
const data3 = {
|
||||
change_reason: "shop",
|
||||
change_reason: "share",
|
||||
id: 2003,
|
||||
num: propData.magic_wand,
|
||||
compensate: compensate
|
||||
|
|
@ -1188,6 +1187,7 @@ var GameTool = {
|
|||
},
|
||||
|
||||
getUserAvatar(callBack: Function) {
|
||||
//@ts-ignore
|
||||
if (typeof wx === 'undefined') {
|
||||
// this.showRanks(); // 非微信环境直接显示
|
||||
return;
|
||||
|
|
@ -1321,6 +1321,29 @@ var GameTool = {
|
|||
|
||||
}, 3000);
|
||||
}
|
||||
},
|
||||
|
||||
isFromShareByScene(): boolean {
|
||||
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
|
||||
try {
|
||||
//@ts-ignore
|
||||
const launchOptions = wx.getLaunchOptionsSync();
|
||||
const scene = launchOptions.scene;
|
||||
// 常见的分享场景值:
|
||||
// 1007: 单人聊天会话中的小程序消息卡片
|
||||
// 1008: 群聊会话中的小程序消息卡片
|
||||
// 1011: 扫描二维码
|
||||
// 1012: 长按图片识别二维码
|
||||
// 1013: 手机相册选取二维码
|
||||
// 1044: 小程序profile页
|
||||
const shareScenes = [1007, 1008, 1011, 1012, 1013];
|
||||
return shareScenes.includes(scene);
|
||||
|
||||
} catch (error) {
|
||||
console.error('获取场景值失败:', error);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -495,36 +495,7 @@ export default class DailyQuests extends cc.Component {
|
|||
|
||||
getShopProp(propData) {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
const num = 0;
|
||||
//console.log("_________道具增加的数量为:", num);
|
||||
cc.fx.GameConfig.GM_INFO.freezeAmount += propData.freeze;
|
||||
cc.fx.GameConfig.GM_INFO.hammerAmount += propData.hammer;
|
||||
cc.fx.GameConfig.GM_INFO.magicAmount += propData.magic_wand;
|
||||
cc.fx.GameTool.setUserProp(0, num, (data) => {
|
||||
})
|
||||
const data1 = {
|
||||
change_reason: "quests",
|
||||
id: 2001,
|
||||
num: propData.freeze,
|
||||
compensate: false
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_get", data1);
|
||||
const data2 = {
|
||||
change_reason: "quests",
|
||||
id: 2002,
|
||||
num: propData.hammer,
|
||||
compensate: false
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_get", data2);
|
||||
const data3 = {
|
||||
change_reason: "quests",
|
||||
id: 2003,
|
||||
num: propData.magic_wand,
|
||||
compensate: false
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_get", data3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"ver": "1.1.3",
|
||||
"uuid": "f799ffac-758e-4e90-8535-3fbd6ac46969",
|
||||
"importer": "folder",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user