MainHeader.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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-list>
  101. </q-menu>
  102. </q-btn>
  103. <q-btn stretch
  104. flat
  105. label="درباره ما"
  106. :to="{ name: 'Public.AboutUs' }"
  107. class="top-menu-item" />
  108. <q-btn stretch
  109. flat
  110. label="تماس با ما"
  111. :to="{ name: 'Public.ContactUs' }"
  112. class="top-menu-item" />
  113. <q-btn stretch
  114. flat
  115. label="سوالات متداول"
  116. :to="{ name: 'Public.FAQ' }"
  117. class="top-menu-item" />
  118. </div>
  119. </q-toolbar>
  120. </div>
  121. <q-btn flat
  122. round
  123. dense
  124. class="center-logo lt-md"
  125. :to="{name: 'Public.Home'}">
  126. <q-img src="/assets/images/web/homepage-first-section-logo.png" />
  127. </q-btn>
  128. <div class="left-side">
  129. <q-btn flat
  130. :to="{ name: 'Public.PostTopic.List' }"
  131. class="btn-cart">
  132. <q-icon name="search" />
  133. </q-btn>
  134. <q-btn v-if="isUserLogin"
  135. flat
  136. :to="{ name: 'Public.Cart' }"
  137. class="btn-cart">
  138. <q-badge>
  139. {{ cartItemCount }}
  140. </q-badge>
  141. <q-icon name="shopping_cart" />
  142. </q-btn>
  143. <q-btn v-if="user && user.id !== null"
  144. color="primary"
  145. @click="goToProperPanel">
  146. <svg id="_000000ff"
  147. data-name="#000000ff"
  148. xmlns="http://www.w3.org/2000/svg"
  149. width="19.995"
  150. height="19.995"
  151. viewBox="0 0 19.995 19.995">
  152. <path id="Path_29101"
  153. data-name="Path 29101"
  154. 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"
  155. fill="#fff" />
  156. <path id="Path_29102"
  157. data-name="Path 29102"
  158. 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"
  159. transform="translate(-147.63 -81.975)"
  160. fill="#fff" />
  161. <path id="Path_29103"
  162. data-name="Path 29103"
  163. 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"
  164. transform="translate(-114.152 -311.642)"
  165. fill="#fff" />
  166. </svg>
  167. <span class="btn-label">
  168. حساب کاربری
  169. </span>
  170. <q-menu v-if="canSeeAdminPanel"
  171. fit>
  172. <q-list>
  173. <q-item v-close-popup
  174. clickable
  175. :to="{ name: 'UserPanel.Profile.UserInfo' }">
  176. <q-item-section>
  177. پنل کاربری
  178. </q-item-section>
  179. </q-item>
  180. <q-item v-close-popup
  181. clickable
  182. :to="{ name: 'Admin' }">
  183. <q-item-section>
  184. پنل ادمین
  185. </q-item-section>
  186. </q-item>
  187. <q-item v-close-popup
  188. clickable
  189. @click="logOut">
  190. <q-item-section>
  191. خروج
  192. </q-item-section>
  193. </q-item>
  194. </q-list>
  195. </q-menu>
  196. </q-btn>
  197. <q-btn v-else
  198. color="primary"
  199. :to="{name: 'Login'}">
  200. <span class="btn-label">
  201. ورود / ثبت نام
  202. </span>
  203. <svg id="Login"
  204. xmlns="http://www.w3.org/2000/svg"
  205. width="18.479"
  206. height="20"
  207. viewBox="0 0 18.479 20">
  208. <path id="Combined_Shape"
  209. data-name="Combined Shape"
  210. 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"
  211. transform="translate(18.479 20) rotate(180)"
  212. fill="#fff" />
  213. </svg>
  214. </q-btn>
  215. </div>
  216. </div>
  217. </div>
  218. </template>
  219. <script>
  220. import { User } from 'src/models/User.js'
  221. import { Basket } from 'src/models/Basket.js'
  222. import { mapGetters, mapMutations } from 'vuex'
  223. import { APIGateway } from 'src/api/APIGateway.js'
  224. export default {
  225. name: 'templateHeader',
  226. data () {
  227. return {
  228. user: new User(),
  229. topMenuItems: [
  230. ]
  231. }
  232. },
  233. computed: {
  234. cartItemCount () {
  235. return this.basket.items_info.list.length
  236. },
  237. basket: {
  238. get () {
  239. return this.$store.getters['Shop/basket']
  240. },
  241. set (newValue) {
  242. this.$store.commit('Shop/updateBasket', newValue)
  243. }
  244. },
  245. isUserLogin () {
  246. return this.user && this.user.id !== null
  247. },
  248. canSeeAdminPanel () {
  249. return this.user.isAdmin() || this.user.isSuperUser() || this.user.isEducationalDepartmentHead() || this.user.isFinancialDepartmentHead()
  250. },
  251. isAdminPage () {
  252. return this.$route.name && this.$route.name.includes('Admin.')
  253. },
  254. isProfilePage () {
  255. return this.$route.name && this.$route.name.includes('UserPanel.Profile.')
  256. },
  257. isHomePage () {
  258. return this.$route.name && this.$route.name === 'Public.Home'
  259. },
  260. ...mapGetters('AppLayout', [
  261. 'breadcrumbs',
  262. 'windowSize'
  263. ])
  264. },
  265. mounted () {
  266. this.loadAuthData()
  267. if (this.isUserLogin) {
  268. this.checkoutReview()
  269. }
  270. },
  271. methods: {
  272. ...mapMutations('AppLayout', [
  273. 'updateLayoutLeftDrawerVisible'
  274. ]),
  275. checkoutReview () {
  276. this.basket.loading = true
  277. APIGateway.basket.checkoutReview()
  278. .then((basket) => {
  279. this.basket = new Basket(basket)
  280. })
  281. .finally(() => {
  282. this.basket.loading = false
  283. })
  284. },
  285. loadAuthData () {
  286. this.user = this.$store.getters['Auth/user']
  287. },
  288. goToProperPanel () {
  289. if (this.canSeeAdminPanel) {
  290. // this.$router.push({ name: 'Admin.User.Index' })
  291. } else {
  292. this.$router.push({ name: 'UserPanel.Profile.UserInfo' })
  293. }
  294. },
  295. goToHome () {
  296. this.$router.push({ name: 'Public.Home' })
  297. },
  298. goToAdminDashboard () {
  299. this.$router.push({ name: 'Admin.Content.Index' })
  300. },
  301. logOut () {
  302. this.$store.dispatch('Auth/logOut')
  303. },
  304. toggleLeftDrawer () {
  305. this.updateLayoutLeftDrawerVisible(true)
  306. },
  307. hasRoute (route) {
  308. if (!route) {
  309. return
  310. }
  311. return !!(route.name || route.path)
  312. },
  313. getRoute (route) {
  314. if (!this.hasRoute(route)) {
  315. return { name: null }
  316. }
  317. if (route.name) {
  318. return { name: route.name }
  319. } else if (route.path) {
  320. return { path: route.path }
  321. } else {
  322. return { name: null }
  323. }
  324. }
  325. }
  326. }
  327. </script>
  328. <style lang="scss" scoped>
  329. .drawer-btn {
  330. display: none;
  331. @media screen and (max-width: 1439px) {
  332. & {
  333. display: block;
  334. }
  335. }
  336. @media screen and (max-width: 599px) {
  337. & {
  338. margin-bottom: 10px;
  339. }
  340. }
  341. }
  342. .right-side {
  343. display: flex;
  344. align-items: center;
  345. .breadcrumbs {
  346. &:deep(> *) {
  347. font-style: normal;
  348. font-weight: bold;
  349. font-size: 16px;
  350. line-height: 31px;
  351. text-align: right;
  352. color: #23263B;
  353. div:first-child {
  354. font-size: 18px;
  355. }
  356. }
  357. }
  358. @media screen and (max-width: 1023px) {
  359. & {
  360. margin-left: 42px;
  361. }
  362. }
  363. @media screen and (max-width: 599px) {
  364. & {
  365. margin-left: 0;
  366. }
  367. }
  368. }
  369. .left-side {
  370. display: flex;
  371. justify-content: flex-end;
  372. @media screen and (max-width: 1439px) {
  373. & {
  374. position: absolute;
  375. right: 0;
  376. }
  377. }
  378. @media screen and (max-width: 1023px) {
  379. .q-btn {
  380. width: 40px;
  381. padding: 0;
  382. .btn-label {
  383. display: none;
  384. }
  385. }
  386. }
  387. @media screen and (max-width: 599px) {
  388. & {
  389. right: 16px;
  390. margin-bottom: 10px;
  391. }
  392. }
  393. }
  394. </style>
  395. <style scoped lang="scss">
  396. .header-inside {
  397. height: 120px;
  398. background-color: #FBF4EA;
  399. color: #212121;
  400. //border-bottom: solid 1px #DFE1EC;
  401. &.isHomePage {
  402. background: transparent;
  403. @media only screen and (max-width: 1023px) {
  404. & {
  405. background-color: #FBF4EA;
  406. }
  407. }
  408. }
  409. .admin-top-menu {
  410. display: flex;
  411. flex-flow: row;
  412. height: 100%;
  413. .top-menu-items {
  414. width: calc( 100% - 240px );
  415. display: flex;
  416. flex-flow: row;
  417. justify-content: space-between;
  418. .q-btn {
  419. height: 40px;
  420. svg {
  421. margin-right: 10px;
  422. }
  423. }
  424. .right-side {
  425. display: flex;
  426. flex-flow: row;
  427. align-items: center;
  428. padding-left: 50px;
  429. }
  430. .left-side {
  431. display: flex;
  432. flex-flow: row;
  433. align-items: center;
  434. padding-right: 50px;
  435. }
  436. }
  437. .logo {
  438. width: 240px;
  439. height: 100%;
  440. background: #FBF4EA;
  441. border-right: solid 1px #DFE1EC;
  442. display: flex;
  443. align-items: center;
  444. justify-content: center;
  445. .logo-image {
  446. width: 106px;
  447. height: auto;
  448. }
  449. }
  450. }
  451. .user-top-menu {
  452. padding-top: 30px;
  453. margin-right: 100px;
  454. margin-left: 100px;
  455. margin-bottom: 22px;
  456. display: flex;
  457. flex-flow: row;
  458. justify-content: space-between;
  459. .q-btn {
  460. height: 40px;
  461. svg {
  462. margin-right: 10px;
  463. margin-left: 10px;
  464. }
  465. }
  466. .right-side {
  467. display: flex;
  468. flex-flow: row;
  469. align-items: center;
  470. .q-toolbar {
  471. min-height: 68px;
  472. .q-btn {
  473. align-self: center;
  474. }
  475. }
  476. }
  477. .center-logo {
  478. $width: 100px;
  479. $height: 55px;
  480. position: absolute;
  481. width: $width;
  482. height: 100%;
  483. top: 0;
  484. left: calc( 50% - (#{$width} / 2));
  485. }
  486. .left-side {
  487. display: flex;
  488. flex-flow: row;
  489. align-items: center;
  490. padding-right: 50px;
  491. @media only screen and (max-width: 1023px) {
  492. & {
  493. height: 100%;
  494. }
  495. }
  496. @media only screen and (max-width: 599px) {
  497. & {
  498. padding-right: 0;
  499. }
  500. }
  501. }
  502. &.isHomePage {
  503. .q-toolbar {
  504. .top-menu-item {
  505. color: white;
  506. }
  507. }
  508. }
  509. @media only screen and (max-width: 1500px) {
  510. & {
  511. margin-right: 10px;
  512. margin-left: 10px;
  513. }
  514. }
  515. @media only screen and (max-width: 1023px) {
  516. & {
  517. padding-top: 0;
  518. margin-bottom: 0;
  519. }
  520. }
  521. }
  522. @media only screen and (max-width: 1023px) {
  523. & {
  524. height: 70px;
  525. }
  526. }
  527. }
  528. .top-menu-items {
  529. border-radius: 10px;
  530. @media only screen and (max-width: 1439px) {
  531. & {
  532. display: none !important;
  533. }
  534. }
  535. @media only screen and (max-width: 500px) {
  536. .q-btn__content {
  537. margin: 4px;
  538. font-size: 0.7rem;
  539. }
  540. }
  541. @media only screen and (max-width: 400px) {
  542. .q-btn__content {
  543. margin: 3px;
  544. font-size: 0.6rem;
  545. }
  546. }
  547. }
  548. .breadcrumbs {
  549. .q-breadcrumbs__separator {
  550. .q-icon {
  551. font-size: 22px;
  552. }
  553. }
  554. }
  555. .drawer-btn {
  556. .q-btn {
  557. flex-direction: row !important;
  558. &.toolbar-button {
  559. margin-left: 0 !important;
  560. }
  561. }
  562. }
  563. .q-btn {
  564. &.toolbar-button {
  565. margin-left: 12px;
  566. height: 48px;
  567. width: 48px;
  568. box-shadow: -2px -4px 10px rgba(255, 255, 255, 0.6), 2px 4px 10px rgba(112, 108, 162, 0.05);
  569. border-radius: 16px;
  570. border: solid 1px #c5c5c5;
  571. }
  572. }
  573. .left-side {
  574. .q-btn {
  575. &.toolbar-button {
  576. .q-btn__content {
  577. .q-btn-dropdown__arrow {
  578. display: none !important;
  579. }
  580. }
  581. }
  582. &.btn-cart {
  583. background: white;
  584. color: $primary;
  585. margin-right: 20px;
  586. .q-badge {
  587. background: #FBF4EA;
  588. color: $primary;
  589. }
  590. }
  591. }
  592. }
  593. </style>