tum 2 gadi atpakaļ
vecāks
revīzija
cd5a4ade8f

+ 8 - 0
capacitor.config.ts

11
     CapacitorHttp: {
11
     CapacitorHttp: {
12
       enabled: true
12
       enabled: true
13
     },
13
     },
14
+    GoogleAuth: {
15
+      scopes: ['profile', 'email'],
16
+      serverClientId: '214019008700-7d2rl1u56edjj1s8lk9fvk9934ook9r3.apps.googleusercontent.com',
17
+      forceCodeForRefreshToken: true,
18
+    },
19
+    PushNotifications: {
20
+      presentationOptions: ["badge", "sound", "alert"]
21
+    }
14
   }
22
   }
15
 };
23
 };
16
 
24
 

+ 18 - 0
package-lock.json

10
       "dependencies": {
10
       "dependencies": {
11
         "@capacitor-community/apple-sign-in": "^5.0.0",
11
         "@capacitor-community/apple-sign-in": "^5.0.0",
12
         "@capacitor-community/facebook-login": "^5.0.3",
12
         "@capacitor-community/facebook-login": "^5.0.3",
13
+        "@capacitor-community/fcm": "^5.0.2",
14
+        "@capacitor/android": "5.5.0",
13
         "@capacitor/app": "5.0.6",
15
         "@capacitor/app": "5.0.6",
14
         "@capacitor/core": "5.5.0",
16
         "@capacitor/core": "5.5.0",
15
         "@capacitor/haptics": "5.0.6",
17
         "@capacitor/haptics": "5.0.6",
1745
         "node": ">=16.0.0"
1747
         "node": ">=16.0.0"
1746
       }
1748
       }
1747
     },
1749
     },
1750
+    "node_modules/@capacitor-community/fcm": {
1751
+      "version": "5.0.2",
1752
+      "resolved": "https://registry.npmjs.org/@capacitor-community/fcm/-/fcm-5.0.2.tgz",
1753
+      "integrity": "sha512-E3RjjI0Vm9RaAPzhrjacN5IdHV7KpTyNEzj4UnsHimwYU62YIs+mtcC4IDhzPvASuA3/XXj8ZOjWvQwN3osYxA==",
1754
+      "peerDependencies": {
1755
+        "@capacitor/core": "^5.0.0"
1756
+      }
1757
+    },
1758
+    "node_modules/@capacitor/android": {
1759
+      "version": "5.5.0",
1760
+      "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-5.5.0.tgz",
1761
+      "integrity": "sha512-ipJijb3M0FA6DvotS9zrbJ8p/mTEVg9EVtBmvUexogm8g5se1mc7i1gvOr3MQ/iTZ3PnNrRC/P7kHxa2R55iqg==",
1762
+      "peerDependencies": {
1763
+        "@capacitor/core": "^5.5.0"
1764
+      }
1765
+    },
1748
     "node_modules/@capacitor/app": {
1766
     "node_modules/@capacitor/app": {
1749
       "version": "5.0.6",
1767
       "version": "5.0.6",
1750
       "resolved": "https://registry.npmjs.org/@capacitor/app/-/app-5.0.6.tgz",
1768
       "resolved": "https://registry.npmjs.org/@capacitor/app/-/app-5.0.6.tgz",

+ 2 - 0
package.json

14
   "dependencies": {
14
   "dependencies": {
15
     "@capacitor-community/apple-sign-in": "^5.0.0",
15
     "@capacitor-community/apple-sign-in": "^5.0.0",
16
     "@capacitor-community/facebook-login": "^5.0.3",
16
     "@capacitor-community/facebook-login": "^5.0.3",
17
+    "@capacitor-community/fcm": "^5.0.2",
18
+    "@capacitor/android": "5.5.0",
17
     "@capacitor/app": "5.0.6",
19
     "@capacitor/app": "5.0.6",
18
     "@capacitor/core": "5.5.0",
20
     "@capacitor/core": "5.5.0",
19
     "@capacitor/haptics": "5.0.6",
21
     "@capacitor/haptics": "5.0.6",

+ 1 - 0
src/components/CourseMat.vue

41
     console.log("name === ", props.obj)
41
     console.log("name === ", props.obj)
42
 
42
 
43
     const obj = props.obj
43
     const obj = props.obj
44
+
44
     if(await isLogin()) {
45
     if(await isLogin()) {
45
       pref = await getPref()
46
       pref = await getPref()
46
       console.debug(" pref = ", pref)
47
       console.debug(" pref = ", pref)

+ 18 - 16
src/composable/settings.ts

8
 
8
 
9
 
9
 
10
 export const TOKEN = '173cb9e357a861abd91e8008fab9246e0cc116af'
10
 export const TOKEN = '173cb9e357a861abd91e8008fab9246e0cc116af'
11
-//export const BASE_URL = 'http://192.168.1.35:8020/'
12
-export const BASE_URL = 'http://localhost:8020/'
13
-//export const BASE_URL = 'https://www.tigermuaythai.live/'
11
+
12
+//export const BASE_URL = 'http://localhost:8020/'
13
+export const BASE_URL = 'https://www.tigermuaythai.live/'
14
 
14
 
15
 export const APPLE_CALLBACK = BASE_URL + "soc_accounts/apple/login/callback/";
15
 export const APPLE_CALLBACK = BASE_URL + "soc_accounts/apple/login/callback/";
16
 //const axios = setupCache(Axios); 
16
 //const axios = setupCache(Axios); 
50
     console.log("get token ", data)
50
     console.log("get token ", data)
51
     await Preferences.set({
51
     await Preferences.set({
52
       key: 'token', 
52
       key: 'token', 
53
-      value: data.token
53
+      value: data.key
54
     })
54
     })
55
-    return data.token
55
+    return data.key
56
   }else {
56
   }else {
57
     return token.value
57
     return token.value
58
   }
58
   }
64
   console.log("-- cookie ---")
64
   console.log("-- cookie ---")
65
   const cookieHeaders = r.headers['Set-Cookie'];
65
   const cookieHeaders = r.headers['Set-Cookie'];
66
   console.log(cookieHeaders)
66
   console.log(cookieHeaders)
67
+  return r;
67
 }
68
 }
68
 export const setUserToken = async(token) => {
69
 export const setUserToken = async(token) => {
69
   let data = await Preferences.set({
70
   let data = await Preferences.set({
70
     key: 'user_token', 
71
     key: 'user_token', 
71
     value: token
72
     value: token
72
   })
73
   })
73
-  let data2 = await Preferences.set({
74
-    key: 'token', 
75
-    value: token
76
-  })
74
+  //let data2 = await Preferences.set({
75
+    //key: 'token', 
76
+    //value: token
77
+  //})
77
   return data
78
   return data
78
 }
79
 }
79
 export const getTrainers = async () => {
80
 export const getTrainers = async () => {
148
 }
149
 }
149
 
150
 
150
 export const storeAPNToken = async (device_token) => {
151
 export const storeAPNToken = async (device_token) => {
151
-  
152
   const token = await Preferences.get({ key: 'token' });
152
   const token = await Preferences.get({ key: 'token' });
153
+  console.log('storeAPNToken ', token, device_token) 
153
   console.log("token = ", token)
154
   console.log("token = ", token)
154
   const { data } = await axios.post(BASE_URL + "backend/api/device_tokens/",{token: device_token},
155
   const { data } = await axios.post(BASE_URL + "backend/api/device_tokens/",{token: device_token},
155
   {
156
   {
316
 }
317
 }
317
 export const clearPref = async() => {
318
 export const clearPref = async() => {
318
 
319
 
319
-  const clear = await Preferences.clear()
320
+  //const clear = await Preferences.clear()
321
+  const clear = await Preferences.remove({key: 'user_token'})
320
   return clear
322
   return clear
321
 }
323
 }
322
 export const isLogin = async() => {
324
 export const isLogin = async() => {
356
 
358
 
357
 
359
 
358
 export const getPref = async () => {
360
 export const getPref = async () => {
359
-  const token = await Preferences.get({ key: 'token' });
361
+  const token = await Preferences.get({ key: 'user_token' });
360
   console.log("token = ", token)
362
   console.log("token = ", token)
361
   const { data } = await axios.get(BASE_URL + `backend/api/profiles/myprofile/`, {
363
   const { data } = await axios.get(BASE_URL + `backend/api/profiles/myprofile/`, {
362
     headers: { 
364
     headers: { 
371
   return data
373
   return data
372
 }
374
 }
373
 export const likeCourse = async (cid) => {
375
 export const likeCourse = async (cid) => {
374
-  const token = await Preferences.get({ key: 'token' });
376
+  const token = await Preferences.get({ key: 'user_token' });
375
   console.log("token = ", token)
377
   console.log("token = ", token)
376
   const { data } = await axios.get(BASE_URL + `backend/api/profiles/like_course/?cid=${cid}`, {
378
   const { data } = await axios.get(BASE_URL + `backend/api/profiles/like_course/?cid=${cid}`, {
377
     headers: { 
379
     headers: { 
382
   return data
384
   return data
383
 }
385
 }
384
 export const likeMat = async (cid) => {
386
 export const likeMat = async (cid) => {
385
-  const token = await Preferences.get({ key: 'token' });
387
+  const token = await Preferences.get({ key: 'user_token' });
386
   console.log("token = ", token)
388
   console.log("token = ", token)
387
   const { data } = await axios.get(BASE_URL + `backend/api/profiles/like_mat/?cid=${cid}`, {
389
   const { data } = await axios.get(BASE_URL + `backend/api/profiles/like_mat/?cid=${cid}`, {
388
     headers: { 
390
     headers: { 
395
 
397
 
396
 
398
 
397
 export const updateNoti = async (noti) => {
399
 export const updateNoti = async (noti) => {
398
-  const token = await Preferences.get({ key: 'token' });
400
+  const token = await Preferences.get({ key: 'user_token' });
399
   console.log("token = ", token)
401
   console.log("token = ", token)
400
   const { data } = await axios.post(BASE_URL + `backend/api/profiles/update_noti/`,
402
   const { data } = await axios.post(BASE_URL + `backend/api/profiles/update_noti/`,
401
   {live_noti: noti.liveNoti, 'news_noti':noti.newsNoti},
403
   {live_noti: noti.liveNoti, 'news_noti':noti.newsNoti},
410
 
412
 
411
 export const appleLogin = async(access_token) => {
413
 export const appleLogin = async(access_token) => {
412
 
414
 
413
-  const token = await Preferences.get({ key: 'token' });
415
+  const token = await Preferences.get({ key: 'user_token' });
414
   console.log("access_code = ", access_token)
416
   console.log("access_code = ", access_token)
415
   const { data } = await axios.post(BASE_URL + 'dj-rest-auth/apple/',{access_token: access_token.authorizationCode, id_token: access_token.identityToken}, {
417
   const { data } = await axios.post(BASE_URL + 'dj-rest-auth/apple/',{access_token: access_token.authorizationCode, id_token: access_token.identityToken}, {
416
     headers: {
418
     headers: {

+ 5 - 1
src/views/CourseMatDetailPage.vue

46
 import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent,   IonNavLink,
46
 import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent,   IonNavLink,
47
     IonButton,
47
     IonButton,
48
     IonButtons,
48
     IonButtons,
49
-    IonBackButton, onIonViewWillEnter, IonRow, IonGrid, IonCol, IonItem, IonList, IonAvatar, IonLabel, IonItemDivider,
49
+    IonBackButton, onIonViewWillEnter, onIonViewDidLeave, IonRow, IonGrid, IonCol, IonItem, IonList, IonAvatar, IonLabel, IonItemDivider,
50
     useIonRouter } from '@ionic/vue';
50
     useIonRouter } from '@ionic/vue';
51
 
51
 
52
 import { Autoplay, Keyboard, Pagination, Scrollbar, Zoom } from 'swiper/modules';
52
 import { Autoplay, Keyboard, Pagination, Scrollbar, Zoom } from 'swiper/modules';
88
   mats.value  = await listMats(mat.value.related_mats)
88
   mats.value  = await listMats(mat.value.related_mats)
89
 
89
 
90
 })
90
 })
91
+onIonViewDidLeave(async () => {
92
+  mat.value.embed = null; 
93
+})
94
+
91
 </script>
95
 </script>
92
 
96
 
93
 <style scoped>
97
 <style scoped>

+ 8 - 3
src/views/ProfilePage.vue

82
 </template>
82
 </template>
83
 
83
 
84
 <script setup lang="ts">
84
 <script setup lang="ts">
85
-import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonButton, onIonViewWillEnter, IonRow, IonCol, IonGrid, IonToggle, IonLabel, IonChip, IonIcon, IonSelect, IonSelectOption, IonList, IonListHeader, IonItem, IonText } from '@ionic/vue';
85
+import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonButton, onIonViewWillEnter, IonRow, IonCol, IonGrid, IonToggle, IonLabel, IonChip, IonIcon, IonSelect, IonSelectOption, IonList, IonListHeader, IonItem, IonText, IonImg } from '@ionic/vue';
86
 import ExploreContainer from '@/components/ExploreContainer.vue';
86
 import ExploreContainer from '@/components/ExploreContainer.vue';
87
 import LoginForm from '@/components/LoginForm.vue';
87
 import LoginForm from '@/components/LoginForm.vue';
88
 import { defineComponent, onMounted } from 'vue';
88
 import { defineComponent, onMounted } from 'vue';
162
 
162
 
163
 const ggLoginClick = async () => {
163
 const ggLoginClick = async () => {
164
   console.log("ggLogin")
164
   console.log("ggLogin")
165
-  const response = await GoogleAuth.signIn();
165
+  let response = null;
166
+  try{
167
+    response = await GoogleAuth.signIn();
168
+  }catch(error) {
169
+    console.log("Error ", error);
170
+  }
166
   let t1 = response.authentication.accessToken;
171
   let t1 = response.authentication.accessToken;
167
   let t2 = response.authentication.idToken;
172
   let t2 = response.authentication.idToken;
168
   let t3 = response.authentication.refreshToken;
173
   let t3 = response.authentication.refreshToken;
297
   }else {
302
   }else {
298
     console.log("Success")
303
     console.log("Success")
299
     await setUserToken(data.key)
304
     await setUserToken(data.key)
300
-    
305
+    myprofile.value  = await getPref()
301
     // Login successful.
306
     // Login successful.
302
     refIsLogin.value = true
307
     refIsLogin.value = true
303
   }
308
   }

+ 10 - 1
src/views/Tab1Page.vue

79
 import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
79
 import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
80
 
80
 
81
 import { PushNotifications } from '@capacitor/push-notifications';
81
 import { PushNotifications } from '@capacitor/push-notifications';
82
+import { FCM } from "@capacitor-community/fcm";
83
+
82
 
84
 
83
 import Player from '@vimeo/player';
85
 import Player from '@vimeo/player';
84
 
86
 
122
     let v = await isLogin()
124
     let v = await isLogin()
123
     console.log("v === ", v)
125
     console.log("v === ", v)
124
     if( v == false ) {
126
     if( v == false ) {
125
-      ionRouter.navigate('/tabs/tab4', 'forward', 'replace');
127
+    ;
128
+      //ionRouter.navigate('/tabs/tab4', 'forward', 'replace');
126
     }
129
     }
127
     //console.log("video " ,video)
130
     //console.log("video " ,video)
128
     //console.log("video id", video.value.id)
131
     //console.log("video id", video.value.id)
196
   await PushNotifications.addListener('registration', token => {
199
   await PushNotifications.addListener('registration', token => {
197
     console.info('Registration token: ', token.value);
200
     console.info('Registration token: ', token.value);
198
     storeAPNToken(token.value)
201
     storeAPNToken(token.value)
202
+    
203
+    FCM.subscribeTo({ topic: "TMT" })
204
+    .then((r) => {
205
+      console.log("subsribe to topic ", r)
206
+    })
207
+    .catch((err) => console.log(err));
199
   });
208
   });
200
 
209
 
201
   await PushNotifications.addListener('registrationError', err => {
210
   await PushNotifications.addListener('registrationError', err => {