更新论坛模块-公告模版

change
panqihua 5 years ago
parent d81f98a820
commit cadf5204fe
  1. 21
      src/app/account/register/register.component.ts
  2. 16
      src/app/account/register/register.service.ts
  3. 1
      src/app/app.service.ts
  4. 60
      src/app/forum/forum.component.html
  5. 34
      src/app/forum/forum.component.ts
  6. 4
      src/app/interface/HttpInterface.ts
  7. 9
      src/app/interface/vo/Token.ts
  8. 2
      src/assets/i18n/en-US.json
  9. 2
      src/assets/i18n/zh-CN.json

@ -3,6 +3,9 @@ import {AbstractControl, FormBuilder, FormGroup, ValidatorFn, Validators} from '
import {Commons} from '../../commons'; import {Commons} from '../../commons';
import {RegisterService} from './register.service'; import {RegisterService} from './register.service';
import {AppService} from '../../app.service'; import {AppService} from '../../app.service';
import {Result} from '../../interface/Result';
import {Router} from '@angular/router';
import {MessageService} from '../../message/message.service';
@Component({ @Component({
selector: 'app-register', selector: 'app-register',
@ -41,7 +44,9 @@ export class RegisterComponent extends Commons implements OnInit {
constructor( constructor(
private fb: FormBuilder, private fb: FormBuilder,
private registerService: RegisterService, private registerService: RegisterService,
private appService: AppService private appService: AppService,
private router: Router,
private messageService: MessageService
) { ) {
super(); 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 { ngOnInit(): void {
this.validForm = {}; this.validForm = {};
for (const key of Object.keys(this.registerForm.value)) { for (const key of Object.keys(this.registerForm.value)) {

@ -7,6 +7,7 @@ import {HttpInterface} from '../../interface/HttpInterface';
import {Result} from '../../interface/Result'; import {Result} from '../../interface/Result';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {MessageService} from '../../message/message.service'; import {MessageService} from '../../message/message.service';
import {Observable} from 'rxjs';
@Injectable({ @Injectable({
@ -16,8 +17,6 @@ export class RegisterService extends JSONRequest {
constructor( constructor(
private http: HttpClient, private http: HttpClient,
private router: Router,
private messageService: MessageService
) { ) {
super(); super();
} }
@ -26,17 +25,10 @@ export class RegisterService extends JSONRequest {
* *
* @param body * @param body
*/ */
register(body) { register(body): Observable<JSONResponse<any>> {
this.http.post<JSONResponse<any>>(HttpInterface.register, body, this.httpOptions) return this.http.post<JSONResponse<any>>(HttpInterface.register, body, this.httpOptions)
.pipe( .pipe(
catchError(this.handleError<any>('注册')) catchError(this.handleError<any>('注册'))
).subscribe(r => { );
if (r.result === Result.OK) {
this.messageService.info('注册成功');
this.router.navigateByUrl('/login');
} else {
this.messageService.danger('注册失败');
}
});
} }
} }

@ -26,4 +26,5 @@ export class AppService extends JSONRequest {
catchError(this.handleError<any>('获取邮箱类型')) catchError(this.handleError<any>('获取邮箱类型'))
); );
} }
} }

@ -1,24 +1,46 @@
<!--公告栏-->
<div class="notice bg-light col-5 mx-auto"> <!--公告轮播-->
<!-- 公告标志--> <div id="carouselExampleControls" class="carousel slide bg-info m-3" data-ride="carousel">
<h1 class="text-center mb-3 mt-3">{{ 'forum.notice' | translate }}</h1> <div class="carousel-inner">
<!-- 公告内容--> <!-- <li *ngFor="let item of notices; index as i;">-->
<div class="notice-content border-success mt-3 mb-3 position-relative"> <!-- {{i}}-->
<!-- 公告标题--> <!-- </li>-->
<h2 class="text-center mb-3 mt-3">公告标题</h2> <ng-container *ngFor="let notice of notices;first as isFirst">
<!-- 公告正文--> <div class="carousel-item" [class.active]="isFirst" >
<div class="notice-body overflow-auto"> <!--公告栏-->
公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容公告内容 <div class="notice bg-light col-5 mx-auto">
</div> <!-- 公告标志-->
<!-- 公告底部--> <h1 class="text-center mb-3">{{ 'forum.notice' | translate }}</h1>
<div class="notice-footer border border-info text-right align-text-bottom position-absolute"> <!-- 公告内容-->
<div class="col-12">{{ 'forum.sender' | translate }} :admin<br>{{ 'forum.time' | translate }}:2020-01-01</div> <div class="notice-content border-success mt-3 mb-3 position-relative">
</div> <!-- 公告标题-->
<h2 class="text-center mb-3 mt-3">{{notice.title}}</h2>
<!-- 公告正文-->
<div class="notice-body overflow-auto p-3">
{{notice.content}}
</div>
<!-- 公告底部-->
<div class="notice-footer border border-info text-right align-text-bottom position-absolute">
<div class="col-12">{{ 'forum.sender' | translate }} :{{notice.managerName}}<br>{{ 'forum.time' | translate }}:{{notice.createTime|date:'yyyy-MM-dd HH:mm:ss'}}</div>
</div>
</div>
</div>
</div>
</ng-container>
</div> </div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div> </div>
<!--审核贴--> <!--审核贴-->
<div class="row border-warning check p-3"> <div class="row border-warning check m-3">
<!-- 审核帖标识--> <!-- 审核帖标识-->
<h1 class="text-info col-12 text-center">{{ 'forum.check' | translate }}</h1> <h1 class="text-info col-12 text-center">{{ 'forum.check' | translate }}</h1>
@ -42,11 +64,11 @@
<!-- 分页按钮--> <!-- 分页按钮-->
<ul class="pagination ml-5 mt-3"> <ul class="pagination ml-5 mt-3">
<li class="page-item"><a class="page-link" href="#">Previous</a></li> <li class="page-item"><a class="page-link" href="#">{{'button.prev_page'|translate}}</a></li>
<li class="page-item active"><a class="page-link" href="#">1</a></li> <li class="page-item active"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li> <li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li> <li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item"><a class="page-link" href="#">Next</a></li> <li class="page-item"><a class="page-link" href="#">{{'button.next_page'|translate}}</a></li>
</ul> </ul>
</div> </div>

@ -1,6 +1,11 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {ForumService} from './forum.service';
import {Result} from '../interface/Result';
/**
*
*/
@Component({ @Component({
selector: 'app-forum', selector: 'app-forum',
templateUrl: './forum.component.html', templateUrl: './forum.component.html',
@ -8,13 +13,40 @@ import {Router} from '@angular/router';
}) })
export class ForumComponent implements OnInit { export class ForumComponent implements OnInit {
/**
*
*/
notices: [
{
managerName: string;
content: string;
title: string,
createTime: number
}
];
constructor( constructor(
private router: Router, 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 { ngOnInit(): void {
console.debug(this.router); this.getAllNotices();
} }
} }

@ -17,7 +17,9 @@ const HttpInterface = {
// 检查邮箱接口 // 检查邮箱接口
checkEmail: '/api/manager/reset/checkEmail', 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)) { for (const key of Object.keys(HttpInterface)) {

@ -1,9 +0,0 @@
// 登陆成功记录的令牌信息
export interface Token {
// 令牌
token: string;
// 创建时间
createTime: number;
// 有效时间
useTime: number;
}

@ -48,6 +48,8 @@
"logout": "logout", "logout": "logout",
"next": "next", "next": "next",
"prev": "prev", "prev": "prev",
"next_page": "Next",
"prev_page": "Previous",
"check_code": "check_code" "check_code": "check_code"
} }
} }

@ -48,6 +48,8 @@
"logout": "注销登录", "logout": "注销登录",
"next": "下一步", "next": "下一步",
"prev": "上一步", "prev": "上一步",
"next_page": "下一页",
"prev_page": "上一页",
"check_code": "检查验证码" "check_code": "检查验证码"
} }
} }

Loading…
Cancel
Save