Commit 61f8be1d authored by 伊藤雄大's avatar 伊藤雄大

2024/7/29

Serviceの戻り値をObservableに変更
parent 3ee07dcc
......@@ -25,7 +25,10 @@ export class CardSelectPage implements OnInit {
* 初期化
*/
ngOnInit(): void {
this.cardList = this.cardService.getList(this.routeService.customerId);
//this.cardList = this.cardService.getList(this.routeService.customerId);
this.cardService.getList(this.routeService.customerId).subscribe((ret: CreditCardModel[]) => {
this.cardList = ret;
});
}
/**
......
......@@ -18,7 +18,7 @@
<ion-col style="padding-top:3px;text-align:right;">
<div (click)="onClickLogout()">ログアウト</div>
</ion-col>
<ion-col style="padding-top:5px;padding-left:5px;padding-right:10px;" size="auto">
<ion-col style="padding-top:5px;padding-left:5px;padding-right:10px;" size="auto" (click)="onClickSetting()">
<ion-icon name="settings-outline"></ion-icon>
</ion-col>
</ion-row>
......
......@@ -34,7 +34,7 @@ export class DenyInfoComponent implements OnInit {
* 選択イベント
* @param event イベント情報
*/
onChangeSelect(event: any) {
onChangeSelect(event: any): void {
this.model.select = event.target.checked;
}
......
......@@ -41,7 +41,10 @@ export class DenyListPage implements OnInit {
*/
ngOnInit() {
if (this.routeService.customerId) {
this.denyList = this.denyListService.getList(this.routeService.customerId);
//this.denyList = this.denyListService.getList(this.routeService.customerId);
this.denyListService.getList(this.routeService.customerId).subscribe((ret: DenyListModel[]) => {
this.denyList = ret;
});
}
}
......
......@@ -27,14 +27,17 @@ export class HistoryPage implements OnInit {
/**
* 初期化
*/
ngOnInit() {
ngOnInit(): void {
this.searchDate = (new Date()).toLocaleDateString("ja-JP", {
year: "numeric",
month: "2-digit",
day: "2-digit",
}).split("/").join("-");
if (this.routeService.customerId) {
this.historyList = this.historyService.getHistoryList(this.routeService.customerId, this.searchDate);
//this.historyList = this.historyService.getHistoryList(this.routeService.customerId, this.searchDate);
this.historyService.getHistoryList(this.routeService.customerId, this.searchDate).subscribe((ret: HistoryModel[]) => {
this.historyList = ret;
});
}
}
......@@ -50,7 +53,7 @@ export class HistoryPage implements OnInit {
/**
* 前日へ
*/
onClickBefore() {
onClickBefore(): void {
if (this.searchDate) {
let date = new Date(this.searchDate);
date.setDate(date.getDate() - 1);
......@@ -60,7 +63,10 @@ export class HistoryPage implements OnInit {
day: "2-digit",
}).split("/").join("-");
if (this.routeService.customerId) {
this.historyList = this.historyService.getHistoryList(this.routeService.customerId, this.searchDate);
//this.historyList = this.historyService.getHistoryList(this.routeService.customerId, this.searchDate);
this.historyService.getHistoryList(this.routeService.customerId, this.searchDate).subscribe((ret: HistoryModel[]) => {
this.historyList = ret;
});
}
}
}
......@@ -68,7 +74,7 @@ export class HistoryPage implements OnInit {
/**
* 翌日へ
*/
onClickAfter() {
onClickAfter(): void {
if (this.searchDate) {
let date = new Date(this.searchDate);
date.setDate(date.getDate() + 1);
......@@ -78,7 +84,10 @@ export class HistoryPage implements OnInit {
day: "2-digit",
}).split("/").join("-");
if (this.routeService.customerId) {
this.historyList = this.historyService.getHistoryList(this.routeService.customerId, this.searchDate);
//this.historyList = this.historyService.getHistoryList(this.routeService.customerId, this.searchDate);
this.historyService.getHistoryList(this.routeService.customerId, this.searchDate).subscribe((ret: HistoryModel[]) => {
this.historyList = ret;
});
}
}
}
......@@ -89,7 +98,10 @@ export class HistoryPage implements OnInit {
*/
onChangeDate(event: any): void {
if (this.routeService.customerId) {
this.historyList = this.historyService.getHistoryList(this.routeService.customerId, event.target.value);
//this.historyList = this.historyService.getHistoryList(this.routeService.customerId, event.target.value);
this.historyService.getHistoryList(this.routeService.customerId, this.searchDate).subscribe((ret: HistoryModel[]) => {
this.historyList = ret;
});
}
}
}
......@@ -45,10 +45,13 @@ export class HomePage implements OnInit {
return;
}
if (this.loginService.login(this.email, this.password)) {
this.loginService.login(this.email, this.password).subscribe((ret: boolean) => {
//TODO
this.routeService.navigateMenu("0000");
}
if (ret) {
this.routeService.navigateMenu("0000");
}
});
}
/**
......
......@@ -53,7 +53,10 @@ export class PassChangePage implements OnInit {
ngOnInit(): void {
//停留所一覧
if (this.commuterPassModel) {
this.stopList = this.passService.getStopList(this.commuterPassModel?.agencyId, this.commuterPassModel?.routeId);
//this.stopList = this.passService.getStopList(this.commuterPassModel?.agencyId, this.commuterPassModel?.routeId);
this.passService.getStopList(this.commuterPassModel?.agencyId, this.commuterPassModel?.routeId).subscribe((ret: Map<string, string>) => {
this.stopList = ret;
})
this.getonStopId = this.commuterPassModel.getonStopId;
this.getoffStopId = this.commuterPassModel.getoffStopId;
this.purchasePrice = this.passService.calcPassAmount(this.commuterPassModel.agencyId, this.commuterPassModel.routeId, this.commuterPassModel.useTermId, this.commuterPassModel.priceRangeId, this.getonStopId, this.getoffStopId);
......@@ -70,6 +73,7 @@ export class PassChangePage implements OnInit {
/**
* 定期券区間変更
* @param event イベント情報
*/
onClickChange(event: any): void {
if (event.detail.role === 'confirm') {
......
......@@ -51,7 +51,10 @@ export class PassContinuePage implements OnInit {
ngOnInit(): void {
//使用期間一覧
if (this.commuterPassModel) {
this.useTermList = this.passService.getUseTermList(this.commuterPassModel?.agencyId);
//this.useTermList = this.passService.getUseTermList(this.commuterPassModel?.agencyId);
this.passService.getUseTermList(this.commuterPassModel.agencyId).subscribe((ret: Map<string, string>) => {
this.useTermList = ret;
});
this.useTermId = this.commuterPassModel.useTermId;
this.price = this.passService.calcPassAmount(this.commuterPassModel.agencyId, this.commuterPassModel.routeId, this.useTermId, this.commuterPassModel.priceRangeId, this.commuterPassModel.getonStopId, this.commuterPassModel.getoffStopId);
}
......@@ -66,6 +69,7 @@ export class PassContinuePage implements OnInit {
/**
* 定期券継続
* @param event イベント情報
*/
onClickContinue(event: any): void {
if (event.detail.role === 'confirm') {
......
......@@ -71,6 +71,7 @@ export class PassRefundPage implements OnInit {
/**
* 払い戻し
* @param event イベント情報
*/
onClickRefund(event: any): void {
if (event.detail.role === 'confirm') {
......
......@@ -64,21 +64,38 @@ export class PassRegistPage implements OnInit {
//路線一覧
//TODO 事業者IDはどうやって決める?
this.routeList = this.passService.getRouteList(this.agencyId);
this.routeId = this.routeList.keys().next().value;
//this.routeList = this.passService.getRouteList(this.agencyId);
//this.routeId = this.routeList.keys().next().value;
this.passService.getRouteList(this.agencyId).subscribe((ret: Map<string, string>) => {
this.routeList = ret;
this.routeId = ret.keys().next().value;
//停留所一覧
//this.stopList = this.passService.getStopList(this.agencyId, this.routeList.values().next().value);
//this.getonStopId = this.stopList.keys().next().value;
//this.getoffStopId = this.stopList.keys().next().value;
this.passService.getStopList(this.agencyId, ret.values().next().value).subscribe((stopList: Map<string, string>) => {
this.stopList = stopList;
this.getonStopId = stopList.keys().next().value;
this.getoffStopId = stopList.keys().next().value;
});
});
//使用期間一覧
this.useTermList = this.passService.getUseTermList(this.agencyId);
this.useTermId = this.useTermList.keys().next().value;
//this.useTermList = this.passService.getUseTermList(this.agencyId);
//this.useTermId = this.useTermList.keys().next().value;
this.passService.getUseTermList(this.agencyId).subscribe((ret: Map<string, string>) => {
this.useTermList = ret;
this.useTermId = ret.keys().next().value;
})
//料金区分一覧
this.priceRangeList = this.passService.getPriceRangeList(this.agencyId);
this.priceRangeId = this.priceRangeList.keys().next().value;
//this.priceRangeList = this.passService.getPriceRangeList(this.agencyId);
//this.priceRangeId = this.priceRangeList.keys().next().value;
this.passService.getPriceRangeList(this.agencyId).subscribe((ret: Map<string, string>) => {
this.priceRangeList = ret;
this.priceRangeId = ret.keys().next().value;
})
//停留所一覧
this.stopList = this.passService.getStopList(this.agencyId, this.routeList.values().next().value);
this.getonStopId = this.stopList.keys().next().value;
this.getoffStopId = this.stopList.keys().next().value;
}
/**
......@@ -86,7 +103,10 @@ export class PassRegistPage implements OnInit {
* @param event イベント情報
*/
onChangeRoute(event: any): void {
this.stopList = this.passService.getStopList(this.agencyId, event.target.value);
//this.stopList = this.passService.getStopList(this.agencyId, event.target.value);
this.passService.getStopList(this.agencyId, event.target.value).subscribe((ret: Map<string, string>) => {
this.stopList = ret;
});
this.price = this.passService.calcPassAmount(this.agencyId, event.target.value, this.useTermId, this.priceRangeId, this.getonStopId, this.getoffStopId);
}
......@@ -131,6 +151,7 @@ export class PassRegistPage implements OnInit {
/**
* 追加
* @param event イベント情報
*/
onClickAdd(event: any): void {
if (event.detail.role === 'confirm') {
......
......@@ -29,9 +29,12 @@ export class PassSelectPage implements OnInit {
/**
* 初期化
*/
ngOnInit() {
ngOnInit(): void {
if (this.routeService.tokenId) {
this.commuterPassList = this.passService.getList(this.routeService.tokenId);
//this.commuterPassList = this.passService.getList(this.routeService.tokenId);
this.passService.getList(this.routeService.tokenId).subscribe((ret: CommuterPassModel[]) => {
this.commuterPassList = ret;
});
}
}
......@@ -46,7 +49,7 @@ export class PassSelectPage implements OnInit {
* 定期券区間変更
* @param model 定期券情報
*/
onClickChange(model: CommuterPassModel) {
onClickChange(model: CommuterPassModel): void {
this.routeService.navigatePassChange(model);
}
......@@ -54,7 +57,7 @@ export class PassSelectPage implements OnInit {
* 定期券継続
* @param model 定期券情報
*/
onClickContinue(model: CommuterPassModel) {
onClickContinue(model: CommuterPassModel): void {
this.routeService.navigatePassContinue(model);
}
......@@ -62,14 +65,14 @@ export class PassSelectPage implements OnInit {
* 定期券払戻
* @param model 定期券情報
*/
onClickRefund(model: CommuterPassModel) {
onClickRefund(model: CommuterPassModel): void {
this.routeService.navigatePassRefund(model);
}
/**
* 定期券登録
*/
onClickAddPass() {
onClickAddPass(): void {
this.routeService.navigatePassRegist();
}
}
import { Injectable } from '@angular/core';
import { CreditCardModel } from '../model/credit-card.model';
import { Observable } from 'rxjs';
/**
* クレジットカードサービス
......@@ -17,7 +18,7 @@ export class CardService {
* クレジットカード情報一覧取得
* @param customerId 利用者ID
*/
getList(customerId?: string): CreditCardModel[] {
getList(customerId?: string): Observable<CreditCardModel[]> {
//TODO
let cardList = new Array();
for (let i = 0; i < 2; i++) {
......@@ -31,7 +32,10 @@ export class CardService {
model.cardMonth = "02";
cardList.push(model);
}
return cardList;
//return cardList;
return new Observable<CreditCardModel[]>(o => {
o.next(cardList);
})
}
/**
......@@ -39,7 +43,7 @@ export class CardService {
* @param customerId 利用者ID
* @param model クレジットカード情報
*/
regist(customerId?: string, model?: CreditCardModel) {
regist(customerId?: string, model?: CreditCardModel): void {
//TODO
}
......
import { Injectable } from '@angular/core';
import { DenyListModel } from '../model/deny-list.model';
import { Observable } from 'rxjs';
/**
* 拒否リストサービス
......@@ -16,8 +17,9 @@ export class DenylistService {
/**
* 拒否リスト取得
* @param customerId 利用者ID
* @return 拒否リスト
*/
getList(customerId: string): DenyListModel[] {
getList(customerId: string): Observable<DenyListModel[]> {
//TODO
let denyList = new Array();
for (let i = 0; i < 4; i++) {
......@@ -31,7 +33,10 @@ export class DenylistService {
denyListModel.amount = 1000;
denyList.push(denyListModel);
}
return denyList;
//return denyList;
return new Observable<DenyListModel[]>(o => {
o.next(denyList);
});
}
/**
......
import { Injectable } from '@angular/core';
import { HistoryModel } from '../model/history.model';
import { Observable } from 'rxjs';
/**
* 乗降履歴サービス
......@@ -19,7 +20,7 @@ export class HistoryService {
* @param searchDate 検索対象日
* @returns 乗降履歴一覧
*/
getHistoryList(customerId: string, searchDate?: string): HistoryModel[] {
getHistoryList(customerId: string, searchDate?: string): Observable<HistoryModel[]> {
//TODO
let historyList = new Array();
for (let i = 0; i < 10; i++) {
......@@ -56,6 +57,9 @@ export class HistoryService {
historyModel.status = 0;
historyList.push(historyModel);
return historyList;
//return historyList;
return new Observable<HistoryModel[]>(o => {
o.next(historyList);
});
}
}
import { Injectable } from '@angular/core';
import { from, Observable } from 'rxjs';
import { Observable } from 'rxjs';
/**
* ログインサービス
......@@ -19,8 +19,10 @@ export class LoginService {
* @param password パスワード
* @returns ログイン結果
*/
public login(email: string, password: string): boolean {
public login(email: string, password: string): Observable<boolean> {
// TODO
return true;
return new Observable<boolean>(o => {
o.next(true);
});
}
}
import { Injectable } from '@angular/core';
import { CommuterPassModel } from '../model/commuter-pass.model';
import { RefundModel } from '../model/refund.model';
import { Observable } from 'rxjs';
/**
* 定期券サービス
......@@ -17,8 +18,10 @@ export class PassService {
/**
* 定期一覧取得
* @param tokenId トークンID
* @return 定期一覧
*/
getList(tokenId: string): CommuterPassModel[] {
getList(tokenId: string): Observable<CommuterPassModel[]> {
//TODO
let commuterPassList = new Array();
for (let i = 0; i < 2; i++) {
let model: CommuterPassModel = new CommuterPassModel();
......@@ -37,7 +40,10 @@ export class PassService {
model.getoffStopName = "停留所5";
commuterPassList.push(model);
}
return commuterPassList;
//return commuterPassList;
return new Observable<CommuterPassModel[]>(o => {
o.next(commuterPassList);
});
}
/**
......@@ -77,14 +83,17 @@ export class PassService {
* @param agencyId 事業者ID
* @returns 路線一覧
*/
getRouteList(agencyId: string): Map<string, string> {
getRouteList(agencyId: string): Observable<Map<string, string>> {
//路線一覧
let routeList = new Map();
for (let i = 0; i < 5; i++) {
let str = String(i + 1);
routeList.set(str, "路線" + str);
}
return routeList;
//return routeList;
return new Observable<Map<string, string>>(o => {
o.next(routeList);
})
}
/**
......@@ -92,13 +101,16 @@ export class PassService {
* @param agencyId 事業者ID
* @returns 使用期間一覧
*/
getUseTermList(agencyId: string): Map<string, string> {
getUseTermList(agencyId: string): Observable<Map<string, string>> {
let useTermList = new Map();
useTermList.set("1", "1ヶ月");
useTermList.set("3", "3ヶ月");
useTermList.set("6", "6ヶ月");
return useTermList;
//return useTermList;
return new Observable<Map<string, string>>(o => {
o.next(useTermList);
})
}
/**
......@@ -106,12 +118,15 @@ export class PassService {
* @param agencyId 事業者ID
* @returns 料金区分一覧
*/
getPriceRangeList(agencyId: string): Map<string, string> {
getPriceRangeList(agencyId: string): Observable<Map<string, string>> {
let priceRangeList = new Map();
priceRangeList.set("1", "大人");
priceRangeList.set("2", "小児");
priceRangeList.set("3", "学生");
return priceRangeList;
//return priceRangeList;
return new Observable<Map<string, string>>(o => {
o.next(priceRangeList);
})
}
/**
......@@ -120,13 +135,16 @@ export class PassService {
* @param routeId 路線ID
* @returns 停留所一覧
*/
getStopList(agencyId: string, routeId: string): Map<string, string> {
getStopList(agencyId: string, routeId: string): Observable<Map<string, string>> {
let stopList = new Map();
for (let i = 0; i < 5; i++) {
let str = String(i + 1);
stopList.set(str, "停留所" + str);
}
return stopList;
//return stopList;
return new Observable<Map<string, string>>(o => {
o.next(stopList);
})
}
/**
......@@ -235,7 +253,6 @@ export class PassService {
let unit = (getoffStop - getonStop) >= 0 ? (getoffStop - getonStop) : (getonStop - getoffStop);
ret.standardFare = unit * 100;
//使用日数計算
let now = new Date();
let start = new Date("2024/07/01");
......
import { Injectable } from '@angular/core';
import { UserInfoModel } from '../model/user-info.model';
import { Observable } from 'rxjs';
/**
* 利用者サービス
......@@ -18,7 +19,7 @@ export class UserService {
* 利用者情報取得
* @param customerId 利用者ID
*/
getInfo(customerId: string): UserInfoModel {
getInfo(customerId: string): Observable<UserInfoModel> {
let model: UserInfoModel = new UserInfoModel();
//TODO ダミー
......@@ -28,7 +29,10 @@ export class UserService {
model.email = "yamada_tarou@test.com";
model.password = "password00";
return model;
//return model;
return new Observable<UserInfoModel>(o => {
o.next(model);
});
}
/**
......
......@@ -53,12 +53,14 @@ export class UserRegistPage implements OnInit {
*/
ngOnInit(): void {
if (this.customerId) {
let model: UserInfoModel = this.userService.getInfo(this.customerId);
this.name = model.name;
this.nameKana = model.nameKana;
this.phoneNumber = model.phoneNumber;
this.email = model.email;
this.password = model.password;
//let model: UserInfoModel = this.userService.getInfo(this.customerId);
this.userService.getInfo(this.customerId).subscribe((model: UserInfoModel) => {
this.name = model.name;
this.nameKana = model.nameKana;
this.phoneNumber = model.phoneNumber;
this.email = model.email;
this.password = model.password;
});
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment