This commit is contained in:
Wang Kejun 2023-04-25 09:56:00 +08:00
parent b26338272f
commit 2f7bbe2984
6 changed files with 82 additions and 131 deletions

View File

@ -9,7 +9,7 @@ export interface Schema extends EntityShape {
unionId?: String<32>;
sessionKey?: String<64>;
accessToken?: String<128>;
refreshToken?: String<64>;
refreshToken?: String<128>;
scope?: String<64>;
atExpiredAt?: Datetime;
rtExpiredAt?: Datetime;

View File

@ -15,7 +15,7 @@ export declare type OpSchema = EntityShape & {
unionId?: String<32> | null;
sessionKey?: String<64> | null;
accessToken?: String<128> | null;
refreshToken?: String<64> | null;
refreshToken?: String<128> | null;
scope?: String<64> | null;
atExpiredAt?: Datetime | null;
rtExpiredAt?: Datetime | null;
@ -34,7 +34,7 @@ export declare type Schema = EntityShape & {
unionId?: String<32> | null;
sessionKey?: String<64> | null;
accessToken?: String<128> | null;
refreshToken?: String<64> | null;
refreshToken?: String<128> | null;
scope?: String<64> | null;
atExpiredAt?: Datetime | null;
rtExpiredAt?: Datetime | null;

View File

@ -6,79 +6,79 @@ exports.desc = {
attributes: {
origin: {
notNull: true,
type: 'enum',
enumeration: ['mp', 'public', 'web'],
type: "enum",
enumeration: ["mp", "public", "web"]
},
openId: {
type: 'varchar',
type: "varchar",
params: {
length: 32,
},
length: 32
}
},
unionId: {
type: 'varchar',
type: "varchar",
params: {
length: 32,
},
length: 32
}
},
sessionKey: {
type: 'varchar',
type: "varchar",
params: {
length: 64,
},
length: 64
}
},
accessToken: {
type: 'varchar',
type: "varchar",
params: {
length: 128,
},
length: 128
}
},
refreshToken: {
type: 'varchar',
type: "varchar",
params: {
length: 128,
},
length: 128
}
},
scope: {
type: 'varchar',
type: "varchar",
params: {
length: 64,
},
length: 64
}
},
atExpiredAt: {
type: 'datetime',
type: "datetime"
},
rtExpiredAt: {
type: 'datetime',
type: "datetime"
},
subscribed: {
type: 'boolean',
type: "boolean"
},
subscribedAt: {
type: 'datetime',
type: "datetime"
},
unsubscribedAt: {
type: 'datetime',
type: "datetime"
},
userId: {
type: 'ref',
ref: 'user',
type: "ref",
ref: "user"
},
applicationId: {
notNull: true,
type: 'ref',
ref: 'application',
type: "ref",
ref: "application"
},
nickname: {
type: 'varchar',
type: "varchar",
params: {
length: 128,
},
length: 128
}
},
avatar: {
type: 'text',
},
type: "text"
}
},
actionType: 'crud',
actions: action_1.genericActions,
actionType: "crud",
actions: action_1.genericActions
};

View File

