diff --git a/src/app/account/register/register.component.ts b/src/app/account/register/register.component.ts index a3273c1..63d835b 100644 --- a/src/app/account/register/register.component.ts +++ b/src/app/account/register/register.component.ts @@ -3,6 +3,9 @@ import {AbstractControl, FormBuilder, FormGroup, ValidatorFn, Validators} from ' import {Commons} from '../../commons'; import {RegisterService} from './register.service'; import {AppService} from '../../app.service'; +import {Result} from '../../interface/Result'; +import {Router} from '@angular/router'; +import {MessageService} from '../../message/message.service'; @Component({ selector: 'app-register', @@ -41,7 +44,9 @@ export class RegisterComponent extends Commons implements OnInit { constructor( private fb: FormBuilder, private registerService: RegisterService, - private appService: AppService + private appService: AppService, + private router: Router, + private messageService: MessageService ) { super(); } @@ -59,6 +64,20 @@ export class RegisterComponent extends Commons implements OnInit { }; } + /** + * 注册 + */ + register() { + this.registerService.register(this.registerForm.value).subscribe(r => { + if (r.result === Result.OK) { + this.messageService.info('注册成功'); + this.router.navigateByUrl('/login'); + } else { + this.messageService.danger('注册失败'); + } + }); + } + ngOnInit(): void { this.validForm = {}; for (const key of Object.keys(this.registerForm.value)) { diff --git a/src/app/account/register/register.service.ts b/src/app/account/register/register.service.ts index d1969b5..4772fc6 100644 --- a/src/app/account/register/register.service.ts +++ b/src/app/account/register/register.service.ts @@ -7,6 +7,7 @@ import {HttpInterface} from '../../interface/HttpInterface'; import {Result} from '../../interface/Result'; import {Router} from '@angular/router'; import {MessageService} from '../../message/message.service'; +import {Observable} from 'rxjs'; @Injectable({ @@ -16,8 +17,6 @@ export class RegisterService extends JSONRequest { constructor( private http: HttpClient, - private router: Router, - private messageService: MessageService ) { super(); } @@ -26,17 +25,10 @@ export class RegisterService extends JSONRequest { * * @param body 注册表单 */ - register(body) { - this.http.post>(HttpInterface.register, body, this.httpOptions) + register(body): Observable> { + return this.http.post>(HttpInterface.register, body, this.httpOptions) .pipe( catchError(this.handleError('注册')) - ).subscribe(r => { - if (r.result === Result.OK) { - this.messageService.info('注册成功'); - this.router.navigateByUrl('/login'); - } else { - this.messageService.danger('注册失败'); - } - }); + ); } } diff --git a/src/app/app.service.ts b/src/app/app.service.ts index 0ee889b..4d57aaf 100644 --- a/src/app/app.service.ts +++ b/src/app/app.service.ts @@ -26,4 +26,5 @@ export class AppService extends JSONRequest { catchError(this.handleError('获取邮箱类型')) ); } + } diff --git a/src/app/forum/forum.component.html b/src/app/forum/forum.component.html index a43b697..f681fc9 100644 --- a/src/app/forum/forum.component.html +++ b/src/app/forum/forum.component.html @@ -1,24 +1,46 @@ - -
- -

{{ 'forum.notice' | translate }}

- -
- -

公告标题

- -
- 公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容 -
- - + + + -
+

{{ 'forum.check' | translate }}

@@ -42,11 +64,11 @@
diff --git a/src/app/forum/forum.component.ts b/src/app/forum/forum.component.ts index 1b8b051..90d86b4 100644 --- a/src/app/forum/forum.component.ts +++ b/src/app/forum/forum.component.ts @@ -1,6 +1,11 @@ import {Component, OnInit} from '@angular/core'; import {Router} from '@angular/router'; +import {ForumService} from './forum.service'; +import {Result} from '../interface/Result'; +/** + * 论坛组件 + */ @Component({ selector: 'app-forum', templateUrl: './forum.component.html', @@ -8,13 +13,40 @@ import {Router} from '@angular/router'; }) export class ForumComponent implements OnInit { + /** + * 公告信息 + */ + notices: [ + { + managerName: string; + content: string; + title: string, + createTime: number + } + ]; + constructor( private router: Router, + private forumService: ForumService ) { } + /** + * 获取公告信息 + */ + getAllNotices() { + this.forumService.getAllNotices().subscribe(res => { + if (res.result === Result.OK) { + console.debug('获取公告信息成功'); + this.notices = res.body; + } else { + alert('获取公告信息失败'); + } + }); + } + ngOnInit(): void { - console.debug(this.router); + this.getAllNotices(); } } diff --git a/src/app/interface/HttpInterface.ts b/src/app/interface/HttpInterface.ts index 4b5f8cc..c84c56e 100644 --- a/src/app/interface/HttpInterface.ts +++ b/src/app/interface/HttpInterface.ts @@ -17,7 +17,9 @@ const HttpInterface = { // 检查邮箱接口 checkEmail: '/api/manager/reset/checkEmail', // 重置密码 - resetPwd: '/api/manager/reset/resetPwd' + resetPwd: '/api/manager/reset/resetPwd', + // 获取所有公告 + getAllNotices: '/api/forum/notices' }; for (const key of Object.keys(HttpInterface)) { diff --git a/src/app/interface/vo/Token.ts b/src/app/interface/vo/Token.ts deleted file mode 100644 index 510d26a..0000000 --- a/src/app/interface/vo/Token.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 登陆成功记录的令牌信息 -export interface Token { - // 令牌 - token: string; - // 创建时间 - createTime: number; - // 有效时间 - useTime: number; -} diff --git a/src/assets/i18n/en-US.json b/src/assets/i18n/en-US.json index 0adaa67..d432d13 100644 --- a/src/assets/i18n/en-US.json +++ b/src/assets/i18n/en-US.json @@ -48,6 +48,8 @@ "logout": "logout", "next": "next", "prev": "prev", + "next_page": "Next", + "prev_page": "Previous", "check_code": "check_code" } } diff --git a/src/assets/i18n/zh-CN.json b/src/assets/i18n/zh-CN.json index 1bc294c..04d32a6 100644 --- a/src/assets/i18n/zh-CN.json +++ b/src/assets/i18n/zh-CN.json @@ -48,6 +48,8 @@ "logout": "注销登录", "next": "下一步", "prev": "上一步", + "next_page": "下一页", + "prev_page": "上一页", "check_code": "检查验证码" } }