import { Component } from '@angular/core';
import { NavController } from '@ionic/angular';

@Component({
  selector: 'app-points-and-coupons',
  templateUrl: './points-and-coupons.page.html',
  styleUrls: ['./points-and-coupons.page.scss'],
})
export class PointsAndCouponsPage {
  userPoints = 500; // 示例用户积分
  hasNewPromotions = true;
  promotions = [
    { title: '迎新年特惠', description: '享受8折优惠', isNew: true },
    { title: '会员日折扣', description: '每月特定日期额外9折', isNew: false },
    // ... 添加更多优惠活动 ...
  ];
  gifts = [
    { name: '精美保温杯', image: 'https://img.alicdn.com/bao/uploaded/i3/1689522943/O1CN01DCaxvA1XbwOqP1Gm7_!!0-item_pic.jpg', pointsRequired: 200 },
    { name: '便携充电宝', image: 'https://tse4-mm.cn.bing.net/th/id/OIP-C.F755jeHNi2oKZRUGpNfVlgHaEd?rs=1&pid=ImgDetMain', pointsRequired: 300 },
    // ... 添加更多礼品 ...
  ];

  constructor(private navCtrl: NavController) {}

  doRefresh(event: any) {
    console.log('Begin async operation');
    setTimeout(() => {
      console.log('Async operations have ended');
      event.target.complete();
    }, 1000);
  }

  viewPromotionDetails(promotion: any) {
    console.log(`查看优惠活动: ${promotion.title}`);
    this.navCtrl.navigateForward('/promotions');
  }

  viewGiftDetails(gift: any) {
    console.log(`查看礼品: ${gift.name}`);
    this.navCtrl.navigateForward('/promotions');
  }
}