@ -4,6 +4,7 @@ var tslib_1 = require("tslib");
var SEND_KEY = 'captcha:sendAt';
var LOGIN_AGREED = 'login:agreed';
var LOGIN_MODE = 'login:mode';
var SEND_CAPTCHA_LATENCY = process.env.NODE_ENV === 'development' ? 10 : 60;
exports.default = OakComponent({
isList: false,
projection: {
@ -38,7 +39,7 @@ exports.default = OakComponent({
var now = Date.now();
var counter = 0;
if (typeof lastSendAt === 'number') {
counter = Math.max(60 - Math.ceil((now - lastSendAt) / 1000), 0);
counter = Math.max(SEND_CAPTCHA_LATENCY - Math.ceil((now - lastSendAt) / 1000), 0);
if (counter > 0) {
this.counterHandler = setTimeout(function () { return _this.reRender(); }, 1000);
}

View File

@ -2,6 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var SEND_KEY = 'captcha:sendAt';
var SEND_CAPTCHA_LATENCY = process.env.NODE_ENV === 'development' ? 10 : 60;
exports.default = OakComponent({
isList: false,
projection: {
@ -29,7 +30,7 @@ exports.default = OakComponent({
var now = Date.now();
var counter = 0;
if (typeof lastSendAt === 'number') {
counter = Math.max(60 - Math.ceil((now - lastSendAt) / 1000), 0);
counter = Math.max(SEND_CAPTCHA_LATENCY - Math.ceil((now - lastSendAt) / 1000), 0);
if (counter > 0) {
this.counterHandler = setTimeout(function () { return _this.reRender(); }, 1000);
}

View File

@ -50,50 +50,21 @@ exports.default = OakComponent({
},
isList: false,
formData: function (_a) {
var user = _a.data,
features = _a.features;
var user = _a.data, features = _a.features;
var application = features.application.getApplication();
var avatar =
(user === null || user === void 0
? void 0
: user.extraFile$entity) &&
(user === null || user === void 0
? void 0
: user.extraFile$entity[0]);
var avatar = (user === null || user === void 0 ? void 0 : user.extraFile$entity) && (user === null || user === void 0 ? void 0 : user.extraFile$entity[0]);
var avatarUrl = features.extraFile.getUrl(avatar);
var mobile = (
((user === null || user === void 0 ? void 0 : user.mobile$user) &&
(user === null || user === void 0
? void 0
: user.mobile$user[0])) ||
{}
).mobile;
var genderOption =
(user === null || user === void 0 ? void 0 : user.gender) &&
this.state.genderOptions.find(function (ele) {
return (
ele.value ===
(user === null || user === void 0 ? void 0 : user.gender)
);
});
var appType =
application === null || application === void 0
? void 0
: application.type;
var config =
application === null || application === void 0
? void 0
: application.config;
var mobile = (((user === null || user === void 0 ? void 0 : user.mobile$user) && (user === null || user === void 0 ? void 0 : user.mobile$user[0])) || {}).mobile;
var genderOption = (user === null || user === void 0 ? void 0 : user.gender) &&
this.state.genderOptions.find(function (ele) { return ele.value === (user === null || user === void 0 ? void 0 : user.gender); });
var appType = application === null || application === void 0 ? void 0 : application.type;
var config = application === null || application === void 0 ? void 0 : application.config;
var appId;
var isSupportSyncWeChat = false; //是否支持微信公众号授权登录
if (appType === 'wechatPublic') {
var config2 = config;
var isService =
config2 === null || config2 === void 0
? void 0
: config2.isService; //是否服务号 服务号才能授权登录
appId =
config2 === null || config2 === void 0 ? void 0 : config2.appId;
var isService = config2 === null || config2 === void 0 ? void 0 : config2.isService; //是否服务号 服务号才能授权登录
appId = config2 === null || config2 === void 0 ? void 0 : config2.appId;
isSupportSyncWeChat = !!(isService && appId);
}
return {
@ -101,18 +72,14 @@ exports.default = OakComponent({
name: user === null || user === void 0 ? void 0 : user.name,
nickname: user === null || user === void 0 ? void 0 : user.nickname,
gender: user === null || user === void 0 ? void 0 : user.gender,
genderStr:
genderOption === null || genderOption === void 0
? void 0
: genderOption.label,
genderStr: genderOption === null || genderOption === void 0 ? void 0 : genderOption.label,
birthText: (user === null || user === void 0 ? void 0 : user.birth)
? (0, dayjs_1.default)(user.birth).format('YYYY-MM-DD')
: '',
birth: user === null || user === void 0 ? void 0 : user.birth,
avatarUrl: avatarUrl,
mobile: mobile,
userState:
user === null || user === void 0 ? void 0 : user.userState,
userState: user === null || user === void 0 ? void 0 : user.userState,
idState: user === null || user === void 0 ? void 0 : user.idState,
isSupportSyncWeChat: isSupportSyncWeChat,
};
@ -158,9 +125,7 @@ exports.default = OakComponent({
if (userId !== oakId) {
throw new types_1.OakUserUnpermittedException();
}
this.setState({
birthEnd: (0, dayjs_1.default)().format('YYYY-MM-DD'),
});
this.setState({ birthEnd: (0, dayjs_1.default)().format('YYYY-MM-DD') });
return [2 /*return*/];
});
});
@ -179,10 +144,7 @@ exports.default = OakComponent({
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [
4 /*yield*/,
this.features.token.refreshWechatPublicUserInfo(),
];
return [4 /*yield*/, this.features.token.refreshWechatPublicUserInfo()];
case 2:
_a.sent();
this.setState({
@ -195,21 +157,17 @@ exports.default = OakComponent({
refreshing: false,
});
throw err_1;
case 4:
return [2 /*return*/];
case 4: return [2 /*return*/];
}
});
});
},
goAddMobile: function () {
this.navigateTo(
{
url: '/mobile/me',
},
{
showBack: true,
}
);
this.navigateTo({
url: '/mobile/me',
}, {
showBack: true,
});
},
setVisibleMp: function (e) {
var dataset = e.target.dataset;
@ -218,16 +176,13 @@ exports.default = OakComponent({
},
genderChangeMp: function (e) {
var detail = e.detail;
var checked = detail.checked,
currentKey = detail.currentKey;
var checked = detail.checked, currentKey = detail.currentKey;
var attr = this.state.attr;
this.setCustomData(attr, currentKey);
},
birthChangeMp: function (e) {
var value = e.detail.value;
var birth = (0, dayjs_1.default)(
(0, dayjs_1.default)(value).format('YYYY-MM-DD')
).valueOf();
var birth = (0, dayjs_1.default)((0, dayjs_1.default)(value).format('YYYY-MM-DD')).valueOf();
var attr = this.state.attr;
this.setState({
birthText2: (0, dayjs_1.default)(value).format('YYYY-MM-DD'),
@ -236,32 +191,31 @@ exports.default = OakComponent({
},
setVisible: function (visible, attr) {
var _a;
this.setState(
((_a = {
this.setState((_a = {
visible: visible,
attr: visible ? attr : '',
}),
(_a['new_'.concat(attr)] = ''),
(_a.birthText2 = ''),
_a)
);
attr: visible ? attr : ''
},
_a["new_".concat(attr)] = '',
_a.birthText2 = '',
_a));
},
setCustomData: function (attr, value) {
var _a;
this.setState(((_a = {}), (_a['new_'.concat(attr)] = value), _a));
this.setState((_a = {},
_a["new_".concat(attr)] = value,
_a));
},
setCustomDataMp: function (e) {
var detail = e.detail,
dataset = e.target.dataset;
var detail = e.detail, dataset = e.target.dataset;
var value = detail.value;
var attr = this.state.attr;
this.setCustomData(attr, value);
},
updateData: function (attr, value) {
var _a;
this.update(
((_a = {}), (_a[attr] = this.state['new_'.concat(attr)]), _a)
);
this.update((_a = {},
_a[attr] = this.state["new_".concat(attr)],
_a));
},
onConfirmMp: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
@ -286,21 +240,16 @@ exports.default = OakComponent({
switch (_b.label) {
case 0:
oakId = this.props.oakId;
if (!this.state['new_'.concat(attr)]) {
if (!this.state["new_".concat(attr)]) {
this.setMessage({
type: 'warning',
content: ''.concat(
this.state.attrs[attr],
'\u4E0D\u80FD\u4E3A\u7A7A'
),
content: "".concat(this.state.attrs[attr], "\u4E0D\u80FD\u4E3A\u7A7A"),
});
return [2 /*return*/];
}
this.update(
((_a = {}),
(_a[attr] = this.state['new_'.concat(attr)]),
_a)
);
this.update((_a = {},
_a[attr] = this.state["new_".concat(attr)],
_a));
return [4 /*yield*/, this.execute()];
case 1:
_b.sent();