|
@@ -1,6 +1,4 @@
|
|
|
-import { UserData } from "./UserData";
|
|
|
-
|
|
|
-interface Mail {
|
|
|
+export interface Mail {
|
|
|
id: string;
|
|
|
sys: number;
|
|
|
expire: string;
|
|
@@ -38,6 +36,11 @@ class Data {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ getData(): { [id: string]: Mail } {
|
|
|
+ return this._mails;
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置最后获得邮件索引
|
|
|
setMailMax(data: number[]): void {
|
|
|
for (const v of data) {
|
|
|
if (v > this._mailMaxIdTab[1]) {
|
|
@@ -46,6 +49,7 @@ class Data {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //设置最新获得邮件索引
|
|
|
setNewMail(data: Mail[]): void {
|
|
|
for (const v of data) {
|
|
|
this._mails[v.id] = v;
|
|
@@ -57,56 +61,12 @@ class Data {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- getData(): { [id: string]: Mail } {
|
|
|
- return this._mails;
|
|
|
- }
|
|
|
-
|
|
|
+ //获取最新获得邮件索引
|
|
|
getMaxMailId(type: number): number {
|
|
|
return this._mailMaxIdTab[type];
|
|
|
}
|
|
|
|
|
|
- orderMail(): Mail[] {
|
|
|
- const mailList: Mail[] = [];
|
|
|
- const nowTime = UserData.getServerTime();
|
|
|
-
|
|
|
- for (const key in this._mails) {
|
|
|
- const v = this._mails[key];
|
|
|
- // if (parseInt(v.expire, 10) >= nowTime) {
|
|
|
- mailList.push(v);
|
|
|
- // }
|
|
|
- }
|
|
|
-
|
|
|
- mailList.sort((a, b) => {
|
|
|
- const x = parseInt(a.read, 10) === 0 ? 1 : 0;
|
|
|
- const y = parseInt(b.read, 10) === 0 ? 1 : 0;
|
|
|
-
|
|
|
- if (x > y) {
|
|
|
- return -1;
|
|
|
- } else if (x < y) {
|
|
|
- return 1;
|
|
|
- }
|
|
|
- return parseInt(a.expire, 10) > parseInt(b.expire, 10) ? -1 : 1;
|
|
|
- });
|
|
|
-
|
|
|
- return mailList;
|
|
|
- }
|
|
|
-
|
|
|
- getLeftDays(time: number): number {
|
|
|
- let leftTime = time - UserData.getServerTime();
|
|
|
- leftTime = Math.ceil(leftTime / (24 * 60 * 60));
|
|
|
- return leftTime <= 0 ? 0 : leftTime;
|
|
|
- }
|
|
|
-
|
|
|
- haveItemToGet(): boolean {
|
|
|
- for (const key in this._mails) {
|
|
|
- const v = this._mails[key];
|
|
|
- if (v.awards && v.awards.length > 0) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
+ //根据id设置邮件已读状态
|
|
|
setMailReadById(id: string): void {
|
|
|
for (const key in this._mails) {
|
|
|
const v = this._mails[key];
|
|
@@ -117,6 +77,7 @@ class Data {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //批量设置邮件已读状态
|
|
|
setMailRead(ids: string[]): void {
|
|
|
for (const k1 of ids) {
|
|
|
for (const key in this._mails) {
|
|
@@ -128,70 +89,7 @@ class Data {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- haveMailNotRead(): boolean {
|
|
|
- const nowTime = UserData.getServerTime();
|
|
|
- for (const key in this._mails) {
|
|
|
- const v = this._mails[key];
|
|
|
- if (parseInt(v.expire, 10) >= nowTime && parseInt(v.read, 10) === 0) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- getShowAward(id: string): any {
|
|
|
- for (const key in this._mails) {
|
|
|
- const v = this._mails[key];
|
|
|
- if (parseInt(v.id, 10) === parseInt(id, 10)) {
|
|
|
- if (v.awards && v.awards.length > 0) {
|
|
|
- if (this._mails[parseInt(v.id, 10)].read === '1') {
|
|
|
- return null;
|
|
|
- } else {
|
|
|
- return v.awards[0];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- getMailText(content: any, isTitle: boolean): string {
|
|
|
- let jsonData = content;
|
|
|
- let text: string;
|
|
|
-
|
|
|
- // if (isTitle) {
|
|
|
- // if (typeof jsonData === 'number') {
|
|
|
- // text = ConfData.getMapData('maillocaltext.dat')[jsonData.toString()].Title;
|
|
|
- // } else {
|
|
|
- // text = content;
|
|
|
- // }
|
|
|
- // return Util.getString(text);
|
|
|
- // } else {
|
|
|
- // if (Array.isArray(jsonData)) {
|
|
|
- // const count = jsonData.length;
|
|
|
- // text = ConfData.getMapData('maillocaltext.dat')[jsonData[0].toString()].Desc;
|
|
|
-
|
|
|
- // if (count === 2) {
|
|
|
- // const tcConfNew = ConfData.getMapData('manorcity.dat');
|
|
|
- // const tcsConfNew = ConfData.getMapData('manorschedule.dat');
|
|
|
- // const tcConf = ConfData.getMapData('territorycity.dat');
|
|
|
- // const tcsConf = ConfData.getMapData('territoryschedule.dat');
|
|
|
-
|
|
|
- // if (parseInt(jsonData[0], 10) === 14) {
|
|
|
- // const str = ' Lv.' + tcConf[jsonData[1]].CityLevel + ' ' + Util.getString(tcConf[jsonData[1]].Name);
|
|
|
- // text = Util.getString(text).replace('%s', str);
|
|
|
- // } else {
|
|
|
-
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // return text;
|
|
|
- // } else {
|
|
|
- return content;
|
|
|
- // }
|
|
|
- // }
|
|
|
- }
|
|
|
-
|
|
|
+ //批量移除邮件
|
|
|
removeMail(mailList): void {
|
|
|
for (const k1 in mailList) {
|
|
|
for (const key in this._mails) {
|
|
@@ -203,6 +101,7 @@ class Data {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //根据id移除邮件
|
|
|
removeMailById(id: string): void {
|
|
|
for (const key in this._mails) {
|
|
|
const v = this._mails[key];
|