Commit 53858931306b3184d8c705af0b7436762d856e6b

Authored by 宋庆平
1 parent 6c0b9c7c

X

sdk/Analytics.ts
@@ -95,8 +95,25 @@ export class Analytics { @@ -95,8 +95,25 @@ export class Analytics {
95 consume(id: number, typ: number, nums: number, gsne: string) { 95 consume(id: number, typ: number, nums: number, gsne: string) {
96 return WXSDK.stat.consume(id, typ, nums, gsne) 96 return WXSDK.stat.consume(id, typ, nums, gsne)
97 } 97 }
  98 + /**
  99 + * loading上报
  100 + * @param typ 1开始加载、2加载进行中、3加载结束
  101 + * @param stageid 加载id
  102 + * @param stagename 加载内容
  103 + * @param event complete:成功 fail:失败
  104 + * @param times 加载消耗时间 单位毫秒
  105 + * @param perc 完成度
  106 + */
  107 + loading(typ: string, stageid: string, stagename: string, event: string, times: string, perc?: number) {
  108 + return WXSDK.stat.loading(typ, stageid, stagename, event, times, perc)
  109 + }
98 110
99 111
100 } 112 }
101 export enum EventKey { 113 export enum EventKey {
  114 + toggleScene = 'toggleScene',
  115 + recoverGame = 'recoverGame',
  116 + replayGame = 'replayGame',
  117 + settingClose = 'settingClose',
  118 + updateLvUI = 'updateLvUI',
102 } 119 }
sdk/SDKTools.ts
@@ -242,7 +242,16 @@ export class SDKTools { @@ -242,7 +242,16 @@ export class SDKTools {
242 242
243 243
244 244
245 - 245 + /**
  246 + * 互动数据解密
  247 + * @param iv
  248 + * @param encryptedData
  249 + * @returns
  250 + */
  251 + static wxencrypted(iv, encryptedData): Promise<IResult<any>> {
  252 + if (!this.isWx) return Promise.resolve({ code: -1 })
  253 + return WXSDK.game.wxencrypted(iv, encryptedData);
  254 + }
246 /** 255 /**
247 * 互导数据 256 * 互导数据
248 * 1抽屉广告2猜你喜欢3格子广告4试玩 257 * 1抽屉广告2猜你喜欢3格子广告4试玩
@@ -287,7 +296,7 @@ export class SDKTools { @@ -287,7 +296,7 @@ export class SDKTools {
287 * @returns 296 * @returns
288 */ 297 */
289 static pay(params: { payid: string, goodid: string, money: number; orderid: string }, opts: any = {}) { 298 static pay(params: { payid: string, goodid: string, money: number; orderid: string }, opts: any = {}) {
290 - return WXSDK.game.pay(params, opts) 299 + return WXSDK.game.pay(params, opts);
291 } 300 }
292 /** 301 /**
293 * 检测支付是否成功 302 * 检测支付是否成功
@@ -308,7 +317,7 @@ export class SDKTools { @@ -308,7 +317,7 @@ export class SDKTools {
308 /** 317 /**
309 * 获取商品列表 318 * 获取商品列表
310 */ 319 */
311 - static goodslist() { 320 + static goodslist() {
312 return WXSDK.game.goodslist() 321 return WXSDK.game.goodslist()
313 } 322 }
314 323
wxsdk/base/SDKConst.ts
1 // 游戏配置数据 只需要改动这里的配置信息 1 // 游戏配置数据 只需要改动这里的配置信息
2 // 游戏配置数据 只需要改动这里的配置信息 2 // 游戏配置数据 只需要改动这里的配置信息
  3 +
3 export const GAMEDATA = { 4 export const GAMEDATA = {
4 game_id: '10001',//游戏id 5 game_id: '10001',//游戏id
5 channel_id: '10001',//渠道id 暂时和游戏id一致 6 channel_id: '10001',//渠道id 暂时和游戏id一致
@@ -32,10 +33,8 @@ export const GAMEDATA = { @@ -32,10 +33,8 @@ export const GAMEDATA = {
32 } 33 }
33 } 34 }
34 35
35 -  
36 -  
37 // sdk版本 36 // sdk版本
38 -export const SDKVersion = 'v1.0.10'; 37 +export const SDKVersion = 'v1.0.11';
39 // 是否打印 38 // 是否打印
40 export const __LOG__ = false; 39 export const __LOG__ = false;
41 // 是否mock 40 // 是否mock
@@ -90,6 +89,7 @@ export const HostKeys = { @@ -90,6 +89,7 @@ export const HostKeys = {
90 client_log: 'logstores/client_log/track', //客户端日志 89 client_log: 'logstores/client_log/track', //客户端日志
91 consume: 'logstores/consume/track', //资源上报 90 consume: 'logstores/consume/track', //资源上报
92 daystay: 'logstores/daystay/track', //300s停留上报 91 daystay: 'logstores/daystay/track', //300s停留上报
  92 + loading: 'logstores/loading/track', //loading上报
93 93
94 //登录 94 //登录
95 Login: 'api/login', //登录 95 Login: 'api/login', //登录
@@ -109,6 +109,7 @@ export const HostKeys = { @@ -109,6 +109,7 @@ export const HostKeys = {
109 adList: 'api/adplan/list', //广告计划列表 109 adList: 'api/adplan/list', //广告计划列表
110 behavior: 'api/douyin/behavior', //抖音投放关键行为 110 behavior: 'api/douyin/behavior', //抖音投放关键行为
111 attribute: 'api/member/attribute/set', //修改用户属性 111 attribute: 'api/member/attribute/set', //修改用户属性
  112 + wxencrypted: 'api/wx/encrypted',
112 //订单 113 //订单
113 orderReport: 'api/order/v2/mimas/new', //订单信息上报 114 orderReport: 'api/order/v2/mimas/new', //订单信息上报
114 orderQuery: 'api/order/query', //订单信息查询 115 orderQuery: 'api/order/query', //订单信息查询
wxsdk/http/SDKApi.ts
@@ -30,6 +30,8 @@ export class SDKApi { @@ -30,6 +30,8 @@ export class SDKApi {
30 public static behavior = (...args) => SDKHttp.httpPost(DataService.I.GameApi, HostKeys.behavior, ...args); 30 public static behavior = (...args) => SDKHttp.httpPost(DataService.I.GameApi, HostKeys.behavior, ...args);
31 //修改用户属性 31 //修改用户属性
32 public static attribute = (...args) => SDKHttp.httpPost(DataService.I.GameApi, HostKeys.attribute, ...args); 32 public static attribute = (...args) => SDKHttp.httpPost(DataService.I.GameApi, HostKeys.attribute, ...args);
  33 + // 解密关系链互动数据
  34 + public static wxencrypted = (...args) => SDKHttp.httpPost(DataService.I.GameApi, HostKeys.wxencrypted, ...args);
33 35
34 //LoginApi 36 //LoginApi
35 public static Login = (...args) => SDKHttp.httpPost(DataService.I.LoginApi, HostKeys.Login, ...args); 37 public static Login = (...args) => SDKHttp.httpPost(DataService.I.LoginApi, HostKeys.Login, ...args);
@@ -69,6 +71,8 @@ export class SDKApi { @@ -69,6 +71,8 @@ export class SDKApi {
69 public static consume = (...args) => SDKHttp.httpGet(DataService.I.DotApi, HostKeys.consume, ...args); 71 public static consume = (...args) => SDKHttp.httpGet(DataService.I.DotApi, HostKeys.consume, ...args);
70 72
71 public static daystay = (...args) => SDKHttp.httpGet(DataService.I.DotApi, HostKeys.daystay, ...args); 73 public static daystay = (...args) => SDKHttp.httpGet(DataService.I.DotApi, HostKeys.daystay, ...args);
  74 +
  75 + public static loading = (...args) => SDKHttp.httpGet(DataService.I.DotApi, HostKeys.loading, ...args);
72 76
73 77
74 // OrderApi 78 // OrderApi
wxsdk/service/DataService.ts
@@ -16,9 +16,11 @@ export default class DataService { @@ -16,9 +16,11 @@ export default class DataService {
16 this._data = new SdkData; 16 this._data = new SdkData;
17 // 0点数据变动 17 // 0点数据变动
18 let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0); 18 let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0);
19 - setTimeout(this.resetData, expiration * 1000);  
20 - wx.onShow(this.onShow.bind(this));  
21 - wx.onHide(this.onHide.bind(this)); 19 + setTimeout(this.resetData.bind(this), expiration * 1000);
  20 + if (typeof wx != 'undefined') {
  21 + wx.onShow(this.onShow.bind(this));
  22 + wx.onHide(this.onHide.bind(this));
  23 + }
22 } 24 }
23 25
24 onShow() { 26 onShow() {
@@ -554,7 +556,7 @@ export default class DataService { @@ -554,7 +556,7 @@ export default class DataService {
554 let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0); 556 let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0);
555 let time = StorageUtils.I.get("pcsdk_today_online_time") || 0; 557 let time = StorageUtils.I.get("pcsdk_today_online_time") || 0;
556 time += 1; 558 time += 1;
557 - StorageUtils.I.set("pcsdk_today_online_time", time, expiration) 559 + StorageUtils.I.set("pcsdk_today_online_time", time, expiration);
558 let dot = StorageUtils.I.get("pcsdk_today_online_time_300") || 0; 560 let dot = StorageUtils.I.get("pcsdk_today_online_time_300") || 0;
559 if (dot === 1) { 561 if (dot === 1) {
560 this.setPtm(1) 562 this.setPtm(1)
wxsdk/service/GameService.ts
@@ -64,6 +64,10 @@ export default class GameService { @@ -64,6 +64,10 @@ export default class GameService {
64 return SDKApi.adList({ adtyp, uid: DataService.I.UserId, token: DataService.I.Token }) 64 return SDKApi.adList({ adtyp, uid: DataService.I.UserId, token: DataService.I.Token })
65 } 65 }
66 66
  67 + wxencrypted(iv,encryptedData) {
  68 + return SDKApi.wxencrypted({iv,encryptedData,openid:DataService.I.OpenId,token: DataService.I.Token,uid: DataService.I.UserId})
  69 + }
  70 +
67 71
68 subScribe(tmplIds: Array<string>, ids: Array<string>): Promise<any> { 72 subScribe(tmplIds: Array<string>, ids: Array<string>): Promise<any> {
69 return new Promise((resolve, reject) => { 73 return new Promise((resolve, reject) => {
wxsdk/service/LogService.ts
@@ -510,6 +510,22 @@ export default class LogService { @@ -510,6 +510,22 @@ export default class LogService {
510 }) 510 })
511 this.checkLogin(fun); 511 this.checkLogin(fun);
512 } 512 }
  513 + /**
  514 + * loading上报
  515 + * @param typ 1开始加载、2加载进行中、3加载结束
  516 + * @param stageid 加载id
  517 + * @param stagename 加载内容
  518 + * @param event complete:成功 fail:失败
  519 + * @param times 加载消耗时间 单位毫秒
  520 + * @param perc 完成度
  521 + */
  522 + loading(typ: string, stageid: string, stagename: string, event: string, times: string, perc?: number) {
  523 + let fun = () => SDKApi.loading({
  524 + ...this.buildParams(),
  525 + typ, stageid, stagename, event, times, perc
  526 + })
  527 + this.checkLogin(fun);
  528 + }
513 529
514 530
515 /** 531 /**