|
@@ -160,6 +160,55 @@ export class Tab1Page implements OnInit,OnDestroy {
|
|
|
this.blueColor = !this.blueColor;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //每日习惯按钮颜色变化
|
|
|
+ buttons = [
|
|
|
+ { text: '足量饮水', color: 'light', icon: 'water' },
|
|
|
+ { text: '干净饮食', color: 'light', icon: 'nutrition' },
|
|
|
+ { text: '健康作息', color: 'light', icon: 'bed' },
|
|
|
+ { text: '有氧', color: 'light', icon: 'bicycle' },
|
|
|
+ { text: '力量', color: 'light', icon: 'barbell' },
|
|
|
+ { text: '拉伸', color: 'light', icon: 'body' }
|
|
|
+ ];
|
|
|
+
|
|
|
+ habitText = '今日习惯待保持';
|
|
|
+
|
|
|
+ onButtonClick(index: number) {
|
|
|
+ const button = this.buttons[index];
|
|
|
+ switch(button.color) {
|
|
|
+ case 'light':
|
|
|
+ button.color = 'success';
|
|
|
+ break;
|
|
|
+ case 'success':
|
|
|
+ button.color = 'danger';
|
|
|
+ break;
|
|
|
+ case 'danger':
|
|
|
+ button.color = 'light';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.checkHabitText();
|
|
|
+ }
|
|
|
+
|
|
|
+ checkHabitText() {
|
|
|
+ if (this.buttons.every(btn => btn.color === 'success')) {
|
|
|
+ this.habitText = '你成功保持了良好的习惯';
|
|
|
+ } else if (this.buttons.some(btn => btn.color === 'danger')) {
|
|
|
+ this.habitText = '今日好习惯保持失败,再接再厉';
|
|
|
+ } else {
|
|
|
+ this.habitText = '今日习惯待保持';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ get allButtonsSuccess() {
|
|
|
+ return this.buttons.every(btn => btn.color === 'success');
|
|
|
+ }
|
|
|
+
|
|
|
+ get anyButtonFailure() {
|
|
|
+ return this.buttons.some(btn => btn.color === 'danger');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
navigateToTreePage() {
|
|
|
this.router.navigate(['/tabs/tree']);
|
|
|
}
|