5 changed files with 68 additions and 17 deletions
@ -1,18 +1,63 @@ |
|||
import {Component, Inject} from "@angular/core"; |
|||
import {MAT_DIALOG_DATA} from "@angular/material/dialog"; |
|||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; |
|||
import {VipBuy} from "../../entities/VipBuy"; |
|||
import {AuthService} from "../../services/auth.service"; |
|||
import {VipService} from "../../services/vip.service"; |
|||
|
|||
@Component({ |
|||
selector: "app-vip-buy-dialog", |
|||
template:` |
|||
<h1 mat-dialog-title style="color: black">Получение бесплатно</h1> |
|||
<mat-dialog-content> |
|||
<app-need-auth-to-continue *ngIf="authService.isAuth()"></app-need-auth-to-continue> |
|||
<div *ngIf="!authService.isAuth()"> |
|||
<p>Бесплатная випка отличный способ проверить ее перед "покупкой", но стоит знать что для ее получения стоит отыграть некоторое время на наших серверах. Бесплатную випку можно получать неограниченное количество раз, но с перерывами!</p> |
|||
<p *ngIf="text.length>0" [style]="{'color': text_color}">{{text}}</p> |
|||
<button *ngIf="text.length==0" mat-button mat-raised-button style="width: 100%" (click)="getFreeVip()">Получить випку бесплатно</button> |
|||
<button (click)="dialogRef.close()" mat-button mat-raised-button style="width: 100%">Закрыть</button> |
|||
</div> |
|||
</mat-dialog-content> |
|||
<mat-dialog-actions> |
|||
|
|||
</mat-dialog-actions> |
|||
` |
|||
}) |
|||
export class VipFreeDialog { |
|||
constructor(@Inject(MAT_DIALOG_DATA) public vip:VipBuy) {} |
|||
constructor(@Inject(MAT_DIALOG_DATA) public vip:VipBuy, |
|||
public authService: AuthService, |
|||
private vipService: VipService, |
|||
public dialogRef: MatDialogRef<any>) {} |
|||
text: string = ''; |
|||
text_color: string = 'black'; |
|||
|
|||
getFreeVip() { |
|||
this.vipService.getFreeVip().subscribe( |
|||
(res) => { |
|||
switch (res) { |
|||
case 0: { |
|||
this.text = 'У тебя уже есть VIP права на сервере, приходи когда кончатся'; |
|||
this.text_color = '#DDD78D'; |
|||
//права уже есть
|
|||
break; |
|||
} |
|||
case 1: { |
|||
this.text = 'Иди развлекайся браток, бесплатная випка твоя'; |
|||
this.text_color = '#3A7D44'; |
|||
//права выданы
|
|||
break; |
|||
} |
|||
default: { |
|||
if (res > 1) { |
|||
//стоит подождать пока можно получить новые
|
|||
this.text = `Чел, ты недавно уже забрал свою випку, подожди до ${new Date(new Date().getTime() + res*1000).toLocaleString()}`; |
|||
this.text_color = '#2B4570'; |
|||
} else { |
|||
this.text = `Ты недостаточно наиграл у нас на серверах, наиграй еще ${res/60*-1} минут`; |
|||
this.text_color = '#7180AC'; |
|||
} |
|||
} |
|||
} |
|||
}, (err) => { |
|||
this.text = 'Произошла ошибка, попробуй чуть позже' |
|||
this.text_color = 'red'; |
|||
} |
|||
) |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue