|
|
@@ -7,6 +7,7 @@ import { HTTP, HTTPResponse } from '@ionic-native/http';
|
|
7
|
7
|
import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/file-transfer';
|
|
8
|
8
|
import { NativeStorage } from '@ionic-native/native-storage';
|
|
9
|
9
|
|
|
|
10
|
+
|
|
10
|
11
|
/*
|
|
11
|
12
|
Generated class for the HealthProvider provider.
|
|
12
|
13
|
|
|
|
@@ -22,6 +23,7 @@ const QR_URL = HOSTBASE + "/static/";
|
|
22
|
23
|
const REDEEM_API = HOSTBASE + "/coredata/api/redeem";
|
|
23
|
24
|
const SV_API = HOSTBASE + "/strava/api";
|
|
24
|
25
|
const UPLOAD_API = HOSTBASE + "/strava/uploadPhoto";
|
|
|
26
|
+const GET_EVENT_PHOTO_API = HOSTBASE + "/strava/getEventPhotos";
|
|
25
|
27
|
const WP = "https://whitesports.net/wp-json/wp/v2/";
|
|
26
|
28
|
|
|
27
|
29
|
@Injectable()
|
|
|
@@ -61,6 +63,20 @@ export class HealthProvider {
|
|
61
|
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
|
80
|
totalCal(): Observable<any> {
|
|
65
|
81
|
return this.http.post(COREAPI, {action: "TOTALCAL"});
|
|
66
|
82
|
}
|
|
|
@@ -111,9 +127,30 @@ export class HealthProvider {
|
|
111
|
127
|
console.log("get ath ", athId);
|
|
112
|
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
|
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
|
154
|
getWSProfile(athId, token) {
|
|
118
|
155
|
return this.http.post(SV_API, {action: "GET_WS_PROFILE", athId: athId, token: token });
|
|
119
|
156
|
}
|
|
|
@@ -147,7 +184,31 @@ export class HealthProvider {
|
|
147
|
184
|
let url = UPLOAD_API + "?eventId="+eventId+"&athId="+athId;
|
|
148
|
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
|
214
|
let info = await this.kohaService.getPatronInfo();
|