MainHeader.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <template>
  2. <div class="header-inside col"
  3. :class="{'isHomePage': isHomePage}">
  4. <div class="user-top-menu"
  5. :class="{'isHomePage': isHomePage}">
  6. <div class="right-side">
  7. <q-toolbar>
  8. <q-btn class="lt-md q-mr-md"
  9. icon="menu"
  10. color="primary"
  11. round
  12. flat
  13. text-color="gray"
  14. dense
  15. unelevated
  16. @click="toggleLeftDrawer" />
  17. <q-btn flat
  18. round
  19. dense
  20. class="top-menu-item top-menu-logo gt-sm"
  21. :to="{name: 'Public.Home'}">
  22. <q-img src="/assets/images/web/user-top-menu-logo.png"
  23. width="53" />
  24. </q-btn>
  25. <div class="gt-sm">
  26. <q-btn stretch
  27. flat
  28. label="اخبار و اطلاعیه ها"
  29. :to="{ name: 'Public.Post.List.News' }"
  30. class="top-menu-item" />
  31. <q-btn stretch
  32. flat
  33. label="راهنما"
  34. :to="{ name: 'Public.Post.List.Guide' }"
  35. class="top-menu-item" />
  36. <!--<q-btn stretch-->
  37. <!--flat-->
  38. <!--label="Shop"-->
  39. <!--:to="{ name: 'Public.Shop' }"-->
  40. <!--class="top-menu-item" />-->
  41. <q-btn stretch
  42. flat
  43. label="آرشیو محتوا"
  44. :to="{ name: 'Public.ContentCategoryParentParent.List' }"
  45. class="top-menu-item" />
  46. <q-btn stretch
  47. flat
  48. label="فروشگاه"
  49. class="top-menu-item">
  50. <q-menu>
  51. <q-list style="min-width: 100px">
  52. <q-item v-close-popup
  53. href="https://formafzar.ir/form/unfv5"
  54. target="_blank"
  55. clickable>
  56. <q-item-section>کتب سطح یک</q-item-section>
  57. </q-item>
  58. <q-item v-close-popup
  59. href="https://formafzar.com/form/zmvhh"
  60. target="_blank"
  61. clickable>
  62. <q-item-section>کتب سطح دو</q-item-section>
  63. </q-item>
  64. <q-item v-close-popup
  65. href="https://formafzar.com/form/9949w"
  66. target="_blank"
  67. clickable>
  68. <q-item-section>کتب سطح سه</q-item-section>
  69. </q-item>
  70. <q-item v-close-popup
  71. href="https://formafzar.com/form/dttpf"
  72. target="_blank"
  73. clickable>
  74. <q-item-section>کتب سطح چهار</q-item-section>
  75. </q-item>
  76. <q-item v-close-popup
  77. href="https://formafzar.com/form/qlif0"
  78. target="_blank"
  79. clickable>
  80. <q-item-section>کتب سطح پنج</q-item-section>
  81. </q-item>
  82. <q-item v-close-popup
  83. href="https://formafzar.com/form/q9abs"
  84. target="_blank"
  85. clickable>
  86. <q-item-section>کتب جریان‌شناسی سطح یک</q-item-section>
  87. </q-item>
  88. <q-item v-close-popup
  89. href="https://formafzar.com/form/xskmo"
  90. target="_blank"
  91. clickable>
  92. <q-item-section>کتب جریان‌شناسی سطح دو</q-item-section>
  93. </q-item>
  94. <q-item v-close-popup
  95. href="https://formafzar.com/form/j3x1d"
  96. target="_blank"
  97. clickable>
  98. <q-item-section>کتاب تشکیلات بهشتی</q-item-section>
  99. </q-item>
  100. <q-item v-close-popup
  101. href="https://formafzar.com/form/1uxoa"
  102. target="_blank"
  103. clickable>
  104. <q-item-section>کتب دوره تربیت مربی</q-item-section>
  105. </q-item>
  106. <q-item v-close-popup
  107. href="https://formafzar.com/form/2zn2i"
  108. target="_blank"
  109. clickable>
  110. <q-item-section>خرید کتاب بدون توقف دکتر غلامی</q-item-section>
  111. </q-item>
  112. </q-list>
  113. </q-menu>
  114. </q-btn>
  115. <q-btn stretch
  116. flat
  117. label="درباره ما"
  118. :to="{ name: 'Public.AboutUs' }"
  119. class="top-menu-item" />
  120. <q-btn stretch
  121. flat
  122. label="تماس با ما"
  123. :to="{ name: 'Public.ContactUs' }"
  124. class="top-menu-item" />
  125. <q-btn stretch
  126. flat
  127. label="سوالات متداول"
  128. :to="{ name: 'Public.FAQ' }"
  129. class="top-menu-item" />
  130. </div>
  131. </q-toolbar>
  132. </div>
  133. <q-btn flat
  134. round
  135. dense
  136. class="center-logo lt-md"
  137. :to="{name: 'Public.Home'}">
  138. <q-img src="/assets/images/web/homepage-first-section-logo.png" />
  139. </q-btn>
  140. <div class="left-side">
  141. <q-btn flat
  142. :to="{ name: 'Public.PostTopic.List' }"
  143. class="btn-cart">
  144. <q-icon name="search" />
  145. </q-btn>
  146. <q-btn v-if="isUserLogin"
  147. flat
  148. :to="{ name: 'Public.Cart' }"
  149. class="btn-cart">
  150. <q-badge>
  151. {{ cartItemCount }}
  152. </q-badge>
  153. <q-icon name="shopping_cart" />
  154. </q-btn>
  155. <q-btn v-if="user && user.id !== null"
  156. color="primary"
  157. @click="goToProperPanel">
  158. <svg id="_000000ff"
  159. data-name="#000000ff"
  160. xmlns="http://www.w3.org/2000/svg"
  161. width="19.995"
  162. height="19.995"
  163. viewBox="0 0 19.995 19.995">
  164. <path id="Path_29101"
  165. data-name="Path 29101"
  166. d="M5.87,0h8.253a6.009,6.009,0,0,1,5.509,3.949A6.133,6.133,0,0,1,20,5.873v8.214a6.011,6.011,0,0,1-4.645,5.752A6.293,6.293,0,0,1,14.124,20H5.873A6.008,6.008,0,0,1,0,14.085V5.872A6.012,6.012,0,0,1,5.87,0M5.526,1.356a4.673,4.673,0,0,0-4.195,4.66q0,4,0,8.005a4.676,4.676,0,0,0,4.684,4.643q4,0,8,0a4.675,4.675,0,0,0,4.645-4.644q0-4.024,0-8.047a4.673,4.673,0,0,0-3.974-4.589,8.038,8.038,0,0,0-1.257-.053H6.288A7.085,7.085,0,0,0,5.526,1.356Z"
  167. fill="#fff" />
  168. <path id="Path_29102"
  169. data-name="Path 29102"
  170. d="M157.367,85.315a4,4,0,1,1-2.651,1.25,4,4,0,0,1,2.651-1.25m-.228,1.373a2.666,2.666,0,1,0,1.776.286A2.674,2.674,0,0,0,157.139,86.688Z"
  171. transform="translate(-147.63 -81.975)"
  172. fill="#fff" />
  173. <path id="Path_29103"
  174. data-name="Path 29103"
  175. d="M122.8,324.315c.815-.016,1.63,0,2.446-.007a5.976,5.976,0,0,1,4.042,1.606.67.67,0,0,1,.145.733.651.651,0,0,1-.749.385,1.129,1.129,0,0,1-.5-.325,4.66,4.66,0,0,0-2.94-1.081q-1.093,0-2.187,0a4.66,4.66,0,0,0-3.1,1.23.694.694,0,0,1-.528.214.668.668,0,0,1-.457-1.121A5.994,5.994,0,0,1,122.8,324.315Z"
  176. transform="translate(-114.152 -311.642)"
  177. fill="#fff" />
  178. </svg>
  179. <span class="btn-label">
  180. حساب کاربری
  181. </span>
  182. <q-menu v-if="canSeeAdminPanel"
  183. fit>
  184. <q-list>
  185. <q-item v-close-popup
  186. clickable
  187. :to="{ name: 'UserPanel.Profile.UserInfo' }">
  188. <q-item-section>
  189. پنل کاربری
  190. </q-item-section>
  191. </q-item>
  192. <q-item v-close-popup
  193. clickable
  194. :to="{ name: 'Admin' }">
  195. <q-item-section>
  196. پنل ادمین
  197. </q-item-section>
  198. </q-item>
  199. <q-item v-close-popup
  200. clickable
  201. @click="logOut">
  202. <q-item-section>
  203. خروج
  204. </q-item-section>
  205. </q-item>
  206. </q-list>
  207. </q-menu>
  208. </q-btn>
  209. <q-btn v-else
  210. color="primary"
  211. :to="{name: 'Login'}">
  212. <span class="btn-label">
  213. ورود / ثبت نام
  214. </span>
  215. <svg id="Login"
  216. xmlns="http://www.w3.org/2000/svg"
  217. width="18.479"
  218. height="20"
  219. viewBox="0 0 18.479 20">
  220. <path id="Combined_Shape"
  221. data-name="Combined Shape"
  222. d="M9.157,0A4.429,4.429,0,0,0,4.733,4.424v.942a.75.75,0,0,0,1.5,0V4.424A2.928,2.928,0,0,1,9.157,1.5h4.885a2.939,2.939,0,0,1,2.936,2.937V15.575A2.929,2.929,0,0,1,14.053,18.5H9.169a2.938,2.938,0,0,1-2.935-2.934v-.932a.75.75,0,1,0-1.5,0v.932A4.44,4.44,0,0,0,9.169,20h4.884a4.431,4.431,0,0,0,4.425-4.425V4.436A4.442,4.442,0,0,0,14.042,0Zm.176,6.556a.75.75,0,0,0,0,1.06L10.975,9.25H.75a.75.75,0,1,0,0,1.5H10.976L9.334,12.385a.75.75,0,1,0,1.058,1.062l2.929-2.916a.747.747,0,0,0,0-1.062L10.393,6.554a.75.75,0,0,0-1.06,0Z"
  223. transform="translate(18.479 20) rotate(180)"
  224. fill="#fff" />
  225. </svg>
  226. </q-btn>
  227. </div>
  228. </div>
  229. </div>
  230. </template>
  231. <script>
  232. import { User } from 'src/models/User.js'
  233. import { Basket } from 'src/models/Basket.js'
  234. import { mapGetters, mapMutations } from 'vuex'
  235. import { APIGateway } from 'src/api/APIGateway.js'
  236. export default {
  237. name: 'templateHeader',
  238. data () {
  239. return {
  240. user: new User(),
  241. topMenuItems: [
  242. ]
  243. }
  244. },
  245. computed: {
  246. cartItemCount () {
  247. return this.basket.items_info.list.length
  248. },
  249. basket: {
  250. get () {
  251. return this.$store.getters['Shop/basket']
  252. },
  253. set (newValue) {
  254. this.$store.commit('Shop/updateBasket', newValue)
  255. }
  256. },
  257. isUserLogin () {
  258. return this.user && this.user.id !== null
  259. },
  260. canSeeAdminPanel () {
  261. return this.user.isAdmin() || this.user.isSuperUser() || this.user.isEducationalDepartmentHead() || this.user.isFinancialDepartmentHead()
  262. },
  263. isAdminPage () {
  264. return this.$route.name && this.$route.name.includes('Admin.')
  265. },
  266. isProfilePage () {
  267. return this.$route.name && this.$route.name.includes('UserPanel.Profile.')
  268. },
  269. isHomePage () {
  270. return this.$route.name && this.$route.name === 'Public.Home'
  271. },
  272. ...mapGetters('AppLayout', [
  273. 'breadcrumbs',
  274. 'windowSize'
  275. ])
  276. },
  277. mounted () {
  278. this.loadAuthData()
  279. if (this.isUserLogin) {
  280. this.checkoutReview()
  281. }
  282. },
  283. methods: {
  284. ...mapMutations('AppLayout', [
  285. 'updateLayoutLeftDrawerVisible'
  286. ]),
  287. checkoutReview () {
  288. this.basket.loading = true
  289. APIGateway.basket.checkoutReview()
  290. .then((basket) => {
  291. this.basket = new Basket(basket)
  292. })
  293. .finally(() => {
  294. this.basket.loading = false
  295. })
  296. },
  297. loadAuthData () {
  298. this.user = this.$store.getters['Auth/user']
  299. },
  300. goToProperPanel () {
  301. if (this.canSeeAdminPanel) {
  302. // this.$router.push({ name: 'Admin.User.Index' })
  303. } else {
  304. this.$router.push({ name: 'UserPanel.Profile.UserInfo' })
  305. }
  306. },
  307. goToHome () {
  308. this.$router.push({ name: 'Public.Home' })
  309. },
  310. goToAdminDashboard () {
  311. this.$router.push({ name: 'Admin.Content.Index' })
  312. },
  313. logOut () {
  314. this.$store.dispatch('Auth/logOut')
  315. },
  316. toggleLeftDrawer () {
  317. this.updateLayoutLeftDrawerVisible(true)
  318. },
  319. hasRoute (route) {
  320. if (!route) {
  321. return
  322. }
  323. return !!(route.name || route.path)
  324. },
  325. getRoute (route) {
  326. if (!this.hasRoute(route)) {
  327. return { name: null }
  328. }
  329. if (route.name) {
  330. return { name: route.name }
  331. } else if (route.path) {
  332. return { path: route.path }
  333. } else {
  334. return { name: null }
  335. }
  336. }
  337. }
  338. }
  339. </script>
  340. <style lang="scss" scoped>
  341. .drawer-btn {
  342. display: none;
  343. @media screen and (max-width: 1439px) {
  344. & {
  345. display: block;
  346. }
  347. }
  348. @media screen and (max-width: 599px) {
  349. & {
  350. margin-bottom: 10px;
  351. }
  352. }
  353. }
  354. .right-side {
  355. display: flex;
  356. align-items: center;
  357. .breadcrumbs {
  358. &:deep(> *) {
  359. font-style: normal;
  360. font-weight: bold;
  361. font-size: 16px;
  362. line-height: 31px;
  363. text-align: right;
  364. color: #23263B;
  365. div:first-child {
  366. font-size: 18px;
  367. }
  368. }
  369. }
  370. @media screen and (max-width: 1023px) {
  371. & {
  372. margin-left: 42px;
  373. }
  374. }
  375. @media screen and (max-width: 599px) {
  376. & {
  377. margin-left: 0;
  378. }
  379. }
  380. }
  381. .left-side {
  382. display: flex;
  383. justify-content: flex-end;
  384. @media screen and (max-width: 1439px) {
  385. & {
  386. position: absolute;
  387. right: 0;
  388. }
  389. }
  390. @media screen and (max-width: 1023px) {
  391. .q-btn {
  392. width: 40px;
  393. padding: 0;
  394. .btn-label {
  395. display: none;
  396. }
  397. }
  398. }
  399. @media screen and (max-width: 599px) {
  400. & {
  401. right: 16px;
  402. margin-bottom: 10px;
  403. }
  404. }
  405. }
  406. </style>
  407. <style scoped lang="scss">
  408. .header-inside {
  409. height: 120px;
  410. background-color: #FBF4EA;
  411. color: #212121;
  412. //border-bottom: solid 1px #DFE1EC;
  413. &.isHomePage {
  414. background: transparent;
  415. @media only screen and (max-width: 1023px) {
  416. & {
  417. background-color: #FBF4EA;
  418. }
  419. }
  420. }
  421. .admin-top-menu {
  422. display: flex;
  423. flex-flow: row;
  424. height: 100%;
  425. .top-menu-items {
  426. width: calc( 100% - 240px );
  427. display: flex;
  428. flex-flow: row;
  429. justify-content: space-between;
  430. .q-btn {
  431. height: 40px;
  432. svg {
  433. margin-right: 10px;
  434. }
  435. }
  436. .right-side {
  437. display: flex;
  438. flex-flow: row;
  439. align-items: center;
  440. padding-left: 50px;
  441. }
  442. .left-side {
  443. display: flex;
  444. flex-flow: row;
  445. align-items: center;
  446. padding-right: 50px;
  447. }
  448. }
  449. .logo {
  450. width: 240px;
  451. height: 100%;
  452. background: #FBF4EA;
  453. border-right: solid 1px #DFE1EC;
  454. display: flex;
  455. align-items: center;
  456. justify-content: center;
  457. .logo-image {
  458. width: 106px;
  459. height: auto;
  460. }
  461. }
  462. }
  463. .user-top-menu {
  464. padding-top: 30px;
  465. margin-right: 100px;
  466. margin-left: 100px;
  467. margin-bottom: 22px;
  468. display: flex;
  469. flex-flow: row;
  470. justify-content: space-between;
  471. .q-btn {
  472. height: 40px;
  473. svg {
  474. margin-right: 10px;
  475. margin-left: 10px;
  476. }
  477. }
  478. .right-side {
  479. display: flex;
  480. flex-flow: row;
  481. align-items: center;
  482. .q-toolbar {
  483. min-height: 68px;
  484. .q-btn {
  485. align-self: center;
  486. }
  487. }
  488. }
  489. .center-logo {
  490. $width: 100px;
  491. $height: 55px;
  492. position: absolute;
  493. width: $width;
  494. height: 100%;
  495. top: 0;
  496. left: calc( 50% - (#{$width} / 2));
  497. }
  498. .left-side {
  499. display: flex;
  500. flex-flow: row;
  501. align-items: center;
  502. padding-right: 50px;
  503. @media only screen and (max-width: 1023px) {
  504. & {
  505. height: 100%;
  506. }
  507. }
  508. @media only screen and (max-width: 599px) {
  509. & {
  510. padding-right: 0;
  511. }
  512. }
  513. }
  514. &.isHomePage {
  515. .q-toolbar {
  516. .top-menu-item {
  517. color: white;
  518. }
  519. }
  520. }
  521. @media only screen and (max-width: 1500px) {
  522. & {
  523. margin-right: 10px;
  524. margin-left: 10px;
  525. }
  526. }
  527. @media only screen and (max-width: 1023px) {
  528. & {
  529. padding-top: 0;
  530. margin-bottom: 0;
  531. }
  532. }
  533. }
  534. @media only screen and (max-width: 1023px) {
  535. & {
  536. height: 70px;
  537. }
  538. }
  539. }
  540. .top-menu-items {
  541. border-radius: 10px;
  542. @media only screen and (max-width: 1439px) {
  543. & {
  544. display: none !important;
  545. }
  546. }
  547. @media only screen and (max-width: 500px) {
  548. .q-btn__content {
  549. margin: 4px;
  550. font-size: 0.7rem;
  551. }
  552. }
  553. @media only screen and (max-width: 400px) {
  554. .q-btn__content {
  555. margin: 3px;
  556. font-size: 0.6rem;
  557. }
  558. }
  559. }
  560. .breadcrumbs {
  561. .q-breadcrumbs__separator {
  562. .q-icon {
  563. font-size: 22px;
  564. }
  565. }
  566. }
  567. .drawer-btn {
  568. .q-btn {
  569. flex-direction: row !important;
  570. &.toolbar-button {
  571. margin-left: 0 !important;
  572. }
  573. }
  574. }
  575. .q-btn {
  576. &.toolbar-button {
  577. margin-left: 12px;
  578. height: 48px;
  579. width: 48px;
  580. box-shadow: -2px -4px 10px rgba(255, 255, 255, 0.6), 2px 4px 10px rgba(112, 108, 162, 0.05);
  581. border-radius: 16px;
  582. border: solid 1px #c5c5c5;
  583. }
  584. }
  585. .left-side {
  586. .q-btn {
  587. &.toolbar-button {
  588. .q-btn__content {
  589. .q-btn-dropdown__arrow {
  590. display: none !important;
  591. }
  592. }
  593. }
  594. &.btn-cart {
  595. background: white;
  596. color: $primary;
  597. margin-right: 20px;
  598. .q-badge {
  599. background: #FBF4EA;
  600. color: $primary;
  601. }
  602. }
  603. }
  604. }
  605. </style>