wechatQrCode
This commit is contained in:
parent
80eb4bdf4e
commit
4ffcb85bdd
|
|
@ -17,7 +17,7 @@ var uuid_2 = require("oak-domain/lib/utils/uuid");
|
|||
*/
|
||||
function createWechatQrCode(options, context) {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var entity, entityId, tag, _a, permanent, props, qrCodeType, applicationId, _b, system, appId, appType, url, _c, applications, sysConfig, id, self_1, self_2, self_3, self_4, publicApp, mpApp, data, type, application, applicationType, config, _d, config2, appId_1, appSecret, config2, appId_2, appSecret, wechatInstance, result;
|
||||
var entity, entityId, tag, _a, permanent, props, qrCodeType, applicationId, _b, system, appId, appType, url, _c, applications, sysConfig, id, self_1, self_2, self_3, self_4, selfMp, self_5, publicApp, mpApp, data, type, application, applicationType, config, _d, config2, appId_1, appSecret, config2, appId_2, appSecret, wechatInstance, result;
|
||||
return tslib_1.__generator(this, function (_e) {
|
||||
switch (_e.label) {
|
||||
case 0:
|
||||
|
|
@ -65,16 +65,17 @@ function createWechatQrCode(options, context) {
|
|||
id = (0, uuid_1.generateNewId)();
|
||||
if (qrCodeType) {
|
||||
switch (qrCodeType) {
|
||||
case 'wechatPublic': {
|
||||
self_1 = applications.find(function (ele) { return ele.type === 'wechatPublic'; });
|
||||
if (!(self_1 && self_1.type === 'wechatPublic' &&
|
||||
self_1.config.isService)) {
|
||||
throw new Error('无法生成公众号二维码,服务号未正确配置');
|
||||
case 'wechatPublic':
|
||||
{
|
||||
self_1 = applications.find(function (ele) { return ele.type === 'wechatPublic'; });
|
||||
if (!(self_1 && self_1.type === 'wechatPublic' &&
|
||||
self_1.config.isService)) {
|
||||
throw new Error('无法生成公众号二维码,服务号未正确配置');
|
||||
}
|
||||
appId = self_1.id;
|
||||
appType = 'wechatPublic';
|
||||
break;
|
||||
}
|
||||
appId = self_1.id;
|
||||
appType = 'wechatPublic';
|
||||
break;
|
||||
}
|
||||
case 'wechatMpDomainUrl': {
|
||||
self_2 = applications.find(function (ele) { return ele.type === 'wechatMp'; });
|
||||
if (!(self_2.type === 'wechatMp' &&
|
||||
|
|
@ -95,6 +96,20 @@ function createWechatQrCode(options, context) {
|
|||
appType = 'wechatMpWxaCode';
|
||||
break;
|
||||
}
|
||||
case 'wechatPublicForMp': {
|
||||
self_4 = applications.find(function (ele) { return ele.type === 'wechatPublic'; });
|
||||
if (!(self_4 && self_4.type === 'wechatPublic' &&
|
||||
self_4.config.isService)) {
|
||||
throw new Error('无法生成公众号-小程序二维码,服务号未正确配置');
|
||||
}
|
||||
selfMp = applications.find(function (ele) { return ele.type = 'wechatMp'; });
|
||||
if (!selfMp.config.qrCodePrefix) {
|
||||
throw new Error('无法生成公众号-小程序二维码,小程序未正确配置');
|
||||
}
|
||||
appId = self_4.id;
|
||||
appType = 'wechatPublic';
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new Error('当前类型二维码暂不支持');
|
||||
}
|
||||
|
|
@ -106,19 +121,19 @@ function createWechatQrCode(options, context) {
|
|||
appType = sysConfig.App.qrCodeType;
|
||||
}
|
||||
else {
|
||||
self_4 = applications.find(function (ele) { return ele.id === applicationId; });
|
||||
self_5 = applications.find(function (ele) { return ele.id === applicationId; });
|
||||
// 如果本身是服务号,则优先用自己的
|
||||
if (self_4.type === 'wechatPublic' &&
|
||||
self_4.config.isService) {
|
||||
if (self_5.type === 'wechatPublic' &&
|
||||
self_5.config.isService) {
|
||||
appId = applicationId;
|
||||
appType = 'wechatPublic';
|
||||
}
|
||||
else if ((self_4 === null || self_4 === void 0 ? void 0 : self_4.type) === 'wechatMp') {
|
||||
else if ((self_5 === null || self_5 === void 0 ? void 0 : self_5.type) === 'wechatMp') {
|
||||
// 如果本身是小程序,则次优先用小程序的地址码,再次优先用二维码
|
||||
appId = self_4.id;
|
||||
if (self_4.config.qrCodePrefix) {
|
||||
appId = self_5.id;
|
||||
if (self_5.config.qrCodePrefix) {
|
||||
appType = 'wechatMpDomainUrl';
|
||||
url = "".concat(self_4.config.qrCodePrefix, "/").concat(id);
|
||||
url = "".concat(self_5.config.qrCodePrefix, "/").concat(id);
|
||||
}
|
||||
else {
|
||||
appType = 'wechatMpWxaCode';
|
||||
|
|
@ -173,6 +188,7 @@ function createWechatQrCode(options, context) {
|
|||
_d = type;
|
||||
switch (_d) {
|
||||
case 'wechatMpWxaCode': return [3 /*break*/, 2];
|
||||
case 'wechatPublicForMp': return [3 /*break*/, 3];
|
||||
case 'wechatPublic': return [3 /*break*/, 3];
|
||||
case 'wechatMpDomainUrl': return [3 /*break*/, 7];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ var BackendRuntimeContext = /** @class */ (function (_super) {
|
|||
}
|
||||
if (this.token) {
|
||||
var userState = this.token.user.userState;
|
||||
if (['disabled', 'merged'].includes(userState)) {
|
||||
if (['disabled', 'merged'].includes(userState) && !this.isReallyRoot()) {
|
||||
throw new Exception_1.OakUserDisabledException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ export class BackendRuntimeContext<ED extends EntityDict> extends AsyncContext<E
|
|||
}
|
||||
if (this.token) {
|
||||
const { userState } = this.token.user!;
|
||||
if (['disabled', 'merged'].includes(userState as string)) {
|
||||
if (['disabled', 'merged'].includes(userState as string) && !this.isReallyRoot()) {
|
||||
throw new OakUserDisabledException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue