This commit is contained in:
COMPUTER\EDY 2026-07-10 19:17:54 +08:00
parent 414afc9d3b
commit 70865cd382
9 changed files with 749 additions and 2 deletions

View File

@ -278,6 +278,7 @@ export default class GameManager extends cc.Component {
readUserData(retryCount = 0) { readUserData(retryCount = 0) {
//@ts-ignore //@ts-ignore
if ((typeof wx !== 'undefined' && wx !== null) || (typeof tt !== 'undefined' && tt !== null)) { if ((typeof wx !== 'undefined' && wx !== null) || (typeof tt !== 'undefined' && tt !== null)) {
MiniGameSdk.API.tencent_Init();
MiniGameSdk.API.shushu_Init(); MiniGameSdk.API.shushu_Init();
this.nowTime = Date.now(); this.nowTime = Date.now();
// 最大重试次数 // 最大重试次数
@ -306,6 +307,7 @@ export default class GameManager extends cc.Component {
if (data.data.openid) { if (data.data.openid) {
cc.fx.GameConfig.GM_INFO.openid = data.data.openid; cc.fx.GameConfig.GM_INFO.openid = data.data.openid;
cc.fx.StorageMessage.setStorage("openid", cc.fx.GameConfig.GM_INFO.openid); cc.fx.StorageMessage.setStorage("openid", cc.fx.GameConfig.GM_INFO.openid);
MiniGameSdk.API.tencent_SetOpenId(cc.fx.GameConfig.GM_INFO.openid);
} }
console.log("系统信息________:", data.data.version); console.log("系统信息________:", data.data.version);
@ -835,7 +837,7 @@ export default class GameManager extends cc.Component {
cc.fx.GameTool.shushu_Track("register", data); cc.fx.GameTool.shushu_Track("register", data);
MiniGameSdk.API.shushu_SetSuperProperties(time, false); MiniGameSdk.API.shushu_SetSuperProperties(time, false);
MiniGameSdk.API.tencent_OnRegister();
} }
/** 主循环,判断是否各项加载完成进入游戏 */ /** 主循环,判断是否各项加载完成进入游戏 */
update(dt) { update(dt) {
@ -844,9 +846,98 @@ export default class GameManager extends cc.Component {
MiniGameSdk.API.shushu_Login(); MiniGameSdk.API.shushu_Login();
MiniGameSdk.API.yinli_Init(); MiniGameSdk.API.yinli_Init();
MiniGameSdk.API.yinli_Login(); MiniGameSdk.API.yinli_Login();
this.setWX();
if (this.register_time != 0) MiniGameSdk.API.shushu_userSet(this.register_time); if (this.register_time != 0) MiniGameSdk.API.shushu_userSet(this.register_time);
this.startGame(); this.startGame();
} }
} }
setWX() {
//@ts-ignore
if ((typeof wx !== 'undefined' && wx !== null) || (typeof tt !== 'undefined' && tt !== null)) { // 判断是否在微信环境
//@ts-ignore
wx.setPreferredFramesPerSecond(60);
// // 设置转发按钮点击后的回调
let iphoneArr = [
"https://mmocgame.qpic.cn/wechatgame/Lf3SBqy9XpNkakoIZygRzXqww3HTibq6VyibazqmicwibjCS3YpgqbZtkdyABm4Y1wAr/0",
"https://mmocgame.qpic.cn/wechatgame/TWKuFxnCn7ksT3KXfhCC4yOfZeD4b0hrptDSJ2DFmwz02Yc8SppcwyPAOoS1MsMr/0",
"https://mmocgame.qpic.cn/wechatgame/dibaH2x79o1wSwBDymhyzXwfcyicaDb6R5icrFIO7251T4NgxIzXRXErHvAvn50vXFA/0",
"https://mmocgame.qpic.cn/wechatgame/Pgxad80d8ws3o69OicV3DTuTkcP81upQeJ0JBNS1xib3pzYLTF1ZqGY3niciaI7ICKlL/0",
"https://mmocgame.qpic.cn/wechatgame/SfB1vrRBIHKn9ffKFt5sib62yPLE31m2rCvk6DKlEicJNVZSoryEObD6ItwsQn4xibR/0",
"https://mmocgame.qpic.cn/wechatgame/OiaWk33I6QjgWiatrb5YVUq2p0QRmQgO6rLUWxEQDZ4ib9Ny4Pr8iaHnHI6WdxibY2nPL/0",
"https://mmocgame.qpic.cn/wechatgame/CG5xBibollws251aYD4msEPWCiafrcn4Fgtic4T2wME6sWmdfAUtfibgsWoxm59VadDD/0"
]
let randomIphone = iphoneArr[Math.floor(Math.random() * iphoneArr.length)];
let img = randomIphone;
// const title =
// 构建分享参数
const shareParams = {
title: '快来一起玩这个超有趣的小游戏吧!', // 修改为默认分享标题
imageUrl: 'https://example.com/default_share_image.jpg' // 修改为默认分享图片
};
//@ts-ignore
// 仅设置分享内容,不主动触发分享
wx.onShareAppMessage(() => shareParams);
// 监听分享到朋友圈事件
//@ts-ignore
wx.onShareTimeline(() => {
return {
title: '你想玩上怎样的游戏?'
};
});
//@ts-ignore
wx.showShareMenu(() => {
return {
title: '你想玩上怎样的游戏?',
imageUrl: img,
query: ''
};
});
setTimeout(() => {
//@ts-ignore
wx.showShareMenu({
menus: ['shareAppMessage', 'shareTimeline']
})
}, 2000);
setTimeout(() => {
//@ts-ignore
wx.showShareMenu({
menus: ['shareAppMessage', 'shareTimeline']
})
}, 4000);
//@ts-ignore
wx.onAddToFavorites(() => {
console.log("收藏成功");
MiniGameSdk.API.tencent_ADD_TO_WISHLIST();
return {
title: '收藏标题',
imageUrl: '' // 图片 URL
}
})
// 设置分享到朋友圈
//@ts-ignore
// wx.updateShareMenu({
// withShareTicket: true,
// success: (data) => {
// console.log('更新分享菜单成功', data);
// },
// fail: (data) => {
// console.log('更新分享菜单失败', data);
// },
// complete: (data) => {
// console.log('更新分享菜单完成', data);
// }
// });
//@ts-ignore
}
}
} }

View File

@ -1,3 +1,4 @@
import { SDK } from './index.js';
import Utils from "../module/Pay/Utils"; import Utils from "../module/Pay/Utils";
import { getProvinceName } from "../module/Position/GetPosition"; import { getProvinceName } from "../module/Position/GetPosition";
// import { getProvinceName } from "../module/Position/ProvinceLocator"; // import { getProvinceName } from "../module/Position/ProvinceLocator";
@ -972,6 +973,7 @@ export namespace MiniGameSdk {
private static _userInfo: any = null; private static _userInfo: any = null;
private static _ta: any = null; private static _ta: any = null;
private static _ge: any = null; private static _ge: any = null;
static _tencent: any;
/** /**
* app给朋友onSuccess回调的 * app给朋友onSuccess回调的
* @param title * @param title
@ -1525,6 +1527,45 @@ export namespace MiniGameSdk {
} }
} }
//#region 腾讯平台SDK
/*
* SDK初始化以及登录
*/
static tencent_Init() {
//@ts-ignore
if ((typeof wx !== 'undefined' && wx !== null) || (typeof tt !== 'undefined' && tt !== null)) {
// console.log("开始接入腾讯平台");
//getWechatGameVersion
// 初始化SDK
try {
API._tencent = new SDK({
user_action_set_id: 1215720469,
secret_key: "26d13a9ee610ad406cb04b2b745df8a8",
appid: "wxdd145ced49158a1e",
auto_track: true,
});
} catch (error) {
console.error(error);
}
}
}
static tencent_Purchase(payAmount: number) {
if (API._tencent) API._tencent.onPurchase(payAmount);
}
static tencent_SetOpenId(openId: string) {
if (API._tencent) API._tencent.setOpenId(cc.fx.GameConfig.GM_INFO.openid);
}
static tencent_OnRegister() {
if (API._tencent) API._tencent.onRegister();
}
static tencent_ADD_TO_WISHLIST() {
if (API._tencent) API._tencent.onAddToWishlist();
}
//#region 数数平台 //#region 数数平台
/* /*
* *

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "ce5f4736-0d90-45cf-93c3-0381b24852fe",
"importer": "javascript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -309,7 +309,7 @@ export class GameConfig {
vibrateOpen: true, //震动 vibrateOpen: true, //震动
coinnum: 0, //每局的金币数 coinnum: 0, //每局的金币数
paid_user: false, //是否是付费用户 paid_user: false, //是否是付费用户
version: "1.9.94", //版本号 version: "1.9.95", //版本号
shushu_DistinctId: "", //数数访客ID shushu_DistinctId: "", //数数访客ID
shushu_AccountId: "", //数数账号ID shushu_AccountId: "", //数数账号ID
uid: "", //用户和后端唯一id uid: "", //用户和后端唯一id

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "7d484a11-c131-4dca-bde5-0e88516a3836",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 223,
"height": 194,
"platformSettings": {},
"subMetas": {
"specailBtn (1)": {
"ver": "1.0.6",
"uuid": "2aedd2d3-bc36-4031-92b4-fafca9cbfdbf",
"importer": "sprite-frame",
"rawTextureUuid": "7d484a11-c131-4dca-bde5-0e88516a3836",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 1.5,
"offsetY": 1,
"trimX": 14,
"trimY": 9,
"width": 198,
"height": 174,
"rawWidth": 223,
"rawHeight": 194,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

552
assets/libs/index.d.ts vendored Normal file
View File

@ -0,0 +1,552 @@
/**
* SDK
*/
interface SdkConfig {
/**
* ID
*/
user_action_set_id: number;
/**
* key
*/
secret_key: string;
/**
* /APPIDwx开头
*/
appid: string;
/**
* openidopenid unionid , setOpenId
*/
openid?: string;
/**
* unionidopenid unionid , setUnionId
*/
unionid?: string;
/**
* ID
*/
user_unique_id?: string;
/**
*
*/
auto_track?: boolean;
/**
*
*/
auto_attr?: boolean;
/**
*
*/
on_report_complete?: Function | undefined;
/**
* sdk内部会直接丢弃的行为
*/
on_report_fail?: Function | undefined;
}
/**
* /
*/
interface GameInfo {
/**
* 广idid
*/
ad_trace_id?: string;
/**
* ,
*/
page_url?: string;
/**
* ,
*/
page_title?: string;
/**
*
*/
component_name?: string;
/**
*
*/
source_scene?: number;
/**
*
*/
pkg_channel_id?: string;
/**
* ,
*/
framework?: string;
/**
*
*/
channel: string;
/**
*
*/
launch_options: string;
}
/**
*
*/
interface DeviceInfo {
/**
*
*/
device_brand: string;
/**
*
*/
device_model: string;
/**
* App版本
*/
wx_version: string;
/**
*
*/
wx_lib_version: string;
/**
*
*/
wx_platform: string;
/**
*
*/
os: string;
/**
*
*/
os_version: string;
/**
*
*/
benchmark_level: number;
/**
*
*/
screen_height: number;
/**
*
*/
screen_width: number;
}
interface TrackBaseInfo extends SdkConfig, DeviceInfo {
local_id: string;
sdk_name: string;
sdk_version: string;
inner_param: {
app_version: string;
app_env_version: string;
};
}
/**
*
*/
interface ActionInfo {
action_type: string;
action_param?: Record<string | number | symbol, unknown>;
is_sdk_auto_track: boolean;
session_id: string;
log_id: number;
action_id: string;
action_time: number;
revised_action_time: number;
is_retry: boolean;
retry_count: number;
ad_trace_id?: string;
page_url?: string;
page_title?: string;
component_name?: string;
source_scene?: number;
pkg_channel_id?: string;
/**
*
*/
network_type?: string;
inner_param?: Record<string | number | symbol, unknown>;
channel?: string;
}
interface LogParams {
log_type: string;
code?: number;
message?: string;
err_stack?: string;
user_action_set_id?: number;
appid?: string;
local_id?: string;
session_id?: string;
sdk_name?: string;
sdk_version?: string;
page_url?: string;
framework?: string;
device_brand?: string;
device_model?: string;
wx_version?: string;
wx_lib_version?: string;
wx_platform?: string;
os?: string;
os_version?: string;
}
interface TrackResponse {
code: number;
message: string;
actionId?: string;
}
interface QueueProps {
/**
* IDkey
*/
userActionSetId: number;
/**
*
*/
maxLength: number;
}
interface QueueManagerProps extends QueueProps {
/**
* OG事件列表
*/
ogEvents: string[];
}
interface IEvent extends ActionInfo {
inner_status?: string;
}
/**
*
*/
declare class Queue {
protected maxLength: any;
protected userActionSetId: any;
protected lostActionMaps: Record<string, number>;
private stack;
private localStorageKey;
private timeStamp;
constructor({ userActionSetId, maxLength }: QueueProps);
getItems(): IEvent[];
getStorage(): IEvent[];
/**
*
*/
reportLostNum(): void;
/**
* map
* @returns map
*/
getLostMaps(): Record<string, number>;
protected init(): void;
protected addItem(eventData: IEvent): void;
protected removeItems(actionIds: string[]): void;
protected updateForReportFail(actionIds: string[]): void;
protected updateForReporting(actionIds: string[]): void;
protected updateAllStack(stack: IEvent[]): void;
protected updateToStorage(): void;
/**
*
* @param sessionId id
*/
protected updateLostAction(sessionId: string): void;
/**
*
*/
protected setTimeStamp(): void;
}
declare class QueueManage extends Queue {
protected ogEvents: string[];
constructor({ userActionSetId, maxLength, ogEvents }: QueueManagerProps);
/**
*
* @param reportMaxLength
*/
getReportableActions(reportMaxLength?: number): IEvent[];
/**
*
* @param eventData
*/
addAction(eventData: IEvent): TrackResponse;
/**
* acition_id删除行为
* @param actionIds id列表
*/
removeActions(actionIds: string[]): void;
/**
*
* @param actionIds
*/
updateActionsForReportFail(actionIds: string[]): void;
/**
* reporting
* @param actionIds id数组
*/
updateActionsForReporting(actionIds: string[]): void;
/**
*
* @returns
*/
getReportableActionsLength(): number;
/**
*
* @param currEvent
* @param stack
*/
sortQueue(currEvent: IEvent, stack: IEvent[]): IEvent[];
/**
*
* @param currTime
* @param event
* @returns
*/
private caculateWeight;
/**
*
* @param currTime
* @param actionTime
* @returns
*/
private formatWeight;
}
interface ConfigManager {
getRealTimeActionList: () => Array<string>;
getRequestTimeout: () => number;
}
interface ActionReporterProps {
getBaseInfo: () => TrackBaseInfo;
reportLog: (param: LogParams) => void;
queueManager: QueueManage;
configManager?: ConfigManager;
onReportComplete?: Function | undefined;
onReportFail?: Function | undefined;
}
/**
*
*/
declare class ActionReporter {
private static currentRequestCount;
private static requestConcurrency;
static setRequestConcurrency(n: number): void;
private getBaseInfo;
private reportLog;
private queueManager;
private configManager;
private onReportComplete;
private onReportFail;
private cgiBatchSize;
private reportThreshold;
private reportDelay;
private triggerExecuteSend;
private inspectDelay;
private inspectTimer;
private isNeedContinueSend;
constructor(props: ActionReporterProps);
/**
* track的时候触发
*/
batchSend(): void;
/**
* flush的时候触发
*/
flushSend(): void;
/**
* batch上限则并行发送请求
*/
private executeSend;
/**
*
*/
private generateActionReportParams;
/**
*
* @param resData
* @param actionIdList
*/
private dealSuccessData;
/**
*
* @param errData
* @param actionIdList
*/
private dealFailData;
/**
* wx.request文档https://developers.weixin.qq.com/minigame/dev/api/network/request/wx.request.html
* @param param.data:接口请求参数param.actionIdList:行为id列表
* @returns
*/
private report;
/**
*
*/
private startInspectTimer;
/**
*
*/
private doTrackCallbackFn;
}
declare abstract class SdkExtCommon {
protected special_method_symbol: symbol;
/**
*
*/
onPurchase(value: number): TrackResponse;
/**
*
*/
onEnterForeground(): TrackResponse;
/**
*
*/
onEnterBackground(): TrackResponse;
/**
*
*/
onAppStart(): TrackResponse;
/**
* 退
*/
onAppQuit(): TrackResponse;
/**
*
*/
onAddToWishlist(): TrackResponse;
protected wrapTrack(action_type: ActionInfo["action_type"], action_param?: ActionInfo["action_param"]): TrackResponse;
abstract track(action_type: ActionInfo["action_type"], action_param?: ActionInfo["action_param"]): TrackResponse;
}
declare abstract class sdkExt extends SdkExtCommon {
/**
*
*/
onRegister(): TrackResponse;
/**
*
*/
onCreateRole(name?: string): TrackResponse;
/**
*
*/
onTutorialFinish(): TrackResponse;
}
declare const initializedInstanceSymbol: unique symbol;
declare class SDK extends sdkExt {
private static [initializedInstanceSymbol];
static setRequestConcurrency(n: number): void;
static setDebug(debug: boolean): void;
protected env: string;
protected sdk_version: string;
protected sdk_name: string;
protected config?: SdkConfig;
protected deviceInfo: Partial<DeviceInfo>;
protected gameInfo: Partial<GameInfo>;
protected session_id: string;
protected log_id: number;
protected queueManage?: QueueManage;
protected actionReporter?: ActionReporter;
protected openid?: string;
protected unionid?: string;
protected user_unique_id?: string;
protected inited: boolean;
protected initErrMsg: string;
protected onReportComplete?: Function | undefined;
protected onReportFail?: Function | undefined;
constructor(sdkConfig: SdkConfig);
/**
*
* @returns
*/
getInitResult(): {
inited: boolean;
initErrMsg: string;
};
/**
*
* 0: 成功
* 100: 未完成初始化或重复初始化导致初始化失败
* 101: action_type action_param
* 102: action_param xxxx
* 103: 缓存队列已满
*
*/
track(action_type: ActionInfo['action_type'], action_param?: ActionInfo['action_param']): TrackResponse;
/**
*
*/
flush(): void;
/**
* openId
* 0: 成功
* 101: openid
*/
setOpenId(openid: string): {
code: number;
message: string;
};
/**
* unionid
* 0: 成功
* 101: unionid
*/
setUnionId(unionid: string): {
code: number;
message: string;
};
/**
* user_unique_id
* @param user_unique_id
*/
setUserUniqueId(user_unique_id: string): {
code: number;
message: string;
};
/**
* strategyConfig
* callback
*/
getStrategy(strategyConfig: Record<string | number | symbol, unknown>, callback: Function): void;
protected doReportOnEnterBackground(): void;
/**
* info
*/
private getTrackBaseInfo;
/**
*
* @param actionParams
* @param is_sdk_auto_track
* @returns
*/
private createAction;
/**
* inner_param字段追加字段
* @param action
* @param key inner_param字段的key
* @param value key对应的value
*/
private addActionInnerParam;
/**
*
* @param actionType
* @returns
*/
private getChannelByActionType;
/**
*
* @param params
*/
private reportLog;
private useAutoTrack;
private getAutoProxyRemoteConfig;
/**
* openid时Storage
*/
private saveValidOpenidToStorage;
/**
*
*/
private initDirectGameConfig;
private addDirectGameStatusListener;
}
export { SDK };

View File

@ -0,0 +1,6 @@
{
"ver": "2.0.2",
"uuid": "2f27dc51-5072-4b4b-bb2b-b5955d7014c1",
"importer": "text",
"subMetas": {}
}

View File

@ -14,6 +14,8 @@
] ]
], ],
"excluded-modules": [ "excluded-modules": [
"AudioSource",
"DragonBones",
"Label Effect", "Label Effect",
"NodePool", "NodePool",
"Native Socket", "Native Socket",
@ -22,6 +24,7 @@
"PageViewIndicator", "PageViewIndicator",
"RichText", "RichText",
"StudioComponent", "StudioComponent",
"Toggle",
"TiledMap", "TiledMap",
"VideoPlayer", "VideoPlayer",
"3D", "3D",