Commit ba81485e authored by mqf_0707's avatar mqf_0707

优化capiFn

parent 26e43341
...@@ -111,6 +111,11 @@ var tornadoAPIFn = function (tornadoAPI, nickName, handle, loading, params) { re ...@@ -111,6 +111,11 @@ var tornadoAPIFn = function (tornadoAPI, nickName, handle, loading, params) { re
return [2 /*return*/, tbFn_1.getAuthUserInfo().catch(function (err) { return [2 /*return*/, tbFn_1.getAuthUserInfo().catch(function (err) {
console.log('未授权成功', err); console.log('未授权成功', err);
}).then(function (res) { }).then(function (res) {
var _a = (res || {}).nickName, nickName = _a === void 0 ? '' : _a;
if (!nickName) {
console.warn('请先登录!');
return false;
}
return exports.tornadoAPICb(params_, res, loading, tornadoAPI); return exports.tornadoAPICb(params_, res, loading, tornadoAPI);
})]; })];
} }
......
{"version":3,"file":"requestFn.js","sourceRoot":"","sources":["../../src/helpers/requestFn.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA+C;AAC/C,iCAA0C;AAC1C,iCAAmC;AACnC,IAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;AACvC,IAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAChC;;;GAGG;AACI,IAAM,GAAG,GAAG,UAAC,IAAS;IACzB,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC3E,CAAC,CAAA;AAJY,QAAA,GAAG,OAIf;AACD;;;;;;GAMG;AACI,IAAM,YAAY,GAAG,UAAO,MAAW,EAAE,GAAQ,EAAE,OAAgB,EAAE,UAAkB;;;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UAAU,cAAxB,EAAE,OAAO,GAAK,UAAU,QAAf,CAAe;qBAE5E,CAAA,WAAW,KAAK,YAAY,CAAA,EAA5B,wBAA4B;gBACrB,qBAAM,oBAAY,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,EAAA;oBAA9E,sBAAO,SAAuE,EAAA;;gBAE5E,aAAa,GAAG,OAAO,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;gBACtD,OAAO,GAAG;oBACZ,GAAG,EAAE,aAAa,GAAG,SAAS,GAAG,GAAG,GAAG,MAAM;oBAC7C,MAAM,EAAE,KAAK;oBACb,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,MAAM;iBACnB,CAAA;gBACM,qBAAM,iBAAS,CAAC,OAAO,EAAE,aAAa,CAAC,EAAA;oBAA9C,sBAAO,SAAuC,EAAA;;;KACjD,CAAA;AAfY,QAAA,WAAW,eAevB"}
\ No newline at end of file \ No newline at end of file
...@@ -33,10 +33,10 @@ declare const _default: { ...@@ -33,10 +33,10 @@ declare const _default: {
}; };
}; };
capiFn: (apiList: any, request: any) => { capiFn: (apiList: any, request: any) => {
receiveObjectPrize(params: any, failMessage: any, successMessage: any): Promise<boolean>; receiveObjectPrize(params: any): Promise<false | void>;
getVipInfo(params: any): Promise<any>; getVipInfo(params: any): Promise<any>;
receiveEnamePrize(params: any, failMessage: any, successMessage: any): Promise<boolean>; receiveEnamePrize(params: any): Promise<boolean>;
addStat(type: string | number, param?: {}): Promise<boolean>; addStat(activityId: string, type: string | number): Promise<boolean>;
}; };
tb: { tb: {
getUserAddress: (opts?: {}) => Promise<unknown>; getUserAddress: (opts?: {}) => Promise<unknown>;
......
declare const capiFn: (apiList: any, request: any) => { declare const capiFn: (apiList: any, request: any) => {
receiveObjectPrize(params: any, failMessage: any, successMessage: any): Promise<boolean>; receiveObjectPrize(params: any): Promise<false | void>;
getVipInfo(params: any): Promise<any>; getVipInfo(params: any): Promise<any>;
receiveEnamePrize(params: any, failMessage: any, successMessage: any): Promise<boolean>; receiveEnamePrize(params: any): Promise<boolean>;
addStat(type: number | string, param?: {}): Promise<boolean>; addStat(activityId: string, type: number | string): Promise<boolean>;
}; };
export default capiFn; export default capiFn;
...@@ -53,22 +53,21 @@ var utils_1 = require("../utils"); ...@@ -53,22 +53,21 @@ var utils_1 = require("../utils");
// 通用API封装方法 // 通用API封装方法
var capiFn = function (apiList, request) { var capiFn = function (apiList, request) {
return { return {
receiveObjectPrize: function (params, failMessage, successMessage) { receiveObjectPrize: function (params) {
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var _a, handle, method, ext, userAddress, _b, name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName; var _a, handle, method, ext, userAddress, _b, name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName, confirmResult, _c;
return __generator(this, function (_c) { return __generator(this, function (_d) {
switch (_c.label) { switch (_d.label) {
case 0: case 0:
_a = utils_1.getRequestParams(apiList['receiveObjectPrize']), handle = _a.handle, method = _a.method, ext = _a.ext; _a = utils_1.getRequestParams(apiList['receiveObjectPrize']), handle = _a.handle, method = _a.method, ext = _a.ext;
return [4 /*yield*/, tbFn_1.getUserAddress().catch(function (err) { return [4 /*yield*/, tbFn_1.getUserAddress().catch(function (err) {
tb_1.commonToast(err.errorMessage); tb_1.commonToast(err.errorMessage);
})]; })];
case 1: case 1:
userAddress = _c.sent(); userAddress = _d.sent();
if (!userAddress)
return [2 /*return*/, false];
_b = userAddress || {}, name = _b.name, telNumber = _b.telNumber, provinceName = _b.provinceName, cityName = _b.cityName, cityCode = _b.cityCode, countyName = _b.countyName, detailInfo = _b.detailInfo, streetName = _b.streetName; _b = userAddress || {}, name = _b.name, telNumber = _b.telNumber, provinceName = _b.provinceName, cityName = _b.cityName, cityCode = _b.cityCode, countyName = _b.countyName, detailInfo = _b.detailInfo, streetName = _b.streetName;
params = __assign({ name: name, phone: telNumber, addressDetail: detailInfo, cityCode: cityCode, city: cityName, province: provinceName, area: countyName, streetName: streetName }, params); params = __assign({ name: name, phone: telNumber, addressDetail: detailInfo, cityCode: cityCode, city: cityName, province: provinceName, area: countyName, streetName: streetName }, params);
if (!userAddress) return [3 /*break*/, 3];
return [4 /*yield*/, tb_1.commonConfirm('提示', '确认使用该收货地址:' + name + telNumber + userAddress.duibaAddress.address, function () { return [4 /*yield*/, tb_1.commonConfirm('提示', '确认使用该收货地址:' + name + telNumber + userAddress.duibaAddress.address, function () {
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var result; var result;
...@@ -79,22 +78,23 @@ var capiFn = function (apiList, request) { ...@@ -79,22 +78,23 @@ var capiFn = function (apiList, request) {
})]; })];
case 1: case 1:
result = _a.sent(); result = _a.sent();
if (result && !result.success) {
tb_1.commonToast(failMessage || '领取失败,前去“我的奖品”查看原因');
return [2 /*return*/, true];
}
if (result && result.success) { if (result && result.success) {
successMessage && tb_1.commonToast(successMessage);
return [2 /*return*/, true]; return [2 /*return*/, true];
} }
return [2 /*return*/]; return [2 /*return*/, false];
} }
}); });
}); });
})]; })];
case 2: case 2:
_c.sent(); _c = (_d.sent());
return [2 /*return*/, false]; return [3 /*break*/, 4];
case 3:
_c = false;
_d.label = 4;
case 4:
confirmResult = _c;
return [2 /*return*/, confirmResult];
} }
}); });
}); });
...@@ -120,7 +120,7 @@ var capiFn = function (apiList, request) { ...@@ -120,7 +120,7 @@ var capiFn = function (apiList, request) {
}); });
}); });
}, },
receiveEnamePrize: function (params, failMessage, successMessage) { receiveEnamePrize: function (params) {
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var _a, handle, method, ext, result; var _a, handle, method, ext, result;
return __generator(this, function (_b) { return __generator(this, function (_b) {
...@@ -132,12 +132,7 @@ var capiFn = function (apiList, request) { ...@@ -132,12 +132,7 @@ var capiFn = function (apiList, request) {
})]; })];
case 1: case 1:
result = _b.sent(); result = _b.sent();
if (result && !result.success) {
tb_1.commonToast(failMessage || '领取失败,前去“我的奖品”查看原因');
return [2 /*return*/, true];
}
if (result && result.success) { if (result && result.success) {
successMessage && tb_1.commonToast(successMessage);
return [2 /*return*/, true]; return [2 /*return*/, true];
} }
return [2 /*return*/, false]; return [2 /*return*/, false];
...@@ -145,15 +140,17 @@ var capiFn = function (apiList, request) { ...@@ -145,15 +140,17 @@ var capiFn = function (apiList, request) {
}); });
}); });
}, },
addStat: function (type, param) { addStat: function (activityId, type) {
if (param === void 0) { param = {}; }
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var _a, handle, method, ext, result; var _a, handle, method, ext, result;
return __generator(this, function (_b) { return __generator(this, function (_b) {
switch (_b.label) { switch (_b.label) {
case 0: case 0:
_a = utils_1.getRequestParams(apiList['addStat']), handle = _a.handle, method = _a.method, ext = _a.ext; _a = utils_1.getRequestParams(apiList['addStat']), handle = _a.handle, method = _a.method, ext = _a.ext;
return [4 /*yield*/, request(handle, method, __assign({ type: type }, param), ext).catch(function (res) { return [4 /*yield*/, request(handle, method, {
activityId: activityId,
type: type
}, ext).catch(function (res) {
tb_1.commonToast(res && res.message); tb_1.commonToast(res && res.message);
})]; })];
case 1: case 1:
......
{"version":3,"file":"capiFn.js","sourceRoot":"","sources":["../../src/request/capiFn.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAwD;AACxD,qCAA8C;AAC9C,kCAA4C;AAE5C,YAAY;AACZ,IAAM,MAAM,GAAG,UAAC,OAAO,EAAE,OAAO;IAC9B,OAAO;QACC,kBAAkB,EAAxB,UAAyB,MAAM,EAAC,WAAW,EAAC,cAAc;;;;;;4BAClD,KAA0B,wBAAgB,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,EAAvE,MAAM,YAAA,EAAE,MAAM,YAAA,EAAE,GAAG,SAAA,CAAqD;4BAClD,qBAAM,qBAAc,EAAE,CAAC,KAAK,CAAC,UAAA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,MAAM,CAAC,OAAO,EAAE;gCAC5B,sBAAO,IAAI,EAAC;6BACb;4BACD,sBAAO,KAAK,EAAC;;;;SACd;KACF,CAAA;AACH,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
\ No newline at end of file \ No newline at end of file
...@@ -65,5 +65,9 @@ export declare const formatTimeStamp: (ms: number) => string; ...@@ -65,5 +65,9 @@ export declare const formatTimeStamp: (ms: number) => string;
* @param endTime * @param endTime
* @param noCheck * @param noCheck
*/ */
export declare const validateActivityStatus: (startTime: number, endTime: number, noCheck: boolean) => Promise<unknown>; export declare const validateActivityStatus: (checkParam: {
startTime: number;
endTime: number;
noCheck: boolean;
}) => Promise<unknown>;
export {}; export {};
...@@ -154,13 +154,6 @@ var generateAPI = function (apiList, request) { ...@@ -154,13 +154,6 @@ var generateAPI = function (apiList, request) {
}; };
}); });
return api; return api;
// return Object.keys(apiList).reduce((prev, curr) => {
// const { handle, method, ext, defaultParams } = getRequestParams(apiList[curr]);
// return {
// ...prev,
// [curr]: params => request(handle, method, Object.assign({}, defaultParams, params) , ext)
// }
// }, {})
}; };
exports.generateAPI = generateAPI; exports.generateAPI = generateAPI;
/** /**
...@@ -214,6 +207,10 @@ var checkIsMember = function (sellerId) { return __awaiter(void 0, void 0, void ...@@ -214,6 +207,10 @@ var checkIsMember = function (sellerId) { return __awaiter(void 0, void 0, void
var memberPlugin; var memberPlugin;
return __generator(this, function (_a) { return __generator(this, function (_a) {
memberPlugin = requirePlugin("cemMember"); memberPlugin = requirePlugin("cemMember");
if (!memberPlugin) {
console.log('会员检查失败 :>> 请先申请入会插件');
return [2 /*return*/, false];
}
return [2 /*return*/, new Promise(function (resolve, reject) { return [2 /*return*/, new Promise(function (resolve, reject) {
memberPlugin.checkMember({ memberPlugin.checkMember({
sellerId: sellerId, sellerId: sellerId,
...@@ -251,13 +248,16 @@ exports.formatTimeStamp = formatTimeStamp; ...@@ -251,13 +248,16 @@ exports.formatTimeStamp = formatTimeStamp;
* @param endTime * @param endTime
* @param noCheck * @param noCheck
*/ */
var validateActivityStatus = function (startTime, endTime, noCheck) { return __awaiter(void 0, void 0, void 0, function () { var validateActivityStatus = function (checkParam) { return __awaiter(void 0, void 0, void 0, function () {
var nowTime; var nowTime, startTime, endTime, noCheck;
return __generator(this, function (_a) { return __generator(this, function (_a) {
switch (_a.label) { switch (_a.label) {
case 0: return [4 /*yield*/, tb_1.getServerTime()]; case 0: return [4 /*yield*/, tb_1.getServerTime()];
case 1: case 1:
nowTime = _a.sent(); nowTime = _a.sent();
startTime = checkParam.startTime, endTime = checkParam.endTime, noCheck = checkParam.noCheck;
if (!startTime || !endTime)
return [2 /*return*/, false];
return [2 /*return*/, new Promise(function (resolve, reject) { return [2 /*return*/, new Promise(function (resolve, reject) {
if (nowTime < startTime) { if (nowTime < startTime) {
tb_1.commonToast('活动未开始'); tb_1.commonToast('活动未开始');
......
This diff is collapsed.
...@@ -61,7 +61,12 @@ export const tornadoAPIFn = async (tornadoAPI: string, nickName: string, handle: ...@@ -61,7 +61,12 @@ export const tornadoAPIFn = async (tornadoAPI: string, nickName: string, handle:
if (!nickName) { if (!nickName) {
return getAuthUserInfo().catch(err => { return getAuthUserInfo().catch(err => {
console.log('未授权成功', err); console.log('未授权成功', err);
}).then(res=> { }).then((res: { nickName: string, avatar: string }) => {
const { nickName = '' } = res || {}
if(!nickName) {
console.warn('请先登录!')
return false
}
return tornadoAPICb(params_, res, loading, tornadoAPI) return tornadoAPICb(params_, res, loading, tornadoAPI)
}) })
} }
......
...@@ -5,12 +5,12 @@ import { getRequestParams } from '../utils'; ...@@ -5,12 +5,12 @@ import { getRequestParams } from '../utils';
// 通用API封装方法 // 通用API封装方法
const capiFn = (apiList, request) => { const capiFn = (apiList, request) => {
return { return {
async receiveObjectPrize(params,failMessage,successMessage) { async receiveObjectPrize(params) {
const { handle, method, ext } = getRequestParams(apiList['receiveObjectPrize']); const { handle, method, ext } = getRequestParams(apiList['receiveObjectPrize']);
const userAddress: IAddress = await getUserAddress().catch(err => { const userAddress: IAddress = await getUserAddress().catch(err => {
commonToast(err.errorMessage); commonToast(err.errorMessage);
}); });
if(!userAddress) return false // if(!userAddress) return false
const { name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName } = userAddress || {}; const { name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName } = userAddress || {};
params = { params = {
name, name,
...@@ -23,20 +23,16 @@ const capiFn = (apiList, request) => { ...@@ -23,20 +23,16 @@ const capiFn = (apiList, request) => {
streetName, streetName,
...params ...params
} }
await commonConfirm('提示', '确认使用该收货地址:' + name + telNumber + userAddress.duibaAddress.address, async function() { const confirmResult = userAddress ? (await commonConfirm('提示', '确认使用该收货地址:' + name + telNumber + userAddress.duibaAddress.address, async function() {
const result = await request(handle, method, params, ext).catch(res => { const result = await request(handle, method, params, ext).catch(res => {
commonToast(res && res.message); commonToast(res && res.message);
}); });
if (result && !result.success) {
commonToast(failMessage || '领取失败,前去“我的奖品”查看原因');
return true;
}
if (result && result.success) { if (result && result.success) {
successMessage && commonToast(successMessage)
return true; return true;
} }
}) return false
return false })) : false
return confirmResult
}, },
async getVipInfo(params) { async getVipInfo(params) {
...@@ -51,27 +47,22 @@ const capiFn = (apiList, request) => { ...@@ -51,27 +47,22 @@ const capiFn = (apiList, request) => {
return false; return false;
}, },
async receiveEnamePrize(params,failMessage,successMessage) { async receiveEnamePrize(params) {
const { handle, method, ext } = getRequestParams(apiList['receiveEnamePrize']); const { handle, method, ext } = getRequestParams(apiList['receiveEnamePrize']);
const result = await request(handle, method, params, ext).catch(res => { const result = await request(handle, method, params, ext).catch(res => {
commonToast(res && res.message); commonToast(res && res.message);
}); });
if (result && !result.success) {
commonToast(failMessage || '领取失败,前去“我的奖品”查看原因');
return true;
}
if (result && result.success) { if (result && result.success) {
successMessage && commonToast(successMessage)
return true; return true;
} }
return false; return false;
}, },
async addStat(type: number | string, param = {}) { async addStat(activityId: string, type: number | string) {
const { handle, method, ext } = getRequestParams(apiList['addStat']); const { handle, method, ext } = getRequestParams(apiList['addStat']);
const result = await request(handle, method, { const result = await request(handle, method, {
type, activityId,
...param type
}, ext).catch(res => { }, ext).catch(res => {
commonToast(res && res.message); commonToast(res && res.message);
}); });
......
...@@ -98,13 +98,6 @@ export const generateAPI = <T, K extends Function>(apiList: T, request: K): IApi ...@@ -98,13 +98,6 @@ export const generateAPI = <T, K extends Function>(apiList: T, request: K): IApi
}); });
return api; return api;
// return Object.keys(apiList).reduce((prev, curr) => {
// const { handle, method, ext, defaultParams } = getRequestParams(apiList[curr]);
// return {
// ...prev,
// [curr]: params => request(handle, method, Object.assign({}, defaultParams, params) , ext)
// }
// }, {})
}; };
/** /**
* 函数节流,普通防连点 * 函数节流,普通防连点
...@@ -144,6 +137,10 @@ export const getImgShareUrl = async (fileId: string | Array<string>) => { ...@@ -144,6 +137,10 @@ export const getImgShareUrl = async (fileId: string | Array<string>) => {
export const checkIsMember = async (sellerId: number) => { export const checkIsMember = async (sellerId: number) => {
// @ts-ignore // @ts-ignore
const memberPlugin = requirePlugin("cemMember"); const memberPlugin = requirePlugin("cemMember");
if(!memberPlugin) {
console.log('会员检查失败 :>> 请先申请入会插件')
return false
}
return new Promise((resolve,reject) => { return new Promise((resolve,reject) => {
memberPlugin.checkMember({ memberPlugin.checkMember({
sellerId, sellerId,
...@@ -179,8 +176,10 @@ export const formatTimeStamp = (ms: number) => { ...@@ -179,8 +176,10 @@ export const formatTimeStamp = (ms: number) => {
* @param endTime * @param endTime
* @param noCheck * @param noCheck
*/ */
export const validateActivityStatus = async (startTime: number, endTime: number, noCheck: boolean) => { export const validateActivityStatus = async (checkParam: { startTime: number, endTime: number, noCheck: boolean }) => {
const nowTime = await getServerTime() const nowTime = await getServerTime()
const { startTime, endTime, noCheck } = checkParam
if(!startTime || !endTime) return false
return new Promise((resolve,reject) => { return new Promise((resolve,reject) => {
if(nowTime < startTime ) { if(nowTime < startTime ) {
commonToast('活动未开始') commonToast('活动未开始')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment