Açıklama Yok

Tab1Page.vue 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <ion-page>
  3. <ion-header>
  4. <ion-toolbar>
  5. <ion-title>
  6. <ion-img src="/images/tmt-logo.png" />
  7. </ion-title>
  8. <ion-buttons slot="end">
  9. <ion-button :router-link="'/tabs/search_page/'">
  10. <ion-icon slot="icon-only" :icon="search"></ion-icon>
  11. </ion-button>
  12. </ion-buttons>
  13. </ion-toolbar>
  14. </ion-header>
  15. <ion-content>
  16. <ion-header collapse="condense">
  17. <ion-toolbar>
  18. <ion-title size="large">
  19. <ion-img src="/images/tmt-logo.png" />
  20. </ion-title>
  21. </ion-toolbar>
  22. </ion-header>
  23. <template v-if="liveObj && liveObj.result">
  24. <div v-html="liveObj.result.embed_html"></div>
  25. </template>
  26. <div class=''>
  27. <h2 class='ion-margin-start'>Today Programs</h2>
  28. <swiper :slides-per-view="2" :loop="true" v-if="todays" class='ion-no-margin'>
  29. <swiper-slide v-for="m in todays">
  30. <CourseSchedule :course-obj="m.course_level.course" :from-time="m.from_time" :to-time='m.to_time' />
  31. </swiper-slide>
  32. </swiper>
  33. </div>
  34. <template v-if="posts">
  35. <div class=''>
  36. <h2 class="ion-margin-start">Muaythai Techniques</h2>
  37. <swiper :slides-per-view="'auto'" :loop="true" >
  38. <swiper-slide v-for="m in posts" class='ion-no-padding'>
  39. <Post :obj="m" />
  40. </swiper-slide>
  41. </swiper>
  42. </div>
  43. </template>
  44. <template v-if="mats">
  45. <h2 class='ion-padding-start'>Trainings</h2>
  46. <ion-grid>
  47. <ion-row>
  48. <ion-col size="12" size-md="4" size-lg="2" v-for="c in mats">
  49. <CourseMat :obj="c" :course-name="c.course_name" class='ion-no-margin' />
  50. </ion-col>
  51. </ion-row>
  52. </ion-grid>
  53. </template>
  54. </ion-content>
  55. </ion-page>
  56. </template>
  57. <script setup lang="ts">
  58. import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonIcon, onIonViewWillEnter, IonButton,
  59. onIonViewWillLeave, IonItem, IonLabel, IonThumbnail, IonCol, IonGrid, IonRow, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, onIonViewDidEnter, IonButtons, IonImg, useIonRouter } from '@ionic/vue';
  60. import ExploreContainer from '@/components/ExploreContainer.vue';
  61. import CourseSchedule from '@/components/CourseSchedule.vue'
  62. import Post from '@/components/Post.vue'
  63. import CourseMat from '@/components/CourseMat.vue'
  64. import SearchEngine from '@/components/SearchEngine.vue'
  65. import { CapacitorHttp } from '@capacitor/core';
  66. import { ref } from 'vue';
  67. import { TOKEN, getProducts, setToken, getObject, getToken, getTrainers, listMats, storeAPNToken,
  68. getTodayProgs, getLive, getPosts, initAPI, clearPref, isLogin} from '@/composable/settings';
  69. //import VueCoreVideoPlayer from 'vue-core-video-player'
  70. import { vueVimeoPlayer } from 'vue-vimeo-player'
  71. import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
  72. import { PushNotifications } from '@capacitor/push-notifications';
  73. import Player from '@vimeo/player';
  74. import { Autoplay, Keyboard, Pagination, Scrollbar, Zoom } from 'swiper/modules';
  75. import { Swiper, SwiperSlide } from 'swiper/vue';
  76. import 'swiper/css';
  77. import 'swiper/css/autoplay';
  78. import 'swiper/css/keyboard';
  79. import 'swiper/css/pagination';
  80. import 'swiper/css/scrollbar';
  81. import 'swiper/css/zoom';
  82. import '@ionic/vue/css/ionic-swiper.css';
  83. import { search } from 'ionicons/icons';
  84. const safeUrl = "https://vimeo.com/880005259?share=copy"
  85. const token = ref()
  86. const trainers = ref([])
  87. const mats = ref()
  88. const todays = ref()
  89. const posts = ref()
  90. const scrollToBottom = () => {
  91. console.log("scroll")
  92. //content.value.$el.scrollToBottom(300);
  93. };
  94. const items = ref([{msg: 'foo'}, {msg: 'bar2'}])
  95. const ionRouter = useIonRouter();
  96. const options = {
  97. id: 59777392,
  98. width: 640,
  99. loop: true
  100. };
  101. //const video = ref(null)
  102. //const player = new Player(video, options);
  103. const liveObj = ref()
  104. const modules = [Autoplay, Keyboard, Pagination, Scrollbar, Zoom]
  105. onIonViewWillEnter(async () => {
  106. let v = await isLogin()
  107. console.log("v === ", v)
  108. if( v == false ) {
  109. ionRouter.navigate('/tabs/tab4', 'forward', 'replace');
  110. }
  111. //console.log("video " ,video)
  112. //console.log("video id", video.value.id)
  113. //const player = new Player(video.value.id, options);
  114. //player.setVolume(0);
  115. //player.on('play', function() {
  116. // console.log('played the video!');
  117. //});
  118. console.log("view view enter")
  119. // doGet()
  120. // await getProducts()
  121. // console.log(TOKEN)
  122. // setToken()
  123. // let u = getObject()
  124. //console.log('u ', u)
  125. await initAPI()
  126. token.value = await getToken()
  127. try{
  128. trainers.value = await getTrainers()
  129. }catch(error){
  130. console.log("trainers ", error)
  131. await clearPref()
  132. token.value = await getToken()
  133. }
  134. listMats().then( (data) => {
  135. mats.value = data
  136. })
  137. getPosts("muaythai-techniques").then( (data) => {
  138. posts.value = data
  139. })
  140. console.log(" trainers => ", trainers)
  141. GoogleAuth.initialize();
  142. registerNotifications()
  143. addListeners()
  144. getTodayProgs().then( (data) => {
  145. todays.value = data
  146. })
  147. setInterval( async () => {
  148. console.log("did enter")
  149. if( liveObj.value == null || liveObj.value.result == false ) {
  150. liveObj.value = await getLive()
  151. }
  152. }, 100000)
  153. })
  154. onIonViewWillLeave(() => {
  155. console.log("view will leave")
  156. })
  157. onIonViewDidEnter(async() => {
  158. })
  159. const doGet = async () => {
  160. console.log("do get")
  161. const options = {
  162. url: 'https://example.com/my/api',
  163. headers: { 'X-Fake-Header': 'Fake-Value' },
  164. params: { size: 'XL' },
  165. };
  166. const response: HttpResponse = await CapacitorHttp.get(options);
  167. console.log(response)
  168. }
  169. const addListeners = async () => {
  170. await PushNotifications.addListener('registration', token => {
  171. console.info('Registration token: ', token.value);
  172. storeAPNToken(token.value)
  173. });
  174. await PushNotifications.addListener('registrationError', err => {
  175. console.error('Registration error: ', err.error);
  176. });
  177. await PushNotifications.addListener('pushNotificationReceived', notification => {
  178. console.log('Push notification received: ', notification);
  179. });
  180. await PushNotifications.addListener('pushNotificationActionPerformed', notification => {
  181. console.log('Push notification action performed', notification.actionId, notification.inputValue);
  182. });
  183. }
  184. const registerNotifications = async () => {
  185. let permStatus = await PushNotifications.checkPermissions();
  186. if (permStatus.receive === 'prompt') {
  187. permStatus = await PushNotifications.requestPermissions();
  188. }
  189. if (permStatus.receive !== 'granted') {
  190. throw new Error('User denied permissions!');
  191. }
  192. await PushNotifications.register();
  193. }
  194. const getDeliveredNotifications = async () => {
  195. const notificationList = await PushNotifications.getDeliveredNotifications();
  196. console.log('delivered notifications', notificationList);
  197. }
  198. </script>
  199. <style scoped>
  200. #post_slide {
  201. aspect-ratio:4/3 auto;
  202. }
  203. .img_16_9 {
  204. width:480px;
  205. height:270px;
  206. object-fit:cover;
  207. }
  208. .swiper-slide {
  209. width: 90% !important;
  210. &:last-child {
  211. width: 100% !important;
  212. }
  213. }
  214. </style>