lib
This commit is contained in:
parent
8bfb883663
commit
a15762f66e
|
|
@ -207,7 +207,7 @@ function createWechatQrCode(options, context) {
|
|||
if (!(process.env.OAK_PLATFORM === 'web')) return [3 /*break*/, 7];
|
||||
Object.assign(data, {
|
||||
ticket: 'develop环境下无法真实获取二维码数据',
|
||||
url: 'https://www.test.com',
|
||||
url: "http://localhost:3000/wechatQrCode/scan?scene=".concat((0, uuid_2.shrinkUuidTo32Bytes)(id)),
|
||||
});
|
||||
return [3 /*break*/, 9];
|
||||
case 7:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ import { EntityShape } from 'oak-domain/lib/types/Entity';
|
|||
import { Schema as User } from './User';
|
||||
import { Schema as WechatQrCode } from './WechatQrCode';
|
||||
import { QrCodeType } from '../types/Config';
|
||||
export declare type RedirectToProps = {
|
||||
pathname: string;
|
||||
props?: Record<string, any>;
|
||||
state?: Record<string, any>;
|
||||
};
|
||||
export interface Schema extends EntityShape {
|
||||
entity: String<32>;
|
||||
entityId: String<64>;
|
||||
|
|
@ -17,5 +22,5 @@ export interface Schema extends EntityShape {
|
|||
qrCodeType: QrCodeType;
|
||||
expiresAt?: Datetime;
|
||||
expired?: Boolean;
|
||||
redirectTo?: Object;
|
||||
redirectTo?: RedirectToProps;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var string_1 = require("oak-domain/lib/utils/string");
|
||||
exports.default = OakComponent({
|
||||
entity: 'userEntityGrant',
|
||||
projection: {
|
||||
|
|
@ -27,13 +28,17 @@ exports.default = OakComponent({
|
|||
formData: function (_a) {
|
||||
var userEntityGrant = _a.data, features = _a.features;
|
||||
var userId = features.token.getUserId(true);
|
||||
var granter = userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.granter;
|
||||
var type = userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.type;
|
||||
var relation = userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.relation;
|
||||
var entity = userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.entity;
|
||||
return {
|
||||
relation: userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.relation,
|
||||
type: userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.type,
|
||||
relation: relation,
|
||||
type: type,
|
||||
expired: userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.expired,
|
||||
expiresAt: userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.expiresAt,
|
||||
granter: userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.granter,
|
||||
entity: userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.entity,
|
||||
granter: granter,
|
||||
entity: entity,
|
||||
entityId: userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.entityId,
|
||||
granteeId: userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.granteeId,
|
||||
number: userEntityGrant === null || userEntityGrant === void 0 ? void 0 : userEntityGrant.number,
|
||||
|
|
@ -45,6 +50,7 @@ exports.default = OakComponent({
|
|||
data: {
|
||||
redirectCounter: 0,
|
||||
hasConfirmed: false,
|
||||
loading: true,
|
||||
},
|
||||
observers: {
|
||||
redirectCounter: function (value) {
|
||||
|
|
@ -57,11 +63,50 @@ exports.default = OakComponent({
|
|||
}, 1000);
|
||||
}
|
||||
else {
|
||||
this.redirectMp();
|
||||
this.redirectPage();
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getUserRelations: function () {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var userId, _a, entity, entityId, relation, entityStr, data;
|
||||
var _b, _c;
|
||||
return tslib_1.__generator(this, function (_d) {
|
||||
switch (_d.label) {
|
||||
case 0: return [4 /*yield*/, this.features.token.getUserId(true)];
|
||||
case 1:
|
||||
userId = _d.sent();
|
||||
if (!userId) {
|
||||
return [2 /*return*/];
|
||||
}
|
||||
_a = this.state, entity = _a.entity, entityId = _a.entityId, relation = _a.relation;
|
||||
entityStr = (0, string_1.firstLetterUpperCase)(entity);
|
||||
return [4 /*yield*/, this.features.cache.refresh("user".concat(entityStr), {
|
||||
data: (_b = {
|
||||
id: 1,
|
||||
userId: 1,
|
||||
relation: 1
|
||||
},
|
||||
_b["".concat(entity, "Id")] = 1,
|
||||
_b),
|
||||
filter: (_c = {
|
||||
userId: userId
|
||||
},
|
||||
_c["".concat(entity, "Id")] = entityId,
|
||||
_c.relation = relation,
|
||||
_c),
|
||||
})];
|
||||
case 2:
|
||||
data = (_d.sent()).data;
|
||||
this.setState({
|
||||
hasConfirmed: data.length > 0,
|
||||
});
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
handleConfirm: function () {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var redirectTo;
|
||||
|
|
@ -87,10 +132,11 @@ exports.default = OakComponent({
|
|||
});
|
||||
});
|
||||
},
|
||||
redirectMp: function () {
|
||||
redirectPage: function () {
|
||||
var redirectTo = this.props.redirectTo;
|
||||
var url = redirectTo.url, _a = redirectTo.props, props = _a === void 0 ? {} : _a;
|
||||
this.redirectTo(tslib_1.__assign({ url: url }, props));
|
||||
var pathname = redirectTo.pathname, _a = redirectTo.props, props = _a === void 0 ? {} : _a, _b = redirectTo.state, state = _b === void 0 ? {} : _b;
|
||||
var url = pathname.substring(0, 1) === '/' ? pathname : "/".concat(pathname);
|
||||
this.redirectTo(tslib_1.__assign({ url: url }, props), state);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"navigationBarTitleText": "认领权限",
|
||||
"navigationBarTitleText": "领取",
|
||||
"usingComponents": {
|
||||
"l-icon": "../../../miniprogram_npm/lin-ui/icon/index",
|
||||
"l-button": "../../../miniprogram_npm/lin-ui/button/index"
|
||||
|
|
|
|||
|
|
@ -12,11 +12,14 @@ export default function render(props: WebComponentProps<EntityDict, 'userEntityG
|
|||
nickname: string;
|
||||
};
|
||||
entity: string;
|
||||
isExists: boolean;
|
||||
hasConfirmed: boolean;
|
||||
granteeId: string;
|
||||
number: number;
|
||||
confirmed: number;
|
||||
userId: string;
|
||||
redirectTo: EntityDict['userEntityGrant']['Schema']['redirectTo'];
|
||||
redirectCounter: number;
|
||||
}, {
|
||||
handleConfirm: () => void;
|
||||
redirectPage: () => void;
|
||||
}>): JSX.Element;
|
||||
|
|
|
|||
|
|
@ -7,36 +7,42 @@ var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
|
|||
var icons_1 = require("@ant-design/icons");
|
||||
var utils_1 = require("oak-frontend-base/lib/utils/utils");
|
||||
function render(props) {
|
||||
var _a = props.data, oakLoading = _a.oakLoading, oakExecuting = _a.oakExecuting, type = _a.type, expired = _a.expired, relation = _a.relation, expiresAt = _a.expiresAt, granter = _a.granter, entity = _a.entity, isExists = _a.isExists, //当前用户关系是否存在
|
||||
granteeId = _a.granteeId, number = _a.number, confirmed = _a.confirmed, userId = _a.userId;
|
||||
var _b = props.methods, t = _b.t, handleConfirm = _b.handleConfirm;
|
||||
var _a = props.data, oakLoading = _a.oakLoading, oakExecuting = _a.oakExecuting, type = _a.type, expired = _a.expired, relation = _a.relation, expiresAt = _a.expiresAt, granter = _a.granter, entity = _a.entity, hasConfirmed = _a.hasConfirmed, //当前用户关系是否存在
|
||||
granteeId = _a.granteeId, number = _a.number, confirmed = _a.confirmed, userId = _a.userId, redirectTo = _a.redirectTo, redirectCounter = _a.redirectCounter;
|
||||
var _b = props.methods, t = _b.t, handleConfirm = _b.handleConfirm, redirectPage = _b.redirectPage;
|
||||
var isOwner = !!(granteeId && userId === granteeId);
|
||||
var getRelationTip = function () {
|
||||
var str = "".concat((granter === null || granter === void 0 ? void 0 : granter.name) || (granter === null || granter === void 0 ? void 0 : granter.nickname));
|
||||
var relationStr = relation ? t("".concat(entity, ":r.").concat(relation)) : '';
|
||||
if (type === 'grant') {
|
||||
str = str.concat('授予您【').concat(relationStr).concat('】权限');
|
||||
str = str.concat('授予您【').concat(relationStr).concat('】');
|
||||
return str;
|
||||
}
|
||||
str = str.concat('转让您【').concat(relationStr).concat('】权限');
|
||||
str = str.concat('转让您【').concat(relationStr).concat('】');
|
||||
return str;
|
||||
};
|
||||
var getDescTip = function () {
|
||||
if (isExists || isOwner) {
|
||||
if (hasConfirmed || isOwner) {
|
||||
return '您已领取';
|
||||
}
|
||||
if (expired) {
|
||||
return '已过期,请联系相关人员重新分享';
|
||||
}
|
||||
// number设置1个的时候
|
||||
if (number === 1 && confirmed > 0 && (!isOwner || !isExists)) {
|
||||
if (number === 1 && confirmed > 0 && (!isOwner || !hasConfirmed)) {
|
||||
return '被他人已领取';
|
||||
}
|
||||
return '请您领取';
|
||||
};
|
||||
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.content }, { children: [type === 'grant' ? ((0, jsx_runtime_1.jsx)(icons_1.UserAddOutlined, { className: web_module_less_1.default.icon })) : ((0, jsx_runtime_1.jsx)(icons_1.UserSwitchOutlined, { className: web_module_less_1.default.icon })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.title }, { children: getRelationTip() })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.description }, { children: getDescTip() }))] })), (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical" }, { children: [!oakLoading && !expired && !isExists && !isOwner && ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ block: true, type: "primary", onClick: function () {
|
||||
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.content }, { children: [type === 'grant' ? ((0, jsx_runtime_1.jsx)(icons_1.UserAddOutlined, { className: web_module_less_1.default.icon })) : ((0, jsx_runtime_1.jsx)(icons_1.UserSwitchOutlined, { className: web_module_less_1.default.icon })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.title }, { children: getRelationTip() })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.description }, { children: getDescTip() }))] })), (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical" }, { children: [!oakLoading &&
|
||||
!expired &&
|
||||
!hasConfirmed &&
|
||||
!isOwner &&
|
||||
number > confirmed && ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ size: "large", block: true, type: "primary", onClick: function () {
|
||||
handleConfirm();
|
||||
}, disabled: oakExecuting }, { children: "\u9886\u53D6" }))), utils_1.isWeiXin && ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ block: true, onClick: function () {
|
||||
}, disabled: oakExecuting }, { children: "\u9886\u53D6" }))), !oakLoading && !expired && (isOwner || hasConfirmed) && ((0, jsx_runtime_1.jsxs)(antd_1.Button, tslib_1.__assign({ size: "large", block: true, type: "primary", onClick: function () {
|
||||
redirectPage();
|
||||
}, disabled: oakExecuting }, { children: ["\u9886\u53D6\u6210\u529F", redirectTo ? '(' + redirectCounter + 's)' : ''] }))), utils_1.isWeiXin && ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ size: "large", block: true, onClick: function () {
|
||||
WeixinJSBridge.call('closeWindow');
|
||||
} }, { children: "\u5173\u95ED" })))] }))] })));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
exports.default = OakComponent({
|
||||
entity: 'wechatQrCode',
|
||||
|
|
@ -13,53 +14,68 @@ exports.default = OakComponent({
|
|||
expired: 1,
|
||||
buffer: 1,
|
||||
props: 1,
|
||||
expiresAt: 1,
|
||||
},
|
||||
isList: true,
|
||||
properties: {
|
||||
scene: String,
|
||||
},
|
||||
data: {
|
||||
loading: true,
|
||||
},
|
||||
filters: [
|
||||
{
|
||||
filter: function () {
|
||||
var scene = decodeURIComponent(this.props.scene);
|
||||
var uuid = scene && (0, uuid_1.expandUuidTo36Bytes)(scene);
|
||||
return {
|
||||
id: uuid,
|
||||
id: uuid || 'illegal',
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
formData: function (_a) {
|
||||
var wechatQrCodes = _a.data;
|
||||
var wechatQrCodes = _a.data, props = _a.props;
|
||||
var wechatQrCode = wechatQrCodes[0];
|
||||
if (!wechatQrCode) {
|
||||
return {
|
||||
loading: false,
|
||||
isExist: false,
|
||||
};
|
||||
}
|
||||
if (!wechatQrCode.expired) {
|
||||
var _b = wechatQrCode.props, props = _b.props, pathname = _b.pathname;
|
||||
var scene = decodeURIComponent(props.scene);
|
||||
var uuid = scene && (0, uuid_1.expandUuidTo36Bytes)(scene);
|
||||
if (wechatQrCode.id !== uuid) {
|
||||
return {
|
||||
loading: false,
|
||||
isExist: false,
|
||||
};
|
||||
}
|
||||
else if (!wechatQrCode.expired) {
|
||||
var _b = wechatQrCode.props, _c = _b.props, props_1 = _c === void 0 ? {} : _c, _d = _b.state, state = _d === void 0 ? {} : _d, pathname = _b.pathname;
|
||||
var url = pathname.substring(0, 1) === '/'
|
||||
? pathname
|
||||
: "/".concat(pathname);
|
||||
if (props) {
|
||||
for (var param in props) {
|
||||
var param2 = param;
|
||||
url += url.includes('?') ? '&' : '?';
|
||||
url += "".concat(param, "=").concat(typeof props[param2] === 'string'
|
||||
? props[param2]
|
||||
: JSON.stringify(props[param2]));
|
||||
}
|
||||
}
|
||||
this.redirectTo({
|
||||
url: url,
|
||||
});
|
||||
// if (props) {
|
||||
// for (const param in props) {
|
||||
// const param2 = param as unknown as keyof typeof props;
|
||||
// url += url.includes('?') ? '&' : '?';
|
||||
// url += `${param}=${
|
||||
// typeof props[param2] === 'string'
|
||||
// ? props[param2]
|
||||
// : JSON.stringify(props[param2])
|
||||
// }`;
|
||||
// }
|
||||
// }
|
||||
this.redirectTo(tslib_1.__assign({ url: url }, props_1), state);
|
||||
return {
|
||||
loading: false,
|
||||
expired: false,
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
loading: false,
|
||||
expired: true,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"navigationBarTitleText": "扫码结果",
|
||||
"usingComponents": {
|
||||
"l-icon": "../../../miniprogram_npm/lin-ui/icon/icon"
|
||||
"l-icon": "../../../miniprogram_npm/lin-ui/icon/index"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ function render(props) {
|
|||
V = ((0, jsx_runtime_1.jsx)(success_1.default, { icon: (0, jsx_runtime_1.jsx)(icons_1.LoadingOutlined, { className: web_module_less_1.default.brand_icon }), title: "\u52A0\u8F7D\u4E2D", description: "\u6B63\u5728\u83B7\u53D6\u6570\u636E\uFF0C\u8BF7\u7A0D\u540E" }));
|
||||
}
|
||||
else if (!isExist) {
|
||||
V = ((0, jsx_runtime_1.jsx)(fail_1.default, { title: "\u4E8C\u7EF4\u7801\u975E\u6CD5", description: "\u62B1\u6B49\uFF0C\u8BE5\u4E8C\u7EF4\u7801\u4E0D\u5B58\u5728\uFF0C\u8BF7\u68C0\u67E5\u662F\u5426\u626B\u9519\u4E8C\u7EF4\u7801" }));
|
||||
V = ((0, jsx_runtime_1.jsx)(fail_1.default, { title: "\u4E8C\u7EF4\u7801\u975E\u6CD5", description: "\u62B1\u6B49\uFF0C\u8BE5\u7801\u4E0D\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u626B\u4E8C\u7EF4\u7801" }));
|
||||
}
|
||||
else if (expired) {
|
||||
V = ((0, jsx_runtime_1.jsx)(fail_1.default, { icon: (0, jsx_runtime_1.jsx)(icons_1.WarningOutlined, { className: web_module_less_1.default.icon }), title: "\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F", description: "\u62B1\u6B49\uFF0C\u8BE5\u7801\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u8054\u7CFB\u76F8\u5173\u4EBA\u5458\u91CD\u65B0\u5206\u4EAB" }));
|
||||
|
|
|
|||
Loading…
Reference in New Issue