ClassroomCarousel.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <div class="classroomCarousel">
  3. <div class="classroomCarousel-title">
  4. <div>
  5. <q-banner class="banner">
  6. دوره های آموزشی
  7. </q-banner>
  8. </div>
  9. <div>
  10. <q-btn flat
  11. :to="{name: 'Public.AllClassrooms'}">
  12. مشاهده همه
  13. <svg xmlns="http://www.w3.org/2000/svg"
  14. width="18.387"
  15. height="11.502"
  16. viewBox="0 0 18.387 11.502"
  17. class="q-ml-sm">
  18. <path id="Combined_Shape"
  19. data-name="Combined Shape"
  20. d="M-9.338,11.408a.748.748,0,0,0,.388-.656V6.5h8.2A.751.751,0,0,0,0,5.75.75.75,0,0,0-.75,5h-8.2V.75A.751.751,0,0,0-9.338.093.769.769,0,0,0-9.7,0a.735.735,0,0,0-.4.115l-7.938,5a.747.747,0,0,0-.35.635.742.742,0,0,0,.35.634l7.938,5a.751.751,0,0,0,.4.116A.746.746,0,0,0-9.338,11.408ZM-10.45,9.392l-5.78-3.641,5.78-3.642Z"
  21. transform="translate(18.387)"
  22. fill="#eac38a" />
  23. </svg>
  24. </q-btn>
  25. </div>
  26. </div>
  27. <div class="carousel-section">
  28. <carousel v-if="!classrooms.loading && classrooms.list.length > 0"
  29. :breakpoints="breakpoints"
  30. dir="rtl">
  31. <slide v-for="classroom in classrooms.list"
  32. :key="classroom.id + classroomsKey">
  33. <q-card flat
  34. class="classroomCarousel-item"
  35. :class="{'isRegistered' : isClassroomRegistered(classroom.id) }">
  36. <q-card-section class="thumbnail">
  37. <router-link :to="{name: 'Public.ShowClassroomInfo', params: {id: classroom.id}}">
  38. <div class="RegisteredSign">
  39. <svg class="ribbon"
  40. xmlns="http://www.w3.org/2000/svg"
  41. width="123.945"
  42. height="123.422"
  43. viewBox="0 0 123.945 123.422">
  44. <g id="Group_11524"
  45. data-name="Group 11524"
  46. transform="translate(-361 -1111)">
  47. <g id="Group_7903"
  48. data-name="Group 7903"
  49. transform="translate(361 1111)">
  50. <g id="Group_7901"
  51. data-name="Group 7901"
  52. transform="translate(0 0)">
  53. <rect id="Rectangle_1771"
  54. data-name="Rectangle 1771"
  55. width="13.986"
  56. height="39.668"
  57. transform="translate(0 83.754)"
  58. fill="#cfb184" />
  59. <rect id="Rectangle_1772"
  60. data-name="Rectangle 1772"
  61. width="39.668"
  62. height="13.986"
  63. transform="translate(84.277 0)"
  64. fill="#cfb184" />
  65. <path id="Path_18668"
  66. data-name="Path 18668"
  67. d="M1938.931,282.651l123.945-123.406-.016-.016h-44a9.041,9.041,0,0,0-6.379,2.631l-70.907,70.6a8.962,8.962,0,0,0-2.642,6.352Z"
  68. transform="translate(-1938.931 -159.229)"
  69. fill="#eac38a" />
  70. </g>
  71. </g>
  72. <text id="دوره_های_من"
  73. data-name="دوره‌های من"
  74. transform="translate(445.063 1135.174) rotate(-45)"
  75. fill="#fff"
  76. font-size="18"
  77. font-family="SegoeUI-Bold, Segoe UI"
  78. font-weight="700"><tspan x="0"
  79. y="0">دوره‌های من</tspan></text>
  80. </g>
  81. </svg>
  82. </div>
  83. <q-img class="q-ma-xs"
  84. :src="classroom.thumbnail" />
  85. </router-link>
  86. </q-card-section>
  87. <q-card-section class="title">
  88. <router-link :to="{name: 'Public.ShowClassroomInfo', params: {id: classroom.id}}">
  89. {{classroom.title}}
  90. </router-link>
  91. </q-card-section>
  92. <q-card-section class="attribute">
  93. <div class="attribute-item">
  94. <div class="attribute-logo">
  95. <svg id="Profile"
  96. xmlns="http://www.w3.org/2000/svg"
  97. width="17.058"
  98. height="21.399"
  99. viewBox="0 0 17.058 21.399">
  100. <path id="Combined_Shape"
  101. data-name="Combined Shape"
  102. d="M0,17.418c0-3.55,4.868-3.96,8.53-3.96,2.109,0,8.528,0,8.528,3.982,0,3.548-4.867,3.959-8.528,3.959C6.42,21.4,0,21.4,0,17.418Zm1.616,0c0,1.57,2.326,2.366,6.914,2.366s6.913-.789,6.913-2.345-2.326-2.366-6.913-2.366S1.616,15.862,1.616,17.418ZM8.5,11.436A5.718,5.718,0,0,1,8.53,0a5.718,5.718,0,0,1,0,11.436ZM4.349,5.718A4.171,4.171,0,0,0,8.5,9.9l.031.77V9.9a4.18,4.18,0,1,0-4.181-4.18Z"
  103. transform="translate(0 0)"
  104. fill="#aaa095" />
  105. </svg>
  106. </div>
  107. <div class="attribute-value">
  108. {{classroom.professor_info.firstname}}
  109. {{classroom.professor_info.lastname}}
  110. </div>
  111. </div>
  112. <div class="attribute-item">
  113. <div class="attribute-logo">
  114. <svg id="Calendar"
  115. xmlns="http://www.w3.org/2000/svg"
  116. width="21"
  117. height="23.154"
  118. viewBox="0 0 21 23.154">
  119. <path id="Combined_Shape"
  120. data-name="Combined Shape"
  121. d="M5.945,23.154c-3.668,0-5.945-2.26-5.945-5.9V7.51A5.382,5.382,0,0,1,5.347,1.721V.807a.808.808,0,0,1,1.616,0V1.7h7.084V.807a.807.807,0,1,1,1.615,0v.914a5.8,5.8,0,0,1,3.8,1.572A5.793,5.793,0,0,1,21,7.513v9.824c0,3.588-2.279,5.817-5.946,5.817Zm-4.33-5.9c0,2.762,1.537,4.284,4.33,4.284h9.109c2.792,0,4.331-1.493,4.331-4.2V9.59H1.616ZM19.385,7.974V7.51a4.159,4.159,0,0,0-1.063-3.074,4.164,4.164,0,0,0-2.66-1.094v1.01a.807.807,0,0,1-1.615,0V3.317H6.963V4.352a.808.808,0,0,1-1.616,0V3.341c-2.413.2-3.732,1.664-3.732,4.169v.464Zm-4.9,9.2a.8.8,0,0,1,.8-.807h.01a.807.807,0,1,1-.812.807Zm-4.778,0a.8.8,0,0,1,.8-.807h.01a.807.807,0,1,1-.812.807Zm-4.79,0a.8.8,0,0,1,.8-.807h.01a.807.807,0,1,1-.813.807Zm9.568-4.185a.8.8,0,0,1,.8-.808h.01a.808.808,0,1,1-.812.808Zm-4.778,0a.8.8,0,0,1,.8-.808h.01a.808.808,0,1,1-.812.808Zm-4.79,0a.8.8,0,0,1,.8-.808h.01a.808.808,0,1,1-.813.808Z"
  122. transform="translate(0 0)"
  123. fill="#aaa095" />
  124. </svg>
  125. </div>
  126. <div class="attribute-value">
  127. {{ getTerm(classroom) }}
  128. </div>
  129. </div>
  130. <div class="attribute-item">
  131. <div class="attribute-logo">
  132. <svg id="Group_11306"
  133. data-name="Group 11306"
  134. xmlns="http://www.w3.org/2000/svg"
  135. width="21.539"
  136. height="21.044"
  137. viewBox="0 0 21.539 21.044">
  138. <g id="Buy"
  139. transform="translate(0 0)">
  140. <path id="Combined_Shape"
  141. data-name="Combined Shape"
  142. d="M16.3,19.649A1.395,1.395,0,1,1,17.7,21.044,1.4,1.4,0,0,1,16.3,19.649Zm-12.147,0a1.394,1.394,0,1,1,1.394,1.395A1.4,1.4,0,0,1,4.157,19.649ZM17.77,16.139H6.014A2.76,2.76,0,0,1,3.28,13.615L2.294,1.883.671,1.6A.812.812,0,0,1,.012.668.811.811,0,0,1,.815,0a.829.829,0,0,1,.13.011L3.186.4a.808.808,0,0,1,.666.729L4.1,4.143c15.367.007,15.424.014,15.5.022a2.254,2.254,0,0,1,1.912,2.553l-1.023,7.062a2.76,2.76,0,0,1-2.717,2.358ZM4.89,13.483a1.123,1.123,0,0,0,1.127,1.04H17.771a1.139,1.139,0,0,0,1.122-.972l1.024-7.064a.632.632,0,0,0-.121-.472.625.625,0,0,0-.418-.249c-.052,0-.6,0-1.677,0-1.693,0-4.455,0-7.291,0l-6.17,0ZM13.059,9.74a.808.808,0,0,1,0-1.616h2.985a.808.808,0,0,1,0,1.616Z"
  143. transform="translate(0)"
  144. fill="#aaa095" />
  145. </g>
  146. </svg>
  147. </div>
  148. <div class="attribute-value">
  149. {{classroom.price}}
  150. ریال
  151. </div>
  152. </div>
  153. </q-card-section>
  154. <q-card-actions class="action-section">
  155. <q-btn color="primary"
  156. class="btn-show-classroom"
  157. :to="{name: 'Public.ShowClassroomInfo', params: {id: classroom.id}}">
  158. جزییات دوره
  159. <svg xmlns="http://www.w3.org/2000/svg"
  160. width="18.387"
  161. height="11.502"
  162. viewBox="0 0 18.387 11.502">
  163. <path id="Combined_Shape"
  164. data-name="Combined Shape"
  165. d="M-9.338,11.408a.748.748,0,0,0,.388-.656V6.5h8.2A.751.751,0,0,0,0,5.75.75.75,0,0,0-.75,5h-8.2V.75A.751.751,0,0,0-9.338.093.769.769,0,0,0-9.7,0a.735.735,0,0,0-.4.115l-7.938,5a.747.747,0,0,0-.35.635.742.742,0,0,0,.35.634l7.938,5a.751.751,0,0,0,.4.116A.746.746,0,0,0-9.338,11.408ZM-10.45,9.392l-5.78-3.641,5.78-3.642Z"
  166. transform="translate(18.387)"
  167. fill="#fff" />
  168. </svg>
  169. </q-btn>
  170. </q-card-actions>
  171. </q-card>
  172. </slide>
  173. <template #addons="{ slidesCount }">
  174. <navigation v-if="slidesCount > 1" />
  175. <pagination v-if="slidesCount > 1 && false" />
  176. </template>
  177. </carousel>
  178. <div v-else-if="!classrooms.loading && classrooms.list.length === 0">
  179. دوره ای یافت نشد.
  180. </div>
  181. <div v-else-if="classrooms.loading">
  182. کمی صبر کنید ...
  183. </div>
  184. </div>
  185. </div>
  186. </template>
  187. <script>
  188. import 'vue3-carousel/dist/carousel.css'
  189. import { User } from 'src/models/User.js'
  190. import ShamsiDate from 'src/assets/ShamsiDate.js'
  191. import { APIGateway } from 'src/api/APIGateway.js'
  192. import { ClassroomList } from 'src/models/Classroom.js'
  193. import { mixinPrefetchServerData } from 'src/mixin/Mixins.js'
  194. import { ClassroomRegistrationList } from 'src/models/ClassroomRegistration.js'
  195. import { Carousel, Slide, Pagination, Navigation } from 'vue3-carousel/dist/carousel'
  196. export default {
  197. name: 'ClassroomCarousel',
  198. components: {
  199. Carousel,
  200. Slide,
  201. Pagination,
  202. Navigation
  203. },
  204. mixins: [mixinPrefetchServerData],
  205. data: () => ({
  206. loading: false,
  207. user: new User(),
  208. classroomsKey: Date.now(),
  209. userRegistrations: new ClassroomRegistrationList(),
  210. slide: 0,
  211. classrooms: new ClassroomList(),
  212. breakpoints: {
  213. // 1024 and up
  214. 1024: {
  215. itemsToShow: 3,
  216. snapAlign: 'start'
  217. },
  218. // 700px and up
  219. 700: {
  220. itemsToShow: 2.2,
  221. snapAlign: 'center'
  222. },
  223. // 300px and up
  224. 300: {
  225. itemsToShow: 1.1,
  226. snapAlign: 'center'
  227. }
  228. },
  229. maximizedToggle: true,
  230. dialog: false
  231. }),
  232. mounted () {
  233. this.loadAuthData()
  234. if (this.user && this.user.id !== null) {
  235. this.getUserRegistrations()
  236. }
  237. },
  238. methods: {
  239. prefetchServerDataPromise () {
  240. return this.getClassrooms()
  241. },
  242. prefetchServerDataPromiseThen (classroomList) {
  243. this.classrooms = new ClassroomList(classroomList.list)
  244. this.classrooms.loading = false
  245. },
  246. prefetchServerDataPromiseCatch () {
  247. this.classrooms.loading = false
  248. },
  249. loadAuthData () {
  250. this.user = this.$store.getters['Auth/user']
  251. },
  252. getTerm (classroom) {
  253. if (!classroom.beginning_registration_period) {
  254. return '-'
  255. }
  256. return ShamsiDate.getTerm(classroom.beginning_registration_period)
  257. },
  258. isClassroomRegistered (classroomId) {
  259. return !!this.userRegistrations.list.find(item => item.classroom === classroomId && (item.status === 'REGISTERED' || item.status === 'ENROLLED'))
  260. },
  261. getUserRegistrations () {
  262. this.userRegistrations.loading = true
  263. APIGateway.classroomRegistration.index()
  264. .then((classroomRegistrationList) => {
  265. this.userRegistrations = new ClassroomRegistrationList(classroomRegistrationList.list)
  266. this.classroomsKey = Date.now()
  267. this.userRegistrations.loading = false
  268. })
  269. .catch(() => {
  270. this.userRegistrations.loading = false
  271. })
  272. },
  273. getClassrooms () {
  274. this.classrooms.loading = true
  275. return APIGateway.classroom.index()
  276. }
  277. }
  278. }
  279. </script>
  280. <style scoped lang="scss">
  281. .classroomCarousel {
  282. padding: 60px 0;
  283. .classroomCarousel-title {
  284. display: flex;
  285. flex-flow: row;
  286. justify-content: space-between;
  287. padding-bottom: 33px;
  288. }
  289. .carousel-section {
  290. padding: 0 60px;
  291. :deep(.carousel__prev),
  292. :deep(.carousel__next) {
  293. width: 48px;
  294. height: 48px;
  295. background-color: #475F4A;
  296. border-radius: 8px;
  297. &.carousel__prev--in-active {
  298. background-color: #DEDEDE;
  299. }
  300. &:after {
  301. }
  302. svg {
  303. //display: none;
  304. }
  305. }
  306. :deep(.carousel__prev) {
  307. right: auto;
  308. left: 0;
  309. transform: translate(-100%, -50%);
  310. color: white;
  311. }
  312. :deep(.carousel__next) {
  313. left: auto;
  314. right: 0;
  315. transform: translate(100%, -50%);
  316. color: white;
  317. }
  318. .carousel__slide {
  319. padding: 0 12px;
  320. .classroomCarousel-item {
  321. width: 100%;
  322. &.isRegistered {
  323. .thumbnail {
  324. position: relative;
  325. z-index: 1;
  326. .RegisteredSign {
  327. position: absolute;
  328. right: 5px;
  329. top: 7px;
  330. z-index: 2;
  331. display: block;
  332. }
  333. }
  334. }
  335. .thumbnail {
  336. padding-top: 17px;
  337. padding-left: 22px;
  338. padding-right: 22px;
  339. padding-bottom: 26px;
  340. .RegisteredSign {
  341. display: none;
  342. }
  343. }
  344. .title {
  345. text-align: left;
  346. padding-top: 0;
  347. padding-left: 46px;
  348. padding-right: 46px;
  349. padding-bottom: 33px;
  350. }
  351. .attribute {
  352. padding-top: 0;
  353. padding-left: 46px;
  354. padding-right: 46px;
  355. padding-bottom: 44px;
  356. .attribute-item {
  357. margin-bottom: 21px;
  358. display: flex;
  359. flex-flow: row;
  360. .attribute-logo {
  361. margin-right: 15px;
  362. }
  363. &:last-child {
  364. margin-bottom: 0;
  365. }
  366. }
  367. }
  368. .action-section {
  369. padding: 0;
  370. .btn-show-classroom {
  371. width: 100%;
  372. height: 60px;
  373. border-top-right-radius: 0;
  374. border-top-left-radius: 0;
  375. }
  376. }
  377. }
  378. }
  379. }
  380. }
  381. </style>