tum 4 年之前
父节点
当前提交
eadb43f992

+ 2 - 3
config.xml

1
 <?xml version='1.0' encoding='utf-8'?>
1
 <?xml version='1.0' encoding='utf-8'?>
2
-<widget id="net.simplico.whitesports" version="1.2.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
2
+<widget id="net.simplico.whitesports" version="1.4.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
3
     <name>White Sports</name>
3
     <name>White Sports</name>
4
     <description>Virtual Run Mobile App</description>
4
     <description>Virtual Run Mobile App</description>
5
     <author email="patumos@gmail.com" href="http://www.simplico.net/">Suebpong Sittimalairut</author>
5
     <author email="patumos@gmail.com" href="http://www.simplico.net/">Suebpong Sittimalairut</author>
6
-    <content original-src="index.html" src="http://localhost:8100" />
6
+    <content src="index.html" />
7
     <access origin="*" />
7
     <access origin="*" />
8
     <allow-intent href="http://*/*" />
8
     <allow-intent href="http://*/*" />
9
     <allow-intent href="https://*/*" />
9
     <allow-intent href="https://*/*" />
138
     <allow-navigation href="http://10.107.138.80:8100" />
138
     <allow-navigation href="http://10.107.138.80:8100" />
139
     <allow-navigation href="http://203.159.52.44:8100" />
139
     <allow-navigation href="http://203.159.52.44:8100" />
140
     <allow-navigation href="http://203.159.52.32:8100" />
140
     <allow-navigation href="http://203.159.52.32:8100" />
141
-    <allow-navigation href="http://localhost:8100" sessionid="2f1d5c27" />
142
 </widget>
141
 </widget>

+ 10 - 1
src/pages/event-upload/event-upload.html

14
 
14
 
15
 
15
 
16
 <ion-content padding>
16
 <ion-content padding>
17
-     <button ion-button (click)="selectImage()" color="tertiary" size='small'>Upload</button>
17
+    <h2>{{ title }}</h2>
18
+    <button ion-button (click)="selectImage()" color="tertiary" size='small' block>{{ msg }}</button>
19
+     <div *ngIf="eventPhotos">
20
+        <ion-card *ngFor="let p of eventPhotos">
21
+            <img [src]="'https://hc.simplico.net/static/events/'+p.fileURL"/>
22
+            <ion-card-content>
23
+            <p>Created At: {{ p.created_at.$date | date :"medium" }}</p>
24
+            </ion-card-content>
25
+        </ion-card>
26
+     </div>
18
 
27
 
19
 </ion-content>
28
 </ion-content>

+ 14 - 7
src/pages/event-upload/event-upload.ts

26
      croppedImagePath:string = "";
26
      croppedImagePath:string = "";
27
 
27
 
28
      photoURL: any;
28
      photoURL: any;
29
-     msg:string = "Upload Your Photo";
29
+    eventPhotos: Array<any>;
30
+     msg:string = "Upload Stat Photo";
31
+    eventId:string;
32
+    title: string;
30
 
33
 
31
     constructor(public navCtrl: NavController, public navParams: NavParams, private camera: Camera,   public actionSheetController: ActionSheetController, private hp: HealthProvider) {
34
     constructor(public navCtrl: NavController, public navParams: NavParams, private camera: Camera,   public actionSheetController: ActionSheetController, private hp: HealthProvider) {
32
-        let eventId = navParams.get('eventId');
33
-        console.log("eventId "+eventId);
35
+        this.eventId = navParams.get('eventId');
36
+        this.title = navParams.get('title');
37
+        //console.log("eventId "+eventId);
34
     }
38
     }
35
 
39
 
36
-    ionViewDidLoad() {
40
+    async ionViewDidEnter() {
37
         console.log('ionViewDidLoad EventUploadPage');
41
         console.log('ionViewDidLoad EventUploadPage');
42
+        this.eventPhotos = await this.hp.getEventPhotos(this.eventId);
43
+        console.log(JSON.stringify(this.eventPhotos));
38
     }
44
     }
39
       async selectImage() {
45
       async selectImage() {
40
          const actionSheet = await this.actionSheetController.create({
46
          const actionSheet = await this.actionSheetController.create({
41
-             header: "Select Image source",
47
+             title: "Select Image source",
42
              buttons: [{
48
              buttons: [{
43
                  text: 'Load from Library',
49
                  text: 'Load from Library',
44
                  handler: () => {
50
                  handler: () => {
73
 
79
 
74
             console.log(this.croppedImagePath);
80
             console.log(this.croppedImagePath);
75
             this.msg = "Uploading ...";
81
             this.msg = "Uploading ...";
76
-            let r0  = await this.hp.uploadPhoto(imageData);
77
-            this.photoURL = await this.hp.getPhoto();
82
+            let r0  = await this.hp.uploadPhoto(this.eventId, imageData);
83
+            this.eventPhotos = await this.hp.getEventPhotos(this.eventId);
84
+            //this.photoURL = await this.hp.getPhoto();
78
             this.msg = "Upload Your Photo";
85
             this.msg = "Upload Your Photo";
79
             console.log("r0");
86
             console.log("r0");
80
             console.log(r0);
87
             console.log(r0);

+ 2 - 2
src/pages/event/event.html

31
       </button>
31
       </button>
32
     </ion-col>
32
     </ion-col>
33
     <ion-col>
33
     <ion-col>
34
-      <button ion-button icon-start color='success' block (click)="joinEvent(p.id)">
34
+      <button ion-button icon-start color='success' block (click)="joinEvent(p.id, p.title.rendered)">
35
         <ion-icon name="text"></ion-icon>
35
         <ion-icon name="text"></ion-icon>
36
-        <div>Join</div>
36
+        <div>Upload</div>
37
       </button>
37
       </button>
38
     </ion-col>
38
     </ion-col>
39
   </ion-row>
39
   </ion-row>

+ 8 - 3
src/pages/event/event.ts

8
 import { NativeStorage } from '@ionic-native/native-storage';
8
 import { NativeStorage } from '@ionic-native/native-storage';
9
 import { InAppBrowser } from '@ionic-native/in-app-browser';
9
 import { InAppBrowser } from '@ionic-native/in-app-browser';
10
 import { EventUploadPage }  from '../event-upload/event-upload';
10
 import { EventUploadPage }  from '../event-upload/event-upload';
11
+import { LoginPage }  from '../login/login';
11
 /**
12
 /**
12
  * Generated class for the EventPage page.
13
  * Generated class for the EventPage page.
13
  *
14
  *
190
     openLink(link: string) {
191
     openLink(link: string) {
191
          this.ab.create(link, '_blank');
192
          this.ab.create(link, '_blank');
192
     }
193
     }
193
-    joinEvent(id) {
194
-        console.log("join "+id);
195
-        this.navCtrl.push(EventUploadPage, { eventId: id });
194
+    async joinEvent(id, title) {
195
+        if(await this.hp.isLogin() == false ) {
196
+            this.navCtrl.parent.select(3);
197
+            console.log("token");
198
+        }else {
199
+            this.navCtrl.push(EventUploadPage, { eventId: id , title: title});
200
+        }
196
     }
201
     }
197
 }
202
 }

+ 18 - 2
src/pages/login/login.html

65
                                     <ion-card-title>
65
                                     <ion-card-title>
66
                                         {{ profileObject.firstname }} {{ profileObject.lastname }}
66
                                         {{ profileObject.firstname }} {{ profileObject.lastname }}
67
                                     </ion-card-title>
67
                                     </ion-card-title>
68
+                                    <br/>
69
+                                    <p>
70
+                                    
71
+                                    Bib No.:
72
+                                    <span style='background-color:#f00; color:#fff; font-weight:bold; font-size:large;padding:0.5em'>
73
+                                       {{ profileObject.athId }}
74
+                                    </span></p>
68
                                     <p>
75
                                     <p>
69
                                     {{ profileObject.city }} {{ profileObject.state }} {{ profileObject.country }}<br>
76
                                     {{ profileObject.city }} {{ profileObject.state }} {{ profileObject.country }}<br>
70
                                     {{ profileObject.description }}
77
                                     {{ profileObject.description }}
85
                                         </div>
92
                                         </div>
86
                                     </ion-label>
93
                                     </ion-label>
87
                                     <ion-input placeholder="Enter Tel." [(ngModel)]="profile.tel" required name='tel' #tel="ngModel"></ion-input>
94
                                     <ion-input placeholder="Enter Tel." [(ngModel)]="profile.tel" required name='tel' #tel="ngModel"></ion-input>
88
-
89
                                     <ion-label color="danger" *ngIf="tel.invalid && (tel.dirty || tel.touched)">
95
                                     <ion-label color="danger" *ngIf="tel.invalid && (tel.dirty || tel.touched)">
90
                                         <div *ngIf="tel.errors.required">
96
                                         <div *ngIf="tel.errors.required">
91
                                             Tel. is required.
97
                                             Tel. is required.
92
                                         </div>
98
                                         </div>
93
                                     </ion-label>
99
                                     </ion-label>
100
+                                    <ion-item>
101
+                                        <ion-label>Birthdate: </ion-label>
102
+                                        <ion-datetime displayFormat="DD/MM/YYYY" [(ngModel)]="profile.birthDate" required name='birthDate' #birthDate="ngModel" placeholder="Enter Your Birthdate"></ion-datetime>
103
+
104
+                                    <ion-label color="danger" *ngIf="birthDate.invalid && (birthDate.dirty || birthDate.touched)">
105
+                                        <div *ngIf="birthDate.errors.required">
106
+                                            Birthdate. is required.
107
+                                        </div>
108
+                                    </ion-label>
109
+                                    </ion-item>
94
                                      <ion-textarea placeholder="Enter Your Address" [(ngModel)]="profile.address" required name='address' #address="ngModel"></ion-textarea>
110
                                      <ion-textarea placeholder="Enter Your Address" [(ngModel)]="profile.address" required name='address' #address="ngModel"></ion-textarea>
95
 
111
 
96
                                     <ion-label color="danger" *ngIf="address.invalid && (address.dirty || address.touched)">
112
                                     <ion-label color="danger" *ngIf="address.invalid && (address.dirty || address.touched)">
99
                                         </div>
115
                                         </div>
100
                                     </ion-label>
116
                                     </ion-label>
101
                                         <button ion-button  color="primary" name='updateProfile' type='submit' block>
117
                                         <button ion-button  color="primary" name='updateProfile' type='submit' block>
102
-                                            <ion-icon name='save'></ion-icon>
118
+                                            <ion-icon name='create'></ion-icon>
103
                                             Update Profile
119
                                             Update Profile
104
                                         </button>
120
                                         </button>
105
                                         <!--
121
                                         <!--

+ 5 - 0
src/pages/login/login.ts

25
     email: string;
25
     email: string;
26
     tel: string;
26
     tel: string;
27
     address: string;
27
     address: string;
28
+    birthDate: string;
28
 }
29
 }
29
 //@IonicPage()
30
 //@IonicPage()
30
 
31
 
81
                                 console.dir(acts.output.firstname, acts.output.lastname);
82
                                 console.dir(acts.output.firstname, acts.output.lastname);
82
                                 this.nativeStorage.setItem('profileObject', acts.output);
83
                                 this.nativeStorage.setItem('profileObject', acts.output);
83
                                 this.profileObject = acts.output;
84
                                 this.profileObject = acts.output;
85
+
86
+                                this.nativeStorage.setItem('athId', this.profileObject.athId);
84
                                 this.hp.getWSProfile(this.profileObject.athId,this.token)
87
                                 this.hp.getWSProfile(this.profileObject.athId,this.token)
85
                                     .subscribe( wsdata => {
88
                                     .subscribe( wsdata => {
86
                                         console.log(JSON.stringify(wsdata));
89
                                         console.log(JSON.stringify(wsdata));
88
                                         this.profile.tel = wsdata['output']['tel'];
91
                                         this.profile.tel = wsdata['output']['tel'];
89
                                         this.profile.email = wsdata['output']['email'];
92
                                         this.profile.email = wsdata['output']['email'];
90
                                         this.profile.address = wsdata['output']['address'];
93
                                         this.profile.address = wsdata['output']['address'];
94
+                                        this.profile.birthDate = (new Date(wsdata['output']['birthDate']['$date'])).toISOString();
91
                                         console.log(JSON.stringify(this.profile));
95
                                         console.log(JSON.stringify(this.profile));
92
                                     }, error => {
96
                                     }, error => {
93
                                         console.log("error "+error);
97
                                         console.log("error "+error);
180
                 tel: f.value.tel,
184
                 tel: f.value.tel,
181
                 address: f.value.address,
185
                 address: f.value.address,
182
                 token: this.token,
186
                 token: this.token,
187
+                birthDate: f.value.birthDate
183
             };
188
             };
184
             this.hp.saveWSProfile(profile)
189
             this.hp.saveWSProfile(profile)
185
                 .subscribe(
190
                 .subscribe(

+ 63 - 2
src/providers/health/health.ts

7
 import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/file-transfer';
7
 import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/file-transfer';
8
 import { NativeStorage } from '@ionic-native/native-storage';
8
 import { NativeStorage } from '@ionic-native/native-storage';
9
 
9
 
10
+
10
 /*
11
 /*
11
   Generated class for the HealthProvider provider.
12
   Generated class for the HealthProvider provider.
12
 
13
 
22
 const REDEEM_API = HOSTBASE + "/coredata/api/redeem";
23
 const REDEEM_API = HOSTBASE + "/coredata/api/redeem";
23
 const SV_API = HOSTBASE + "/strava/api";
24
 const SV_API = HOSTBASE + "/strava/api";
24
 const UPLOAD_API = HOSTBASE + "/strava/uploadPhoto";
25
 const UPLOAD_API = HOSTBASE + "/strava/uploadPhoto";
26
+const GET_EVENT_PHOTO_API = HOSTBASE + "/strava/getEventPhotos";
25
 const WP = "https://whitesports.net/wp-json/wp/v2/";
27
 const WP = "https://whitesports.net/wp-json/wp/v2/";
26
 
28
 
27
 @Injectable()
29
 @Injectable()
61
         return this.http.post(COREAPI, {token: token, action: "HISTORY"});
63
         return this.http.post(COREAPI, {token: token, action: "HISTORY"});
62
     }
64
     }
63
 
65
 
66
+    async isLogin(){
67
+        return await this.storage.getItem('token')
68
+            .then(
69
+                data => { return data;  }, 
70
+                error => { return false;  }
71
+            );
72
+    }
73
+    async getAthId(){
74
+        return await this.storage.getItem('athId')
75
+            .then(
76
+                data => { return data;  }, 
77
+                error => { return false;  }
78
+            );
79
+    }
64
     totalCal(): Observable<any> {
80
     totalCal(): Observable<any> {
65
         return this.http.post(COREAPI, {action: "TOTALCAL"});
81
         return this.http.post(COREAPI, {action: "TOTALCAL"});
66
     }
82
     }
111
         console.log("get ath ", athId);
127
         console.log("get ath ", athId);
112
         return this.http.post(COREAPI, {action: "GETRUNNER", athId: athId});
128
         return this.http.post(COREAPI, {action: "GETRUNNER", athId: athId});
113
     }
129
     }
130
+    async getEventPhotos(eventId) {
131
+         let athId = await this.getAthId();
132
+        console.log(GET_EVENT_PHOTO_API)
133
+        let photos = await this.nhttp.get(GET_EVENT_PHOTO_API+"?athId="+athId+"&eventId="+ eventId,{}, {}).then(
134
+            res => {
135
+                console.log("res ", JSON.stringify(res));
136
+                let data = JSON.parse(res.data);
137
+                return data.output;
138
+            },
139
+            error => {
140
+                console.log(JSON.stringify(error));
141
+                return null;
142
+            }
143
+        );
144
+        return photos;
145
+    }
114
     saveWSProfile(profile) {
146
     saveWSProfile(profile) {
115
-        return this.http.post(SV_API, {action: "UPDATE_PROFILE", athId: profile['athId'],  fullName: profile['fullName'], email: profile['email'], tel: profile['tel'], address: profile['address'], token: profile['token']});
147
+        let d = new Date(profile['birthDate']);
148
+        console.log(d.getMonth())
149
+        let fd = d.getFullYear()  + "-" + (d.getMonth() + 1) + "-" +d.getDate();
150
+
151
+        return this.http.post(SV_API, {action: "UPDATE_PROFILE", athId: profile['athId'],  fullName: profile['fullName'], email: profile['email'], tel: profile['tel'], address: profile['address'], token: profile['token'], birthDate: fd});
116
     }
152
     }
153
+
117
     getWSProfile(athId, token) {
154
     getWSProfile(athId, token) {
118
         return this.http.post(SV_API, {action: "GET_WS_PROFILE", athId: athId,   token: token });
155
         return this.http.post(SV_API, {action: "GET_WS_PROFILE", athId: athId,   token: token });
119
     }
156
     }
147
         let url = UPLOAD_API + "?eventId="+eventId+"&athId="+athId;
184
         let url = UPLOAD_API + "?eventId="+eventId+"&athId="+athId;
148
         return url;
185
         return url;
149
     }
186
     }
150
-     async uploadPhoto(filePath) {
187
+    
188
+     async uploadPhoto(eventId, filePath) {
189
+         let athId = await this.getAthId();
190
+
191
+         if( athId ) {
192
+             const fileTransfer: FileTransferObject = this.transfer.create();
193
+
194
+             let options: FileUploadOptions = {
195
+                 fileKey: 'file',
196
+                 //fileName: 'name.jpg',
197
+             }
198
+
199
+             return fileTransfer.upload(filePath, this.uploadPhotoUrl(eventId, athId), options)
200
+                 .then((data) => {
201
+                     // success
202
+                     console.log("from tranfer");
203
+                     console.log(data);
204
+                     return JSON.parse(data.response);
205
+                 }, (err) => {
206
+                     // error
207
+                     return err;
208
+                 })
209
+         } else {
210
+             return null;
211
+         }
151
 
212
 
152
          /*
213
          /*
153
          let info = await this.kohaService.getPatronInfo();
214
          let info = await this.kohaService.getPatronInfo();