75 lines
1.8 KiB
JavaScript
Raw Normal View History

2024-10-25 18:09:59 +08:00
/* eslint-disable @typescript-eslint/no-this-alias */
2024-10-23 09:14:01 +08:00
import moduleHelper from './module-helper';
export default {
handleText(s, f, c) {
const self = this;
return {
success(res) {
self.textFormat(s, res);
},
fail(res) {
self.textFormat(f, res);
},
complete(res) {
self.textFormat(c, res);
},
};
},
handleTextLongBack(s, f, c) {
const self = this;
return {
success(res) {
self.textFormatLongBack(s, res);
},
fail(res) {
self.textFormatLongBack(f, res);
},
complete(res) {
self.textFormatLongBack(c, res);
},
};
},
textFormat(id, res) {
if (!id) {
return false;
}
moduleHelper.send('TextResponseCallback', JSON.stringify({
callbackId: id,
errMsg: res.errMsg,
errCode: res.errCode,
}));
},
textFormatLongBack(id, res) {
if (!id) {
return false;
}
moduleHelper.send('TextResponseLongCallback', JSON.stringify({
callbackId: id,
errMsg: res.errMsg,
errCode: res.errCode,
}));
},
handle(formatFunc, s, f, c) {
return {
success(res) {
if (!s) {
return false;
}
formatFunc(s, res);
},
fail(res) {
if (!f) {
return false;
}
formatFunc(f, res);
},
complete(res) {
if (!c) {
return false;
}
formatFunc(c, res);
},
};
},
};