wechatlogin 生成二维码
This commit is contained in:
parent
c9659a7c8b
commit
f5d64a6545
|
|
@ -78,7 +78,9 @@ exports.default = OakComponent({
|
|||
switch (_d.label) {
|
||||
case 0:
|
||||
wechatLoginId = this.state.wechatLoginId;
|
||||
return [4 /*yield*/, this.features.cache.refresh('wechatLogin', {
|
||||
return [
|
||||
4 /*yield*/,
|
||||
this.features.cache.refresh('wechatLogin', {
|
||||
data: {
|
||||
id: 1,
|
||||
userId: 1,
|
||||
|
|
@ -103,7 +105,7 @@ exports.default = OakComponent({
|
|||
applicationId: 1,
|
||||
},
|
||||
filter: {
|
||||
entity: 'userEntityGrant',
|
||||
entity: 'wechatLogin',
|
||||
},
|
||||
indexFrom: 0,
|
||||
count: 1,
|
||||
|
|
@ -112,7 +114,8 @@ exports.default = OakComponent({
|
|||
filter: {
|
||||
id: wechatLoginId,
|
||||
},
|
||||
})];
|
||||
}),
|
||||
];
|
||||
case 1:
|
||||
_c = tslib_1.__read.apply(void 0, [(_d.sent()).data, 1]), wechatLogin = _c[0];
|
||||
qrCodeUrl = (_a = wechatLogin === null || wechatLogin === void 0 ? void 0 : wechatLogin.wechatQrCode$entity[0]) === null || _a === void 0 ? void 0 : _a.url;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ type IQrCodeProps = {
|
|||
size?: number;
|
||||
url: string;
|
||||
loading?: boolean;
|
||||
disableDownload?: boolean;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -32,6 +33,7 @@ function QrCode(props: IQrCodeProps) {
|
|||
size = 280,
|
||||
url,
|
||||
loading = false,
|
||||
disableDownload = false,
|
||||
} = props;
|
||||
const prefixCls = 'oak';
|
||||
|
||||
|
|
@ -81,7 +83,8 @@ function QrCode(props: IQrCodeProps) {
|
|||
style={{
|
||||
width: size,
|
||||
height: size,
|
||||
marginBottom: 10,
|
||||
marginBottom: 16,
|
||||
marginTop: 16
|
||||
}}
|
||||
>
|
||||
{isBase64(url) ? (
|
||||
|
|
@ -94,7 +97,7 @@ function QrCode(props: IQrCodeProps) {
|
|||
{tips}
|
||||
{
|
||||
<Space className={`${prefixCls}-qrCodeBox_actions`}>
|
||||
{!!url && (
|
||||
{!!url && !disableDownload && (
|
||||
<Button
|
||||
type="text"
|
||||
onClick={() => {
|
||||
|
|
|
|||
|
|
@ -18,17 +18,26 @@ export default OakComponent({
|
|||
}
|
||||
},
|
||||
},
|
||||
data: {
|
||||
loading: false,
|
||||
},
|
||||
properties: {
|
||||
type: 'bind' as EntityDict['wechatLogin']['Schema']['type'],
|
||||
},
|
||||
methods: {
|
||||
async createWechatLogin() {
|
||||
const userId = this.features.token.getUserId();
|
||||
const wechatLoginId = await generateNewIdAsync();
|
||||
|
||||
const { type = 'bind' } = this.props;
|
||||
|
||||
await this.features.cache.operate('wechatLogin', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: {
|
||||
id: wechatLoginId,
|
||||
userId,
|
||||
type: 'bind',
|
||||
type,
|
||||
expiresAt: Date.now() + Interval,
|
||||
expired: false,
|
||||
qrCodeType: 'wechatPublic',
|
||||
|
|
@ -73,7 +82,7 @@ export default OakComponent({
|
|||
applicationId: 1,
|
||||
},
|
||||
filter: {
|
||||
entity: 'userEntityGrant',
|
||||
entity: 'wechatLogin',
|
||||
},
|
||||
indexFrom: 0,
|
||||
count: 1,
|
||||
|
|
|
|||
|
|
@ -13,15 +13,21 @@ export default function Render(
|
|||
{
|
||||
wechatLoginId: string;
|
||||
qrCodeUrl: string;
|
||||
loading: boolean;
|
||||
},
|
||||
{}
|
||||
>
|
||||
) {
|
||||
const { oakFullpath, wechatLoginId, qrCodeUrl } = props.data;
|
||||
const { oakFullpath, qrCodeUrl, loading } = props.data;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<QrCode url={qrCodeUrl} />
|
||||
<QrCode
|
||||
loading={loading}
|
||||
url={qrCodeUrl}
|
||||
disableDownload={true}
|
||||
tips={<div>微信扫一扫</div>}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue