From 726f2de7e6e0b600c991de13660f61b90ee40aa8 Mon Sep 17 00:00:00 2001
From: wkj <278599135@qq.com>
Date: Fri, 28 Apr 2023 12:36:52 +0800
Subject: [PATCH] =?UTF-8?q?fix=20wechatqrcode/scan=20=E9=A1=B5=E9=9D=A2?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=86=85=E5=AE=B9=E4=B8=8D=E5=AF=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/pages/wechatQrCode/scan/index.js | 32 ++---
lib/pages/wechatQrCode/scan/web.d.ts | 5 +-
lib/pages/wechatQrCode/scan/web.js | 6 +-
src/pages/wechatQrCode/scan/index.ts | 161 +++++++++++++-------------
src/pages/wechatQrCode/scan/index.xml | 2 +-
src/pages/wechatQrCode/scan/web.tsx | 10 +-
6 files changed, 111 insertions(+), 105 deletions(-)
diff --git a/lib/pages/wechatQrCode/scan/index.js b/lib/pages/wechatQrCode/scan/index.js
index 046126aec..93d0314ad 100644
--- a/lib/pages/wechatQrCode/scan/index.js
+++ b/lib/pages/wechatQrCode/scan/index.js
@@ -12,7 +12,6 @@ exports.default = OakComponent({
ticket: 1,
url: 1,
expired: 1,
- // buffer: 1,
props: 1,
expiresAt: 1,
},
@@ -21,16 +20,21 @@ exports.default = OakComponent({
scene: '',
},
data: {
- loading: true,
+ loading: false,
+ illegal: false,
},
- listeners: {
- oakLoading: function (prev, next) {
- if (!!prev.oakLoading && !next.oakLoading) {
- this.setState({
+ lifetimes: {
+ attached: function () {
+ var _this = this;
+ this.setState({
+ loading: true,
+ });
+ setTimeout(function () {
+ _this.setState({
loading: false,
});
- }
- }
+ }, 500);
+ },
},
filters: [
{
@@ -48,29 +52,29 @@ exports.default = OakComponent({
var wechatQrCode = wechatQrCodes[0];
if (!wechatQrCode) {
return {
- isExist: false,
+ illegal: true,
};
}
var scene = decodeURIComponent(props.scene);
var uuid = scene && (0, uuid_1.expandUuidTo36Bytes)(scene);
if (wechatQrCode.id !== uuid) {
return {
- isExist: false,
+ illegal: true,
};
}
- else if (!wechatQrCode.expired) {
+ 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);
+ var url = pathname.substring(0, 1) === '/' ? pathname : "/".concat(pathname);
this.redirectTo(tslib_1.__assign({ url: url }, props_1), state);
return {
expired: false,
+ illegal: false,
};
}
else {
return {
expired: true,
+ illegal: false,
};
}
},
diff --git a/lib/pages/wechatQrCode/scan/web.d.ts b/lib/pages/wechatQrCode/scan/web.d.ts
index 46deb98c8..fcca31952 100644
--- a/lib/pages/wechatQrCode/scan/web.d.ts
+++ b/lib/pages/wechatQrCode/scan/web.d.ts
@@ -1,8 +1,7 @@
-///
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function render(props: WebComponentProps): JSX.Element;
diff --git a/lib/pages/wechatQrCode/scan/web.js b/lib/pages/wechatQrCode/scan/web.js
index 65c0edb87..beb2731e6 100644
--- a/lib/pages/wechatQrCode/scan/web.js
+++ b/lib/pages/wechatQrCode/scan/web.js
@@ -7,12 +7,12 @@ var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var success_1 = tslib_1.__importDefault(require("../../../components/common/result/success"));
var fail_1 = tslib_1.__importDefault(require("../../../components/common/result/fail"));
function render(props) {
- var _a = props.data, oakLoading = _a.oakLoading, isExist = _a.isExist, expired = _a.expired;
+ var _a = props.data, oakLoading = _a.oakLoading, expired = _a.expired, illegal = _a.illegal, loading = _a.loading;
var V;
- if (oakLoading) {
+ if (oakLoading || loading) {
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) {
+ else if (illegal) {
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) {
diff --git a/src/pages/wechatQrCode/scan/index.ts b/src/pages/wechatQrCode/scan/index.ts
index 080abce22..ea27def59 100644
--- a/src/pages/wechatQrCode/scan/index.ts
+++ b/src/pages/wechatQrCode/scan/index.ts
@@ -1,85 +1,88 @@
import { expandUuidTo36Bytes } from 'oak-domain/lib/utils/uuid'
-export default OakComponent(
- {
- entity: 'wechatQrCode',
- projection: {
- id: 1,
- entity: 1,
- entityId: 1,
- type: 1, //类型
- ticket: 1,
- url: 1,
- expired: 1,
- // buffer: 1,
- props: 1,
- expiresAt: 1,
+export default OakComponent({
+ entity: 'wechatQrCode',
+ projection: {
+ id: 1,
+ entity: 1,
+ entityId: 1,
+ type: 1, //类型
+ ticket: 1,
+ url: 1,
+ expired: 1,
+ props: 1,
+ expiresAt: 1,
+ },
+ isList: true,
+ properties: {
+ scene: '',
+ },
+ data: {
+ loading: false,
+ illegal: false,
+ },
+ lifetimes: {
+ attached() {
+ this.setState({
+ loading: true,
+ });
+ setTimeout(() => {
+ this.setState({
+ loading: false,
+ });
+ }, 500);
},
- isList: true,
- properties: {
- scene: '',
- },
- data: {
- loading: true,
- },
- listeners: {
- oakLoading(prev, next) {
- if (!!prev.oakLoading && !next.oakLoading) {
- this.setState({
- loading: false,
- });
- }
- }
- },
- filters: [
- {
- filter() {
- const scene = decodeURIComponent(this.props.scene!);
- const uuid = scene && expandUuidTo36Bytes(scene!);
- return {
- id: uuid! || 'illegal',
- };
- },
+ },
+ filters: [
+ {
+ filter() {
+ const scene = decodeURIComponent(this.props.scene!);
+ const uuid = scene && expandUuidTo36Bytes(scene!);
+ return {
+ id: uuid! || 'illegal',
+ };
},
- ],
- formData: function({ data: wechatQrCodes, props }) {
- const wechatQrCode = wechatQrCodes[0];
- if (!wechatQrCode) {
- return {
- isExist: false,
- };
- }
-
- const scene = decodeURIComponent(props.scene!);
- const uuid = scene && expandUuidTo36Bytes(scene!);
- if (wechatQrCode.id !== uuid) {
- return {
- isExist: false,
- };
- }
- else if (!wechatQrCode.expired) {
- const { props = {}, state = {}, pathname } = wechatQrCode!.props!;
- const url =
- pathname.substring(0, 1) === '/'
- ? pathname
- : `/${pathname}`;
-
- this.redirectTo(
- {
- url: url,
- ...props,
- },
- state
- );
- return {
- expired: false,
- };
- } else {
- return {
- expired: true,
- };
- }
},
- }
-);
\ No newline at end of file
+ ],
+ formData: function ({ data: wechatQrCodes, props }) {
+ const wechatQrCode = wechatQrCodes[0];
+
+ if (!wechatQrCode) {
+ return {
+ illegal: true,
+ };
+ }
+
+ const scene = decodeURIComponent(props.scene!);
+ const uuid = scene && expandUuidTo36Bytes(scene!);
+ if (wechatQrCode.id !== uuid) {
+ return {
+ illegal: true,
+ };
+ }
+
+ if (!wechatQrCode.expired) {
+ const { props = {}, state = {}, pathname } = wechatQrCode!.props!;
+ const url =
+ pathname.substring(0, 1) === '/' ? pathname : `/${pathname}`;
+
+ this.redirectTo(
+ {
+ url: url,
+ ...props,
+ },
+ state
+ );
+ return {
+ expired: false,
+ illegal: false,
+ };
+ } else {
+ return {
+ expired: true,
+ illegal: false,
+ };
+ }
+ },
+});
\ No newline at end of file
diff --git a/src/pages/wechatQrCode/scan/index.xml b/src/pages/wechatQrCode/scan/index.xml
index d37bb56c5..7b439199e 100644
--- a/src/pages/wechatQrCode/scan/index.xml
+++ b/src/pages/wechatQrCode/scan/index.xml
@@ -7,7 +7,7 @@
正在获取数据,请稍后
-
+
二维码非法
diff --git a/src/pages/wechatQrCode/scan/web.tsx b/src/pages/wechatQrCode/scan/web.tsx
index 28270f0bd..298f30065 100644
--- a/src/pages/wechatQrCode/scan/web.tsx
+++ b/src/pages/wechatQrCode/scan/web.tsx
@@ -16,17 +16,17 @@ export default function render(
'token',
false,
{
- oakLoading: boolean;
- isExist: boolean;
+ loading: boolean;
+ illegal: boolean;
expired: boolean;
},
{}
>
) {
- const { oakLoading, isExist, expired } = props.data;
+ const { oakLoading, expired, illegal, loading } = props.data;
let V;
- if (oakLoading) {
+ if (oakLoading || loading) {
V = (
}
@@ -34,7 +34,7 @@ export default function render(
description="正在获取数据,请稍后"
/>
);
- } else if (!isExist) {
+ } else if (illegal) {
V = (