Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-general-business into dev
This commit is contained in:
commit
7c7684b163
|
|
@ -94,13 +94,87 @@ function tryMakeChangeLoginWay(userId, context) {
|
|||
});
|
||||
});
|
||||
}
|
||||
function dealWithUserState(user, context, tokenData) {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b, user2;
|
||||
var _c, _d;
|
||||
return tslib_1.__generator(this, function (_e) {
|
||||
switch (_e.label) {
|
||||
case 0:
|
||||
_a = user.userState;
|
||||
switch (_a) {
|
||||
case 'disabled': return [3 /*break*/, 1];
|
||||
case 'shadow': return [3 /*break*/, 2];
|
||||
case 'merged': return [3 /*break*/, 4];
|
||||
}
|
||||
return [3 /*break*/, 7];
|
||||
case 1:
|
||||
{
|
||||
throw new Exception_1.OakUserDisabledException();
|
||||
}
|
||||
_e.label = 2;
|
||||
case 2:
|
||||
_c = {
|
||||
userId: user.id
|
||||
};
|
||||
_d = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 3: return [2 /*return*/, (_c.user = (_d.id = _e.sent(),
|
||||
_d.action = 'activate',
|
||||
_d.data = {},
|
||||
_d),
|
||||
_c)];
|
||||
case 4:
|
||||
(0, assert_1.assert)(user === null || user === void 0 ? void 0 : user.refId);
|
||||
return [4 /*yield*/, context.select('user', {
|
||||
data: {
|
||||
id: 1,
|
||||
userState: 1,
|
||||
refId: 1,
|
||||
wechatUser$user: {
|
||||
$entity: 'wechatUser',
|
||||
data: {
|
||||
id: 1,
|
||||
},
|
||||
},
|
||||
userSystem$user: {
|
||||
$entity: 'userSystem',
|
||||
data: {
|
||||
id: 1,
|
||||
systemId: 1,
|
||||
},
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
id: user.refId,
|
||||
}
|
||||
}, {
|
||||
dontCollect: true,
|
||||
})];
|
||||
case 5:
|
||||
_b = tslib_1.__read.apply(void 0, [_e.sent(), 1]), user2 = _b[0];
|
||||
return [4 /*yield*/, dealWithUserState(user2, context, tokenData)];
|
||||
case 6: return [2 /*return*/, _e.sent()];
|
||||
case 7:
|
||||
{
|
||||
(0, assert_1.assert)(user.userState === 'normal');
|
||||
return [2 /*return*/, {
|
||||
userId: user.id,
|
||||
}];
|
||||
}
|
||||
_e.label = 8;
|
||||
case 8: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
function setupMobile(mobile, env, context) {
|
||||
var _a;
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var currentToken, applicationId, systemId, result2, _b, mobileRow, userId, user, userState, _c, tokenData, user, userState, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, mobileData, _p, _q, _r, userData, _s, _t, _u, mobileData, tokenData, _v, _w, _x, _y, _z, _0;
|
||||
var _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14;
|
||||
return tslib_1.__generator(this, function (_15) {
|
||||
switch (_15.label) {
|
||||
var currentToken, applicationId, systemId, result2, _b, mobileRow, userId, user, userState, _c, tokenData, user, userState, _d, _e, _f, _g, _h, _j, _k, _l, _m, mobileData, _o, _p, _q, userData, _r, _s, _t, mobileData, tokenData, _u, _v, _w, _x, _y, _z;
|
||||
var _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
|
||||
return tslib_1.__generator(this, function (_12) {
|
||||
switch (_12.label) {
|
||||
case 0:
|
||||
currentToken = context.getToken(true);
|
||||
applicationId = context.getApplicationId();
|
||||
|
|
@ -114,6 +188,7 @@ function setupMobile(mobile, env, context) {
|
|||
user: {
|
||||
id: 1,
|
||||
userState: 1,
|
||||
refId: 1,
|
||||
wechatUser$user: {
|
||||
$entity: 'wechatUser',
|
||||
data: {
|
||||
|
|
@ -135,8 +210,8 @@ function setupMobile(mobile, env, context) {
|
|||
}
|
||||
}, { dontCollect: true })];
|
||||
case 1:
|
||||
result2 = _15.sent();
|
||||
if (!(result2.length > 0)) return [3 /*break*/, 23];
|
||||
result2 = _12.sent();
|
||||
if (!(result2.length > 0)) return [3 /*break*/, 19];
|
||||
// 此手机号已经存在
|
||||
(0, assert_1.assert)(result2.length === 1);
|
||||
_b = tslib_1.__read(result2, 1), mobileRow = _b[0];
|
||||
|
|
@ -156,13 +231,13 @@ function setupMobile(mobile, env, context) {
|
|||
{
|
||||
throw new Exception_1.OakUserDisabledException();
|
||||
}
|
||||
_15.label = 4;
|
||||
_12.label = 4;
|
||||
case 4:
|
||||
// 直接合并
|
||||
return [4 /*yield*/, (0, user_1.mergeUser)({ from: userId, to: currentToken.userId }, context, true)];
|
||||
case 5:
|
||||
// 直接合并
|
||||
_15.sent();
|
||||
_12.sent();
|
||||
return [2 /*return*/, currentToken.id];
|
||||
case 6:
|
||||
/* assert(userState === 'normal');
|
||||
|
|
@ -173,170 +248,142 @@ function setupMobile(mobile, env, context) {
|
|||
/* assert(userState === 'normal');
|
||||
throw await makeDistinguishException<ED, Cxt>(userId as string, context, '该手机号已被一个有效用户占用,请联系管理员处理'); */
|
||||
// 直接合并
|
||||
_15.sent();
|
||||
_12.sent();
|
||||
return [2 /*return*/, currentToken.id];
|
||||
case 8: return [3 /*break*/, 22];
|
||||
case 8: return [3 /*break*/, 18];
|
||||
case 9:
|
||||
_1 = {};
|
||||
_0 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 10:
|
||||
tokenData = (_1.id = _15.sent(),
|
||||
_1.applicationId = applicationId,
|
||||
_1.playerId = mobileRow.userId,
|
||||
_1.env = env,
|
||||
_1.entity = 'mobile',
|
||||
_1.entityId = mobileRow.id,
|
||||
_1);
|
||||
tokenData = (_0.id = _12.sent(),
|
||||
_0.applicationId = applicationId,
|
||||
_0.playerId = mobileRow.userId,
|
||||
_0.env = env,
|
||||
_0.entity = 'mobile',
|
||||
_0.entityId = mobileRow.id,
|
||||
_0);
|
||||
user = mobileRow.user;
|
||||
userState = user.userState;
|
||||
_d = userState;
|
||||
switch (_d) {
|
||||
case 'disabled': return [3 /*break*/, 11];
|
||||
case 'shadow': return [3 /*break*/, 12];
|
||||
}
|
||||
return [3 /*break*/, 14];
|
||||
// 可能出现多次merge的情况
|
||||
_e = (_d = Object).assign;
|
||||
_f = [tokenData];
|
||||
return [4 /*yield*/, dealWithUserState(user, context, tokenData)];
|
||||
case 11:
|
||||
{
|
||||
throw new Exception_1.OakUserDisabledException();
|
||||
}
|
||||
_15.label = 12;
|
||||
case 12:
|
||||
_f = (_e = Object).assign;
|
||||
_g = [tokenData];
|
||||
_2 = {
|
||||
userId: mobileRow.userId
|
||||
};
|
||||
// 可能出现多次merge的情况
|
||||
_e.apply(_d, _f.concat([_12.sent()]));
|
||||
_h = (_g = context).operate;
|
||||
_j = ['token'];
|
||||
_1 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 12: return [4 /*yield*/, _h.apply(_g, _j.concat([(_1.id = _12.sent(),
|
||||
_1.data = tokenData,
|
||||
_1.action = 'create',
|
||||
_1), {
|
||||
dontCollect: true,
|
||||
}]))];
|
||||
case 13:
|
||||
_12.sent();
|
||||
if (!(((_a = user === null || user === void 0 ? void 0 : user.userSystem$user) === null || _a === void 0 ? void 0 : _a.length) == 0)) return [3 /*break*/, 17];
|
||||
_l = (_k = context).operate;
|
||||
_m = ['userSystem'];
|
||||
_2 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 14:
|
||||
_2.id = _12.sent(),
|
||||
_2.action = 'create';
|
||||
_3 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 13:
|
||||
_f.apply(_e, _g.concat([(_2.user = (_3.id = _15.sent(),
|
||||
_3.action = 'activate',
|
||||
_3.data = {},
|
||||
case 15: return [4 /*yield*/, _l.apply(_k, _m.concat([(_2.data = (_3.id = _12.sent(),
|
||||
_3.userId = user.id,
|
||||
_3.systemId = systemId,
|
||||
_3),
|
||||
_2)]));
|
||||
return [3 /*break*/, 15];
|
||||
case 14:
|
||||
{
|
||||
(0, assert_1.assert)(userState === 'normal');
|
||||
Object.assign(tokenData, {
|
||||
userId: mobileRow.userId,
|
||||
});
|
||||
}
|
||||
_15.label = 15;
|
||||
case 15:
|
||||
_j = (_h = context).operate;
|
||||
_k = ['token'];
|
||||
_2), {
|
||||
dontCollect: true,
|
||||
}]))];
|
||||
case 16:
|
||||
_12.sent();
|
||||
_12.label = 17;
|
||||
case 17: return [2 /*return*/, tokenData.id];
|
||||
case 18: return [3 /*break*/, 34];
|
||||
case 19:
|
||||
if (!currentToken) return [3 /*break*/, 23];
|
||||
_4 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 16: return [4 /*yield*/, _j.apply(_h, _k.concat([(_4.id = _15.sent(),
|
||||
_4.data = tokenData,
|
||||
_4.action = 'create',
|
||||
_4), {
|
||||
dontCollect: true,
|
||||
}]))];
|
||||
case 17:
|
||||
_15.sent();
|
||||
if (!(((_a = user === null || user === void 0 ? void 0 : user.userSystem$user) === null || _a === void 0 ? void 0 : _a.length) == 0)) return [3 /*break*/, 21];
|
||||
_m = (_l = context).operate;
|
||||
_o = ['userSystem'];
|
||||
case 20:
|
||||
mobileData = (_4.id = _12.sent(),
|
||||
_4.mobile = mobile,
|
||||
_4.userId = currentToken.userId,
|
||||
_4);
|
||||
_p = (_o = context).operate;
|
||||
_q = ['mobile'];
|
||||
_5 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 18:
|
||||
_5.id = _15.sent(),
|
||||
_5.action = 'create';
|
||||
case 21: return [4 /*yield*/, _p.apply(_o, _q.concat([(_5.id = _12.sent(),
|
||||
_5.action = 'create',
|
||||
_5.data = mobileData,
|
||||
_5), {}]))];
|
||||
case 22:
|
||||
_12.sent();
|
||||
return [2 /*return*/, currentToken.id];
|
||||
case 23:
|
||||
_6 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 19: return [4 /*yield*/, _m.apply(_l, _o.concat([(_5.data = (_6.id = _15.sent(),
|
||||
_6.userId = user.id,
|
||||
_6.systemId = systemId,
|
||||
_6),
|
||||
_5), {
|
||||
dontCollect: true,
|
||||
}]))];
|
||||
case 20:
|
||||
_15.sent();
|
||||
_15.label = 21;
|
||||
case 21: return [2 /*return*/, tokenData.id];
|
||||
case 22: return [3 /*break*/, 38];
|
||||
case 23:
|
||||
if (!currentToken) return [3 /*break*/, 27];
|
||||
case 24:
|
||||
userData = (_6.id = _12.sent(),
|
||||
_6.userState = 'normal',
|
||||
_6);
|
||||
_s = (_r = context).operate;
|
||||
_t = ['user'];
|
||||
_7 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 24:
|
||||
mobileData = (_7.id = _15.sent(),
|
||||
_7.mobile = mobile,
|
||||
_7.userId = currentToken.userId,
|
||||
_7);
|
||||
_q = (_p = context).operate;
|
||||
_r = ['mobile'];
|
||||
case 25: return [4 /*yield*/, _s.apply(_r, _t.concat([(_7.id = _12.sent(),
|
||||
_7.action = 'create',
|
||||
_7.data = userData,
|
||||
_7), {}]))];
|
||||
case 26:
|
||||
_12.sent();
|
||||
_8 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 25: return [4 /*yield*/, _q.apply(_p, _r.concat([(_8.id = _15.sent(),
|
||||
_8.action = 'create',
|
||||
_8.data = mobileData,
|
||||
_8), {}]))];
|
||||
case 26:
|
||||
_15.sent();
|
||||
return [2 /*return*/, currentToken.id];
|
||||
case 27:
|
||||
mobileData = (_8.id = _12.sent(),
|
||||
_8.mobile = mobile,
|
||||
_8.userId = userData.id,
|
||||
_8);
|
||||
_9 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 28:
|
||||
userData = (_9.id = _15.sent(),
|
||||
_9.userState = 'normal',
|
||||
tokenData = (_9.id = _12.sent(),
|
||||
_9.userId = userData.id,
|
||||
_9.playerId = userData.id,
|
||||
_9.env = env,
|
||||
_9.entity = 'mobile',
|
||||
_9.entityId = mobileData.id,
|
||||
_9);
|
||||
_t = (_s = context).operate;
|
||||
_u = ['user'];
|
||||
_v = (_u = context).operate;
|
||||
_w = ['token'];
|
||||
_10 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 29: return [4 /*yield*/, _t.apply(_s, _u.concat([(_10.id = _15.sent(),
|
||||
case 29: return [4 /*yield*/, _v.apply(_u, _w.concat([(_10.id = _12.sent(),
|
||||
_10.action = 'create',
|
||||
_10.data = userData,
|
||||
_10), {}]))];
|
||||
_10.data = tokenData,
|
||||
_10), { dontCollect: true }]))];
|
||||
case 30:
|
||||
_15.sent();
|
||||
_12.sent();
|
||||
return [4 /*yield*/, context.setTokenValue(tokenData.id)];
|
||||
case 31:
|
||||
_12.sent();
|
||||
_y = (_x = context).operate;
|
||||
_z = ['mobile'];
|
||||
_11 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 31:
|
||||
mobileData = (_11.id = _15.sent(),
|
||||
_11.mobile = mobile,
|
||||
_11.userId = userData.id,
|
||||
_11);
|
||||
_12 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 32:
|
||||
tokenData = (_12.id = _15.sent(),
|
||||
_12.userId = userData.id,
|
||||
_12.playerId = userData.id,
|
||||
_12.env = env,
|
||||
_12.entity = 'mobile',
|
||||
_12.entityId = mobileData.id,
|
||||
_12);
|
||||
_w = (_v = context).operate;
|
||||
_x = ['token'];
|
||||
_13 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 33: return [4 /*yield*/, _w.apply(_v, _x.concat([(_13.id = _15.sent(),
|
||||
_13.action = 'create',
|
||||
_13.data = tokenData,
|
||||
_13), { dontCollect: true }]))];
|
||||
case 34:
|
||||
_15.sent();
|
||||
return [4 /*yield*/, context.setTokenValue(tokenData.id)];
|
||||
case 35:
|
||||
_15.sent();
|
||||
_z = (_y = context).operate;
|
||||
_0 = ['mobile'];
|
||||
_14 = {};
|
||||
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
|
||||
case 36: return [4 /*yield*/, _z.apply(_y, _0.concat([(_14.id = _15.sent(),
|
||||
_14.action = 'create',
|
||||
_14.data = mobileData,
|
||||
_14), { dontCollect: true }]))];
|
||||
case 37:
|
||||
_15.sent();
|
||||
case 32: return [4 /*yield*/, _y.apply(_x, _z.concat([(_11.id = _12.sent(),
|
||||
_11.action = 'create',
|
||||
_11.data = mobileData,
|
||||
_11), { dontCollect: true }]))];
|
||||
case 33:
|
||||
_12.sent();
|
||||
return [2 /*return*/, tokenData.id];
|
||||
case 38: return [2 /*return*/];
|
||||
case 34: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ declare type Router = {
|
|||
pathname: string;
|
||||
props?: Record<string, any>;
|
||||
state?: Record<string, any>;
|
||||
isTabBar?: boolean;
|
||||
};
|
||||
declare type MessageRestriction = {
|
||||
systemIds?: string[];
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ export declare type RedirectToProps = {
|
|||
pathname: string;
|
||||
props?: Record<string, any>;
|
||||
state?: Record<string, any>;
|
||||
isTabBar?: boolean;
|
||||
};
|
||||
export interface Schema extends EntityShape {
|
||||
entity: String<32>;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ export declare type WechatQrCodeProps = {
|
|||
pathname: string;
|
||||
props?: Record<string, any>;
|
||||
state?: Record<string, any>;
|
||||
isTabBar?: boolean;
|
||||
};
|
||||
export interface Schema extends EntityShape {
|
||||
entity: String<32>;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ declare type Router = {
|
|||
pathname: string;
|
||||
props?: Record<string, any>;
|
||||
state?: Record<string, any>;
|
||||
isTabBar?: boolean;
|
||||
};
|
||||
declare type MessageRestriction = {
|
||||
systemIds?: string[];
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export declare type RedirectToProps = {
|
|||
pathname: string;
|
||||
props?: Record<string, any>;
|
||||
state?: Record<string, any>;
|
||||
isTabBar?: boolean;
|
||||
};
|
||||
export declare type OpSchema = EntityShape & {
|
||||
entity: "role" | string;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export declare type WechatQrCodeProps = {
|
|||
pathname: string;
|
||||
props?: Record<string, any>;
|
||||
state?: Record<string, any>;
|
||||
isTabBar?: boolean;
|
||||
};
|
||||
export declare type OpSchema = EntityShape & {
|
||||
entity: "user" | "userEntityGrant" | string;
|
||||
|
|
|
|||
|
|
@ -141,9 +141,13 @@ exports.default = OakComponent({
|
|||
});
|
||||
return;
|
||||
}
|
||||
var pathname = redirectTo.pathname, _a = redirectTo.props, props = _a === void 0 ? {} : _a, _b = redirectTo.state, state = _b === void 0 ? {} : _b;
|
||||
var pathname = redirectTo.pathname, props = redirectTo.props, state = redirectTo.state, isTabBar = redirectTo.isTabBar;
|
||||
var url = pathname.substring(0, 1) === '/' ? pathname : "/".concat(pathname);
|
||||
this.redirectTo(tslib_1.__assign({ url: url }, props), state);
|
||||
if (isTabBar) {
|
||||
this.switchTab(tslib_1.__assign({ url: url }, (props || {})), state);
|
||||
return;
|
||||
}
|
||||
this.redirectTo(tslib_1.__assign({ url: url }, (props || {})), state);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@
|
|||
</block>
|
||||
|
||||
<block wx:elif="{{redirectTo && !oakLoading && !expired && (hasConfirmed || !!(granteeId && userId === granteeId) )}}">
|
||||
<l-button l-class="btn" type="success" style="margin: 16rpx" size="large" bind:lintap="redirectPage" disabled="{{!redirectTo}}">
|
||||
领取成功{{redirectTo ? '(' + redirectCounter + 's)' : '' }}
|
||||
<l-button l-class="btn" type="success" style="margin: 16rpx" size="large" bind:lintap="redirectPage">
|
||||
领取成功{{redirectTo && redirectCounter > 0 ? '(' + redirectCounter + 's)' : '' }}
|
||||
</l-button>
|
||||
</block>
|
||||
</view>
|
||||
|
|
@ -83,6 +83,59 @@ async function tryMakeChangeLoginWay<ED extends EntityDict, Cxt extends BackendR
|
|||
}
|
||||
}
|
||||
|
||||
async function dealWithUserState(user: Partial<EntityDict['user']['Schema']>, context: BackendRuntimeContext<EntityDict>, tokenData: EntityDict['token']['CreateSingle']['data']): Promise<Partial<EntityDict['token']['CreateSingle']['data']>> {
|
||||
switch (user.userState) {
|
||||
case 'disabled': {
|
||||
throw new OakUserDisabledException();
|
||||
}
|
||||
case 'shadow': {
|
||||
return {
|
||||
userId: user.id,
|
||||
user: {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'activate',
|
||||
data: {},
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'merged': {
|
||||
assert(user?.refId);
|
||||
const [user2] = await context.select('user', {
|
||||
data: {
|
||||
id: 1,
|
||||
userState: 1,
|
||||
refId: 1,
|
||||
wechatUser$user: {
|
||||
$entity: 'wechatUser',
|
||||
data: {
|
||||
id: 1,
|
||||
},
|
||||
},
|
||||
userSystem$user: {
|
||||
$entity: 'userSystem',
|
||||
data: {
|
||||
id: 1,
|
||||
systemId: 1,
|
||||
},
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
id: user.refId,
|
||||
}
|
||||
}, {
|
||||
dontCollect: true,
|
||||
})
|
||||
return await dealWithUserState(user2, context, tokenData);
|
||||
}
|
||||
default: {
|
||||
assert(user.userState === 'normal');
|
||||
return {
|
||||
userId: user.id,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function setupMobile<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(mobile: string, env: WebEnv | WechatMpEnv, context: Cxt) {
|
||||
const currentToken = context.getToken(true);
|
||||
const applicationId = context.getApplicationId();
|
||||
|
|
@ -97,6 +150,7 @@ async function setupMobile<ED extends EntityDict, Cxt extends BackendRuntimeCont
|
|||
user: {
|
||||
id: 1,
|
||||
userState: 1,
|
||||
refId: 1,
|
||||
wechatUser$user: {
|
||||
$entity: 'wechatUser',
|
||||
data: {
|
||||
|
|
@ -161,29 +215,9 @@ async function setupMobile<ED extends EntityDict, Cxt extends BackendRuntimeCont
|
|||
};
|
||||
const { user } = mobileRow;
|
||||
const { userState } = user!;
|
||||
switch (userState) {
|
||||
case 'disabled': {
|
||||
throw new OakUserDisabledException();
|
||||
}
|
||||
case 'shadow': {
|
||||
Object.assign(tokenData, {
|
||||
userId: mobileRow.userId,
|
||||
user: {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'activate',
|
||||
data: {},
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
assert(userState === 'normal');
|
||||
Object.assign(tokenData, {
|
||||
userId: mobileRow.userId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 可能出现多次merge的情况
|
||||
Object.assign(tokenData, await dealWithUserState(user as Partial<EntityDict['user']['Schema']>, context as BackendRuntimeContext<EntityDict>, tokenData));
|
||||
await context.operate('token', {
|
||||
id: await generateNewIdAsync(),
|
||||
data: tokenData,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ type Router = {
|
|||
pathname: string;
|
||||
props?: Record<string, any>;
|
||||
state?: Record<string, any>;
|
||||
isTabBar?: boolean; //小程序独有 小程序跳回tabBar的话 必须使用 wx.switchTab
|
||||
};
|
||||
|
||||
type MessageRestriction = {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ export type RedirectToProps = {
|
|||
pathname: string;
|
||||
props?: Record<string, any>;
|
||||
state?: Record<string, any>;
|
||||
isTabBar?: boolean; //小程序独有 小程序跳回tabBar的话 必须使用 wx.switchTab
|
||||
};
|
||||
|
||||
export interface Schema extends EntityShape {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ export type WechatQrCodeProps = {
|
|||
pathname: string;
|
||||
props?: Record<string, any>;
|
||||
state?: Record<string, any>;
|
||||
isTabBar?: boolean; //小程序独有 小程序跳回tabBar的话 必须使用 wx.switchTab
|
||||
};
|
||||
|
||||
export interface Schema extends EntityShape {
|
||||
|
|
|
|||
|
|
@ -117,13 +117,24 @@ export default OakComponent({
|
|||
});
|
||||
return;
|
||||
}
|
||||
const { pathname, props = {}, state = {} } = redirectTo;
|
||||
const { pathname, props, state, isTabBar } = redirectTo;
|
||||
const url =
|
||||
pathname.substring(0, 1) === '/' ? pathname : `/${pathname}`;
|
||||
|
||||
if (isTabBar) {
|
||||
this.switchTab(
|
||||
{
|
||||
url,
|
||||
...(props || {}),
|
||||
},
|
||||
state
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.redirectTo(
|
||||
{
|
||||
url,
|
||||
...props,
|
||||
...(props || {}),
|
||||
},
|
||||
state
|
||||
);
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@
|
|||
</block>
|
||||
|
||||
<block wx:elif="{{redirectTo && !oakLoading && !expired && (hasConfirmed || !!(granteeId && userId === granteeId) )}}">
|
||||
<l-button l-class="btn" type="success" style="margin: 16rpx" size="large" bind:lintap="redirectPage" disabled="{{!redirectTo}}">
|
||||
领取成功{{redirectTo ? '(' + redirectCounter + 's)' : '' }}
|
||||
<l-button l-class="btn" type="success" style="margin: 16rpx" size="large" bind:lintap="redirectPage">
|
||||
领取成功{{redirectTo && redirectCounter > 0 ? '(' + redirectCounter + 's)' : '' }}
|
||||
</l-button>
|
||||
</block>
|
||||
</view>
|
||||
Loading…
Reference in New Issue