import { LoadingController, AlertController, ToastController } from 'ionic-angular';
import { Injectable } from '@angular/core';
import { Http,Response, Headers, RequestOptions} from '@angular/http';

import { AppService } from '../service/appHttpService';

@Injectable()
export class ActivityStatisticService { 

    constructor(
        public http: Http, 
        public loadingCtrl: LoadingController, 
        private alertCtrl: AlertController, 
        private toastCtrl: ToastController,
        public appService: AppService,) { } 

    //待出行活动,待确认活动,所有活动
    myActivityOrderCount(callback?){
        this.appService.ObserverHttpPost("/wisdomgroup/modules/order/findMyActivityOrderCount",null)
        .subscribe((res: Response) => {
          let data = res.json();
          console.log("myactivityCount------->",data);    
          callback(data == null ? "[]" : data);
          }, error => {        
            this.appService.alert('网络异常！');  
          }   
        );
    }
    //未读通知统计
    myNoticeNotreadCount(callback?){
        this.appService.ObserverHttpPost("/wisdomgroup/modules/notice/getNotReadNotice",null)
        .subscribe((res: Response) => {
          let data = res.json();            
          callback(data == null ? "[]" : data);
          }, error => {        
            this.appService.alert('网络异常！');  
          }   
        );
    }
    //尚未报备统计
    myNotdoPremanagerCount(callback?){
        this.appService.ObserverHttpPost("/wisdomgroup/modules/premanager/findMyNotdoPremanager",null)
        .subscribe((res: Response) => {
          let data = res.json();            
          callback(data == null ? "[]" : data);
          }, error => {        
            this.appService.alert('网络异常！');  
          }   
        );
    }
    //统计活动的报名订单数目
    activityOrderCount(id,callback?){
      this.appService.ObserverHttpPost("/wisdomgroup/modules/order/findActivityOrderCount",{id:id})
      .subscribe((res: Response) => {
        let data = res.json();
        console.log("myactivityCount------->",data);    
        callback(data == null ? "[]" : data);
        }, error => {        
          this.appService.alert('网络异常！');  
        }   
      );
  }
    //统计已发布，已结束活动数目
  statisticActivityNum(callback?){
      this.appService.ObserverHttpGet("/wisdomgroup/modules/activity/statisticActivityNum",null)
      .subscribe((res: Response) => {
        let data = res.json(); 
        callback(data == null ? "[]" : data);
        }, error => {        
          this.appService.alert('网络异常！');  
        }   
      );
  }

  



}