Commit b9a9b8993afb19021adbd2e8940b485c3ce403c9
1 parent
ff2edf11
Exists in
master
and in
3 other branches
X
Showing
7 changed files
with
74 additions
and
5 deletions
Show diff stats
sdk/SDKTools.ts
| ... | ... | @@ -317,6 +317,23 @@ export class SDKTools { |
| 317 | 317 | static pay(params: { money: number; source:string }, opts: any = {}) { |
| 318 | 318 | return WXSDK.game.pay(params, opts) |
| 319 | 319 | } |
| 320 | + /** | |
| 321 | + * 检测支付是否成功 | |
| 322 | + */ | |
| 323 | + static orderQuery(source:string) { | |
| 324 | + return WXSDK.game.orderQuery(source) | |
| 325 | + } | |
| 326 | + | |
| 327 | + | |
| 328 | + /** | |
| 329 | + * 用户创角 | |
| 330 | + * @param role_name 角色名称 | |
| 331 | + * @param region 区服 | |
| 332 | + */ | |
| 333 | + static role(role_name: string,region:string) { | |
| 334 | + return WXSDK.stat.role(role_name, region) | |
| 335 | + } | |
| 336 | + | |
| 320 | 337 | |
| 321 | 338 | } |
| 322 | 339 | |
| ... | ... | @@ -326,4 +343,9 @@ export class SDKTools { |
| 326 | 343 | export enum OnlineKeys { |
| 327 | 344 | isOpenInterstitialAdId = 'isOpenInterstitialAdId', |
| 328 | 345 | shareRandom = 'shareRandom', |
| 346 | + switch_draw = 'switch_draw', | |
| 347 | + switch_banner = 'switch_banner', | |
| 348 | + switch_grid = 'switch_grid', | |
| 349 | + calendar_level_max = 'calendar_level_max', | |
| 350 | + over_show_ad = 'over_show_ad' | |
| 329 | 351 | } |
| 330 | 352 | \ No newline at end of file | ... | ... |
wxsdk/base/SDKConst.ts
| ... | ... | @@ -37,7 +37,7 @@ export const GAMEDATA = { |
| 37 | 37 | // sdk版本 |
| 38 | 38 | export const SDKVersion = 'v1.0'; |
| 39 | 39 | // 是否打印 |
| 40 | -export const __LOG__ = true; | |
| 40 | +export const __LOG__ = false; | |
| 41 | 41 | |
| 42 | 42 | //游戏基础信息 |
| 43 | 43 | export const VersionHost = 'https://wxsdk-ver.d3games.com/version'; |
| ... | ... | @@ -75,6 +75,7 @@ export const HostKeys = { |
| 75 | 75 | dot: 'logstores/events/track', //自定义打点 |
| 76 | 76 | jumps: 'logstores/jumps/track', //游戏跳转 |
| 77 | 77 | level: 'logstores/level/track', //关卡打点 |
| 78 | + role: 'logstores/role/track', //创建角色 | |
| 78 | 79 | |
| 79 | 80 | //登录 |
| 80 | 81 | Login: 'api/login', //登录 |
| ... | ... | @@ -94,7 +95,8 @@ export const HostKeys = { |
| 94 | 95 | adList: 'api/adplan/list', //广告计划列表 |
| 95 | 96 | |
| 96 | 97 | //订单 |
| 97 | - orderReport: 'api/order/report' //订单信息上报 | |
| 98 | + orderReport: 'api/order/report', //订单信息上报 | |
| 99 | + orderQuery: 'api/order/query' //订单信息查询 | |
| 98 | 100 | }; |
| 99 | 101 | |
| 100 | 102 | // 本地存储keys | ... | ... |
wxsdk/http/SDKApi.ts
| ... | ... | @@ -58,6 +58,10 @@ export class SDKApi { |
| 58 | 58 | public static jumps = (...args) => SDKHttp.httpGet(`${DataService.I.DotApi}${HostKeys.jumps}`, ...args); |
| 59 | 59 | |
| 60 | 60 | public static level = (...args) => SDKHttp.httpGet(`${DataService.I.DotApi}${HostKeys.level}`, ...args); |
| 61 | + | |
| 62 | + public static role = (...args) => SDKHttp.httpGet(`${DataService.I.DotApi}${HostKeys.role}`, ...args); | |
| 61 | 63 | |
| 62 | 64 | public static pay = (...args) => SDKHttp.httpPost(`${DataService.I.OrderApi}${HostKeys.orderReport}`, ...args); |
| 65 | + | |
| 66 | + public static orderQuery = (...args) => SDKHttp.httpPost(`${DataService.I.OrderApi}${HostKeys.orderQuery}`, ...args); | |
| 63 | 67 | } | ... | ... |
wxsdk/http/SDKHttp.ts
| ... | ... | @@ -25,7 +25,7 @@ export default class SDKHttp { |
| 25 | 25 | if (data && typeof data === "object") { |
| 26 | 26 | data = JSON.stringify(data); |
| 27 | 27 | } |
| 28 | - //console.error("sign", url, JSON.stringify(data)) | |
| 28 | + // console.error("sign", url, JSON.stringify(data)) | |
| 29 | 29 | data = data || ""; |
| 30 | 30 | if (method == "GET" && data != "") { |
| 31 | 31 | data = JSON.parse(data); | ... | ... |
wxsdk/service/GameService.ts
| 1 | 1 | import DataService from "./DataService"; |
| 2 | 2 | import { SDKApi } from "../http/SDKApi"; |
| 3 | -import { __LOG__ } from "../base/SDKConst"; | |
| 3 | +import { GAMEDATA, __LOG__ } from "../base/SDKConst"; | |
| 4 | 4 | import WxLogin from "../wx/WxLogin"; |
| 5 | 5 | import WxApi from "../wx/WxApi"; |
| 6 | 6 | import WxPay from "../wx/WxPay"; |
| ... | ... | @@ -106,6 +106,32 @@ export default class GameService { |
| 106 | 106 | pay(params: { money: number; source:string}, opts: any = {}) { |
| 107 | 107 | return WxPay.I.pay(params, opts); |
| 108 | 108 | } |
| 109 | + /** | |
| 110 | + * 订单查询 | |
| 111 | + */ | |
| 112 | + orderQuery(source) { | |
| 113 | + return SDKApi.orderQuery({ | |
| 114 | + ...this.buildParams(), | |
| 115 | + source | |
| 116 | + }); | |
| 117 | + } | |
| 118 | + | |
| 119 | + | |
| 120 | + /** | |
| 121 | + * 构建登录/弱登录公用参数 | |
| 122 | + */ | |
| 123 | + private buildParams() { | |
| 124 | + let gameid = GAMEDATA.game_id; | |
| 125 | + let channel = DataService.I.ChannelId; | |
| 126 | + let uid = DataService.I.UserId; | |
| 127 | + let token = DataService.I.Token; | |
| 128 | + return { | |
| 129 | + gameid, | |
| 130 | + channel, | |
| 131 | + uid, | |
| 132 | + token | |
| 133 | + }; | |
| 134 | + } | |
| 109 | 135 | |
| 110 | 136 | private static instance: GameService; |
| 111 | 137 | static get I(): GameService { | ... | ... |
wxsdk/service/LogService.ts
| ... | ... | @@ -423,6 +423,21 @@ export default class LogService { |
| 423 | 423 | |
| 424 | 424 | |
| 425 | 425 | /** |
| 426 | + * 用户创角 | |
| 427 | + * @param role_name 角色名称 | |
| 428 | + * @param region 区服 | |
| 429 | + */ | |
| 430 | + role(role_name: string,region:string) { | |
| 431 | + let fun = () => SDKApi.role({ | |
| 432 | + ...this.buildParams(), | |
| 433 | + role_name, | |
| 434 | + region | |
| 435 | + }) | |
| 436 | + this.checkLogin(fun); | |
| 437 | + } | |
| 438 | + | |
| 439 | + | |
| 440 | + /** | |
| 426 | 441 | * 构建登录/弱登录公用参数 |
| 427 | 442 | */ |
| 428 | 443 | private buildParams() { | ... | ... |
wxsdk/utils/SignUtils.ts
| ... | ... | @@ -11,7 +11,7 @@ export default class SignUtils { |
| 11 | 11 | |
| 12 | 12 | createSign(params: any) { |
| 13 | 13 | let signStr = this.createQuery(params) + '' + GAMEDATA.appkey; |
| 14 | - //console.error("signStr",signStr) | |
| 14 | + // console.error("signStr",signStr) | |
| 15 | 15 | return Md5.hashStr(signStr); |
| 16 | 16 | } |
| 17 | 17 | ... | ... |