logingwechat 增加 wechatloginid参数
This commit is contained in:
parent
4f73b42ca2
commit
75c517cc3c
|
|
@ -20,9 +20,10 @@ declare type GeneralAspectDict<ED extends EntityDict, Cxt extends BackendRuntime
|
|||
mobile: string;
|
||||
env: WebEnv | WechatMpEnv;
|
||||
}, context: Cxt) => Promise<string>;
|
||||
loginWechat: ({ code, env, }: {
|
||||
loginWechat: ({ code, env, wechatLoginId, }: {
|
||||
code: string;
|
||||
env: WebEnv;
|
||||
wechatLoginId?: string;
|
||||
}, context: Cxt) => Promise<string>;
|
||||
logout: ({}: {}, context: Cxt) => Promise<void>;
|
||||
loginWechatMp: ({ code, env, }: {
|
||||
|
|
|
|||
|
|
@ -136,17 +136,18 @@ var Token = /** @class */ (function (_super) {
|
|||
});
|
||||
};
|
||||
Token.prototype.logout = function () {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.cache.exec('logout', {})];
|
||||
case 1:
|
||||
_a.sent();
|
||||
this.removeToken();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
// return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
// return tslib_1.__generator(this, function (_a) {
|
||||
// switch (_a.label) {
|
||||
// case 0: return [4 /*yield*/, this.cache.exec('logout', {})];
|
||||
// case 1:
|
||||
// _a.sent();
|
||||
// this.removeToken();
|
||||
// return [2 /*return*/];
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
this.removeToken();
|
||||
};
|
||||
Token.prototype.removeToken = function () {
|
||||
this.tokenValue = undefined;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
/// <reference types="wechat-miniprogram" />
|
||||
/// <reference types="react" />
|
||||
import { EntityDict } from '../../../general-app-domain';
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "wechatLogin", false, WechatMiniprogram.Component.DataOption>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
export default _default;
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = OakComponent({
|
||||
entity: 'wechatLogin',
|
||||
projection: {
|
||||
id: 1,
|
||||
expired: 1,
|
||||
expiresAt: 1,
|
||||
userId: 1,
|
||||
type: 1,
|
||||
qrCodeType: 1,
|
||||
successed: 1,
|
||||
},
|
||||
isList: false,
|
||||
formData: function (_a) {
|
||||
var wechatLogin = _a.data, features = _a.features;
|
||||
var loginUserId = features.token.getUserId(true);
|
||||
var user = wechatLogin === null || wechatLogin === void 0 ? void 0 : wechatLogin.user;
|
||||
var userId = wechatLogin === null || wechatLogin === void 0 ? void 0 : wechatLogin.userId;
|
||||
var type = wechatLogin === null || wechatLogin === void 0 ? void 0 : wechatLogin.type;
|
||||
return {
|
||||
type: type,
|
||||
userId: userId,
|
||||
expired: wechatLogin === null || wechatLogin === void 0 ? void 0 : wechatLogin.expired,
|
||||
expiresAt: wechatLogin === null || wechatLogin === void 0 ? void 0 : wechatLogin.expiresAt,
|
||||
successed: wechatLogin === null || wechatLogin === void 0 ? void 0 : wechatLogin.successed,
|
||||
loginUserId: loginUserId,
|
||||
};
|
||||
},
|
||||
listeners: {},
|
||||
methods: {},
|
||||
});
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"navigationBarTitleText": "绑定/登录",
|
||||
"usingComponents": {
|
||||
"l-icon": "@oak-frontend-base/miniprogram_npm/lin-ui/icon/index",
|
||||
"l-button": "@oak-frontend-base/miniprogram_npm/lin-ui/button/index"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { WebComponentProps } from 'oak-frontend-base';
|
||||
import { EntityDict } from '../../../general-app-domain';
|
||||
export default function Render(props: WebComponentProps<EntityDict, 'wechatLogin', true, {
|
||||
type: EntityDict['wechatLogin']['Schema']['type'];
|
||||
expired: boolean;
|
||||
expiresAt: boolean;
|
||||
user?: {
|
||||
name: string;
|
||||
nickname: string;
|
||||
};
|
||||
successed: number;
|
||||
userId: string;
|
||||
loginUserId: string;
|
||||
}, {
|
||||
handleConfirm: () => void;
|
||||
}>): JSX.Element;
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var jsx_runtime_1 = require("react/jsx-runtime");
|
||||
var antd_1 = require("antd");
|
||||
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
|
||||
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, expiresAt = _a.expiresAt, user = _a.user, successed = _a.successed, userId = _a.userId, loginUserId = _a.loginUserId;
|
||||
var _b = props.methods, t = _b.t, handleConfirm = _b.handleConfirm;
|
||||
var V;
|
||||
if (successed) {
|
||||
V = '成功的';
|
||||
}
|
||||
else if (expired) {
|
||||
V = '过期了';
|
||||
}
|
||||
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: [(0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.content }, { children: V })), (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical" }, { children: [!oakLoading && !expired && !successed && ((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({ size: "large", block: true, onClick: function () {
|
||||
WeixinJSBridge.call('closeWindow');
|
||||
} }, { children: "\u5173\u95ED" })))] }))] })));
|
||||
}
|
||||
exports.default = Render;
|
||||
|
|
@ -34,9 +34,11 @@ type GeneralAspectDict<
|
|||
{
|
||||
code,
|
||||
env,
|
||||
wechatLoginId,
|
||||
}: {
|
||||
code: string;
|
||||
env: WebEnv;
|
||||
wechatLoginId?: string;
|
||||
},
|
||||
context: Cxt
|
||||
) => Promise<string>;
|
||||
|
|
|
|||
|
|
@ -56,11 +56,12 @@ export class Token<
|
|||
this.publish();
|
||||
}
|
||||
|
||||
async loginWechat(code: string) {
|
||||
async loginWechat(code: string, params?: { wechatLoginId: string }) {
|
||||
const env = await getEnv();
|
||||
const { result } = await this.cache.exec('loginWechat', {
|
||||
code,
|
||||
env: env as WebEnv,
|
||||
wechatLoginId: params?.wechatLoginId,
|
||||
});
|
||||
this.tokenValue = result;
|
||||
this.storage.save('token:token', result);
|
||||
|
|
@ -103,7 +104,7 @@ export class Token<
|
|||
}
|
||||
|
||||
async logout() {
|
||||
await this.cache.exec('logout', {});
|
||||
// await this.cache.exec('logout', {});
|
||||
this.removeToken();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import { EntityDict } from '../../../general-app-domain';
|
|||
import PageHeader from '../../../components/common/pageHeader';
|
||||
import OakAvatar from '../../../components/extraFile/avatar';
|
||||
import MobileLogin from '../../../pages/mobile/login';
|
||||
// import WechatLoginQrCode from '../../../components/wechatLogin/qrCode';
|
||||
|
||||
import Style from './web.module.less';
|
||||
|
||||
|
|
@ -59,9 +60,10 @@ export default function Render(
|
|||
oakDirty,
|
||||
} = data;
|
||||
const [open, setOpen] = useState(false);
|
||||
const [open2, setOpen2] = useState(false);
|
||||
|
||||
return (
|
||||
<PageHeader title="修改个人信息" showBack={showBack}>
|
||||
<PageHeader title="个人设置" showBack={showBack}>
|
||||
<div className={Style.container}>
|
||||
<Form
|
||||
labelCol={{ xs: { span: 4 }, md: { span: 6 } }}
|
||||
|
|
@ -191,6 +193,21 @@ export default function Render(
|
|||
</Space>
|
||||
</>
|
||||
</Form.Item>
|
||||
{/* <Form.Item label="帐号管理">
|
||||
<>
|
||||
<Space>
|
||||
<Typography>{mobile || '未设置'}</Typography>
|
||||
<Button
|
||||
size="small"
|
||||
onClick={() => {
|
||||
setOpen2(true);
|
||||
}}
|
||||
>
|
||||
绑定
|
||||
</Button>
|
||||
</Space>
|
||||
</>
|
||||
</Form.Item> */}
|
||||
<Form.Item
|
||||
wrapperCol={{
|
||||
xs: { offset: 4 },
|
||||
|
|
@ -228,6 +245,22 @@ export default function Render(
|
|||
oakAutoUnmount={true}
|
||||
/>
|
||||
</Modal>
|
||||
{/*
|
||||
<Modal
|
||||
title="绑定微信"
|
||||
open={open2}
|
||||
destroyOnClose={true}
|
||||
footer={null}
|
||||
maskClosable={false}
|
||||
onCancel={() => {
|
||||
setOpen2(false);
|
||||
}}
|
||||
>
|
||||
<WechatLoginQrCode
|
||||
oakPath="$user/info-wechatLogin/qrCode"
|
||||
oakAutoUnmount={true}
|
||||
/>
|
||||
</Modal> */}
|
||||
</PageHeader>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue