token/login
This commit is contained in:
parent
87aab51a0c
commit
a6c664e278
|
|
@ -1,10 +1,11 @@
|
|||
import { EntityDict } from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-app-domain/EntityDict';
|
||||
import { loginByPassword, loginMp, /* AspectDict as TokenAD */} from './token';
|
||||
import { loginByPassword, loginMp, loginWechatMp } from './token';
|
||||
|
||||
export const aspectDict = {
|
||||
loginByPassword,
|
||||
loginMp,
|
||||
loginWechatMp,
|
||||
};
|
||||
|
||||
// export type AspectDict<ED extends EntityDict & BaseEntityDict> = TokenAD<ED> & CrudAD<ED>;
|
||||
|
|
@ -20,6 +20,10 @@ export async function loginByPassword<ED extends EntityDict, Cxt extends General
|
|||
throw new Error('method not implemented!');
|
||||
}
|
||||
|
||||
export async function loginWechatMp<ED extends EntityDict, Cxt extends GeneralRuntimeContext<ED>>(code: string, context: Cxt): Promise<string> {
|
||||
throw new Error('method not implemented!');
|
||||
}
|
||||
|
||||
/* export type AspectDict<ED extends EntityDict> = {
|
||||
loginMp: (params: { code: string }, context: GeneralRuntimeContext<ED>) => Promise<string>;
|
||||
loginByPassword: (params: { password: string, mobile: string }, context: GeneralRuntimeContext<ED>) => Promise<string>;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ export class Token extends Feature<EntityDict, GeneralRuntimeContext<EntityDict>
|
|||
this.token = await this.getAspectProxy().loginByPassword({ password, mobile });
|
||||
}
|
||||
|
||||
@Action
|
||||
async loginWechatMp(code: string) {
|
||||
this.token = await this.getAspectProxy().loginWechatMp(code);
|
||||
}
|
||||
|
||||
@Action
|
||||
async logout() {
|
||||
this.token = undefined;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ import { MakeOakComponent, MakeOakPage } from 'oak-frontend-base';
|
|||
import { EntityDict } from 'oak-app-domain/EntityDict';
|
||||
import { GeneralRuntimeContext } from '../RuntimeContext';
|
||||
import aspectDict from '../aspects';
|
||||
import { initialize } from '../features';
|
||||
|
||||
declare global {
|
||||
const OakPage: MakeOakPage<EntityDict, GeneralRuntimeContext<EntityDict>, typeof aspectDict, {}>;
|
||||
const OakComponent: MakeOakComponent<EntityDict, GeneralRuntimeContext<EntityDict>, typeof aspectDict, {}>;
|
||||
const OakPage: MakeOakPage<EntityDict, GeneralRuntimeContext<EntityDict>, typeof aspectDict, ReturnType<typeof initialize>>;
|
||||
const OakComponent: MakeOakComponent<EntityDict, GeneralRuntimeContext<EntityDict>, typeof aspectDict, ReturnType<typeof initialize>>;
|
||||
}
|
||||
export {}
|
||||
|
|
@ -76,7 +76,6 @@
|
|||
"node_modules",
|
||||
"**/*.spec.ts",
|
||||
"test",
|
||||
"scripts",
|
||||
"wechatMp"
|
||||
"scripts"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"navigationBarTitleText": "用户登录",
|
||||
"usingComponents": {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
/** index.wxss **/
|
||||
@import "../../../styles/base.less";
|
||||
@import "../../../styles/cpn.less";
|
||||
|
||||
.page-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
background-color: slategrey;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
OakPage({
|
||||
path: 'token-login',
|
||||
entity: 'token',
|
||||
projection: {
|
||||
id: 1,
|
||||
name: 1,
|
||||
depth: 1,
|
||||
level: 1,
|
||||
},
|
||||
isList: true,
|
||||
formData: (tokenList) => {
|
||||
if (tokenList.length > 0) {
|
||||
return {
|
||||
loggedIn: true,
|
||||
};
|
||||
}
|
||||
return {
|
||||
loggedIn: false,
|
||||
}
|
||||
},
|
||||
}, {
|
||||
properties: {
|
||||
depth: Number,
|
||||
},
|
||||
methods: {
|
||||
async onLoginClicked(options: WechatMiniprogram.Touch) {
|
||||
const code = await wx.login();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<!-- index.wxml -->
|
||||
<view class="page-body">
|
||||
<view class="g-form" style="flex: 1" wx:for="{{arealist}}" wx:key="index">
|
||||
<view class="g-form-item" data-id="{{item.id}}" bindtap="onItemClicked">
|
||||
<text>{{item.name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
Loading…
Reference in New Issue