Commit a4da6703cb85afd21d315ae0f56c1e5c5cd8bf7e

Authored by 宋庆平
1 parent 7a097db2

x

sdk/SDKTools.ts
@@ -305,6 +305,12 @@ export class SDKTools { @@ -305,6 +305,12 @@ export class SDKTools {
305 static preorder(goodid: string, orderid: string) { 305 static preorder(goodid: string, orderid: string) {
306 return WXSDK.game.preorder(goodid, orderid) 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,10 +32,8 @@ export const GAMEDATA = {
32 } 32 }
33 } 33 }
34 34
35 -  
36 -  
37 // sdk版本 35 // sdk版本
38 -export const SDKVersion = 'v1.0.6'; 36 +export const SDKVersion = 'v1.0.7';
39 // 是否打印 37 // 是否打印
40 export const __LOG__ = false; 38 export const __LOG__ = false;
41 // 是否mock 39 // 是否mock
@@ -113,6 +111,8 @@ export const HostKeys = { @@ -113,6 +111,8 @@ export const HostKeys = {
113 orderReport: 'api/order/v2/mimas', //订单信息上报 111 orderReport: 'api/order/v2/mimas', //订单信息上报
114 orderQuery: 'api/order/query', //订单信息查询 112 orderQuery: 'api/order/query', //订单信息查询
115 preorder: 'api/order/v2/preorder', //获取支付方式 113 preorder: 'api/order/v2/preorder', //获取支付方式
  114 + //
  115 + goodslist: 'api/v2/goodslist', //商品列表
116 }; 116 };
117 117
118 // 本地存储keys 118 // 本地存储keys
wxsdk/http/SDKApi.ts
@@ -75,4 +75,6 @@ export class SDKApi { @@ -75,4 +75,6 @@ export class SDKApi {
75 public static pay = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.orderReport, ...args); 75 public static pay = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.orderReport, ...args);
76 public static orderQuery = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.orderQuery, ...args); 76 public static orderQuery = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.orderQuery, ...args);
77 public static preorder = (...args) => SDKHttp.httpPost(DataService.I.OrderApi, HostKeys.preorder, ...args); 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,6 +2,8 @@ import { GAMEDATA, sdkEnv } from "../base/SDKConst";
2 import SignUtils from "../utils/SignUtils"; 2 import SignUtils from "../utils/SignUtils";
3 3
4 export default class SDKHttp { 4 export default class SDKHttp {
  5 + public static onErrorResponse: (data: any) => void;
  6 +
5 public static async httpRequest(url: string, method: string, data?: any, dataType: "json" | "string" = "json") { 7 public static async httpRequest(url: string, method: string, data?: any, dataType: "json" | "string" = "json") {
6 return new Promise<IResult<any>>((resolve, reject) => { 8 return new Promise<IResult<any>>((resolve, reject) => {
7 data = { 9 data = {
@@ -11,12 +13,6 @@ export default class SDKHttp { @@ -11,12 +13,6 @@ export default class SDKHttp {
11 sign_type: 'md5', 13 sign_type: 'md5',
12 time_stamp: (Math.floor(Date.now() / 1000)) + '' 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 //生成sign 16 //生成sign
21 data = { 17 data = {
22 ...data, 18 ...data,
@@ -108,15 +104,25 @@ export default class SDKHttp { @@ -108,15 +104,25 @@ export default class SDKHttp {
108 } 104 }
109 105
110 url = baseUrl + url; 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 if (this.withMock(url)) { 116 if (this.withMock(url)) {
116 return this.mockData(url); 117 return this.mockData(url);
117 } 118 }
118 119
119 url = baseUrl + url; 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 \ No newline at end of file 129 \ No newline at end of file
wxsdk/service/GameService.ts
@@ -120,6 +120,12 @@ export default class GameService { @@ -120,6 +120,12 @@ export default class GameService {
120 goodid, orderid 120 goodid, orderid
121 }); 121 });
122 } 122 }
  123 + /**
  124 + * 商品列表
  125 + */
  126 + goodslist() {
  127 + return SDKApi.goodslist();
  128 + }
123 129
124 /** 130 /**
125 * 构建登录/弱登录公用参数 131 * 构建登录/弱登录公用参数