@gt6/sdk 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gt6-sdk.cjs.js +173 -0
- package/dist/gt6-sdk.cjs.js.map +1 -1
- package/dist/gt6-sdk.esm.js +173 -0
- package/dist/gt6-sdk.esm.js.map +1 -1
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/modules/users.d.ts +75 -0
- package/dist/modules/users.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/gt6-sdk.esm.js
CHANGED
@@ -1019,6 +1019,155 @@ class UsersAPI {
|
|
1019
1019
|
localStorage.removeItem('rememberedPassword');
|
1020
1020
|
}
|
1021
1021
|
}
|
1022
|
+
/**
|
1023
|
+
* 获取用户资金信息
|
1024
|
+
* @returns 用户资金信息
|
1025
|
+
*/
|
1026
|
+
async getUserFunds() {
|
1027
|
+
try {
|
1028
|
+
// 获取用户token
|
1029
|
+
const token = this.getToken();
|
1030
|
+
if (!token) {
|
1031
|
+
return {
|
1032
|
+
success: false,
|
1033
|
+
fund: {},
|
1034
|
+
message: '用户未登录'
|
1035
|
+
};
|
1036
|
+
}
|
1037
|
+
const response = await this.client.request('/web/user/fund', {
|
1038
|
+
method: 'GET',
|
1039
|
+
headers: {
|
1040
|
+
'Authorization': `Bearer ${token}`,
|
1041
|
+
'Content-Type': 'application/json'
|
1042
|
+
}
|
1043
|
+
});
|
1044
|
+
return response;
|
1045
|
+
}
|
1046
|
+
catch (error) {
|
1047
|
+
// 如果是HTTP错误,尝试解析响应体
|
1048
|
+
if (error.statusCode && error.message) {
|
1049
|
+
// 对于401错误,返回认证失败信息
|
1050
|
+
if (error.statusCode === 401) {
|
1051
|
+
return {
|
1052
|
+
success: false,
|
1053
|
+
fund: {},
|
1054
|
+
message: '认证失败,请重新登录'
|
1055
|
+
};
|
1056
|
+
}
|
1057
|
+
// 对于其他HTTP错误,返回状态码信息
|
1058
|
+
return {
|
1059
|
+
success: false,
|
1060
|
+
fund: {},
|
1061
|
+
message: error.message || `HTTP ${error.statusCode} 错误`
|
1062
|
+
};
|
1063
|
+
}
|
1064
|
+
// 对于网络错误或其他错误
|
1065
|
+
return {
|
1066
|
+
success: false,
|
1067
|
+
fund: {},
|
1068
|
+
message: error instanceof Error ? error.message : '获取资金信息失败'
|
1069
|
+
};
|
1070
|
+
}
|
1071
|
+
}
|
1072
|
+
/**
|
1073
|
+
* 获取用户资金信息(简化版本,返回资金对象或null)
|
1074
|
+
* @returns 用户资金信息或null
|
1075
|
+
*/
|
1076
|
+
async getFunds() {
|
1077
|
+
const result = await this.getUserFunds();
|
1078
|
+
return result.success ? result.fund : null;
|
1079
|
+
}
|
1080
|
+
/**
|
1081
|
+
* 获取用户支付记录列表
|
1082
|
+
* @param options 查询选项
|
1083
|
+
* @returns 支付记录列表响应
|
1084
|
+
*/
|
1085
|
+
async getPaymentRecords(options) {
|
1086
|
+
try {
|
1087
|
+
// 获取用户token
|
1088
|
+
const token = this.getToken();
|
1089
|
+
if (!token) {
|
1090
|
+
return {
|
1091
|
+
success: false,
|
1092
|
+
records: [],
|
1093
|
+
total: 0,
|
1094
|
+
page: options?.page || 1,
|
1095
|
+
pageSize: options?.pageSize || 10,
|
1096
|
+
message: '用户未登录'
|
1097
|
+
};
|
1098
|
+
}
|
1099
|
+
// 构建查询参数
|
1100
|
+
const params = new URLSearchParams();
|
1101
|
+
if (options?.page)
|
1102
|
+
params.set('page', options.page.toString());
|
1103
|
+
if (options?.pageSize)
|
1104
|
+
params.set('pageSize', options.pageSize.toString());
|
1105
|
+
if (options?.status)
|
1106
|
+
params.set('status', options.status);
|
1107
|
+
if (options?.recordType)
|
1108
|
+
params.set('recordType', options.recordType.toString());
|
1109
|
+
if (options?.methodId)
|
1110
|
+
params.set('methodId', options.methodId.toString());
|
1111
|
+
const url = `/web/payment/records${params.toString() ? `?${params.toString()}` : ''}`;
|
1112
|
+
const response = await this.client.request(url, {
|
1113
|
+
method: 'GET',
|
1114
|
+
headers: {
|
1115
|
+
'Authorization': `Bearer ${token}`,
|
1116
|
+
'Content-Type': 'application/json'
|
1117
|
+
}
|
1118
|
+
});
|
1119
|
+
return response;
|
1120
|
+
}
|
1121
|
+
catch (error) {
|
1122
|
+
// 如果是HTTP错误,尝试解析响应体
|
1123
|
+
if (error.statusCode && error.message) {
|
1124
|
+
// 对于401错误,返回认证失败信息
|
1125
|
+
if (error.statusCode === 401) {
|
1126
|
+
return {
|
1127
|
+
success: false,
|
1128
|
+
records: [],
|
1129
|
+
total: 0,
|
1130
|
+
page: options?.page || 1,
|
1131
|
+
pageSize: options?.pageSize || 10,
|
1132
|
+
message: '认证失败,请重新登录'
|
1133
|
+
};
|
1134
|
+
}
|
1135
|
+
// 对于其他HTTP错误,返回状态码信息
|
1136
|
+
return {
|
1137
|
+
success: false,
|
1138
|
+
records: [],
|
1139
|
+
total: 0,
|
1140
|
+
page: options?.page || 1,
|
1141
|
+
pageSize: options?.pageSize || 10,
|
1142
|
+
message: error.message || `HTTP ${error.statusCode} 错误`
|
1143
|
+
};
|
1144
|
+
}
|
1145
|
+
// 对于网络错误或其他错误
|
1146
|
+
return {
|
1147
|
+
success: false,
|
1148
|
+
records: [],
|
1149
|
+
total: 0,
|
1150
|
+
page: options?.page || 1,
|
1151
|
+
pageSize: options?.pageSize || 10,
|
1152
|
+
message: error instanceof Error ? error.message : '获取支付记录失败'
|
1153
|
+
};
|
1154
|
+
}
|
1155
|
+
}
|
1156
|
+
/**
|
1157
|
+
* 获取用户支付记录列表(简化版本)
|
1158
|
+
* @param page 页码,默认为1
|
1159
|
+
* @param pageSize 每页数量,默认为10
|
1160
|
+
* @returns 支付记录列表或null
|
1161
|
+
*/
|
1162
|
+
async getPaymentRecordsSimple(page = 1, pageSize = 10) {
|
1163
|
+
const result = await this.getPaymentRecords({ page, pageSize });
|
1164
|
+
return result.success ? {
|
1165
|
+
records: result.records,
|
1166
|
+
total: result.total,
|
1167
|
+
page: result.page,
|
1168
|
+
pageSize: result.pageSize
|
1169
|
+
} : null;
|
1170
|
+
}
|
1022
1171
|
}
|
1023
1172
|
|
1024
1173
|
/**
|
@@ -1280,6 +1429,30 @@ class GT6SDK {
|
|
1280
1429
|
clearRememberedLogin() {
|
1281
1430
|
return this.users.clearRememberedLogin();
|
1282
1431
|
}
|
1432
|
+
/**
|
1433
|
+
* 39. 便捷方法:获取用户资金信息
|
1434
|
+
*/
|
1435
|
+
async getUserFunds() {
|
1436
|
+
return this.users.getUserFunds();
|
1437
|
+
}
|
1438
|
+
/**
|
1439
|
+
* 40. 便捷方法:获取用户资金信息(简化版本)
|
1440
|
+
*/
|
1441
|
+
async getFunds() {
|
1442
|
+
return this.users.getFunds();
|
1443
|
+
}
|
1444
|
+
/**
|
1445
|
+
* 41. 便捷方法:获取用户支付记录列表
|
1446
|
+
*/
|
1447
|
+
async getPaymentRecords(options) {
|
1448
|
+
return this.users.getPaymentRecords(options);
|
1449
|
+
}
|
1450
|
+
/**
|
1451
|
+
* 42. 便捷方法:获取用户支付记录列表(简化版本)
|
1452
|
+
*/
|
1453
|
+
async getPaymentRecordsSimple(page = 1, pageSize = 10) {
|
1454
|
+
return this.users.getPaymentRecordsSimple(page, pageSize);
|
1455
|
+
}
|
1283
1456
|
}
|
1284
1457
|
|
1285
1458
|
export { ArticlesAPI, FormsAPI, GT6Client, GT6Error, GT6SDK, ProductsAPI, SettingsAPI, UsersAPI, GT6SDK as default };
|