ClassroomCarousel.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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}}
  109. </div>
  110. </div>
  111. <div class="attribute-item">
  112. <div class="attribute-logo">
  113. <svg id="Calendar"
  114. xmlns="http://www.w3.org/2000/svg"
  115. width="21"
  116. height="23.154"
  117. viewBox="0 0 21 23.154">
  118. <path id="Combined_Shape"
  119. data-name="Combined Shape"
  120. 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"
  121. transform="translate(0 0)"
  122. fill="#aaa095" />
  123. </svg>
  124. </div>
  125. <div class="attribute-value">
  126. {{ getTerm(classroom) }}
  127. </div>
  128. </div>
  129. <div class="attribute-item">
  130. <div class="attribute-logo">
  131. <svg id="Group_11306"
  132. data-name="Group 11306"
  133. xmlns="http://www.w3.org/2000/svg"
  134. width="21.539"
  135. height="21.044"
  136. viewBox="0 0 21.539 21.044">
  137. <g id="Buy"
  138. transform="translate(0 0)">
  139. <path id="Combined_Shape"
  140. data-name="Combined Shape"
  141. 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"
  142. transform="translate(0)"
  143. fill="#aaa095" />
  144. </g>
  145. </svg>
  146. </div>
  147. <div class="attribute-value">
  148. {{classroom.price}}
  149. تومان
  150. </div>
  151. </div>
  152. </q-card-section>
  153. <q-card-actions class="action-section">
  154. <q-btn color="primary"
  155. class="btn-show-classroom"
  156. :to="{name: 'Public.ShowClassroomInfo', params: {id: classroom.id}}">
  157. جزییات دوره
  158. <svg xmlns="http://www.w3.org/2000/svg"
  159. width="18.387"
  160. height="11.502"
  161. viewBox="0 0 18.387 11.502">
  162. <path id="Combined_Shape"
  163. data-name="Combined Shape"
  164. 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"
  165. transform="translate(18.387)"
  166. fill="#fff" />
  167. </svg>
  168. </q-btn>
  169. </q-card-actions>
  170. </q-card>
  171. </slide>
  172. <template #addons="{ slidesCount }">
  173. <navigation v-if="slidesCount > 1" />
  174. <pagination v-if="slidesCount > 1 && false" />
  175. </template>
  176. </carousel>
  177. <div v-else-if="!classrooms.loading && classrooms.list.length === 0">
  178. دوره ای یافت نشد.
  179. </div>
  180. <div v-else-if="classrooms.loading">
  181. کمی صبر کنید ...
  182. </div>
  183. </div>
  184. </div>
  185. </template>
  186. <script>
  187. import 'vue3-carousel/dist/carousel.css'
  188. import { User } from 'src/models/User.js'
  189. import ShamsiDate from 'src/assets/ShamsiDate.js'
  190. import { APIGateway } from 'src/api/APIGateway.js'
  191. import { ClassroomList } from 'src/models/Classroom.js'
  192. import { ClassroomRegistrationList } from 'src/models/ClassroomRegistration.js'
  193. import { Carousel, Slide, Pagination, Navigation } from 'vue3-carousel/dist/carousel'
  194. export default {
  195. name: 'ClassroomCarousel',
  196. components: {
  197. Carousel,
  198. Slide,
  199. Pagination,
  200. Navigation
  201. },
  202. data: () => ({
  203. loading: false,
  204. user: new User(),
  205. classroomsKey: Date.now(),
  206. userRegistrations: new ClassroomRegistrationList(),
  207. slide: 0,
  208. classrooms: new ClassroomList(),
  209. breakpoints: {
  210. // 1024 and up
  211. 1024: {
  212. itemsToShow: 3,
  213. snapAlign: 'start'
  214. },
  215. // 700px and up
  216. 700: {
  217. itemsToShow: 2.2,
  218. snapAlign: 'center'
  219. },
  220. // 300px and up
  221. 300: {
  222. itemsToShow: 1.1,
  223. snapAlign: 'center'
  224. }
  225. },
  226. maximizedToggle: true,
  227. dialog: false
  228. }),
  229. mounted () {
  230. this.loadAuthData()
  231. if (this.user && this.user.id !== null) {
  232. this.getUserRegistrations()
  233. }
  234. this.getClassrooms()
  235. },
  236. methods: {
  237. loadAuthData () {
  238. this.user = this.$store.getters['Auth/user']
  239. },
  240. getTerm (classroom) {
  241. if (!classroom.beginning_registration_period) {
  242. return '-'
  243. }
  244. return ShamsiDate.getTerm(classroom.beginning_registration_period)
  245. },
  246. isClassroomRegistered (classroomId) {
  247. return !!this.userRegistrations.list.find(item => item.classroom === classroomId)
  248. },
  249. getUserRegistrations () {
  250. this.userRegistrations.loading = true
  251. APIGateway.classroomRegistration.index()
  252. .then((classroomRegistrationList) => {
  253. this.userRegistrations = new ClassroomRegistrationList(classroomRegistrationList.list)
  254. this.classroomsKey = Date.now()
  255. this.userRegistrations.loading = false
  256. })
  257. .catch(() => {
  258. this.userRegistrations.loading = false
  259. })
  260. },
  261. getClassrooms () {
  262. this.classrooms.loading = true
  263. APIGateway.classroom.index()
  264. .then(classroomList => {
  265. this.classrooms = new ClassroomList(classroomList.list)
  266. this.classrooms.loading = false
  267. })
  268. .catch(() => {
  269. this.classrooms.loading = false
  270. })
  271. }
  272. }
  273. }
  274. </script>
  275. <style scoped lang="scss">
  276. .classroomCarousel {
  277. padding: 60px 0;
  278. .classroomCarousel-title {
  279. display: flex;
  280. flex-flow: row;
  281. justify-content: space-between;
  282. padding-bottom: 33px;
  283. }
  284. .carousel-section {
  285. padding: 0 60px;
  286. :deep(.carousel__prev),
  287. :deep(.carousel__next) {
  288. width: 48px;
  289. height: 48px;
  290. background-color: #475F4A;
  291. border-radius: 8px;
  292. &.carousel__prev--in-active {
  293. background-color: #DEDEDE;
  294. }
  295. &:after {
  296. }
  297. svg {
  298. //display: none;
  299. }
  300. }
  301. :deep(.carousel__prev) {
  302. right: auto;
  303. left: 0;
  304. transform: translate(-100%, -50%);
  305. color: white;
  306. }
  307. :deep(.carousel__next) {
  308. left: auto;
  309. right: 0;
  310. transform: translate(100%, -50%);
  311. color: white;
  312. }
  313. .carousel__slide {
  314. padding: 0 12px;
  315. .classroomCarousel-item {
  316. width: 100%;
  317. &.isRegistered {
  318. .thumbnail {
  319. position: relative;
  320. z-index: 1;
  321. .RegisteredSign {
  322. position: absolute;
  323. right: 5px;
  324. top: 7px;
  325. z-index: 2;
  326. display: block;
  327. }
  328. }
  329. }
  330. .thumbnail {
  331. padding-top: 17px;
  332. padding-left: 22px;
  333. padding-right: 22px;
  334. padding-bottom: 26px;
  335. .RegisteredSign {
  336. display: none;
  337. }
  338. }
  339. .title {
  340. text-align: left;
  341. padding-top: 0;
  342. padding-left: 46px;
  343. padding-right: 46px;
  344. padding-bottom: 33px;
  345. }
  346. .attribute {
  347. padding-top: 0;
  348. padding-left: 46px;
  349. padding-right: 46px;
  350. padding-bottom: 44px;
  351. .attribute-item {
  352. margin-bottom: 21px;
  353. display: flex;
  354. flex-flow: row;
  355. .attribute-logo {
  356. margin-right: 15px;
  357. }
  358. &:last-child {
  359. margin-bottom: 0;
  360. }
  361. }
  362. }
  363. .action-section {
  364. padding: 0;
  365. .btn-show-classroom {
  366. width: 100%;
  367. height: 60px;
  368. border-top-right-radius: 0;
  369. border-top-left-radius: 0;
  370. }
  371. }
  372. }
  373. }
  374. }
  375. }
  376. </style>