Commit a4da6703cb85afd21d315ae0f56c1e5c5cd8bf7e
1 parent
7a097db2
Exists in
master
and in
3 other branches
x
Showing
5 changed files
with
32 additions
and
12 deletions
Show diff stats
sdk/SDKTools.ts
| ... | ... | @@ -305,6 +305,12 @@ export class SDKTools { |
| 305 | 305 | static preorder(goodid: string, orderid: string) { |
| 306 | 306 | return WXSDK.game.preorder(goodid, orderid) |
| 307 | 307 | } |
| 308 | + /** | |
| 309 | + * 获取商品列表 | |
| 310 | + */ | |
| 311 | + static goodslist() { | |
| 312 | + return WXSDK.game.goodslist() | |
| 313 | + } | |
| 308 | 314 | |
| 309 | 315 | |
| 310 | 316 | /** | ... | ... |
wxsdk/base/SDKConst.ts
| ... | ... | @@ -32,10 +32,8 @@ export const GAMEDATA = { |
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - | |
| 36 | - | |
| 37 | 35 | // sdk版本 |
| 38 | -export const SDKVersion = 'v1.0.6'; | |
| 36 | +export const SDKVersion = 'v1.0.7'; | |
| 39 | 37 | // 是否打印 |
| 40 | 38 | export const __LOG__ = false; |
| 41 | 39 | // 是否mock |
| ... | ... | @@ -113,6 +111,8 @@ export const HostKeys = { |
| 113 | 111 | orderReport: 'api/order/v2/mimas', //订单信息上报 |
| 114 | 112 | orderQuery: 'api/order/query', //订单信息查询 |
| 115 | 113 | preorder: 'api/order/v2/preorder', //获取支付方式 |
| 114 | + // | |
| 115 | + goodslist: 'api/v2/goodslist', //商品列表 | |
| 116 | 116 | }; |
| 117 | 117 | |
| 118 | 118 | // 本地存储keys | ... | ... |
wxsdk/http/SDKApi.ts
| ... | ... | @@ -75,4 +75,6 @@ export class SDKApi { |
| 75 | 75 | public static pay = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.orderReport, ...args); |
| 76 | 76 | public static orderQuery = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.orderQuery, ...args); |
| 77 | 77 | public static preorder = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.preorder, ...args); |
| 78 | + | |
| 79 | + public static goodslist = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.goodslist, ...args); | |
| 78 | 80 | } | ... | ... |
wxsdk/http/SDKHttp.ts
| ... | ... | @@ -2,6 +2,8 @@ import { GAMEDATA, sdkEnv } from "../base/SDKConst"; |
| 2 | 2 | import SignUtils from "../utils/SignUtils"; |
| 3 | 3 | |
| 4 | 4 | export default class SDKHttp { |
| 5 | + public static onErrorResponse: (data: any) => void; | |
| 6 | + | |
| 5 | 7 | public static async httpRequest(url: string, method: string, data?: any, dataType: "json" | "string" = "json") { |
| 6 | 8 | return new Promise<IResult<any>>((resolve, reject) => { |
| 7 | 9 | data = { |
| ... | ... | @@ -11,12 +13,6 @@ export default class SDKHttp { |
| 11 | 13 | sign_type: 'md5', |
| 12 | 14 | time_stamp: (Math.floor(Date.now() / 1000)) + '' |
| 13 | 15 | } |
| 14 | - | |
| 15 | - // if (url.indexOf('totalrank')>-1) { | |
| 16 | - // // console.log("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") | |
| 17 | - // url = 'https://wxsdk-game-pre.d3games.com/game/totalrank/list'; | |
| 18 | - // } | |
| 19 | - | |
| 20 | 16 | //生成sign |
| 21 | 17 | data = { |
| 22 | 18 | ...data, |
| ... | ... | @@ -108,15 +104,25 @@ export default class SDKHttp { |
| 108 | 104 | } |
| 109 | 105 | |
| 110 | 106 | url = baseUrl + url; |
| 111 | - return this.httpRequest(url, "GET", data, dataType); | |
| 107 | + let res = await this.httpRequest(url, "GET", data, dataType); | |
| 108 | + if (this.onErrorResponse && !res.code) { | |
| 109 | + // | |
| 110 | + this.onErrorResponse(res); | |
| 111 | + } | |
| 112 | + return res; | |
| 112 | 113 | } |
| 113 | 114 | |
| 114 | - public static httpPost(baseUrl: string, url: string, data?: any, dataType: "json" | "string" = "json") { | |
| 115 | + public static async httpPost(baseUrl: string, url: string, data?: any, dataType: "json" | "string" = "json") { | |
| 115 | 116 | if (this.withMock(url)) { |
| 116 | 117 | return this.mockData(url); |
| 117 | 118 | } |
| 118 | 119 | |
| 119 | 120 | url = baseUrl + url; |
| 120 | - return this.httpRequest(url, "POST", data, dataType); | |
| 121 | + let res = await this.httpRequest(url, "POST", data, dataType); | |
| 122 | + if (this.onErrorResponse && !res.code) { | |
| 123 | + // | |
| 124 | + this.onErrorResponse(res); | |
| 125 | + } | |
| 126 | + return res | |
| 121 | 127 | } |
| 122 | 128 | } |
| 123 | 129 | \ No newline at end of file | ... | ... |
wxsdk/service/GameService.ts