本文整理匯總了TypeScript中services/localstorage.LocalStorage.saveJson方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript LocalStorage.saveJson方法的具體用法?TypeScript LocalStorage.saveJson怎麽用?TypeScript LocalStorage.saveJson使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類services/localstorage.LocalStorage
的用法示例。
在下文中一共展示了LocalStorage.saveJson方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getWeekCount
getWeekCount(){
if (this.localstorage.get('week-count')) {
let weekJsonReceived = JSON.parse(this.localstorage.get('week-count'));
if (weekJsonReceived.week != moment().week()) {
weekJsonReceived.week = moment().week();
weekJsonReceived.nb = 0;
this.localstorage.saveJson('week-count', JSON.stringify(weekJsonReceived));
}
this.weekCount = weekJsonReceived.nb;
} else {
this.weekCount = 0;
let weekJsonSend = { 'week': moment().week(), 'nb': this.weekCount };
this.localstorage.saveJson('week-count', JSON.stringify(weekJsonSend));
}
return this.weekCount;
}
示例2: getDayCount
getDayCount(){
if (this.localstorage.get('day-count')) {
let dayJsonReceived = JSON.parse(this.localstorage.get('day-count'));
if (dayJsonReceived.day != moment().format("DD/MM/YYYY")) {
dayJsonReceived.day = moment().format("DD/MM/YYYY");
dayJsonReceived.nb = 0;
this.localstorage.saveJson('day-count', JSON.stringify(dayJsonReceived));
}
this.todayCount = dayJsonReceived.nb;
} else {
this.todayCount = 0;
let dayJsonSend = { 'day': moment().format("DD/MM/YYYY"), 'nb': this.todayCount };
this.localstorage.saveJson('day-count', JSON.stringify(dayJsonSend));
}
return this.todayCount;
}
示例3: addACigarette
addACigarette(){
this.totalCigarettes++;
this.weekCount++;
this.todayCount++;
this.budgetCigarettes = parseFloat(Math.round((this.cigarettePrice * this.totalCigarettes)*100)/100);
this.cigarettesLeft = (this.nbPacks * 20) - this.totalCigarettes;
this.localstorage.saveNumber('total-cigarettes', this.totalCigarettes);
let weekCount = JSON.parse( this.localstorage.get('week-count'));
weekCount.nb = this.weekCount;
this.localstorage.saveJson('week-count', JSON.stringify(weekCount));
let dayCount = JSON.parse(this.localstorage.get('day-count'));
dayCount.nb = this.todayCount;
this.localstorage.saveJson('day-count', JSON.stringify(dayCount));
if (!this.beginDate) {
this.beginDate = moment().format('DD/MM/YYYY');
this.localstorage.saveDate('begin-date', this.beginDate);
return this.beginDate;
}
}