diff --git a/sdk/Analytics.ts b/sdk/Analytics.ts index b83c589..7292573 100644 --- a/sdk/Analytics.ts +++ b/sdk/Analytics.ts @@ -102,6 +102,32 @@ export class Analytics { return WXSDK.stat.consume(id, typ, nums, gsne) } + /** + * 游戏行为数据提交(玩一玩) + * @param action_code 用户在游戏中的行动编码 + * @param action_finish_channel 用户完成行动的渠道 + * @param action_finish_date 用户完成时间 + * @param status 上报的结果 0成功 其他失败 + */ + AlipayGameCenter(action_code:string,action_finish_channel:string,action_finish_date:string,status:string) { + WXSDK.stat.AlipayGameCenter(action_code,action_finish_channel,action_finish_date,status); + + } + + /** + * 支付行为上报 + * @param orderid 订单号,游戏方订单号 + * @param goodid 游戏方商品ID + * @param goodname 游戏方商品名字 + * @param money 支付金额,单位分 + * @param paytype 支付方式,1客服消息支付 3米大师支付 4小程序支付 6二维码支付 7字节钱包 8QQ钱包 9华为钱包 10支付宝小游戏支付 11支付宝小程序(跳转到另外一个小程序支付)13美团支付 + * @param paystatus 1支付成功 2支付失败 + * @param ordertype 支付平台,android,ios,windows,mac + */ + orderLogReport(orderid: string, goodid: string, goodname: string, money: number, paytype: number, paystatus: number, ordertype: string) { + WXSDK.stat.orderLogReport(orderid, goodid, goodname, money, paytype, paystatus, ordertype) + } + } export enum EventKey { diff --git a/sdk/SDKTools.ts b/sdk/SDKTools.ts index 4d9fa6c..eae2679 100644 --- a/sdk/SDKTools.ts +++ b/sdk/SDKTools.ts @@ -371,11 +371,4 @@ export class SDKTools { * 中台自定义配置表 */ export enum OnlineKeys { - isOpenInterstitialAdId = 'isOpenInterstitialAdId', - shareRandom = 'shareRandom', - switch_draw = 'switch_draw', - switch_banner = 'switch_banner', - switch_grid = 'switch_grid', - calendar_level_max = 'calendar_level_max', - over_show_ad = 'over_show_ad' } \ No newline at end of file diff --git a/wxsdk/WXSDK.ts b/wxsdk/WXSDK.ts index 677c878..adb8a5e 100644 --- a/wxsdk/WXSDK.ts +++ b/wxsdk/WXSDK.ts @@ -7,6 +7,7 @@ import LogService from "./service/LogService"; import AdService from "./service/AdService"; import OnlineService from "./service/OnlineService"; import WxInterstitial from "./wx/WxInterstitial"; +import { GAMEDATA } from "./base/SDKConst"; export default class WXSDK { public static get isWx(): boolean { return typeof (my) != "undefined" @@ -35,40 +36,20 @@ export default class WXSDK { } - public static async init() { - // if (this.isWx) { - // WxInit.I.init(); - // //视频预加载 启动预加载视频会闪屏 - // // setTimeout(() => { - // // WxInterstitial.initInterstitialAd();//插屏预加载 - // // ShareVideoService.I.preloadVideo(); - // // }, 2000); - // if (this.isWx) { - // setTimeout(() => { - // WxInterstitial.initInterstitialAd();//插屏预加载 - // ShareVideoService.I.preloadVideo(); - // }, 2000); - // } - // } - // DataService.I.updateTodayOnlineTime(); - // await this.game.env(); - // if (this.isWx) { - // ShareVideoService.I.init(); - // } - // return Promise.resolve(); - if (cc.sys.platform === cc.sys.ALIPAY_GAME || cc.sys.platform === cc.sys.WECHAT_GAME) { - WxInit.I.init(); - // 视频预加载 启动预加载视频会闪屏 - // if (cc.sys.platform === cc.sys.WECHAT_GAME && typeof qq == 'undefined') { - if (typeof qq == 'undefined') { - setTimeout(() => { - WXSDK.ad.initInterstitialAd();//插屏预加载 - ShareVideoService.I.preloadVideo(); - }, 2000); + public static async init(gameData?:any) { + if(gameData) { + let keys = Object.keys(gameData); + for(let i = 0; i < keys.length; i++) { + let key = keys[i]; + GAMEDATA[key] = gameData[key]; } + } + if (typeof wx!='undefined' || typeof my!='undefined') { + WxInit.I.init(); DataService.I.updateTodayOnlineTime(); await this.game.env(); - ShareVideoService.I.init(); + + await this.game.login(false); } return Promise.resolve(); } diff --git a/wxsdk/base/SDKConst.ts b/wxsdk/base/SDKConst.ts index 9dff088..b3a7a89 100644 --- a/wxsdk/base/SDKConst.ts +++ b/wxsdk/base/SDKConst.ts @@ -1,31 +1,24 @@ // 游戏配置数据 只需要改动这里的配置信息 // 2021003184609526 export const GAMEDATA = { - game_id: '10150',//游戏id + game_id: 'xxxxx',//游戏id isDebug: false, - channel_id: '10150',//渠道id 暂时和游戏id一致 + channel_id: 'xxxxx',//渠道id 暂时和游戏id一致 version: '1.0.0', //版本号 中台控制正式还是测试服,尽量保持和小游戏版本一致 - appkey: '761bdbb773c59e545ac729adec818ddc',//中台appkey - interstitialAdId: 'ad_tiny_2021004125691158_202311162200070802',//插屏ID - bannerId: 'ad_tiny_2021004125691158_202311162200070801',//banner + appkey: '761bdbb773c59e545ac729adec818aaa',//中台appkey + interstitialAdId: '',//插屏ID + bannerId: '',//banner customId: '',//原生模板单个 - videoAd: 'ad_tiny_2021004125691158_202311162200070775',//初始化视频广告id - shareMessageToFriend: { // 暂时只支持一个场景值 - scene: 0, //定向分享场景值1-50 配>0的会初始化 - sharekey: 'shareMessageToFriendScene',//定向分享对应后台的分享key - share_id: 26,//定向分享对应后台的分享key - }, + videoAd: '',//初始化视频广告id default_share: { - content: '还记得童年的泡泡龙吗?一起来怀旧吧~ 这个可以不?', - icon: 'https://cdn-wxsdk.miso-lab.com/f0/5653094b6b7826c8afd813d12735e3.jpg', - id: '9999', + content: '默认分享标题', + icon: '默认分享图片的url', + id: '9999',//写死9999 key: 'default', title: '默认', typ: 1, videoid: '' - }, - subscribeIds: ['yB-vq0DvOhazzDbvS1UzttLMIQ50Z_i0n8st6yEZYkw', '4al8p3UBb3xqn7TYN1J5wYtKrCbFc2MYESAv1vWi-C0'], //, 'cMo71MjAFzGM2MEpRw2p8T5jJaEhXJUfiIjoOB5oO70'], - versionContent: '1、开启每日幸运转盘活动\r\n2、针对部分玩家出现的卡顿问题进行修复' + } } // sdk版本 @@ -84,6 +77,7 @@ export const HostKeys = { client_log: 'logstores/client_log/track', //客户端日志 consume: 'logstores/consume/track', //资源上报 daystay: 'logstores/daystay/track', //300s停留上报 + zfb_game_center: "logstores/zfb_game_center/track",//支付宝游戏行为数据提交(玩一玩) //登录 Login: 'api/login', //登录 @@ -113,6 +107,7 @@ export const HostKeys = { orderReport: 'api/order/v2/mimas/new', //订单信息上报 orderQuery: 'api/order/query', //订单信息查询 preorder: 'api/order/v2/preorder', //获取支付方式 + orderLogReport: 'api/order/v2/logreport', //支付行为上报 // goodslist: 'api/v2/goodslist', //商品列表 diff --git a/wxsdk/http/SDKApi.ts b/wxsdk/http/SDKApi.ts index 4a84442..cff44f4 100644 --- a/wxsdk/http/SDKApi.ts +++ b/wxsdk/http/SDKApi.ts @@ -78,13 +78,15 @@ export class SDKApi { public static daystay = (...args) => SDKHttp.httpGet(DataService.I.DotApi, HostKeys.daystay, ...args); + public static zfb_game_center = (...args) => SDKHttp.httpGet(DataService.I.DotApi, HostKeys.zfb_game_center, ...args); + // OrderApi public static pay = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.orderReport, ...args); public static orderQuery = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.orderQuery, ...args); public static preorder = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.preorder, ...args); public static goodslist = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.goodslist, ...args); - + public static orderLogReport = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.orderLogReport, ...args); //阿里增量任务 diff --git a/wxsdk/service/GameService.ts b/wxsdk/service/GameService.ts index e75773f..24cdf5e 100644 --- a/wxsdk/service/GameService.ts +++ b/wxsdk/service/GameService.ts @@ -19,11 +19,7 @@ export default class GameService { __LOG__ && console.log("版本信息", data); let num = data.data ? data.data.env ? data.data.env : 2 : 2; DataService.I.setEnvEnum(+num) - // DataService.I.setCdnUrl(data.res_url || ''); } - // 设置在线参数请求 - // let isAutoOnlineUse = CfgManager.I.config.IsOnlineAutoUse; - // isAutoOnlineUse && OnlineService.I.updateOnlineConfig().then(() => EventCenter.I.emit(EventEnum.ONLINE_SUCCESS)); resolve(data); }).catch((err: any) => { reject(err); diff --git a/wxsdk/service/LogService.ts b/wxsdk/service/LogService.ts index 5d6be7f..0458735 100644 --- a/wxsdk/service/LogService.ts +++ b/wxsdk/service/LogService.ts @@ -66,6 +66,9 @@ export default class LogService { private get UserId() { return DataService.I.UserId; } + private get Token() { + return DataService.I.Token; + } private get OpenId() { return DataService.I.OpenId; @@ -513,6 +516,44 @@ export default class LogService { } + + /** + * 游戏行为数据提交(玩一玩) + * @param action_code 用户在游戏中的行动编码 + * @param action_finish_channel 用户完成行动的渠道 + * @param action_finish_date 用户完成时间 + * @param status 上报的结果 0成功 其他失败 + */ + AlipayGameCenter(action_code:string,action_finish_channel:string,action_finish_date:string,status:string) { + let fun = () => SDKApi.zfb_game_center({ + openid: this.OpenId, + uid: this.UserId, + action_code,action_finish_channel,action_finish_date,status + }) + this.checkLogin(fun); + } + + /** + * 支付行为上报 + * @param orderid 订单号,游戏方订单号 + * @param goodid 游戏方商品ID + * @param goodname 游戏方商品名字 + * @param money 支付金额,单位分 + * @param paytype 支付方式,1客服消息支付 3米大师支付 4小程序支付 6二维码支付 7字节钱包 8QQ钱包 9华为钱包 10支付宝小游戏支付 11支付宝小程序(跳转到另外一个小程序支付)13美团支付 + * @param paystatus 1支付成功 2支付失败 + * @param ordertype 支付平台,android,ios,windows,mac + */ + orderLogReport(orderid: string, goodid: string, goodname: string, money: number, paytype: number, paystatus: number, ordertype: string) { + let fun = () => SDKApi.orderLogReport({ + ...this.buildParams(), + openid: this.OpenId, + uid: this.UserId, + token: this.Token, + orderid, goodid, goodname, money, paytype, paystatus, ordertype + }) + this.checkLogin(fun); + } + /** * 构建登录/弱登录公用参数 */ diff --git a/wxsdk/service/ShareVideoService.ts b/wxsdk/service/ShareVideoService.ts index 6dbd66c..20d3e12 100644 --- a/wxsdk/service/ShareVideoService.ts +++ b/wxsdk/service/ShareVideoService.ts @@ -32,12 +32,6 @@ export default class ShareVideoService { this.setShareVideoData(data); // console.log(JSON.stringify(data)) SDKShare.I.updateShareMenu(true);//打开群分享 - - - if (GAMEDATA.shareMessageToFriend.scene > 0) { - my.setMessageToFriendQuery({ shareMessageToFriendScene: GAMEDATA.shareMessageToFriend.scene }) - } - if (this.forwardKey) this.forward(this.forwardKey); } diff --git a/wxsdk/wx/WxInit.ts b/wxsdk/wx/WxInit.ts index 7684372..c64a566 100644 --- a/wxsdk/wx/WxInit.ts +++ b/wxsdk/wx/WxInit.ts @@ -59,12 +59,6 @@ export default class WxInit { fromChannel = ad_id; } - //定向分享统计 - if (shareMessageToFriendScene && shareMessageToFriendScene >= 0 && shareMessageToFriendScene <= 50) { - share_key = GAMEDATA.shareMessageToFriend.sharekey; - share_id = GAMEDATA.shareMessageToFriend.share_id; - } - __LOG__ && console.warn(`====> PCSDK wxinit query user_invite_uid:${user_invite_uid}; fromChannel:${fromChannel}; channelId:${fromChannel}; scene:${scene}; share_id:${share_id}; share_key:${share_key};`); // 设置sdk 数据的信息 -- libgit2 0.21.0