MainLayout.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="main-layout">
  3. <header class="header qm-primary-text">
  4. <Poptip v-if="ifShowQr" trigger="hover" width="240">
  5. <span class="name-arrow">手机端登录(Android)</span>
  6. <div slot="content">
  7. <div class="qm-primary-text">
  8. <qrcode :value="qrValue" :options="{ width: 200 }"></qrcode>
  9. </div>
  10. </div>
  11. </Poptip>
  12. <span v-if="ifShowQr" style="margin: auto 20px">|</span>
  13. <Poptip trigger="hover" width="300">
  14. <span class="name-arrow"
  15. >{{ user.displayName }} &nbsp;
  16. <i
  17. class="ivu-icon ivu-icon-md-arrow-dropdown"
  18. style="vertical-align: middle;"
  19. ></i>
  20. </span>
  21. <div slot="content">
  22. <div class="info qm-primary-text">
  23. <div class="hr info-row">
  24. <div>底照</div>
  25. <div>
  26. <img class="user-avatar" :src="user.photoPath" alt="无底照" />
  27. </div>
  28. </div>
  29. <div class="hr info-row">
  30. <div>学号</div>
  31. <div>{{ user.studentCodeList.join(",") }}</div>
  32. </div>
  33. <div class="hr info-row">
  34. <div>身份证号</div>
  35. <div>{{ user.identityNumber }}</div>
  36. </div>
  37. <div class="hr info-row">
  38. <div>学习中心</div>
  39. <div>{{ user.orgName }}</div>
  40. </div>
  41. <div
  42. style="grid-column: span 2; place-self: center; width: 100%; padding-top: 10px"
  43. >
  44. <i-button class="qm-primary-button" long @click="goChangePwd">
  45. 修改密码
  46. </i-button>
  47. </div>
  48. </div>
  49. </div>
  50. </Poptip>
  51. <span style="margin: auto 20px">|</span>
  52. <a
  53. @click="() => this.logout('?LogoutReason=正常退出')"
  54. class="qm-primary-text"
  55. style="display: inline-block; margin-right: 20px; text-align: center;"
  56. >退出登录</a
  57. >
  58. </header>
  59. <transition name="fade" appear>
  60. <main class="content" :key="$route.path">
  61. <slot></slot>
  62. </main>
  63. </transition>
  64. <nav class="nav">
  65. <img src="./qm-logo.png" class="qm-logo" />
  66. <ul>
  67. <li>
  68. <router-link class="link" to="/online-exam">
  69. 在线考试
  70. </router-link>
  71. </li>
  72. <li>
  73. <router-link class="link" to="/online-practice">
  74. 在线练习
  75. </router-link>
  76. </li>
  77. <li>
  78. <router-link class="link" to="/offline-exam">
  79. 离线考试
  80. </router-link>
  81. </li>
  82. <li>
  83. <router-link class="link" to="/site-message">
  84. <Badge :count="messageUnread" :offset="[20, -20]">
  85. 公告通知
  86. </Badge>
  87. </router-link>
  88. </li>
  89. <li>
  90. <router-link class="link" to="/password">
  91. 修改密码
  92. </router-link>
  93. </li>
  94. </ul>
  95. </nav>
  96. <footer class="footer">©️2019 启明泰和</footer>
  97. <SiteMessagePopup />
  98. </div>
  99. </template>
  100. <script>
  101. import { mapState } from "vuex";
  102. import VueQrcode from "@chenfengyuan/vue-qrcode";
  103. import SiteMessagePopup from "./SiteMessagePopup.vue";
  104. export default {
  105. name: "MainLayout",
  106. data() {
  107. return {};
  108. },
  109. methods: {
  110. goChangePwd() {
  111. this.$router.push("/password");
  112. },
  113. },
  114. computed: {
  115. ...mapState(["user", "siteMessages"]),
  116. messageUnread() {
  117. return this.siteMessages.filter(v => v.hasRead === false).length;
  118. },
  119. qrValue() {
  120. const { rootOrgId, studentCodeList, identityNumber } = this.user;
  121. return JSON.stringify({
  122. rootOrgId,
  123. studentCode: studentCodeList.join(","),
  124. identityNumber,
  125. });
  126. },
  127. ifShowQr() {
  128. const domain = localStorage.getItem("domain") || "";
  129. return domain.includes("ecs-dev") || domain.includes("exam.qmth.com.cn");
  130. },
  131. },
  132. components: {
  133. qrcode: VueQrcode,
  134. SiteMessagePopup,
  135. },
  136. };
  137. </script>
  138. <style scoped>
  139. .main-layout {
  140. display: grid;
  141. grid-template-areas: "nav header" "nav content" "nav footer";
  142. min-height: 100vh;
  143. grid-template-columns: 180px 1fr;
  144. grid-template-rows: auto 1fr auto;
  145. }
  146. .header {
  147. grid-area: header;
  148. height: 50px;
  149. background-color: #ffffff;
  150. box-shadow: 0px 1px 0px 0px #eeeeee;
  151. text-align: right;
  152. line-height: 50px;
  153. }
  154. .user-avatar {
  155. display: inline-block;
  156. width: 80px;
  157. height: 80px;
  158. object-fit: contain;
  159. }
  160. .info {
  161. width: 260px;
  162. }
  163. .info > div {
  164. min-height: 50px;
  165. }
  166. .hr {
  167. border-bottom: 1px solid #eeeeee;
  168. }
  169. .info-row {
  170. display: grid;
  171. grid-template-columns: 1fr 2fr;
  172. align-items: center;
  173. }
  174. .info-row > div:nth-of-type(odd) {
  175. justify-self: left;
  176. }
  177. .info-row > div:nth-of-type(even) {
  178. justify-self: right;
  179. }
  180. .name-arrow:hover .ivu-icon-md-arrow-dropdown::before {
  181. content: "\F343";
  182. }
  183. .nav {
  184. grid-area: nav;
  185. background-color: rgb(113, 113, 113);
  186. background-repeat: repeat;
  187. width: 180px;
  188. min-height: 100vh;
  189. display: flex;
  190. flex-direction: column;
  191. }
  192. .qm-logo {
  193. width: 80px;
  194. height: 68px;
  195. margin: 30px auto;
  196. }
  197. .link {
  198. background-image: url(./link.png);
  199. background-repeat: no-repeat;
  200. background-position: 30px 50%;
  201. /* margin-left: -40px; */
  202. padding-right: 20px;
  203. line-height: 40px;
  204. width: 100%;
  205. display: inline-block;
  206. color: #ffffff;
  207. }
  208. .router-link-active,
  209. .link:hover {
  210. background-image: url(./link-active.png);
  211. background-color: rgba(255, 255, 255, 0.5);
  212. color: #fafafa;
  213. }
  214. .footer {
  215. grid-area: footer;
  216. margin-bottom: 10px;
  217. }
  218. </style>